SSIHUB: Update file paths for and well path cache

Consolidated cache creation in RimTools
This commit is contained in:
Magne Sjaastad
2013-10-24 09:50:21 +02:00
parent 5772767f79
commit 40092b0d62
12 changed files with 191 additions and 25 deletions
@@ -45,6 +45,7 @@
#include <fstream>
#include <limits>
#include "RimTools.h"
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
@@ -268,11 +269,8 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
//--------------------------------------------------------------------------------------------------
QString RimWellPath::getCacheDirectoryPath()
{
QString cacheDirPath;
QString projectFileName = RiaApplication::instance()->project()->fileName();
QFileInfo fileInfo(projectFileName);
cacheDirPath = fileInfo.canonicalPath();
cacheDirPath += "/" + fileInfo.completeBaseName() + "_wellpaths";
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
cacheDirPath += "_wellpaths";
return cacheDirPath;
}
@@ -298,7 +296,7 @@ QString RimWellPath::getCacheFileName()
void RimWellPath::setupBeforeSave()
{
// SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to new project cache location
if (id().isEmpty())
if (!isStoredInCache())
{
return;
}
@@ -318,3 +316,26 @@ void RimWellPath::setupBeforeSave()
filepath = newCacheFileName;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPath::isStoredInCache()
{
// SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to new project cache location
return !id().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::updateFilePathsFromProjectPath()
{
QString newCacheFileName = getCacheFileName();
if (QFile::exists(newCacheFileName))
{
filepath = newCacheFileName;
}
}