mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge branch 'internal' of https://github.com/OPM/ResInsight into internal
This commit is contained in:
commit
5772767f79
@ -21,6 +21,8 @@
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimProject.h"
|
||||
@ -40,6 +42,7 @@
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
@ -259,3 +262,59 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
|
||||
ssihubGroup->add(&m_surveyType);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPath::getCacheDirectoryPath()
|
||||
{
|
||||
QString cacheDirPath;
|
||||
QString projectFileName = RiaApplication::instance()->project()->fileName();
|
||||
QFileInfo fileInfo(projectFileName);
|
||||
cacheDirPath = fileInfo.canonicalPath();
|
||||
cacheDirPath += "/" + fileInfo.completeBaseName() + "_wellpaths";
|
||||
return cacheDirPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPath::getCacheFileName()
|
||||
{
|
||||
QString cacheFileName;
|
||||
|
||||
// Make the path correct related to the possibly new project filename
|
||||
QString newCacheDirPath = getCacheDirectoryPath();
|
||||
QFileInfo oldCacheFile(filepath);
|
||||
|
||||
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
|
||||
|
||||
return cacheFileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDir::root().mkpath(getCacheDirectoryPath());
|
||||
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
// Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes
|
||||
QFileInfo prevFileInfo(filepath);
|
||||
QFileInfo currentFileInfo(newCacheFileName);
|
||||
|
||||
if (prevFileInfo.absoluteFilePath().compare(currentFileInfo.absoluteFilePath()) != 0)
|
||||
{
|
||||
QFile::copy(filepath, newCacheFileName);
|
||||
|
||||
filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ private:
|
||||
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
QString getCacheFileName();
|
||||
QString getCacheDirectoryPath();
|
||||
|
||||
virtual void setupBeforeSave();
|
||||
|
||||
caf::PdmField<QString> id;
|
||||
caf::PdmField<QString> sourceSystem;
|
||||
|
Loading…
Reference in New Issue
Block a user