mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Initial commit of ResInsight version 0.4.8
This commit is contained in:
115
ApplicationCode/ProjectDataModel/RimProject.cpp
Normal file
115
ApplicationCode/ProjectDataModel/RimProject.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RIStdInclude.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RIApplication.h"
|
||||
#include "RIVersionInfo.h"
|
||||
#include "RimScriptCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimProject::RimProject(void)
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "");
|
||||
m_projectFileVersionString.setHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", "");
|
||||
|
||||
scriptCollection = new RimScriptCollection();
|
||||
scriptCollection->directory.setHidden(true);
|
||||
|
||||
initAfterRead();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimProject::~RimProject(void)
|
||||
{
|
||||
if (scriptCollection()) delete scriptCollection();
|
||||
|
||||
reservoirs.deleteChildren();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::close()
|
||||
{
|
||||
reservoirs.deleteChildren();
|
||||
|
||||
fileName = "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::initAfterRead()
|
||||
{
|
||||
//
|
||||
// TODO : Must store content of scripts in project file and notify user if stored content is different from disk on execute and edit
|
||||
//
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString scriptDirectory = app->scriptDirectory();
|
||||
|
||||
this->setUserScriptPath(scriptDirectory);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::setupBeforeSave()
|
||||
{
|
||||
m_projectFileVersionString = STRPRODUCTVER;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::setUserScriptPath(const QString& scriptDirectory)
|
||||
{
|
||||
scriptCollection->calcScripts().deleteChildren();
|
||||
scriptCollection->subDirectories().deleteChildren();
|
||||
|
||||
|
||||
QDir dir(scriptDirectory);
|
||||
if (!scriptDirectory.isEmpty() && dir.exists())
|
||||
{
|
||||
RimScriptCollection* sharedScriptLocation = new RimScriptCollection;
|
||||
sharedScriptLocation->directory = scriptDirectory;
|
||||
sharedScriptLocation->setUiName(dir.dirName());
|
||||
|
||||
sharedScriptLocation->readContentFromDisc();
|
||||
|
||||
scriptCollection->subDirectories.push_back(sharedScriptLocation);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimProject::projectFileVersionString() const
|
||||
{
|
||||
return m_projectFileVersionString;
|
||||
}
|
||||
Reference in New Issue
Block a user