#include <ModuleBase.h>
#include <ModuleBase_ActionType.h>
#include <ModuleBase_OperationFeature.h>
+#include <ModuleBase_ActionInfo.h>
#include <ModelAPI_Feature.h>
#include <QWidget>
/// Returns true if the event is processed. The default implementation is empty, returns false.
virtual bool processAction(ModuleBase_ActionType theActionType);
+ /// Returns list of accessible actions for Undo/Redo commands. By default it returns empty list.
+ /// \param theActionType type of action. It can be ActionUndo or ActionRedo.
+ virtual QList<ActionInfo> actionsList(ModuleBase_ActionType theActionType) const
+ { return QList<ActionInfo>(); }
+
/// Sends Update and Redisplay for the given object
/// \param theObj is updating object
void updateObject(ObjectPtr theObj);
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
myCurrentHistoryIndex++;
mySelectedHistoryValues.append(aSelected);
+ int aNb = mySelectedHistoryValues.count();
myWorkshop->updateCommandStatus();
#ifdef DEBUG_UNDO_REDO
}
return aFound;
}
+
+QList<ActionInfo> ModuleBase_WidgetMultiSelector::actionsList(ModuleBase_ActionType theActionType) const
+{
+ QList<ActionInfo> aList;
+ if (myCurrentHistoryIndex > -1) {
+ int i = 0;
+ QString aTitle("Selection %1 items");
+ QIcon aIcon(":pictures/selection.png");
+ switch (theActionType) {
+ case ActionUndo:
+ i = 1;
+ while (i <= myCurrentHistoryIndex) {
+ ActionInfo aInfo(aIcon, aTitle.arg(mySelectedHistoryValues.at(i).count()));
+ aList.append(aInfo);
+ i++;
+ }
+ break;
+ case ActionRedo:
+ i = mySelectedHistoryValues.length() - 1;
+ while (i > myCurrentHistoryIndex) {
+ ActionInfo aInfo(aIcon, aTitle.arg(mySelectedHistoryValues.at(i).count()));
+ aList.append(aInfo);
+ i--;
+ }
+ break;
+ }
+ }
+ return aList;
+}
\ No newline at end of file
/// \return a boolean value
virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+ /// Returns list of accessible actions for Undo/Redo commands. By default it returns empty list.
+ /// \param theActionType type of action. It can be ActionUndo or ActionRedo.
+ virtual QList<ActionInfo> actionsList(ModuleBase_ActionType theActionType) const;
+
public slots:
/// Slot is called on selection type changed
void onSelectionTypeChanged();
//******************************************************
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);
}
<file>pictures/insert_folder_before.png</file>
<file>pictures/move_out_after.png</file>
<file>pictures/move_out_before.png</file>
+ <file>pictures/selection.png</file>
</qresource>
</RCC>