Salome HOME
Merge branch 'master' of salome:modules/shaper
[modules/shaper.git] / src / XGUI / XGUI_ActionsMgr.cpp
index 2468786c43859ced97f6586a46310ef28c820908..f1d5e49b15ddf7ab4de2dfc415746b13f76e4823 100644 (file)
@@ -1,9 +1,5 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
-/*
- * XGUI_ActionsMgr.cpp
- */
-
 #ifndef HAVE_SALOME
 #include <AppElements_Command.h>
 #endif
@@ -65,7 +61,11 @@ void XGUI_ActionsMgr::addCommand(QAction* theCmd)
   myActions.insert(aId, theCmd);
 #ifdef HAVE_SALOME
     XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
-    myNestedActions[aId] = aWorkshop->salomeConnector()->nestedActions(aId);
+    const std::shared_ptr<Config_FeatureMessage>& anInfo =
+                         aWorkshop->salomeConnector()->featureInfo(aId);
+    if (anInfo.get())
+      myNestedActions[aId] = QString::fromStdString(anInfo->nestedFeatures())
+                                   .split(" ", QString::SkipEmptyParts);
 #else
   AppElements_Command* aXCmd = dynamic_cast<AppElements_Command*>(theCmd);
   myNestedActions[aId] = aXCmd->nestedCommands();
@@ -97,7 +97,7 @@ bool XGUI_ActionsMgr::isNested(const QString& theId) const
 
 void XGUI_ActionsMgr::updateCommandsStatus()
 {
-  setAllEnabled(true);
+  setAllEnabled();
   XGUI_Selection* aSelection = myWorkshop->selector()->selection();
   if (aSelection->getSelected(ModuleBase_ISelection::Viewer).size() > 0)
     updateOnViewSelection();
@@ -247,6 +247,11 @@ QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QOb
         aResult->setToolTip("Help");
       }
       break;
+      case Preview: {
+        aResult = new QAction("See preview", theParent);
+        aResult->setToolTip("Compute preview");
+      }
+      break;
       default:
         break;
     }
@@ -276,10 +281,13 @@ ActionInfo XGUI_ActionsMgr::actionInfoById(const QString& theId)
   return aResult;
 }
 
-void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
+void XGUI_ActionsMgr::setAllEnabled()
 {
   foreach(QString eachAction, myActions.keys()) {
-    setActionEnabled(eachAction, isEnabled);
+    if (myActions.contains(eachAction)) {
+      QAction* aAction = myActions[eachAction];
+      aAction->setEnabled(true);
+    }
   }
 }
 
@@ -362,11 +370,12 @@ void XGUI_ActionsMgr::updateByDocumentKind()
 #ifdef HAVE_SALOME
     QString aId = eachAction->data().toString();
     if (!aId.isEmpty()) {
-      aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId);
+      aCmdDocKind = QString::fromStdString(
+                 aWorkshop->salomeConnector()->featureInfo(aId)->documentKind());
     }
 #else
     AppElements_Command* aCmd = dynamic_cast<AppElements_Command*>(eachAction);
-    aCmdDocKind = aCmd->documentKind();
+    aCmdDocKind = QString::fromStdString(aCmd->featureMessage()->documentKind());
 #endif
     if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
       eachAction->setEnabled(false);