Improve CmdFeature base class

Add default implementation of isEnabled() and add const
This commit is contained in:
Magne Sjaastad
2023-06-26 14:28:46 +02:00
committed by GitHub
parent 59ca0b943c
commit 1da509166a
786 changed files with 638 additions and 1857 deletions

View File

@@ -38,7 +38,7 @@ CAF_CMD_SOURCE_INIT( RicAddScriptPathFeature, "RicAddScriptPathFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAddScriptPathFeature::isCommandEnabled()
bool RicAddScriptPathFeature::isCommandEnabled() const
{
std::vector<RimScriptCollection*> selection = RicScriptFeatureImpl::selectedScriptCollections();
return selection.size() > 0;

View File

@@ -31,7 +31,7 @@ class RicAddScriptPathFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -38,7 +38,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteScriptPathFeature, "RicDeleteScriptPathFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteScriptPathFeature::isCommandEnabled()
bool RicDeleteScriptPathFeature::isCommandEnabled() const
{
std::vector<RimScriptCollection*> selection = RicScriptFeatureImpl::selectedScriptCollections();
if ( selection.size() == 1 )

View File

@@ -31,7 +31,7 @@ class RicDeleteScriptPathFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -38,7 +38,7 @@ CAF_CMD_SOURCE_INIT( RicEditScriptFeature, "RicEditScriptFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEditScriptFeature::isCommandEnabled()
bool RicEditScriptFeature::isCommandEnabled() const
{
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
return !selection.empty();

View File

@@ -31,7 +31,7 @@ class RicEditScriptFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -41,14 +41,6 @@ QString RicExecuteLastUsedScriptFeature::lastUsedScriptPathKey()
return "lastUsedScriptPath";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExecuteLastUsedScriptFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -32,7 +32,6 @@ class RicExecuteLastUsedScriptFeature : public caf::CmdFeature
static QString lastUsedScriptPathKey();
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -44,7 +44,7 @@ CAF_CMD_SOURCE_INIT( RicExecuteScriptFeature, "RicExecuteScriptFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExecuteScriptFeature::isCommandEnabled()
bool RicExecuteScriptFeature::isCommandEnabled() const
{
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
return selection.size() > 0;

View File

@@ -35,7 +35,7 @@ class RicExecuteScriptFeature : public caf::CmdFeature
static void executeScript( RimCalcScript* calcScript );
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -37,7 +37,7 @@ CAF_CMD_SOURCE_INIT( RicExecuteScriptForCasesFeature, "RicExecuteScriptForCasesF
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExecuteScriptForCasesFeature::isCommandEnabled()
bool RicExecuteScriptForCasesFeature::isCommandEnabled() const
{
std::vector<RimCase*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );

View File

@@ -30,7 +30,7 @@ class RicExecuteScriptForCasesFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -44,7 +44,7 @@ CAF_CMD_SOURCE_INIT( RicNewOctaveScriptFeature, "RicNewOctaveScriptFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewOctaveScriptFeature::isCommandEnabled()
bool RicNewOctaveScriptFeature::isCommandEnabled() const
{
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
if ( calcScriptCollections.empty() ) return false;

View File

@@ -31,7 +31,7 @@ class RicNewOctaveScriptFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -45,7 +45,7 @@ CAF_CMD_SOURCE_INIT( RicNewPythonScriptFeature, "RicNewPythonScriptFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPythonScriptFeature::isCommandEnabled()
bool RicNewPythonScriptFeature::isCommandEnabled() const
{
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
if ( calcScriptCollections.empty() ) return false;

View File

@@ -30,7 +30,7 @@ class RicNewPythonScriptFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -27,14 +27,6 @@
CAF_CMD_SOURCE_INIT( RicRefreshScriptsFeature, "RicRefreshScriptsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRefreshScriptsFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -33,7 +33,6 @@ public:
static void refreshScriptFolders();
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};