mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4632 from OPM/bug-#4629
#4629 Fix setting and reading of summary time values
This commit is contained in:
commit
82e674d6cd
@ -301,8 +301,7 @@ bool RimSummaryTimeAxisProperties::isActive() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QDateTime RimSummaryTimeAxisProperties::visibleDateTimeMin() const
|
||||
{
|
||||
QDateTime fullMin(m_visibleDateRangeMin(), m_visibleTimeRangeMin());
|
||||
return fullMin;
|
||||
return RiaQDateTimeTools::createUtcDateTime(m_visibleDateRangeMin(), m_visibleTimeRangeMin());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -310,8 +309,7 @@ QDateTime RimSummaryTimeAxisProperties::visibleDateTimeMin() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QDateTime RimSummaryTimeAxisProperties::visibleDateTimeMax() const
|
||||
{
|
||||
QDateTime fullMax(m_visibleDateRangeMax(), m_visibleTimeRangeMax());
|
||||
return fullMax;
|
||||
return RiaQDateTimeTools::createUtcDateTime(m_visibleDateRangeMax(), m_visibleTimeRangeMax());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,7 +34,6 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafPdmUiTimeEditor.h"
|
||||
|
||||
#include "cafFactory.h"
|
||||
@ -43,11 +42,10 @@
|
||||
#include "cafPdmUiDefaultObjectEditor.h"
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafQShortenedLabel.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDate>
|
||||
#include <QGridLayout>
|
||||
#include <QIntValidator>
|
||||
#include <QLabel>
|
||||
@ -58,64 +56,69 @@
|
||||
#include <QStatusBar>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiTimeEditor);
|
||||
|
||||
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiTimeEditor);
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTimeEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
CAF_ASSERT(!m_timeEdit.isNull());
|
||||
|
||||
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTimeEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
CAF_ASSERT(!m_timeEdit.isNull());
|
||||
m_timeEdit->setEnabled(!uiField()->isUiReadOnly(uiConfigName));
|
||||
|
||||
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
|
||||
caf::PdmUiObjectHandle* uiObject = uiObj(uiField()->fieldHandle()->ownerObject());
|
||||
if (uiObject)
|
||||
{
|
||||
uiObject->editorAttribute(uiField()->fieldHandle(), uiConfigName, &m_attributes);
|
||||
}
|
||||
|
||||
m_timeEdit->setEnabled(!uiField()->isUiReadOnly(uiConfigName));
|
||||
if (!m_attributes.timeFormat.isEmpty())
|
||||
{
|
||||
m_timeEdit->setDisplayFormat(m_attributes.timeFormat);
|
||||
}
|
||||
|
||||
caf::PdmUiObjectHandle* uiObject = uiObj(uiField()->fieldHandle()->ownerObject());
|
||||
if (uiObject)
|
||||
{
|
||||
uiObject->editorAttribute(uiField()->fieldHandle(), uiConfigName, &m_attributes);
|
||||
}
|
||||
m_timeEdit->setTime(uiField()->uiValue().toTime());
|
||||
}
|
||||
|
||||
if (!m_attributes.timeFormat.isEmpty())
|
||||
{
|
||||
m_timeEdit->setDisplayFormat(m_attributes.timeFormat);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiTimeEditor::createEditorWidget(QWidget* parent)
|
||||
{
|
||||
m_timeEdit = new QTimeEdit(parent);
|
||||
connect(m_timeEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||
connect(m_timeEdit, SIGNAL(timeChanged(QTime)), this, SLOT(slotTimeChanged(QTime)));
|
||||
return m_timeEdit;
|
||||
}
|
||||
|
||||
m_timeEdit->setDate(uiField()->uiValue().toDate());
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiTimeEditor::createLabelWidget(QWidget* parent)
|
||||
{
|
||||
m_label = new QShortenedLabel(parent);
|
||||
return m_label;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTimeEditor::slotEditingFinished()
|
||||
{
|
||||
this->setValueToField(m_timeEdit->time());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiTimeEditor::createEditorWidget(QWidget* parent)
|
||||
{
|
||||
m_timeEdit = new QTimeEdit(parent);
|
||||
connect(m_timeEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||
return m_timeEdit;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiTimeEditor::createLabelWidget(QWidget* parent)
|
||||
{
|
||||
m_label = new QShortenedLabel(parent);
|
||||
return m_label;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTimeEditor::slotEditingFinished()
|
||||
{
|
||||
this->setValueToField(m_timeEdit->date());
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTimeEditor::slotTimeChanged(const QTime& time)
|
||||
{
|
||||
this->setValueToField(m_timeEdit->time());
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -34,60 +34,56 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
|
||||
#include <QTimeEdit>
|
||||
#include <QLabel>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <QTimeEdit>
|
||||
#include <QWidget>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class PdmUiTimeEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
QString timeFormat;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class PdmUiTimeEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
QString timeFormat;
|
||||
public:
|
||||
PdmUiTimeEditorAttribute() {}
|
||||
};
|
||||
|
||||
public:
|
||||
PdmUiTimeEditorAttribute()
|
||||
{
|
||||
}
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class PdmUiTimeEditor : public PdmUiFieldEditorHandle
|
||||
{
|
||||
Q_OBJECT
|
||||
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class PdmUiTimeEditor : public PdmUiFieldEditorHandle
|
||||
{
|
||||
Q_OBJECT
|
||||
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
|
||||
public:
|
||||
PdmUiTimeEditor() {}
|
||||
~PdmUiTimeEditor() override {}
|
||||
|
||||
public:
|
||||
PdmUiTimeEditor() {}
|
||||
~PdmUiTimeEditor() override {}
|
||||
protected:
|
||||
QWidget* createEditorWidget(QWidget* parent) override;
|
||||
QWidget* createLabelWidget(QWidget* parent) override;
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
|
||||
protected:
|
||||
QWidget* createEditorWidget(QWidget * parent) override;
|
||||
QWidget* createLabelWidget(QWidget * parent) override;
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
protected slots:
|
||||
void slotEditingFinished();
|
||||
void slotTimeChanged(const QTime& time);
|
||||
|
||||
protected slots:
|
||||
void slotEditingFinished();
|
||||
|
||||
private:
|
||||
QPointer<QTimeEdit> m_timeEdit;
|
||||
QPointer<QShortenedLabel> m_label;
|
||||
|
||||
PdmUiTimeEditorAttribute m_attributes;
|
||||
};
|
||||
private:
|
||||
QPointer<QTimeEdit> m_timeEdit;
|
||||
QPointer<QShortenedLabel> m_label;
|
||||
|
||||
PdmUiTimeEditorAttribute m_attributes;
|
||||
};
|
||||
|
||||
} // end namespace caf
|
||||
|
Loading…
Reference in New Issue
Block a user