From 6d7b29bb29864d99f32fd977f31c8bcce40b5a48 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 18 Oct 2019 14:45:12 +0200 Subject: [PATCH] #4893 Formations : Make sure "layer_zone_table.txt" is defined once --- .../Commands/RicImportFormationNamesFeature.cpp | 10 +++++++--- .../Commands/RicImportObservedFmuDataFeature.cpp | 3 ++- ApplicationCode/ProjectDataModel/RimFormationNames.cpp | 10 +++++++++- ApplicationCode/ProjectDataModel/RimFormationNames.h | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index 6621afd80b..a37e79316c 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -75,11 +75,15 @@ void RicImportFormationNamesFeature::onActionTriggered( bool isChecked ) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + + QString filterText = QString( + "Formation Names description File (*.lyr);;FMU Layer Zone Table(%1);;All Files (*.*)" ) + .arg( RimFormationNames::layerZoneTableFileName() ); + + QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), "Import Formation Names", defaultDir, - "Formation Names description File (*.lyr);;FMU Layer Zone " - "Table(layer_zone_table.txt);;All Files (*.*)" ); + filterText ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp b/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp index f6ad5f87ad..f6bf21fb08 100644 --- a/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp @@ -26,6 +26,7 @@ #include "RifReaderFmuRft.h" +#include "RimFormationNames.h" #include "RimObservedDataCollection.h" #include "RimObservedFmuRftData.h" #include "RimObservedSummaryData.h" @@ -88,7 +89,7 @@ void RicImportObservedFmuDataFeature::selectObservedDataPathInDialog() { importedData = observedDataCollection->createAndAddFmuRftDataFromPath( subDir ); QDir dir( subDir ); - QString layerZoneFile = dir.absoluteFilePath( "layer_zone_table.txt" ); + QString layerZoneFile = dir.absoluteFilePath( RimFormationNames::layerZoneTableFileName() ); if ( QFileInfo::exists( layerZoneFile ) ) { QStringList fileNames; diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index de1a37ddab..6491f3188d 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -151,7 +151,7 @@ void RimFormationNames::readFormationNamesFile( QString* errorMessage ) QFileInfo fileInfo( m_formationNamesFileName() ); - if ( fileInfo.fileName() == "layer_zone_table.txt" ) + if ( fileInfo.fileName() == RimFormationNames::layerZoneTableFileName() ) { readFmuFormationNameFile( stream, errorMessage ); } @@ -174,6 +174,14 @@ void RimFormationNames::updateFilePathsFromProjectPath( const QString& newProjec nullptr ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFormationNames::layerZoneTableFileName() +{ + return "layer_zone_table.txt"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.h b/ApplicationCode/ProjectDataModel/RimFormationNames.h index 9f1a5a51bc..a46b697cdd 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.h +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.h @@ -49,6 +49,8 @@ public: void readFormationNamesFile( QString* errorMessage ); void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ); + static QString layerZoneTableFileName(); + protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue,