5 #include <XGUI_ActionsMgr.h>
6 #include <XGUI_Command.h>
10 XGUI_ActionsMgr::XGUI_ActionsMgr(QObject* theParent)
16 XGUI_ActionsMgr::~XGUI_ActionsMgr()
21 void XGUI_ActionsMgr::addCommand(XGUI_Command* theCmd)
23 myActions.insert(theCmd->id(),theCmd);
24 myActionsState.insert(theCmd->id(), theCmd->enabled());
25 theCmd->connectTo(this, SLOT(setActionsDisabled(bool)));
28 void XGUI_ActionsMgr::setActionsDisabled(bool isDisabled)
30 //Re-enable actions (just restore their state)
32 myNestedActions.clear();
33 restoreCommandState();
36 //Disable all actions, but caller and unblockable (defined in a xml)
38 XGUI_Command* aToggledFeature = dynamic_cast<XGUI_Command*>(sender());
39 QString aSkippedId = aToggledFeature->id();
40 QStringList anActionIdsList = myActions.keys();
41 foreach(QString eachKey, anActionIdsList) {
42 if (eachKey == aSkippedId) {
45 myActions[eachKey]->setEnabled(false);
47 myNestedActions = aToggledFeature->unblockableCommands();
50 void XGUI_ActionsMgr::saveCommandsState()
52 myActionsState.clear();
53 QStringList anActionIdsList = myActions.keys();
54 foreach(QString eachKey, anActionIdsList) {
55 myActionsState.insert(eachKey, myActions[eachKey]->isEnabled());
60 void XGUI_ActionsMgr::restoreCommandState()
62 QStringList anActionIdsList = myActions.keys();
63 foreach(QString eachKey, anActionIdsList) {
64 myActions[eachKey]->setEnabled(myActionsState[eachKey]);
65 myActions[eachKey]->setChecked(false);
69 void XGUI_ActionsMgr::setNestedActionsEnabled(bool isEnabled)
71 foreach(QString eachKey, myNestedActions) {
72 myActions[eachKey]->setEnabled(isEnabled);