mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
System command command file merger (#4845)
* Move Import WellPaths command-file functionality into RicImportWellPaths * Add new RICF_init macros for command file objects * Make project save commands available in Python * Fix RiaLogging build errors * Move RiaLogging include from RiaGrpcServer.h to cpp file
This commit is contained in:
@@ -646,6 +646,25 @@ bool RiaApplication::loadProject( const QString& projectFileName )
|
||||
return loadProject( projectFileName, PLA_NONE, nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::saveProject( QString* errorMessage )
|
||||
{
|
||||
CAF_ASSERT( errorMessage );
|
||||
CAF_ASSERT( m_project.notNull() );
|
||||
|
||||
if ( !isProjectSavedToDisc() )
|
||||
{
|
||||
*errorMessage = "Project hasn't already been saved and no file name has been provided";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return saveProjectAs( m_project->fileName(), errorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -654,19 +673,22 @@ bool RiaApplication::saveProjectAs( const QString& fileName, QString* errorMessa
|
||||
// Make sure we always store path with forward slash to avoid issues when opening the project file on Linux
|
||||
m_project->fileName = RiaFilePathTools::toInternalSeparator( fileName );
|
||||
|
||||
onProjectBeingSaved();
|
||||
|
||||
if ( !m_project->writeFile() )
|
||||
{
|
||||
CAF_ASSERT( errorMessage );
|
||||
*errorMessage = QString( "Not possible to save project file. Make sure you have sufficient access "
|
||||
"rights.\n\nProject file location : %1" )
|
||||
.arg( fileName );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_preferences->lastUsedProjectFileName = fileName;
|
||||
caf::PdmSettings::writeFieldsToApplicationStore( m_preferences );
|
||||
|
||||
onProjectSaved();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,9 +126,13 @@ public:
|
||||
bool isProjectSavedToDisc() const;
|
||||
QString currentProjectPath() const;
|
||||
QString createAbsolutePathFromProjectRelativePath( QString projectRelativePath );
|
||||
bool loadProject( const QString& projectFileName );
|
||||
|
||||
bool loadProject( const QString& projectFileName );
|
||||
bool loadProject( const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier );
|
||||
bool saveProjectAs( const QString& fileName, QString* errorMessage );
|
||||
|
||||
bool saveProject( QString* errorMessage );
|
||||
bool saveProjectAs( const QString& fileName, QString* errorMessage );
|
||||
|
||||
static bool hasValidProjectFileExtension( const QString& fileName );
|
||||
void closeProject();
|
||||
|
||||
@@ -206,11 +210,15 @@ protected:
|
||||
// Protected implementation specific overrides
|
||||
virtual void invokeProcessEvents( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) = 0;
|
||||
virtual void onFileSuccessfullyLoaded( const QString& fileName, RiaDefines::ImportFileType fileType ) {}
|
||||
|
||||
virtual void onProjectBeingOpened() {}
|
||||
virtual void onProjectOpened() = 0;
|
||||
virtual void onProjectOpeningError( const QString& errMsg ) = 0;
|
||||
virtual void onProjectBeingClosed() {}
|
||||
virtual void onProjectClosed() = 0;
|
||||
virtual void onProjectBeingSaved() {}
|
||||
virtual void onProjectSaved() {}
|
||||
|
||||
virtual void startMonitoringWorkProgress( caf::UiProcess* uiProcess ) {}
|
||||
virtual void stopMonitoringWorkProgress() {}
|
||||
|
||||
|
||||
@@ -209,23 +209,23 @@ bool RiaGuiApplication::saveProject()
|
||||
{
|
||||
CVF_ASSERT( m_project.notNull() );
|
||||
|
||||
QString fileName;
|
||||
if ( !isProjectSavedToDisc() )
|
||||
{
|
||||
return saveProjectPromptForFileName();
|
||||
fileName = promptForProjectSaveAsFileName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return saveProjectAs( m_project->fileName() );
|
||||
fileName = m_project->fileName();
|
||||
}
|
||||
return saveProjectAs( fileName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaGuiApplication::saveProjectPromptForFileName()
|
||||
QString RiaGuiApplication::promptForProjectSaveAsFileName() const
|
||||
{
|
||||
// if (m_project.isNull()) return true;
|
||||
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
QString startPath;
|
||||
@@ -243,19 +243,7 @@ bool RiaGuiApplication::saveProjectPromptForFileName()
|
||||
tr( "Save File" ),
|
||||
startPath,
|
||||
tr( "Project Files (*.rsp);;All files(*.*)" ) );
|
||||
if ( fileName.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember the directory to next time
|
||||
app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileName ).absolutePath() );
|
||||
|
||||
bool bSaveOk = saveProjectAs( fileName );
|
||||
|
||||
setWindowCaptionFromAppState();
|
||||
|
||||
return bSaveOk;
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -300,7 +288,6 @@ bool RiaGuiApplication::askUserToSaveModifiedProject()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaGuiApplication::saveProjectAs( const QString& fileName )
|
||||
{
|
||||
storeTreeViewState();
|
||||
QString errMsg;
|
||||
if ( !RiaApplication::saveProjectAs( fileName, &errMsg ) )
|
||||
{
|
||||
@@ -308,8 +295,6 @@ bool RiaGuiApplication::saveProjectAs( const QString& fileName )
|
||||
return false;
|
||||
}
|
||||
|
||||
m_recentFileActionProvider->addFileName( fileName );
|
||||
caf::PdmUiModelChangeDetector::instance()->reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1486,6 +1471,25 @@ void RiaGuiApplication::onProjectClosed()
|
||||
processEvents();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGuiApplication::onProjectBeingSaved()
|
||||
{
|
||||
setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( m_project->fileName() ).absolutePath() );
|
||||
storeTreeViewState();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGuiApplication::onProjectSaved()
|
||||
{
|
||||
setWindowCaptionFromAppState();
|
||||
m_recentFileActionProvider->addFileName( m_project->fileName() );
|
||||
caf::PdmUiModelChangeDetector::instance()->reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -91,10 +91,10 @@ public:
|
||||
RiaGuiApplication( int& argc, char** argv );
|
||||
~RiaGuiApplication() override;
|
||||
|
||||
bool saveProject();
|
||||
bool saveProjectPromptForFileName();
|
||||
bool askUserToSaveModifiedProject();
|
||||
bool saveProjectAs( const QString& fileName );
|
||||
bool saveProject();
|
||||
QString promptForProjectSaveAsFileName() const;
|
||||
bool askUserToSaveModifiedProject();
|
||||
bool saveProjectAs( const QString& fileName );
|
||||
|
||||
void runMultiCaseSnapshots( const QString& templateProjectFileName,
|
||||
std::vector<QString> gridFileNames,
|
||||
@@ -141,11 +141,15 @@ protected:
|
||||
// Protected RiaApplication overrides
|
||||
void invokeProcessEvents( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) override;
|
||||
void onFileSuccessfullyLoaded( const QString& fileName, RiaDefines::ImportFileType fileType ) override;
|
||||
|
||||
void onProjectBeingOpened() override;
|
||||
void onProjectOpeningError( const QString& errMsg );
|
||||
void onProjectOpened() override;
|
||||
void onProjectBeingClosed() override;
|
||||
void onProjectClosed() override;
|
||||
void onProjectBeingSaved() override;
|
||||
void onProjectSaved() override;
|
||||
|
||||
void startMonitoringWorkProgress( caf::UiProcess* uiProcess ) override;
|
||||
void stopMonitoringWorkProgress() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user