mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3055 Table Editor : Fix display of date as text
This commit is contained in:
parent
4fd2f982fd
commit
18a0a9aa9a
@ -42,6 +42,7 @@
|
|||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
#include "cafPdmUiComboBoxEditor.h"
|
#include "cafPdmUiComboBoxEditor.h"
|
||||||
#include "cafPdmUiCommandSystemProxy.h"
|
#include "cafPdmUiCommandSystemProxy.h"
|
||||||
|
#include "cafPdmUiDateEditor.h"
|
||||||
#include "cafPdmUiFieldEditorHelper.h"
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
#include "cafPdmUiTableItemEditor.h"
|
#include "cafPdmUiTableItemEditor.h"
|
||||||
@ -271,6 +272,7 @@ QVariant PdmUiTableViewQModel::data(const QModelIndex &index, int role /*= Qt::D
|
|||||||
// TODO: Create a function in pdmObject like this
|
// TODO: Create a function in pdmObject like this
|
||||||
// virtual void defineDisplayString(const PdmFieldHandle* field, QString uiConfigName) {}
|
// virtual void defineDisplayString(const PdmFieldHandle* field, QString uiConfigName) {}
|
||||||
|
|
||||||
|
{
|
||||||
PdmUiLineEditorAttributeUiDisplayString leab;
|
PdmUiLineEditorAttributeUiDisplayString leab;
|
||||||
uiObjForRow->editorAttribute(fieldHandle, m_currentConfigName, &leab);
|
uiObjForRow->editorAttribute(fieldHandle, m_currentConfigName, &leab);
|
||||||
|
|
||||||
@ -278,7 +280,26 @@ QVariant PdmUiTableViewQModel::data(const QModelIndex &index, int role /*= Qt::D
|
|||||||
{
|
{
|
||||||
val = leab.m_displayString;
|
val = leab.m_displayString;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
|
||||||
|
if (val.isNull())
|
||||||
|
{
|
||||||
|
PdmUiDateEditorAttribute leab;
|
||||||
|
uiObjForRow->editorAttribute(fieldHandle, m_currentConfigName, &leab);
|
||||||
|
|
||||||
|
QString dateFormat = leab.dateFormat;
|
||||||
|
if (!dateFormat.isEmpty())
|
||||||
|
{
|
||||||
|
QDate date = uiFieldHandle->uiValue().toDate();
|
||||||
|
if (date.isValid())
|
||||||
|
{
|
||||||
|
QString displayString = date.toString(dateFormat);
|
||||||
|
val = displayString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val.isNull())
|
||||||
{
|
{
|
||||||
val = uiFieldHandle->uiValue();
|
val = uiFieldHandle->uiValue();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user