mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use helper class to read/write using QSettings
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "cafEffectCache.h"
|
||||
#include "cafUtils.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmSettings.h"
|
||||
|
||||
#include "RiaVersionInfo.h"
|
||||
#include "RiaBaseDefs.h"
|
||||
@@ -141,7 +142,7 @@ RiaApplication::RiaApplication(int& argc, char** argv)
|
||||
//cvf::Trace::enable(false);
|
||||
|
||||
m_preferences = new RiaPreferences;
|
||||
readFieldsFromApplicationStore(m_preferences);
|
||||
caf::PdmSettings::readFieldsFromApplicationStore(m_preferences);
|
||||
applyPreferences();
|
||||
|
||||
if (useShaders())
|
||||
@@ -314,7 +315,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
|
||||
// VL check regarding specific order mentioned in comment above...
|
||||
|
||||
m_preferences->lastUsedProjectFileName = projectFileName;
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(m_preferences);
|
||||
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
@@ -518,7 +519,7 @@ bool RiaApplication::saveProjectAs(const QString& fileName)
|
||||
m_project->writeFile();
|
||||
|
||||
m_preferences->lastUsedProjectFileName = fileName;
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(m_preferences);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -827,7 +828,7 @@ void RiaApplication::setActiveReservoirView(RimView* rv)
|
||||
void RiaApplication::setUseShaders(bool enable)
|
||||
{
|
||||
m_preferences->useShaders = enable;
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(m_preferences);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -859,7 +860,7 @@ RiaApplication::RINavigationPolicy RiaApplication::navigationPolicy() const
|
||||
void RiaApplication::setShowPerformanceInfo(bool enable)
|
||||
{
|
||||
m_preferences->showHud = enable;
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(m_preferences);
|
||||
}
|
||||
|
||||
|
||||
@@ -1288,93 +1289,6 @@ bool RiaApplication::launchProcessForMultipleCases(const QString& program, const
|
||||
return launchProcess(m_currentProgram, m_currentArguments);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read fields of a Pdm object using QSettings
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::readFieldsFromApplicationStore(caf::PdmObject* object, const QString context)
|
||||
{
|
||||
// MODTODO
|
||||
|
||||
// Replace with existing caf functionality
|
||||
|
||||
/*
|
||||
QSettings settings;
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
|
||||
object->fields(fields);
|
||||
size_t i;
|
||||
for (i = 0; i < fields.size(); i++)
|
||||
{
|
||||
caf::PdmFieldHandle* fieldHandle = fields[i];
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> children;
|
||||
fieldHandle->childObjects(&children);
|
||||
for (size_t childIdx = 0; childIdx < children.size(); childIdx++)
|
||||
{
|
||||
caf::PdmObjectHandle* child = children[childIdx];
|
||||
QString subContext = context + child->classKeyword() + "/";
|
||||
readFieldsFromApplicationStore(child, subContext);
|
||||
}
|
||||
|
||||
|
||||
if (children.size() == 0)
|
||||
{
|
||||
QString key = context + fieldHandle->keyword();
|
||||
if (settings.contains(key))
|
||||
{
|
||||
QVariant val = settings.value(key);
|
||||
fieldHandle->setValueFromUi(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Write fields of a Pdm object using QSettings
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::writeFieldsToApplicationStore(const caf::PdmObject* object, const QString context)
|
||||
{
|
||||
// MODTODO
|
||||
|
||||
// Replace with existing caf functionality
|
||||
|
||||
|
||||
/*
|
||||
CVF_ASSERT(object);
|
||||
|
||||
QSettings settings;
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
object->fields(fields);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < fields.size(); i++)
|
||||
{
|
||||
caf::PdmFieldHandle* fieldHandle = fields[i];
|
||||
|
||||
std::vector<caf::PdmObject*> children;
|
||||
fieldHandle->childObjects(&children);
|
||||
for (size_t childIdx = 0; childIdx < children.size(); childIdx++)
|
||||
{
|
||||
caf::PdmObject* child = children[childIdx];
|
||||
QString subContext;
|
||||
if (context.isEmpty())
|
||||
{
|
||||
subContext = context + child->classKeyword() + "/";
|
||||
}
|
||||
|
||||
writeFieldsToApplicationStore(child, subContext);
|
||||
}
|
||||
|
||||
if (children.size() == 0)
|
||||
{
|
||||
settings.setValue(context + fieldHandle->keyword(), fieldHandle->uiValue());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -139,8 +139,6 @@ public:
|
||||
void terminateProcess();
|
||||
|
||||
RiaPreferences* preferences();
|
||||
void readFieldsFromApplicationStore(caf::PdmObject* object, const QString context = "");
|
||||
void writeFieldsToApplicationStore(const caf::PdmObject* object, const QString context = "");
|
||||
void applyPreferences();
|
||||
|
||||
cvf::Font* standardFont();
|
||||
|
||||
@@ -31,11 +31,8 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
|
||||
// MODTODO Replace with other classes in new caf
|
||||
//#include "cafPdmSettings.h"
|
||||
//#include "cafPdmUiPropertyDialog.h"
|
||||
|
||||
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include <QDir>
|
||||
@@ -248,21 +245,17 @@ cvf::ref<RifReaderInterface> RimEclipseResultCase::createMockModel(QString model
|
||||
}
|
||||
else if (modelName == RimDefines::mockModelCustomized())
|
||||
{
|
||||
|
||||
// MODTODO
|
||||
// Replace with other caf structures
|
||||
/*
|
||||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||||
|
||||
RimMockModelSettings rimMockModelSettings;
|
||||
caf::Settings::readFieldsFromApplicationStore(&rimMockModelSettings);
|
||||
caf::PdmSettings::readFieldsFromApplicationStore(&rimMockModelSettings);
|
||||
|
||||
caf::PdmUiPropertyDialog propertyDialog(NULL, &rimMockModelSettings, "Customize Mock Model");
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &rimMockModelSettings, "Customize Mock Model", "");
|
||||
if (propertyDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
caf::Settings::writeFieldsToApplicationStore(&rimMockModelSettings);
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(&rimMockModelSettings);
|
||||
|
||||
double startX = 0;
|
||||
double startY = 0;
|
||||
@@ -288,7 +281,6 @@ cvf::ref<RifReaderInterface> RimEclipseResultCase::createMockModel(QString model
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
this->setReservoirData( reservoir.p() );
|
||||
|
||||
@@ -60,10 +60,7 @@
|
||||
#include "cafAnimationToolBar.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
|
||||
// MODTODO
|
||||
//#include "cafPdmUiPropertyDialog.h"
|
||||
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiPropertyView.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
@@ -1443,24 +1440,19 @@ void RiuMainWindow::slotShowPerformanceInfo(bool enable)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::slotEditPreferences()
|
||||
{
|
||||
|
||||
// MODTODO
|
||||
// See RPM to find a solution for read/write to registry from pdm object
|
||||
/*
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
caf::PdmUiPropertyDialog propertyDialog(this, app->preferences(), "Preferences");
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(this, app->preferences(), "Preferences", "");
|
||||
if (propertyDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
app->writeFieldsToApplicationStore(app->preferences());
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(app->preferences());
|
||||
app->applyPreferences();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read back currently stored values using QSettings
|
||||
app->readFieldsFromApplicationStore(app->preferences());
|
||||
caf::PdmSettings::readFieldsFromApplicationStore(app->preferences());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2041,13 +2033,13 @@ void RiuMainWindow::slotShowRegressionTestDialog()
|
||||
RiaRegressionTest regTestConfig;
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
app->readFieldsFromApplicationStore(®TestConfig);
|
||||
caf::PdmSettings::readFieldsFromApplicationStore(®TestConfig);
|
||||
|
||||
caf::PdmUiPropertyViewDialog regressionTestDialog(this, ®TestConfig, "Regression Test", "");
|
||||
if (regressionTestDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
app->writeFieldsToApplicationStore(®TestConfig);
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(®TestConfig);
|
||||
|
||||
QString currentApplicationPath = QDir::currentPath();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user