libyui-qt  2.53.0
YQContextMenu.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQContextMenu.h
20 
21  Author: Thomas Goettlicher <tgoettlicher@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQContextMenu_h
27 #define YQContextMenu_h
28 
29 #include <qwidget.h>
30 #include <yui/YContextMenu.h>
31 #include <QHash>
32 
33 class QAction;
34 class QPushButton;
35 class QMenu;
36 
37 class YQContextMenu : public QObject, public YContextMenu
38 {
39  Q_OBJECT
40 
41 public:
42  /**
43  * Constructor.
44  **/
45  YQContextMenu( );
46  YQContextMenu( QWidget* parent, const QPoint position );
47 
48 
49  /**
50  * Destructor.
51  **/
52  virtual ~YQContextMenu();
53 
54  /**
55  * Change the label on the button.
56  *
57  * Reimplemented from YContextMenu / YSelectionWidget.
58  **/
59 // virtual void setLabel( const std::string & label );
60 
61  /**
62  * Rebuild the displayed menu tree from the internally stored YMenuItems.
63  *
64  * Implemented from YContextMenu.
65  **/
66  virtual void rebuildMenuTree();
67 
68  /**
69  * Preferred width of the widget.
70  *
71  * Reimplemented from YWidget.
72  **/
73  virtual int preferredWidth();
74 
75  /**
76  * Preferred height of the widget.
77  *
78  * Reimplemented from YWidget.
79  **/
80  virtual int preferredHeight();
81 
82  /**
83  * Set the new size of the widget.
84  *
85  * Reimplemented from YWidget.
86  **/
87  virtual void setSize( int newWidth, int newHeight );
88 
89 
90 protected slots:
91 
92  /**
93  * Triggered when any menu item is activated.
94  **/
95  void menuEntryActivated( QAction * menuItem );
96 
97  /**
98  * Triggered via menuEntryActivated() by zero timer to get back in sync
99  * with the Qt event loop.
100  **/
101  void returnNow();
102 
103  /**
104  * Triggered when the context menu is hidden
105  **/
106  void slotMenuHidden();
107 
108  /**
109  * Triggered via slotMenuHidden() by zero timer to get back in sync
110  * with the Qt event loop.
111  **/
112  void slotReturnMenuHidden();
113 
114 
115 
116 
117 protected:
118 
119  /**
120  * Recursively insert menu items into 'menu' from iterator 'begin' to iterator 'end'.
121  **/
122  void rebuildMenuTree( QMenu * menu, YItemIterator begin, YItemIterator end );
123 
124 
125  //
126  // Data members
127  //
128 
129  YMenuItem * _selectedItem;
130  QPushButton * _qt_button;
131  QHash<QAction*,int> _serials;
132 
133 
134 private:
135  QPoint _position;
136  bool _suppressCancelEvent;
137  QWidget* _parent;
138 
139 };
140 
141 #endif // YQContextMenu_h
YQContextMenu::preferredHeight
virtual int preferredHeight()
Preferred height of the widget.
Definition: YQContextMenu.cc:201
YQContextMenu
Definition: YQContextMenu.h:38
YQContextMenu::~YQContextMenu
virtual ~YQContextMenu()
Destructor.
Definition: YQContextMenu.cc:60
YQContextMenu::returnNow
void returnNow()
Triggered via menuEntryActivated() by zero timer to get back in sync with the Qt event loop.
Definition: YQContextMenu.cc:185
YQContextMenu::setSize
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
Definition: YQContextMenu.cc:208
YQContextMenu::menuEntryActivated
void menuEntryActivated(QAction *menuItem)
Triggered when any menu item is activated.
Definition: YQContextMenu.cc:152
YQContextMenu::YQContextMenu
YQContextMenu()
Constructor.
Definition: YQContextMenu.cc:40
YQContextMenu::slotMenuHidden
void slotMenuHidden()
Triggered when the context menu is hidden.
Definition: YQContextMenu.cc:133
YQContextMenu::rebuildMenuTree
virtual void rebuildMenuTree()
Change the label on the button.
Definition: YQContextMenu.cc:67
YQContextMenu::slotReturnMenuHidden
void slotReturnMenuHidden()
Triggered via slotMenuHidden() by zero timer to get back in sync with the Qt event loop.
Definition: YQContextMenu.cc:142
YQContextMenu::preferredWidth
virtual int preferredWidth()
Preferred width of the widget.
Definition: YQContextMenu.cc:195