mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* Disable IO for scriptlocations and make sure we save it in preferences when editing * The next valid case Id stuff in initDirectories is irrelevant because it always runs on an empty project
This commit is contained in:
parent
f61df01694
commit
7c30af62c2
@ -1098,6 +1098,7 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
|
||||
this->project()->setScriptDirectories(m_preferences->scriptDirectories());
|
||||
this->project()->updateConnectedEditors();
|
||||
}
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(m_preferences);
|
||||
}
|
||||
|
||||
|
||||
@ -1382,7 +1383,7 @@ void RiaApplication::initialize()
|
||||
|
||||
// Start with a project
|
||||
m_project = new RimProject;
|
||||
m_project->initScriptDirectories(m_preferences->scriptDirectories());
|
||||
m_project->setScriptDirectories(m_preferences->scriptDirectories());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -55,7 +55,6 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked)
|
||||
if (propertyDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(app->preferences());
|
||||
app->applyPreferences(oldPreferences.get());
|
||||
app->applyGuiPreferences(oldPreferences.get());
|
||||
app->updateGrpcServer();
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QStringList>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicDeleteScriptPathFeature, "RicDeleteScriptPathFeature");
|
||||
|
||||
@ -55,18 +56,9 @@ void RicDeleteScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
QString toBeRemoved = scriptCollection->directory;
|
||||
|
||||
QString originalFilePathString = RiaApplication::instance()->preferences()->scriptDirectories();
|
||||
QString filePathString = originalFilePathString.remove(toBeRemoved);
|
||||
|
||||
// Remove duplicate separators
|
||||
QChar separator(';');
|
||||
QString regExpString = QString("%1{1,5}").arg(separator);
|
||||
filePathString.replace(QRegExp(regExpString), separator);
|
||||
|
||||
// Remove separator at end
|
||||
if (filePathString.endsWith(separator))
|
||||
{
|
||||
filePathString = filePathString.left(filePathString.size() - 1);
|
||||
}
|
||||
QStringList allFilePaths = originalFilePathString.split(';');
|
||||
allFilePaths.removeOne(toBeRemoved);
|
||||
QString filePathString = allFilePaths.join(';');
|
||||
|
||||
RiaApplication::instance()->preferences()->scriptDirectories = filePathString;
|
||||
RiaApplication::instance()->applyPreferences();
|
||||
|
@ -37,9 +37,7 @@ RimCalcScript::RimCalcScript()
|
||||
CAF_PDM_InitObject("CalcScript", ":/OctaveScriptFile16x16.png", "Calc Script", "");
|
||||
|
||||
CAF_PDM_InitField(&absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "");
|
||||
CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "", "");
|
||||
RiaFieldhandleTools::disableWriteAndSetFieldHidden(&content);
|
||||
|
||||
|
||||
absoluteFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
static QStringList createCommandLineArguments(const QString& absoluteFileNameScript);
|
||||
|
||||
caf::PdmField<QString> absoluteFileName;
|
||||
caf::PdmField<QString> content; // TODO: Obsolete field, can be deleted on next project file revision.
|
||||
|
||||
protected:
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
|
@ -117,6 +117,7 @@ RimProject::RimProject(void)
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png", "", "");
|
||||
scriptCollection.uiCapability()->setUiHidden(true);
|
||||
scriptCollection.xmlCapability()->disableIO();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wellPathImport, "WellPathImport", "WellPathImport", "", "", "");
|
||||
wellPathImport = new RimWellPathImport();
|
||||
@ -238,103 +239,6 @@ void RimProject::close()
|
||||
plotWindowTreeViewState = "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::initScriptDirectories(const QString& scriptDirectories)
|
||||
{
|
||||
//
|
||||
// TODO : Must store content of scripts in project file and notify user if stored content is different from disk on execute and edit
|
||||
//
|
||||
this->setScriptDirectories(scriptDirectories);
|
||||
|
||||
// Find largest used caseId read from file and make sure all cases have a valid caseId
|
||||
{
|
||||
int largestCaseId = -1;
|
||||
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
if (cases[i]->caseId > largestCaseId)
|
||||
{
|
||||
largestCaseId = cases[i]->caseId;
|
||||
}
|
||||
}
|
||||
|
||||
if (largestCaseId > this->nextValidCaseId)
|
||||
{
|
||||
this->nextValidCaseId = largestCaseId + 1;
|
||||
}
|
||||
|
||||
// Assign case Id to cases with an invalid case Id
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
if (cases[i]->caseId < 0)
|
||||
{
|
||||
assignCaseIdToCase(cases[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find largest used groupId read from file and make sure all groups have a valid groupId
|
||||
RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : nullptr;
|
||||
if (analysisModels)
|
||||
{
|
||||
int largestGroupId = -1;
|
||||
|
||||
for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
if (cg->groupId > largestGroupId)
|
||||
{
|
||||
largestGroupId = cg->groupId;
|
||||
}
|
||||
}
|
||||
|
||||
if (largestGroupId > this->nextValidCaseGroupId)
|
||||
{
|
||||
this->nextValidCaseGroupId = largestGroupId + 1;
|
||||
}
|
||||
|
||||
// Assign group Id to groups with an invalid Id
|
||||
for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
if (cg->groupId < 0)
|
||||
{
|
||||
assignIdToCaseGroup(cg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int maxViewId = -1;
|
||||
std::vector<Rim3dView*> views;
|
||||
this->descendantsIncludingThisOfType(views);
|
||||
for (Rim3dView* view : views)
|
||||
{
|
||||
maxViewId = std::max(maxViewId, view->id());
|
||||
}
|
||||
|
||||
if (maxViewId >= this->nextValidViewId)
|
||||
{
|
||||
this->nextValidViewId = maxViewId + 1;
|
||||
}
|
||||
|
||||
// Assign view id to views with invalid id
|
||||
for (Rim3dView* view : views)
|
||||
{
|
||||
if (view->id() < 0)
|
||||
{
|
||||
assignViewIdToView(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -105,7 +105,6 @@ public:
|
||||
caf::PdmField<QString> plotWindowCurrentModelIndexPath;
|
||||
|
||||
void setScriptDirectories(const QString& scriptDirectories);
|
||||
void initScriptDirectories(const QString& scriptDirectories);
|
||||
|
||||
QString projectFileVersionString() const;
|
||||
bool isProjectFileVersionEqualOrOlderThan(const QString& otherProjectFileVersion) const;
|
||||
|
Loading…
Reference in New Issue
Block a user