mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -38,20 +38,20 @@
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewOctaveScriptFeature, "RicNewOctaveScriptFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicNewOctaveScriptFeature, "RicNewOctaveScriptFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewOctaveScriptFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
if (calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::OCTAVE)
|
||||
if ( calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::OCTAVE )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty())
|
||||
else if ( calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -59,24 +59,24 @@ bool RicNewOctaveScriptFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewOctaveScriptFeature::onActionTriggered(bool isChecked)
|
||||
void RicNewOctaveScriptFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
|
||||
RimCalcScript* calcScript = calcScripts.size() > 0 ? calcScripts[0] : nullptr;
|
||||
RimCalcScript* calcScript = calcScripts.size() > 0 ? calcScripts[0] : nullptr;
|
||||
RimScriptCollection* scriptColl = calcScriptCollections.size() > 0 ? calcScriptCollections[0] : nullptr;
|
||||
|
||||
QString fullPathNewScript;
|
||||
|
||||
if (calcScript)
|
||||
if ( calcScript )
|
||||
{
|
||||
QFileInfo existingScriptFileInfo(calcScript->absoluteFileName());
|
||||
QFileInfo existingScriptFileInfo( calcScript->absoluteFileName() );
|
||||
fullPathNewScript = existingScriptFileInfo.absolutePath();
|
||||
}
|
||||
else if (scriptColl)
|
||||
else if ( scriptColl )
|
||||
{
|
||||
fullPathNewScript = scriptColl->directory();
|
||||
}
|
||||
@@ -88,61 +88,65 @@ void RicNewOctaveScriptFeature::onActionTriggered(bool isChecked)
|
||||
QString fullPathFilenameNewScript;
|
||||
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
|
||||
int num= 1;
|
||||
while (caf::Utils::fileExists(fullPathFilenameNewScript))
|
||||
int num = 1;
|
||||
while ( caf::Utils::fileExists( fullPathFilenameNewScript ) )
|
||||
{
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number( num ) + ".m";
|
||||
num++;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
fullPathFilenameNewScript = QInputDialog::getText(nullptr,
|
||||
"Specify new script file",
|
||||
"File name",
|
||||
QLineEdit::Normal,
|
||||
fullPathFilenameNewScript,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags());
|
||||
fullPathFilenameNewScript = QInputDialog::getText( nullptr,
|
||||
"Specify new script file",
|
||||
"File name",
|
||||
QLineEdit::Normal,
|
||||
fullPathFilenameNewScript,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags() );
|
||||
|
||||
if (ok && !fullPathFilenameNewScript.isEmpty())
|
||||
if ( ok && !fullPathFilenameNewScript.isEmpty() )
|
||||
{
|
||||
QFile file(fullPathFilenameNewScript);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
QFile file( fullPathFilenameNewScript );
|
||||
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to create file\n" + fullPathFilenameNewScript );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RicRefreshScriptsFeature::refreshScriptFolders();
|
||||
|
||||
if (calcScript)
|
||||
if ( calcScript )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem(calcScript);
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( calcScript );
|
||||
}
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if ( !scriptEditor.isEmpty() )
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
QProcess* myProcess = new QProcess( this );
|
||||
myProcess->start( scriptEditor, arguments );
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
if ( !myProcess->waitForStarted( 1000 ) )
|
||||
{
|
||||
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to start script editor executable\n" + scriptEditor );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewOctaveScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicNewOctaveScriptFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("New Octave Script");
|
||||
actionToSetup->setText( "New Octave Script" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user