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