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 restoreCommandState();
35 //Disable all actions, but caller and unblockable (defined in a xml)
37 QStringList aSkippedIds;
38 XGUI_Command* aToggledFeature = dynamic_cast<XGUI_Command*>(sender());
39 aSkippedIds.append(aToggledFeature->unblockableCommands());
40 aSkippedIds.append(aToggledFeature->id());
41 QStringList anActionIdsList = myActions.keys();
42 foreach(QString eachKey, anActionIdsList) {
43 if (aSkippedIds.removeAll(eachKey) > 0) {
46 myActions[eachKey]->setEnabled(false);
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);