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:
@@ -18,13 +18,37 @@
|
||||
|
||||
#include "RicSaveProjectAsFeature.h"
|
||||
|
||||
#include "RicSaveProjectFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RicSaveProjectFeature.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicSaveProjectAsFeature, "RicSaveProjectAsFeature" );
|
||||
RICF_SOURCE_INIT( RicSaveProjectAsFeature, "RicSaveProjectAsFeature", "saveProjectAs" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSaveProjectAsFeature::RicSaveProjectAsFeature()
|
||||
{
|
||||
RICF_InitFieldNoDefault( &m_filePath, "filePath", "", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfCommandResponse RicSaveProjectAsFeature::execute()
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
QString errorMessage;
|
||||
if ( !RiaApplication::instance()->saveProjectAs( m_filePath(), &errorMessage ) )
|
||||
{
|
||||
return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, errorMessage );
|
||||
}
|
||||
return RicfCommandResponse();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -39,12 +63,25 @@ bool RicSaveProjectAsFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveProjectAsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
if ( app )
|
||||
{
|
||||
app->saveProjectPromptForFileName();
|
||||
m_filePath = app->promptForProjectSaveAsFileName();
|
||||
if ( m_filePath().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto response = execute();
|
||||
|
||||
if ( response.status() != RicfCommandResponse::COMMAND_OK )
|
||||
{
|
||||
QString displayMessage = response.messages().join( "\n" );
|
||||
if ( RiaGuiApplication::isRunning() )
|
||||
{
|
||||
QMessageBox::warning( nullptr, "Error when saving project file", displayMessage );
|
||||
}
|
||||
RiaLogging::error( displayMessage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user