5 #include "XGUI_ActionsMgr.h"
6 #include "XGUI_Command.h"
7 #include "XGUI_Workshop.h"
8 #include "XGUI_OperationMgr.h"
9 #include "XGUI_SalomeConnector.h"
11 #include <ModuleBase_Operation.h>
20 XGUI_ActionsMgr::XGUI_ActionsMgr(XGUI_Workshop* theParent)
21 : QObject(theParent), myOperationMgr(theParent->operationMgr())
26 XGUI_ActionsMgr::~XGUI_ActionsMgr()
31 void XGUI_ActionsMgr::addCommand(QAction* theCmd)
33 QString aId = theCmd->data().toString();
37 myActions.insert(aId, theCmd);
38 XGUI_Command* aXCmd = dynamic_cast<XGUI_Command*>(theCmd);
40 myNestedActions[aId] = aXCmd->nestedCommands();
42 XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
43 myNestedActions[aId] = aWorkshop->salomeConnector()->nestedActions(aId);
47 void XGUI_ActionsMgr::addNestedCommands(const QString& theId, const QStringList& theCommands)
49 myNestedActions[theId] = theCommands;
52 void XGUI_ActionsMgr::update()
54 if(myOperationMgr->hasOperation()) {
56 ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
57 QString anOperationId = anOperation->id();
58 setActionEnabled(anOperationId, true);
59 bool isNestedEnabled = anOperation->isNestedOperationsEnabled();
60 setNestedCommandsEnabled(isNestedEnabled, anOperationId);
63 setNestedCommandsEnabled(false);
68 void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
70 foreach(QString eachAction, myActions.keys()) {
71 setActionEnabled(eachAction, isEnabled);
76 void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent)
78 QStringList ltNestedActions;
79 if(theParent.isEmpty()) { //Disable ALL nested
80 foreach(QString eachParent, myNestedActions.keys()) {
81 ltNestedActions << myNestedActions[eachParent];
84 ltNestedActions << myNestedActions[theParent];
86 foreach(QString eachNested, ltNestedActions) {
87 setActionEnabled(eachNested, theEnabled);
91 void XGUI_ActionsMgr::setActionChecked(const QString& theId, const bool theChecked)
93 QAction* anAction = myActions[theId];
94 if(anAction && anAction->isCheckable()) {
95 anAction->setChecked(theChecked);
100 void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled)
102 QAction* anAction = myActions[theId];
104 anAction->setEnabled(theEnabled);
108 void XGUI_ActionsMgr::updateCheckState()
110 QString eachCommand = QString();
111 foreach(eachCommand, myActions.keys()) {
112 setActionChecked(eachCommand, false);
114 QStringList ltActiveCommands = myOperationMgr->operationList();
115 foreach(eachCommand, ltActiveCommands) {
116 setActionChecked(eachCommand, true);