]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #6 Extended processing of nested actions.
authorsbh <sergey.belash@opencascade.com>
Tue, 29 Apr 2014 09:25:38 +0000 (13:25 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 29 Apr 2014 09:25:38 +0000 (13:25 +0400)
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_Workshop.cpp

index 2da65741751e84095ff74d22cce605efb2b33baf..9408522e6a9f90c4ce1fcbead4f96ff3cf7217b8 100644 (file)
@@ -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;
+}
index a7928800a5e5dc36fe20c07f58943bb6030dc937..bcf674cee780c7f505c1496092e2bde03657e55f 100644 (file)
@@ -24,14 +24,12 @@ class Config_FeatureMessage: public Events_Message
   std::string myPluginLibrary;  //Name of feature's library\r
 \r
   bool myUseInput; //Action is being checked until user commit the operation\r
+  std::string myNestedFeatures;\r
 \r
 public:\r
   //const Events_ID theID, const void* theSender = 0\r
   CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);\r
 \r
-  //TODO(sbh): Implement static method to extract event id [SEID]\r
-  //static const char* eventId() { return ""; }\r
-\r
   //Auto-generated getters/setters\r
   CONFIG_EXPORT const std::string& icon() const;\r
   CONFIG_EXPORT const std::string& id() const;\r
@@ -42,17 +40,18 @@ public:
   CONFIG_EXPORT const std::string& groupId() const;\r
   CONFIG_EXPORT const std::string& workbenchId() const;\r
   CONFIG_EXPORT const std::string& pluginLibrary() const;\r
+  CONFIG_EXPORT const std::string& nestedFeatures() const;\r
+  CONFIG_EXPORT bool isUseInput() const;\r
 \r
   CONFIG_EXPORT void setIcon(const std::string& icon);\r
   CONFIG_EXPORT void setId(const std::string& id);\r
   CONFIG_EXPORT void setKeysequence(const std::string& keysequence);\r
   CONFIG_EXPORT void setText(const std::string& text);\r
   CONFIG_EXPORT void setTooltip(const std::string& tooltip);\r
-\r
   CONFIG_EXPORT void setGroupId(const std::string& groupId);\r
   CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);\r
   CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
-  CONFIG_EXPORT bool isUseInput() const;\r
+  CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures);\r
   CONFIG_EXPORT void setUseInput(bool isUseInput);\r
 };\r
 \r
index 2fd10770ef396d5a8db5fe66eedcfba3955cc821..a3b7b56f2c1214cc99788c1d842847adad5c3e1a 100644 (file)
@@ -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));
 }
index 61f09f5c3e01932106fc2081ef4e0ba96a388147..281248f858314326cc871cef581e3d655f054355 100644 (file)
@@ -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";
 
 
index 0d652dceba7eed7cdeba455230e3056d03bc361f..8cc05c494a8a75a01b8c96e38c0ecfd844f3d32e 100644 (file)
@@ -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<XGUI_Command*>(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);
+  }
+}
index a3d7dea19192b14da881cd1c233ec2ddea70a268..d6c55d833ca7b87720107404be8267a1afd434c3 100644 (file)
@@ -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<QString, QAction*> myActions;
   QMap<QString, bool> myActionsState;
 };
index e36e3c26998e037642480ed913fb20c29556a4b4..60bad111dbc77e1b051e2f6df8c41965a11821cc 100644 (file)
@@ -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);
   }