#include "XGUI_OperationMgr.h"
#include "XGUI_SalomeConnector.h"
+#include <ModelAPI_Session.h>
+
#include <ModuleBase_Operation.h>
#include <Events_Error.h>
void XGUI_ActionsMgr::update()
{
if (myOperationMgr->hasOperation()) {
- 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);
+ if(aFeature) {
+ setAllEnabled(false);
+ QString aFeatureId = QString::fromStdString(aFeature->getKind());
+ setActionEnabled(aFeatureId, true);
+ setNestedStackEnabled(anOperation);
+ }
} else {
setAllEnabled(true);
setNestedCommandsEnabled(false);
}
+ updateByDocumentKind();
updateCheckState();
}
}
}
+void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+{
+ if(!theOperation || !theOperation->feature())
+ 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)
{
}
}
+/*
+ * Disables all actions which have the Document Kind different to
+ * the current document's kind
+ */
+void XGUI_ActionsMgr::updateByDocumentKind()
+{
+ std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind();
+ QString aDocKind = QString::fromStdString(aStdDocKind);
+ foreach(QAction* eachAction, myActions.values()) {
+ XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(eachAction);
+ if(aCmd) {
+ QString aCmdDocKind = aCmd->documentKind();
+ if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
+ eachAction->setEnabled(false);
+ }
+ }
+ }
+}
+
void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled)
{
QAction* anAction = myActions[theId];