libyui-qt  2.43.5
 All Classes Functions Variables
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( YWidget * parent,
46 // const std::string & label );
47  YQContextMenu( );
48  YQContextMenu( const QPoint position );
49 
50 
51  /**
52  * Destructor.
53  **/
54  virtual ~YQContextMenu();
55 
56  /**
57  * Change the label on the button.
58  *
59  * Reimplemented from YContextMenu / YSelectionWidget.
60  **/
61 // virtual void setLabel( const std::string & label );
62 
63  /**
64  * Rebuild the displayed menu tree from the internally stored YMenuItems.
65  *
66  * Implemented from YContextMenu.
67  **/
68  virtual void rebuildMenuTree();
69 
70  /**
71  * Preferred width of the widget.
72  *
73  * Reimplemented from YWidget.
74  **/
75  virtual int preferredWidth();
76 
77  /**
78  * Preferred height of the widget.
79  *
80  * Reimplemented from YWidget.
81  **/
82  virtual int preferredHeight();
83 
84  /**
85  * Set the new size of the widget.
86  *
87  * Reimplemented from YWidget.
88  **/
89  virtual void setSize( int newWidth, int newHeight );
90 
91 
92 protected slots:
93 
94  /**
95  * Triggered when any menu item is activated.
96  **/
97  void menuEntryActivated( QAction * menuItem );
98 
99  /**
100  * Triggered via menuEntryActivated() by zero timer to get back in sync
101  * with the Qt event loop.
102  **/
103  void returnNow();
104 
105  /**
106  * Triggered when the context menu is hidden
107  **/
108  void slotMenuHidden();
109 
110  /**
111  * Triggered via slotMenuHidden() by zero timer to get back in sync
112  * with the Qt event loop.
113  **/
114  void slotReturnMenuHidden();
115 
116 
117 
118 
119 protected:
120 
121  /**
122  * Recursively insert menu items into 'menu' from iterator 'begin' to iterator 'end'.
123  **/
124  void rebuildMenuTree( QMenu * menu, YItemIterator begin, YItemIterator end );
125 
126 
127  //
128  // Data members
129  //
130 
131  YMenuItem * _selectedItem;
132  QPushButton * _qt_button;
133  QHash<QAction*,int> _serials;
134 
135 
136 private:
137  QPoint _position;
138  bool _suppressCancelEvent;
139 
140 };
141 
142 #endif // YQContextMenu_h
void menuEntryActivated(QAction *menuItem)
virtual int preferredWidth()
void slotReturnMenuHidden()
virtual int preferredHeight()
void slotMenuHidden()
virtual void setSize(int newWidth, int newHeight)
virtual void rebuildMenuTree()
virtual ~YQContextMenu()