setAllEnabled(false);
ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
FeaturePtr aFeature = anOperation->feature();
- QString anOperationId = QString::fromStdString(aFeature->getKind()); //anOperation->id();
- setActionEnabled(anOperationId, true);
- bool isNestedEnabled = anOperation->isNestedOperationsEnabled();
- setNestedCommandsEnabled(isNestedEnabled, anOperationId);
+ QString aFeatureId = QString::fromStdString(aFeature->getKind());
+ setActionEnabled(aFeatureId, true);
+ setNestedStackEnabled(anOperation);
} else {
setAllEnabled(true);
setNestedCommandsEnabled(false);
}
}
+void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+{
+ if(theOperation == NULL)
+ return;
+ FeaturePtr aFeature = theOperation->feature();
+ QString aFeatureId = QString::fromStdString(aFeature->getKind());
+ bool isNestedEnabled = theOperation->isNestedOperationsEnabled();
+ setNestedCommandsEnabled(isNestedEnabled, aFeatureId);
+
+ setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
+}
+
//!
void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent)
{
class XGUI_Command;
class XGUI_Workshop;
class XGUI_OperationMgr;
+class ModuleBase_Operation;
class QAction;
class XGUI_EXPORT XGUI_ActionsMgr : public QObject
protected:
//! Sets all actions to isEnabled state.
void setAllEnabled(bool isEnabled);
+ //! Sets to isEnabled state all siblings of the given operation and it's parents recursively
+ void setNestedStackEnabled(ModuleBase_Operation* theOperation);
//! Sets all nested actions to isEnabled state for the command with given ID.
//! If ID is empty - all nested actions will be affected.
void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
return myOperations.count();
}
-QStringList XGUI_OperationMgr::operationList()
+QStringList XGUI_OperationMgr::operationList() const
{
QStringList result;
foreach(ModuleBase_Operation* eachOperation, myOperations) {
return result;
}
+ModuleBase_Operation* XGUI_OperationMgr::previousOperation(ModuleBase_Operation* theOperation) const
+{
+ int idx = myOperations.lastIndexOf(theOperation);
+ if(idx == -1 || idx == 0) {
+ return NULL;
+ }
+ return myOperations.at(idx - 1);
+}
+
bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
{
if (theEvent->type() == QEvent::KeyRelease) {
/// Returns number of operations in the stack
int operationsCount() const;
/// Returns list of all operations IDs
- QStringList operationList();
+ QStringList operationList() const;
+
+ /// Returns previous (parent) operation if given operation started.
+ /// else, or if there is no parent - returns NULL
+ ModuleBase_Operation* previousOperation(ModuleBase_Operation* theOperation) const;
virtual bool eventFilter(QObject *theObject, QEvent *theEvent);