mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* #2082 Support custom date time format * Clang-format
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RifReaderSettings.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
@@ -30,6 +31,9 @@
|
||||
#include "cafPdmUiFieldHandle.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
#include <QDate>
|
||||
#include <QLocale>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
#include <QStandardPaths>
|
||||
#endif
|
||||
@@ -167,6 +171,13 @@ RiaPreferences::RiaPreferences(void)
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", "");
|
||||
m_readerSettings = new RifReaderSettings;
|
||||
CAF_PDM_InitFieldNoDefault(&m_dateFormat, "dateFormat", "Date Format", "", "", "");
|
||||
m_dateFormat.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||
m_dateFormat = RiaQDateTimeTools::supportedDateFormats().front();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_timeFormat, "timeFormat", "Time Format", "", "", "");
|
||||
m_timeFormat.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||
m_timeFormat = RiaQDateTimeTools::supportedTimeFormats().front();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -257,6 +268,8 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
viewsGroup->add(&showHud);
|
||||
|
||||
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup("Other");
|
||||
otherGroup->add(&m_dateFormat);
|
||||
otherGroup->add(&m_timeFormat);
|
||||
otherGroup->add(&ssihubAddress);
|
||||
otherGroup->add(&showLasCurveWithoutTvdWarning);
|
||||
otherGroup->add(&holoLensDisableCertificateVerification);
|
||||
@@ -353,6 +366,30 @@ QList<caf::PdmOptionItemInfo> RiaPreferences::calculateValueOptions(const caf::P
|
||||
options.push_back(caf::PdmOptionItemInfo(skip.uiText(), RiaPreferences::NOT_IMPORT));
|
||||
options.push_back(caf::PdmOptionItemInfo(allowImport.uiText(), RiaPreferences::IMPORT));
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_dateFormat)
|
||||
{
|
||||
for (auto dateFormat : RiaQDateTimeTools::supportedDateFormats())
|
||||
{
|
||||
QDate exampleDate = QDate(2019, 8, 16);
|
||||
QString fullDateFormat =
|
||||
RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||
QString uiText = QString("%1 (%2)").arg(fullDateFormat).arg(exampleDate.toString(fullDateFormat));
|
||||
uiText.replace("AP", "AM/PM");
|
||||
options.push_back(caf::PdmOptionItemInfo(uiText, QVariant::fromValue(dateFormat)));
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_timeFormat)
|
||||
{
|
||||
for (auto timeFormat : RiaQDateTimeTools::supportedTimeFormats())
|
||||
{
|
||||
QTime exampleTime = QTime(15, 48, 22);
|
||||
QString timeFormatString =
|
||||
RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND);
|
||||
QString uiText = QString("%1 (%2)").arg(timeFormatString).arg(exampleTime.toString(timeFormatString));
|
||||
uiText.replace("AP", "AM/PM");
|
||||
options.push_back(caf::PdmOptionItemInfo(uiText, QVariant::fromValue(timeFormat)));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
@@ -500,6 +537,22 @@ QString RiaPreferences::holoLensExportFolder() const
|
||||
return m_holoLensExportFolder();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RiaPreferences::dateFormat() const
|
||||
{
|
||||
return m_dateFormat();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RiaPreferences::timeFormat() const
|
||||
{
|
||||
return m_timeFormat();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user