mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2081 LAS import. Display dialog box when reading LAS file with missing or invalid date
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <QStringList>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include "RiaQDateTimeTools.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellLogFile, "WellLogFile");
|
||||
@@ -48,6 +49,11 @@ namespace caf
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QDateTime RimWellLogFile::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtcDateTime(QDate(1900, 1, 1));
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -77,6 +83,10 @@ RimWellLogFile::RimWellLogFile()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellFlowCondition, "WellFlowCondition", "Well Flow Condition", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_invalidDateMessage, "InvalidDateMessage", QString("Invalid or no date"), "", "", "", "");
|
||||
m_invalidDateMessage.uiCapability()->setUiReadOnly(true);
|
||||
m_invalidDateMessage.xmlCapability()->disableIO();
|
||||
|
||||
m_wellLogDataFile = NULL;
|
||||
}
|
||||
|
||||
@@ -153,11 +163,23 @@ bool RimWellLogFile::readFile(QString* errorMessage)
|
||||
m_wellName = m_wellLogDataFile->wellName();
|
||||
|
||||
QDateTime date = RiaDateStringParser::parseDateString(m_wellLogDataFile->date());
|
||||
m_lasFileHasValidDate = date.isValid();
|
||||
m_lasFileHasValidDate = isDateValid(date);
|
||||
if (m_lasFileHasValidDate)
|
||||
{
|
||||
m_date = date;
|
||||
}
|
||||
else if(!isDateValid(m_date()))
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
|
||||
QString message = QString("The LAS-file '%1' contains no recognizable date. Please assign a date in the LAS-file property panel")
|
||||
.arg(m_name());
|
||||
msgBox.setText(message);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
|
||||
m_date = DEFAULT_DATE_TIME;
|
||||
}
|
||||
|
||||
m_wellLogChannelNames.deleteAllChildObjects();
|
||||
|
||||
@@ -236,6 +258,13 @@ void RimWellLogFile::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
uiOrdering.add(&m_date);
|
||||
m_date.uiCapability()->setUiReadOnly(m_lasFileHasValidDate);
|
||||
|
||||
auto timespec = m_date().timeSpec();
|
||||
|
||||
if (!isDateValid(m_date()))
|
||||
{
|
||||
uiOrdering.add(&m_invalidDateMessage);
|
||||
}
|
||||
|
||||
if (hasFlowData())
|
||||
{
|
||||
uiOrdering.add(&m_wellFlowCondition);
|
||||
@@ -247,16 +276,13 @@ void RimWellLogFile::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimWellLogFile::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
void RimWellLogFile::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if (fieldNeedingOptions == &m_date)
|
||||
if (changedField == &m_date)
|
||||
{
|
||||
|
||||
// Due to a possible bug in QDateEdit/PdmUiDateEditor, convert m_date to a QDateTime having UTC timespec
|
||||
m_date = RiaQDateTimeTools::createUtcDateTime(m_date().date(), m_date().time());
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -270,3 +296,11 @@ void RimWellLogFile::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
|
||||
attrib->dateFormat = RimTools::dateFormatString();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogFile::isDateValid(const QDateTime dateTime)
|
||||
{
|
||||
return dateTime.isValid() && dateTime != DEFAULT_DATE_TIME;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ class RimWellLogFile : public caf::PdmObject
|
||||
WELL_FLOW_COND_STANDARD
|
||||
};
|
||||
|
||||
const static QDateTime DEFAULT_DATE_TIME;
|
||||
|
||||
public:
|
||||
RimWellLogFile();
|
||||
virtual ~RimWellLogFile();
|
||||
@@ -70,12 +72,14 @@ public:
|
||||
private:
|
||||
virtual void setupBeforeSave() override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
|
||||
|
||||
static bool isDateValid(const QDateTime dateTime);
|
||||
|
||||
caf::PdmChildArrayField<RimWellLogFileChannel*> m_wellLogChannelNames;
|
||||
|
||||
private:
|
||||
@@ -86,4 +90,6 @@ private:
|
||||
caf::PdmField<QDateTime> m_date;
|
||||
bool m_lasFileHasValidDate;
|
||||
caf::PdmField<caf::AppEnum<WellFlowCondition>> m_wellFlowCondition;
|
||||
|
||||
caf::PdmField<QString> m_invalidDateMessage;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user