Salome HOME
Documentation updated
[modules/shaper.git] / src / XGUI / XGUI_HistoryMenu.h
1 /*
2  * XGUI_HistoryMenu.h
3  *
4  *  Created on: Feb 2, 2015
5  *      Author: sbh
6  */
7
8 #ifndef XGUI_HISTORYMENU_H_
9 #define XGUI_HISTORYMENU_H_
10
11 #include <XGUI.h>
12 #include <QMenu>
13
14 #include <ModuleBase_ActionInfo.h>
15
16 class QListWidget;
17 class QToolButton;
18 class QListWidgetItem;
19
20 /**
21  * \class XGUI_HistoryMenu
22  * \ingroup GUI
23  * \brief Extends regular QToolButton of QAction with HistoryMenu (stack of actions)
24  */
25 class XGUI_EXPORT XGUI_HistoryMenu : public QMenu
26 {
27   Q_OBJECT
28  public:
29   /// Creates history menu for button
30   explicit XGUI_HistoryMenu(QToolButton* theParent);
31   /// Creates history menu for action
32   explicit XGUI_HistoryMenu(QAction* theParent);
33   virtual ~XGUI_HistoryMenu();
34
35  signals:
36   /// Signal. Emited then n-th action is selected in stack
37   void actionSelected(int);
38
39  public slots:
40   /// Set list of actions
41   void setHistory(const QList<ActionInfo>&);
42
43  protected:
44   /// Unselects all items when cursor leaves the list
45   virtual void leaveEvent(QEvent *);
46
47  protected slots:
48   /// Selects all items in stack to the given item including it
49   void setStackSelectedTo(QListWidgetItem *);
50   /// Emits actionSelected() signal.
51   void onItemPressed(QListWidgetItem *);
52   /// Initializes internal controls of the Menu
53   void initMenu();
54
55  private:
56   QListWidget* myHistoryList; ///< List to contain actions
57 };
58
59 #endif /* XGUI_OPERATIONSSTACKPOPUP_H_ */