mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#339) Refactored execution of scripts for selected cases
Moved slotExecuteScriptForSelectedCases() from RiuMainWindow to RicExecuteScriptForCasesFeature.
This commit is contained in:
@@ -2253,46 +2253,3 @@ void RiuMainWindow::customMenuRequested(const QPoint& pos)
|
||||
|
||||
menu.exec(globalPos);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::slotExecuteScriptForSelectedCases()
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
if (!action) return;
|
||||
|
||||
QString scriptAbsolutePath = action->data().toString();
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
{
|
||||
// TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing
|
||||
// absolutePath() is a function in QFileInfo
|
||||
|
||||
QFileInfo fi(scriptAbsolutePath);
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
|
||||
QStringList arguments = app->octaveArguments();
|
||||
arguments.append("--path");
|
||||
arguments << octaveFunctionSearchPath;
|
||||
arguments << scriptAbsolutePath;
|
||||
|
||||
std::vector<RimCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
// Get case ID from selected cases in selection model
|
||||
std::vector<int> caseIdsInSelection;
|
||||
for (size_t i = 0; i < selection.size(); i++)
|
||||
{
|
||||
RimCase* casePtr = selection[i];
|
||||
caseIdsInSelection.push_back(casePtr->caseId);
|
||||
}
|
||||
|
||||
if (caseIdsInSelection.size() > 0)
|
||||
{
|
||||
RiaApplication::instance()->launchProcessForMultipleCases(octavePath, arguments, caseIdsInSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,6 @@ private slots:
|
||||
|
||||
void selectedObjectsChanged();
|
||||
void customMenuRequested(const QPoint& pos);
|
||||
void slotExecuteScriptForSelectedCases();
|
||||
|
||||
|
||||
// Animation slots
|
||||
|
||||
Reference in New Issue
Block a user