(#791) Update well path filename if project file is relocated

This commit is contained in:
Magne Sjaastad
2016-06-29 16:09:27 +02:00
parent 124585b96a
commit e730e5bf9f
5 changed files with 17 additions and 10 deletions

View File

@@ -390,7 +390,7 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName
{ {
RimOilField* oilField = oilFields[oilFieldIdx]; RimOilField* oilField = oilFields[oilFieldIdx];
if (oilField == NULL || oilField->wellPathCollection == NULL) continue; if (oilField == NULL || oilField->wellPathCollection == NULL) continue;
oilField->wellPathCollection->updateFilePathsFromProjectPath(); oilField->wellPathCollection->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
} }
wellPathImport->updateFilePaths(); wellPathImport->updateFilePaths();

View File

@@ -365,13 +365,20 @@ bool RimWellPath::isStoredInCache()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::updateFilePathsFromProjectPath() void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
{ {
QString newCacheFileName = getCacheFileName(); if (isStoredInCache())
if (QFile::exists(newCacheFileName))
{ {
filepath = newCacheFileName; QString newCacheFileName = getCacheFileName();
if (QFile::exists(newCacheFileName))
{
filepath = newCacheFileName;
}
}
else
{
filepath = RimTools::relocateFile(filepath(), newProjectPath, oldProjectPath, NULL, NULL);
} }
} }

View File

@@ -73,7 +73,7 @@ public:
RivWellPathPartMgr* partMgr(); RivWellPathPartMgr* partMgr();
bool readWellPathFile(QString * errorMessage, RifWellPathAsciiFileReader* asciiReader); bool readWellPathFile(QString * errorMessage, RifWellPathAsciiFileReader* asciiReader);
void updateFilePathsFromProjectPath(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);

View File

@@ -310,11 +310,11 @@ void RimWellPathCollection::scheduleGeometryRegenAndRedrawViews()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathCollection::updateFilePathsFromProjectPath() void RimWellPathCollection::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
{ {
for (size_t wellPathIdx = 0; wellPathIdx < wellPaths.size(); wellPathIdx++) for (size_t wellPathIdx = 0; wellPathIdx < wellPaths.size(); wellPathIdx++)
{ {
wellPaths[wellPathIdx]->updateFilePathsFromProjectPath(); wellPaths[wellPathIdx]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
} }
} }

View File

@@ -91,7 +91,7 @@ public:
void scheduleGeometryRegenAndRedrawViews(); void scheduleGeometryRegenAndRedrawViews();
void updateFilePathsFromProjectPath(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);
protected: protected:
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );