Salome HOME
Issue #2340: Provide list of accessible Undo/Redo commands for widgets
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 91d8757f272822c02d17db2f199c9b835bc4b94c..e4fc24368d2ab890d8cb274497b87a3de308ff78 100755 (executable)
@@ -1041,6 +1041,7 @@ void XGUI_Workshop::onUndo(int theTimes)
     if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
       myObjectBrowser->rebuildDataTree();
   }
+  facesPanel()->reset(true);
 
   operationMgr()->updateApplyOfOperations();
   updateCommandStatus();
@@ -1075,6 +1076,7 @@ void XGUI_Workshop::onRedo(int theTimes)
       myObjectBrowser->rebuildDataTree();
   }
   operationMgr()->updateApplyOfOperations();
+  facesPanel()->reset(true);
   updateCommandStatus();
 
   // unblock the viewer update functionality and make update on purpose
@@ -1263,12 +1265,21 @@ void XGUI_Workshop::updateCommandStatus()
 //******************************************************
 void XGUI_Workshop::updateHistory()
 {
-  std::list<std::string> aUndoList = ModelAPI_Session::get()->undoList();
-  QList<ActionInfo> aUndoRes = processHistoryList(aUndoList);
-  emit updateUndoHistory(aUndoRes);
+  bool isActionEnabled = false;
+  ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
+  QList<ActionInfo> aUndoRes;
+  QList<ActionInfo> aRedoRes;
+  if (anActiveWidget && anActiveWidget->canProcessAction(ActionUndo, isActionEnabled)) {
+    aUndoRes = anActiveWidget->actionsList(ActionUndo);
+    aRedoRes = anActiveWidget->actionsList(ActionRedo);
+  } else {
+    std::list<std::string> aUndoList = ModelAPI_Session::get()->undoList();
+    aUndoRes = processHistoryList(aUndoList);
 
-  std::list<std::string> aRedoList = ModelAPI_Session::get()->redoList();
-  QList<ActionInfo> aRedoRes = processHistoryList(aRedoList);
+    std::list<std::string> aRedoList = ModelAPI_Session::get()->redoList();
+    aRedoRes = processHistoryList(aRedoList);
+  }
+  emit updateUndoHistory(aUndoRes);
   emit updateRedoHistory(aRedoRes);
 }
 
@@ -1472,10 +1483,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     viewer()->eraseAll();
 #endif
     updateCommandStatus();
-#ifndef WIN32
-  // Necessary for update icons in ObjectBrowser on Linux
-  myObjectBrowser->updateAllIndexes();
-#endif
+    // Necessary for update icons in ObjectBrowser on Linux
+    myObjectBrowser->updateAllIndexes();
   } else if (theId == "SELECT_VERTEX_CMD") {
     setViewerSelectionMode(TopAbs_VERTEX);
   } else if (theId == "SELECT_EDGE_CMD") {
@@ -1614,8 +1623,8 @@ bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) con
   // find hidden objects in faces panel
   std::set<ObjectPtr> aHiddenObjects;
   QStringList aHiddenObjectNames;
-  for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
-    anObjectsIt != theObjects.end(); anObjectsIt++) {
+  for (std::set<ObjectPtr>::const_iterator anObjectsIt = anAllProcessedObjects.begin();
+       anObjectsIt != anAllProcessedObjects.end(); anObjectsIt++) {
     if (!facesPanel()->isObjectHiddenByPanel(*anObjectsIt))
       continue;
     aHiddenObjects.insert(*anObjectsIt);
@@ -1627,7 +1636,7 @@ bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) con
   int anAnswer = QMessageBox::question(
         desktop(), tr("Show object"),
         tr("'%1'\n are hidden by %2:\nRemove objects from the panel to be displayed?")
-        .arg(aHiddenObjectNames.join(',').arg(facesPanel()->windowTitle()),
+        .arg(aHiddenObjectNames.join(',')).arg(facesPanel()->windowTitle(),
         QMessageBox::Yes | QMessageBox::No, QMessageBox::No));
 
   bool aToBeDisplayed = anAnswer == QMessageBox::Yes;
@@ -2396,15 +2405,9 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
     aObj->setDisplayed(true);
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-#ifndef WIN32
+
   // Necessary for update icons in ObjectBrowser on Linux
-  QModelIndexList aIndexes = mySelector->selection()->selectedIndexes();
-  foreach (QModelIndex aIdx, aIndexes) {
-    if (aIdx.column() == 0) {
-      myObjectBrowser->treeView()->update(aIdx);
-    }
-  }
-#endif
+  myObjectBrowser->updateAllIndexes();
 }
 
 //**************************************************************