From: sbh Date: Tue, 29 Apr 2014 09:25:38 +0000 (+0400) Subject: Issue #6 Extended processing of nested actions. X-Git-Tag: V_0.2~108 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d86c77d1c6210bbe04fbc3e5b00f9e212e1ec930;p=modules%2Fshaper.git Issue #6 Extended processing of nested actions. --- diff --git a/src/Config/Config_FeatureMessage.cpp b/src/Config/Config_FeatureMessage.cpp index 2da657417..9408522e6 100644 --- a/src/Config/Config_FeatureMessage.cpp +++ b/src/Config/Config_FeatureMessage.cpp @@ -105,3 +105,13 @@ void Config_FeatureMessage::setUseInput(bool isUseInput) { myUseInput = isUseInput; } + +const std::string& Config_FeatureMessage::nestedFeatures() const +{ + return myNestedFeatures; +} + +void Config_FeatureMessage::setNestedFeatures(const std::string& theNestedFeatures) +{ + myNestedFeatures = theNestedFeatures; +} diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index a7928800a..bcf674cee 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -24,14 +24,12 @@ class Config_FeatureMessage: public Events_Message std::string myPluginLibrary; //Name of feature's library bool myUseInput; //Action is being checked until user commit the operation + std::string myNestedFeatures; public: //const Events_ID theID, const void* theSender = 0 CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0); - //TODO(sbh): Implement static method to extract event id [SEID] - //static const char* eventId() { return ""; } - //Auto-generated getters/setters CONFIG_EXPORT const std::string& icon() const; CONFIG_EXPORT const std::string& id() const; @@ -42,17 +40,18 @@ public: CONFIG_EXPORT const std::string& groupId() const; CONFIG_EXPORT const std::string& workbenchId() const; CONFIG_EXPORT const std::string& pluginLibrary() const; + CONFIG_EXPORT const std::string& nestedFeatures() const; + CONFIG_EXPORT bool isUseInput() const; CONFIG_EXPORT void setIcon(const std::string& icon); CONFIG_EXPORT void setId(const std::string& id); CONFIG_EXPORT void setKeysequence(const std::string& keysequence); CONFIG_EXPORT void setText(const std::string& text); CONFIG_EXPORT void setTooltip(const std::string& tooltip); - CONFIG_EXPORT void setGroupId(const std::string& groupId); CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId); CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary); - CONFIG_EXPORT bool isUseInput() const; + CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures); CONFIG_EXPORT void setUseInput(bool isUseInput); }; diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 2fd10770e..a3b7b56f2 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -79,4 +79,5 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage outFtMessage.setGroupId(myLastGroup); outFtMessage.setWorkbenchId(myLastWorkbench); outFtMessage.setPluginLibrary(myLibraryName); + outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED)); } diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 61f09f5c3..281248f85 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -38,6 +38,7 @@ const static char* FEATURE_TEXT = "text"; const static char* FEATURE_TOOLTIP = "tooltip"; const static char* FEATURE_ICON = "icon"; const static char* FEATURE_KEYSEQUENCE = "keysequence"; +const static char* FEATURE_NESTED = "nested"; const static char* SOURCE_FILE = "path"; diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 0d652dceb..8cc05c494 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -29,22 +29,22 @@ void XGUI_ActionsMgr::setActionsDisabled(bool isDisabled) { //Re-enable actions (just restore their state) if (!isDisabled) { + myNestedActions.clear(); restoreCommandState(); return; } //Disable all actions, but caller and unblockable (defined in a xml) saveCommandsState(); - QStringList aSkippedIds; XGUI_Command* aToggledFeature = dynamic_cast(sender()); - aSkippedIds.append(aToggledFeature->unblockableCommands()); - aSkippedIds.append(aToggledFeature->id()); + QString aSkippedId = aToggledFeature->id(); QStringList anActionIdsList = myActions.keys(); foreach(QString eachKey, anActionIdsList) { - if (aSkippedIds.removeAll(eachKey) > 0) { + if (eachKey == aSkippedId) { continue; } myActions[eachKey]->setEnabled(false); } + myNestedActions = aToggledFeature->unblockableCommands(); } void XGUI_ActionsMgr::saveCommandsState() @@ -65,3 +65,10 @@ void XGUI_ActionsMgr::restoreCommandState() myActions[eachKey]->setChecked(false); } } + +void XGUI_ActionsMgr::setNestedActionsEnabled(bool isEnabled) +{ + foreach(QString eachKey, myNestedActions) { + myActions[eachKey]->setEnabled(isEnabled); + } +} diff --git a/src/XGUI/XGUI_ActionsMgr.h b/src/XGUI/XGUI_ActionsMgr.h index a3d7dea19..d6c55d833 100644 --- a/src/XGUI/XGUI_ActionsMgr.h +++ b/src/XGUI/XGUI_ActionsMgr.h @@ -20,14 +20,18 @@ public: XGUI_ActionsMgr(QObject* theParent); virtual ~XGUI_ActionsMgr(); + void addCommand(XGUI_Command* theCmd); - void restoreCommandState(); void saveCommandsState(); + void restoreCommandState(); + + void setNestedActionsEnabled(bool); public slots: void setActionsDisabled(bool isEnabled); private: + QStringList myNestedActions; QMap myActions; QMap myActionsState; }; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e36e3c269..60bad111d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -291,6 +291,8 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage) QString::fromStdString(theMessage->tooltip()), QIcon(theMessage->icon().c_str()), QKeySequence(), isUsePropPanel); + QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures()); + aCommand->setUnblockableCommands(aNestedFeatures.split(" ")); myActionsMgr->addCommand(aCommand); myPartSetModule->featureCreated(aCommand); }