diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp index f05a6a3523..bd9e466cd7 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp @@ -33,7 +33,7 @@ RimFileWellPath::RimFileWellPath() m_surveyType.uiCapability()->setUiReadOnly( true ); m_surveyType.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_filepath, "WellPathFilepath", QString( "" ), "File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filepath, "WellPathFilepath", "File Path", "", "", "" ); m_filepath.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" ); m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true ); @@ -49,7 +49,7 @@ RimFileWellPath::~RimFileWellPath() {} //-------------------------------------------------------------------------------------------------- QString RimFileWellPath::filepath() const { - return m_filepath(); + return m_filepath().path(); } //-------------------------------------------------------------------------------------------------- @@ -112,10 +112,12 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ) { - if ( caf::Utils::fileExists( m_filepath() ) ) + if ( caf::Utils::fileExists( m_filepath().path() ) ) { - RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath(), m_wellPathIndexInFile() ); - RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath(), + RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath().path(), + m_wellPathIndexInFile() ); + + RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath().path(), m_wellPathIndexInFile() ); // General well info @@ -132,7 +134,7 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport } else { - if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + m_filepath(); + if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + m_filepath().path(); return false; } } @@ -152,7 +154,7 @@ QString RimFileWellPath::getCacheDirectoryPath() //-------------------------------------------------------------------------------------------------- QString RimFileWellPath::getCacheFileName() { - if ( m_filepath().isEmpty() ) + if ( m_filepath().path().isEmpty() ) { return ""; } @@ -161,7 +163,7 @@ QString RimFileWellPath::getCacheFileName() // Make the path correct related to the possibly new project filename QString newCacheDirPath = getCacheDirectoryPath(); - QFileInfo oldCacheFile( m_filepath ); + QFileInfo oldCacheFile( m_filepath().path() ); cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName(); @@ -179,7 +181,7 @@ void RimFileWellPath::setupBeforeSave() return; } - if ( m_filepath().isEmpty() ) + if ( m_filepath().path().isEmpty() ) { return; } @@ -189,12 +191,12 @@ void RimFileWellPath::setupBeforeSave() QString newCacheFileName = getCacheFileName(); // Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes - QFileInfo prevFileInfo( m_filepath ); + QFileInfo prevFileInfo( m_filepath().path() ); QFileInfo currentFileInfo( newCacheFileName ); if ( prevFileInfo.absoluteFilePath().compare( currentFileInfo.absoluteFilePath() ) != 0 ) { - QFile::copy( m_filepath, newCacheFileName ); + QFile::copy( m_filepath().path(), newCacheFileName ); m_filepath = newCacheFileName; } @@ -214,7 +216,7 @@ bool RimFileWellPath::isStoredInCache() //-------------------------------------------------------------------------------------------------- void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); + // RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); if ( isStoredInCache() ) { @@ -225,8 +227,8 @@ void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectP m_filepath = newCacheFileName; } } - else - { - m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr ); - } + // else + // { + // m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr ); + // } } diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.h b/ApplicationCode/ProjectDataModel/RimFileWellPath.h index 3dfdcbc3a3..77e91051f8 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.h @@ -45,8 +45,8 @@ private: void setupBeforeSave() override; - caf::PdmField m_filepath; - caf::PdmField m_wellPathIndexInFile; // -1 means none. + caf::PdmField m_filepath; + caf::PdmField m_wellPathIndexInFile; // -1 means none. caf::PdmField id; caf::PdmField sourceSystem; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index ec658990f9..5293359909 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -118,7 +118,7 @@ RimWellPath::RimWellPath() CAF_PDM_InitField( &m_formationKeyInFile, "WellPathFormationKeyInFile", QString( "" ), "Key in File", "", "", "" ); m_formationKeyInFile.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_wellPathFormationFilePath, "WellPathFormationFilePath", QString( "" ), "File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathFormationFilePath, "WellPathFormationFilePath", "File Path", "", "", "" ); m_wellPathFormationFilePath.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitFieldNoDefault( &m_wellLogFile_OBSOLETE, "WellLogFile", "Well Log File", "", "", "" ); @@ -627,20 +627,20 @@ size_t RimWellPath::simulationWellBranchCount( const QString& simWellName ) //-------------------------------------------------------------------------------------------------- void RimWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - { - bool foundFile = false; - std::vector searchedPaths; - - QString fileNameCandidate = RimTools::relocateFile( m_wellPathFormationFilePath, - newProjectPath, - oldProjectPath, - &foundFile, - &searchedPaths ); - if ( foundFile ) - { - m_wellPathFormationFilePath = fileNameCandidate; - } - } + //{ + // bool foundFile = false; + // std::vector searchedPaths; + // + // QString fileNameCandidate = RimTools::relocateFile( m_wellPathFormationFilePath, + // newProjectPath, + // oldProjectPath, + // &foundFile, + // &searchedPaths ); + // if ( foundFile ) + // { + // m_wellPathFormationFilePath = fileNameCandidate; + // } + //} } //-------------------------------------------------------------------------------------------------- @@ -738,14 +738,14 @@ void RimWellPath::setFormationsGeometry( cvf::ref wellPat bool RimWellPath::readWellPathFormationsFile( QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter ) { - if ( m_wellPathFormationFilePath().isEmpty() ) + if ( m_wellPathFormationFilePath().path().isEmpty() ) { return true; } - if ( caf::Utils::fileExists( m_wellPathFormationFilePath() ) ) + if ( caf::Utils::fileExists( m_wellPathFormationFilePath().path() ) ) { - m_wellPathFormations = wellPathFormationsImporter->readWellPathFormations( m_wellPathFormationFilePath(), + m_wellPathFormations = wellPathFormationsImporter->readWellPathFormations( m_wellPathFormationFilePath().path(), m_formationKeyInFile() ); if ( m_name().isEmpty() ) { @@ -755,7 +755,8 @@ bool RimWellPath::readWellPathFormationsFile( QString* err } else { - if ( errorMessage ) ( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath(); + if ( errorMessage ) + ( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath().path(); return false; } } @@ -766,20 +767,21 @@ bool RimWellPath::readWellPathFormationsFile( QString* err bool RimWellPath::reloadWellPathFormationsFile( QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter ) { - if ( m_wellPathFormationFilePath().isEmpty() ) + if ( m_wellPathFormationFilePath().path().isEmpty() ) { return true; } - if ( caf::Utils::fileExists( m_wellPathFormationFilePath() ) ) + if ( caf::Utils::fileExists( m_wellPathFormationFilePath().path() ) ) { - m_wellPathFormations = wellPathFormationsImporter->reloadWellPathFormations( m_wellPathFormationFilePath(), + m_wellPathFormations = wellPathFormationsImporter->reloadWellPathFormations( m_wellPathFormationFilePath().path(), m_formationKeyInFile() ); return true; } else { - if ( errorMessage ) ( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath(); + if ( errorMessage ) + ( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath().path(); return false; } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 1a978ce839..0694a60724 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -25,6 +25,7 @@ #include "RimWellPathComponentInterface.h" #include "cafAppEnum.h" +#include "cafFilePath.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -158,8 +159,8 @@ private: caf::PdmField m_unitSystem; - caf::PdmField m_wellPathFormationFilePath; - caf::PdmField m_formationKeyInFile; + caf::PdmField m_wellPathFormationFilePath; + caf::PdmField m_formationKeyInFile; caf::PdmField m_showWellPath; caf::PdmField m_showWellPathLabel;