mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Simplify PdmDocument class and move fileName to private
Remove resolveReferencesRecursively() and initAfterReadRecursively() from PdmDocument::readFile(). These functions will be called in RiaApplication::loadProject after the file paths modifications are done. This will ensure that file paths can be used in initAfterRead() functions.
This commit is contained in:
@@ -461,8 +461,9 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
|
||||
return false;
|
||||
}
|
||||
|
||||
m_project->fileName = fullPathProjectFileName;
|
||||
m_project->setFileName( fullPathProjectFileName );
|
||||
m_project->readFile();
|
||||
m_project->updatesAfterProjectFileIsRead();
|
||||
|
||||
// Apply any modifications to the loaded project before we go ahead and load actual data
|
||||
if ( projectModifier )
|
||||
@@ -493,6 +494,11 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
|
||||
return true;
|
||||
}
|
||||
|
||||
// At this point, all the file paths variables are replaced and all file paths updated to the new location. This will enable use of file
|
||||
// paths in initAfterRead().
|
||||
m_project->resolveReferencesRecursively();
|
||||
m_project->initAfterReadRecursively();
|
||||
|
||||
// Migrate all RimGridCases to RimFileSummaryCase
|
||||
RimGridSummaryCase_obsolete::convertGridCasesToSummaryFileCases( m_project.get() );
|
||||
|
||||
@@ -802,7 +808,7 @@ bool RiaApplication::saveProjectAs( const QString& fileName, gsl::not_null<QStri
|
||||
{
|
||||
CAF_ASSERT( m_project );
|
||||
// Make sure we always store path with forward slash to avoid issues when opening the project file on Linux
|
||||
m_project->fileName = RiaFilePathTools::toInternalSeparator( fileName );
|
||||
m_project->setFileName( RiaFilePathTools::toInternalSeparator( fileName ) );
|
||||
|
||||
onProjectBeingSaved();
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre
|
||||
|
||||
if ( writeProjectInfo )
|
||||
{
|
||||
formatter.comment( "Project: " + RimProject::current()->fileName );
|
||||
formatter.comment( "Project: " + RimProject::current()->fileName() );
|
||||
stream << "\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ void RimProject::close()
|
||||
delete viewLinkerCollection->viewLinker();
|
||||
viewLinkerCollection->viewLinker = nullptr;
|
||||
|
||||
fileName = "";
|
||||
setFileName( "" );
|
||||
|
||||
m_globalPathList = "";
|
||||
|
||||
@@ -303,7 +303,7 @@ void RimProject::close()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::beforeInitAfterRead()
|
||||
void RimProject::updatesAfterProjectFileIsRead()
|
||||
{
|
||||
distributePathsFromGlobalPathList();
|
||||
|
||||
@@ -408,7 +408,7 @@ bool RimProject::writeProjectFile()
|
||||
{
|
||||
transferPathsToGlobalPathList();
|
||||
|
||||
QFile xmlFile( fileName );
|
||||
QFile xmlFile( fileName() );
|
||||
if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
|
||||
|
||||
QString content = documentAsString();
|
||||
@@ -416,7 +416,7 @@ bool RimProject::writeProjectFile()
|
||||
|
||||
if ( RiaPreferences::current()->storeBackupOfProjectFiles() )
|
||||
{
|
||||
QString backupFilename = fileName + "db";
|
||||
QString backupFilename = fileName() + "db";
|
||||
const int maximumRecordCount = 50;
|
||||
RiaProjectBackupTools::appendTextToDatabase( backupFilename, maximumRecordCount, content );
|
||||
}
|
||||
@@ -488,9 +488,10 @@ bool RimProject::isProjectFileVersionEqualOrOlderThan( const QString& otherProje
|
||||
void RimProject::setProjectFileNameAndUpdateDependencies( const QString& projectFileName )
|
||||
{
|
||||
// Extract the filename of the project file when it was saved
|
||||
QString oldProjectFileName = fileName;
|
||||
QString oldProjectFileName = fileName();
|
||||
|
||||
// Replace with the new actual filename
|
||||
fileName = projectFileName;
|
||||
setFileName( projectFileName );
|
||||
|
||||
QFileInfo fileInfo( projectFileName );
|
||||
QString newProjectPath = fileInfo.path();
|
||||
|
||||
@@ -195,8 +195,9 @@ public:
|
||||
|
||||
std::vector<caf::FilePath*> allFilePaths() const;
|
||||
|
||||
void updatesAfterProjectFileIsRead();
|
||||
|
||||
protected:
|
||||
void beforeInitAfterRead() override;
|
||||
void initAfterRead() override;
|
||||
void setupBeforeSave() override;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST( RimRelocatePathTest, findPathsInProjectFile )
|
||||
|
||||
RimProject project;
|
||||
|
||||
project.fileName = fileName;
|
||||
project.setFileName( fileName );
|
||||
project.readFile();
|
||||
|
||||
std::vector<caf::FilePath*> filePaths;
|
||||
|
||||
Reference in New Issue
Block a user