diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 7a5299f038..1b6e7399cf 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -615,7 +615,7 @@ std::map > RimWellPltPlot::timeStepsFromW { std::map > timeStepsMap; - QDateTime timeStep = RiaDateStringParser::parseDateString(wellLogFile->date()); + QDateTime timeStep = wellLogFile->date(); if (timeStepsMap.count(timeStep) == 0) { @@ -779,7 +779,7 @@ std::pair RimWellPltPlot::curveDefFromCurve(const if (wellLogFile != nullptr) { - const QDateTime date = RiaDateStringParser::parseDateString(wellLogFile->date()); + const QDateTime date = wellLogFile->date(); if (date.isValid()) { diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index bfd4e2be28..e5f7c336b4 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -583,7 +583,7 @@ std::map > RimWellRftPlot::timeStepsFromW { std::map > timeStepsMap; - QDateTime timeStep = RiaDateStringParser::parseDateString(wellLogFile->date()); + QDateTime timeStep = wellLogFile->date(); if (timeStepsMap.count(timeStep) == 0) { @@ -745,7 +745,7 @@ std::pair RimWellRftPlot::curveDefFromCurve(const if (wellLogFile != nullptr) { - const QDateTime date = RiaDateStringParser::parseDateString(wellLogFile->date()); + const QDateTime date = wellLogFile->date(); if (date.isValid()) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp index c90b55ea44..c054c6d785 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp @@ -29,10 +29,11 @@ #include "RiuMainWindow.h" +#include "cafPdmUiDateEditor.h" + #include #include #include -#include "cafPdmUiLineEditor.h" CAF_PDM_SOURCE_INIT(RimWellLogFile, "WellLogFile"); @@ -59,16 +60,8 @@ RimWellLogFile::RimWellLogFile() m_wellName.uiCapability()->setUiHidden(true); m_wellName.xmlCapability()->setIOWritable(false); - CAF_PDM_InitFieldNoDefault(&m_uiDate, "ui_Date", "Date", "", "", ""); - m_uiDate.registerGetMethod(this, &RimWellLogFile::formatDate); - m_uiDate.uiCapability()->setUiHidden(false); - m_uiDate.uiCapability()->setUiReadOnly(true); - m_uiDate.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault(&m_date, "Date", "Date", "", "", ""); m_date.uiCapability()->setUiReadOnly(true); - m_date.uiCapability()->setUiHidden(true); - m_date.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault(&m_fileName, "FileName", "Filename", "", "", ""); m_fileName.uiCapability()->setUiReadOnly(true); @@ -158,7 +151,13 @@ bool RimWellLogFile::readFile(QString* errorMessage) } m_wellName = m_wellLogDataFile->wellName(); - m_date = m_wellLogDataFile->date(); + + QDateTime date = RiaDateStringParser::parseDateString(m_wellLogDataFile->date()); + m_lasFileHasValidDate = date.isValid(); + if (m_lasFileHasValidDate) + { + m_date = date; + } m_wellLogChannelNames.deleteAllChildObjects(); @@ -194,7 +193,7 @@ QString RimWellLogFile::wellName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellLogFile::date() const +QDateTime RimWellLogFile::date() const { return m_date; } @@ -212,15 +211,32 @@ std::vector RimWellLogFile::wellLogChannels() const return channels; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogFile::hasFlowData() const +{ + return RimWellPltPlot::hasFlowData(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFile::setupBeforeSave() +{ + m_wellFlowCondition.xmlCapability()->setIOWritable(hasFlowData()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogFile::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&m_fileName); - uiOrdering.add(&m_uiDate); + uiOrdering.add(&m_date); + m_date.uiCapability()->setUiReadOnly(m_lasFileHasValidDate); - if (RimWellPltPlot::hasFlowData(this)) + if (hasFlowData()) { uiOrdering.add(&m_wellFlowCondition); } @@ -231,14 +247,26 @@ void RimWellLogFile::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellLogFile::formatDate() const +QList RimWellLogFile::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { - QDateTime timeStep = RiaDateStringParser::parseDateString(m_date()); - if (timeStep.isValid()) + QList options; + + if (fieldNeedingOptions == &m_date) { - const QString dateFormatString = RimTools::createTimeFormatStringFromDates({ timeStep }); - auto ddd = timeStep.toString(dateFormatString); - return timeStep.toString(dateFormatString); + + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogFile::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiDateEditorAttribute* attrib = dynamic_cast (attribute); + if (attrib != nullptr) + { + attrib->dateFormat = RimTools::dateFormatString(); } - return ""; } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.h b/ApplicationCode/ProjectDataModel/RimWellLogFile.h index eb218ede4b..8ba8322ff0 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.h @@ -27,6 +27,9 @@ #include "cvfBase.h" +#include + + class RimWellLogFileChannel; class QString; @@ -57,18 +60,22 @@ public: bool readFile(QString* errorMessage); QString wellName() const; - QString date() const; + QDateTime date() const; RigWellLogFile* wellLogFile() { return m_wellLogDataFile.p(); } std::vector wellLogChannels() const; + bool hasFlowData() const; + private: + virtual void setupBeforeSave() override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } - QString formatDate() const; - caf::PdmChildArrayField m_wellLogChannelNames; private: @@ -76,7 +83,7 @@ private: caf::PdmField m_wellName; caf::PdmField m_fileName; caf::PdmField m_name; - caf::PdmField m_date; - caf::PdmProxyValueField m_uiDate; + caf::PdmField m_date; + bool m_lasFileHasValidDate; caf::PdmField> m_wellFlowCondition; };