Diffstat (limited to 'microkde/kdeui/kjanuswidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kjanuswidget.h | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/microkde/kdeui/kjanuswidget.h b/microkde/kdeui/kjanuswidget.h index 6d3f23d..72465ea 100644 --- a/microkde/kdeui/kjanuswidget.h +++ b/microkde/kdeui/kjanuswidget.h | |||
@@ -1,565 +1,571 @@ | |||
1 | /* This file is part of the KDE Libraries | 1 | /* This file is part of the KDE Libraries |
2 | * Copyright (C) 1999-2000 Espen Sand (espen@kde.org) | 2 | * Copyright (C) 1999-2000 Espen Sand (espen@kde.org) |
3 | * | 3 | * |
4 | * This library is free software; you can redistribute it and/or | 4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public | 5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either | 6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. | 7 | * version 2 of the License, or (at your option) any later version. |
8 | * | 8 | * |
9 | * This library is distributed in the hope that it will be useful, | 9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. | 12 | * Library General Public License for more details. |
13 | * | 13 | * |
14 | * You should have received a copy of the GNU Library General Public License | 14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to | 15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | * Boston, MA 02111-1307, USA. | 17 | * Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _KJANUS_WIDGET_H_ | 20 | #ifndef _KJANUS_WIDGET_H_ |
21 | #define _KJANUS_WIDGET_H_ | 21 | #define _KJANUS_WIDGET_H_ |
22 | 22 | ||
23 | #include <qptrlist.h> | 23 | #include <q3ptrlist.h> |
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qmap.h> | 25 | #include <qmap.h> |
26 | #include <qgrid.h> | 26 | #include <q3grid.h> |
27 | //Added by qt3to4: | ||
28 | #include <QShowEvent> | ||
29 | #include <Q3Frame> | ||
30 | #include <QPixmap> | ||
31 | #include <QLabel> | ||
32 | #include <QEvent> | ||
27 | #include <klistbox.h> | 33 | #include <klistbox.h> |
28 | 34 | ||
29 | /*US | 35 | /*US |
30 | #include <qptrlist.h> | 36 | #include <qptrlist.h> |
31 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
32 | #include <qsplitter.h> | 38 | #include <qsplitter.h> |
33 | 39 | ||
34 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
35 | #include <qmap.h> | 41 | #include <qmap.h> |
36 | 42 | ||
37 | */ | 43 | */ |
38 | 44 | ||
39 | class KSeparator; | 45 | class KSeparator; |
40 | class KListView; | 46 | class KListView; |
41 | class QWidgetStack; | 47 | class Q3WidgetStack; |
42 | class QLabel; | 48 | class QLabel; |
43 | class QTabWidget; | 49 | class QTabWidget; |
44 | class QListViewItem; | 50 | class Q3ListViewItem; |
45 | class QVBox; | 51 | class Q3VBox; |
46 | class QHBox; | 52 | class Q3HBox; |
47 | 53 | ||
48 | /** | 54 | /** |
49 | * Provides a number of ready to use layouts (faces). It is used | 55 | * Provides a number of ready to use layouts (faces). It is used |
50 | * as an internal widget in @ref KDialogBase, but can also used as a | 56 | * as an internal widget in @ref KDialogBase, but can also used as a |
51 | * widget of its own. | 57 | * widget of its own. |
52 | * | 58 | * |
53 | * It provides TreeList, IconList, Tabbed, Plain and Swallow layouts. | 59 | * It provides TreeList, IconList, Tabbed, Plain and Swallow layouts. |
54 | * | 60 | * |
55 | * The TreeList face provides a list in the left area and pages in the | 61 | * The TreeList face provides a list in the left area and pages in the |
56 | * right. The area are separated by a movable splitter. The style is somewhat | 62 | * right. The area are separated by a movable splitter. The style is somewhat |
57 | * similar to the layout in the Control Center. A page is raised by | 63 | * similar to the layout in the Control Center. A page is raised by |
58 | * selecting the corresponding tree list item. | 64 | * selecting the corresponding tree list item. |
59 | * | 65 | * |
60 | * The IconList face provides an icon list in the left area and pages in the | 66 | * The IconList face provides an icon list in the left area and pages in the |
61 | * right. For each entry the Icon is on top with the text below. The style | 67 | * right. For each entry the Icon is on top with the text below. The style |
62 | * is somewhat similar to the layout of the Eudora configuation dialog box. | 68 | * is somewhat similar to the layout of the Eudora configuation dialog box. |
63 | * A page is raised by selecting the corresponding icon list item. The | 69 | * A page is raised by selecting the corresponding icon list item. The |
64 | * preferred icon size is 32x32 pixels. | 70 | * preferred icon size is 32x32 pixels. |
65 | * | 71 | * |
66 | * The Tabbed face is a common tabbed widget. The procedure for creating a | 72 | * The Tabbed face is a common tabbed widget. The procedure for creating a |
67 | * page is similar for creating a TreeList. This has the advantage that if | 73 | * page is similar for creating a TreeList. This has the advantage that if |
68 | * your widget contain too many pages it is trivial to convert it into a | 74 | * your widget contain too many pages it is trivial to convert it into a |
69 | * TreeList. Just change the face in the KJanusWidget constructor to | 75 | * TreeList. Just change the face in the KJanusWidget constructor to |
70 | * KJanusWidget::TreeList and you have a tree list layout instead. | 76 | * KJanusWidget::TreeList and you have a tree list layout instead. |
71 | * | 77 | * |
72 | * The Plain face provides an empty widget (QFrame) where you can place your | 78 | * The Plain face provides an empty widget (QFrame) where you can place your |
73 | * widgets. The KJanusWidget makes no assumptions regarding the contents so | 79 | * widgets. The KJanusWidget makes no assumptions regarding the contents so |
74 | * you are free to add whatever you want. | 80 | * you are free to add whatever you want. |
75 | * | 81 | * |
76 | * The Swallow face is provided in order to simplify the usage of existing | 82 | * The Swallow face is provided in order to simplify the usage of existing |
77 | * widgets and to allow changing the visible widget. You specify the widget | 83 | * widgets and to allow changing the visible widget. You specify the widget |
78 | * to be displayed by @ref #setSwallowedWidget(). Your widget will be | 84 | * to be displayed by @ref #setSwallowedWidget(). Your widget will be |
79 | * reparented inside the widget. You can specify a Null (0) widget. A empty | 85 | * reparented inside the widget. You can specify a Null (0) widget. A empty |
80 | * space is then displayed. | 86 | * space is then displayed. |
81 | * | 87 | * |
82 | * For all modes it is important that you specify the @ref QWidget::minimumSize() | 88 | * For all modes it is important that you specify the @ref QWidget::minimumSize() |
83 | * on the page, plain widget or the swallowed widget. If you use a QLayout | 89 | * on the page, plain widget or the swallowed widget. If you use a QLayout |
84 | * on the page, plain widget or the swallowed widget this will be taken care | 90 | * on the page, plain widget or the swallowed widget this will be taken care |
85 | * of automatically. The size is used when the KJanusWidget determines its | 91 | * of automatically. The size is used when the KJanusWidget determines its |
86 | * own minimum size. You get the minimum size by using the | 92 | * own minimum size. You get the minimum size by using the |
87 | * @ref #minimumSizeHint() or @ref #sizeHint() methods. | 93 | * @ref #minimumSizeHint() or @ref #sizeHint() methods. |
88 | * | 94 | * |
89 | * Pages that have been added in TreeList, IconList or Tabbed mode can be | 95 | * Pages that have been added in TreeList, IconList or Tabbed mode can be |
90 | * removed by simply deleting the page. However, it would be preferable to use | 96 | * removed by simply deleting the page. However, it would be preferable to use |
91 | * the QObject::deleteLater() function on the page as the main event loop | 97 | * the QObject::deleteLater() function on the page as the main event loop |
92 | * may have optimized UI update events of the page by scheduling them for later. | 98 | * may have optimized UI update events of the page by scheduling them for later. |
93 | * | 99 | * |
94 | * @short Easy to use widget with many layouts | 100 | * @short Easy to use widget with many layouts |
95 | * @author Espen Sand (espen@kde.org) | 101 | * @author Espen Sand (espen@kde.org) |
96 | */ | 102 | */ |
97 | class KJanusWidget : public QWidget | 103 | class KJanusWidget : public QWidget |
98 | { | 104 | { |
99 | Q_OBJECT | 105 | Q_OBJECT |
100 | 106 | ||
101 | private: | 107 | private: |
102 | class IconListBox : public KListBox | 108 | class IconListBox : public KListBox |
103 | { | 109 | { |
104 | public: | 110 | public: |
105 | IconListBox( QWidget *parent=0, const char *name=0, WFlags f=0 ); | 111 | IconListBox( QWidget *parent=0, const char *name=0, Qt::WFlags f=0 ); |
106 | void updateMinimumHeight(); | 112 | void updateMinimumHeight(); |
107 | void updateWidth(); | 113 | void updateWidth(); |
108 | void invalidateHeight(); | 114 | void invalidateHeight(); |
109 | void invalidateWidth(); | 115 | void invalidateWidth(); |
110 | void setShowAll( bool showAll ); | 116 | void setShowAll( bool showAll ); |
111 | 117 | ||
112 | private: | 118 | private: |
113 | bool mShowAll; | 119 | bool mShowAll; |
114 | bool mHeightValid; | 120 | bool mHeightValid; |
115 | bool mWidthValid; | 121 | bool mWidthValid; |
116 | }; | 122 | }; |
117 | 123 | ||
118 | public: | 124 | public: |
119 | enum Face | 125 | enum Face |
120 | { | 126 | { |
121 | TreeList = 0, | 127 | TreeList = 0, |
122 | Tabbed, | 128 | Tabbed, |
123 | Plain, | 129 | Plain, |
124 | Swallow, | 130 | Swallow, |
125 | IconList | 131 | IconList |
126 | }; | 132 | }; |
127 | 133 | ||
128 | public: | 134 | public: |
129 | 135 | ||
130 | /** | 136 | /** |
131 | * Constructor where you specify the face. | 137 | * Constructor where you specify the face. |
132 | * | 138 | * |
133 | * @param parent Parent of the widget. | 139 | * @param parent Parent of the widget. |
134 | * @param name Widget name. | 140 | * @param name Widget name. |
135 | * @param int face The kind of dialog, Use TreeList, Tabbed, Plain or | 141 | * @param int face The kind of dialog, Use TreeList, Tabbed, Plain or |
136 | * Swallow. | 142 | * Swallow. |
137 | */ | 143 | */ |
138 | KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain ); | 144 | KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain ); |
139 | 145 | ||
140 | /** | 146 | /** |
141 | * Destructor. | 147 | * Destructor. |
142 | */ | 148 | */ |
143 | ~KJanusWidget(); | 149 | ~KJanusWidget(); |
144 | 150 | ||
145 | /** | 151 | /** |
146 | * Raises the page which was added by @ref addPage(). | 152 | * Raises the page which was added by @ref addPage(). |
147 | * | 153 | * |
148 | * @param index The index of the page you want to raise. | 154 | * @param index The index of the page you want to raise. |
149 | */ | 155 | */ |
150 | virtual bool showPage( int index ); | 156 | virtual bool showPage( int index ); |
151 | 157 | ||
152 | /** | 158 | /** |
153 | * Returns the index of the page that are currently displayed. | 159 | * Returns the index of the page that are currently displayed. |
154 | * | 160 | * |
155 | * @return The index or -1 if the face is not Tabbed, TreeList or | 161 | * @return The index or -1 if the face is not Tabbed, TreeList or |
156 | * IconList. | 162 | * IconList. |
157 | */ | 163 | */ |
158 | virtual int activePageIndex() const; | 164 | virtual int activePageIndex() const; |
159 | 165 | ||
160 | /** | 166 | /** |
161 | * Use this to verify | 167 | * Use this to verify |
162 | * that no memory allocation failed. | 168 | * that no memory allocation failed. |
163 | * | 169 | * |
164 | * @return true if the widget was properly created. | 170 | * @return true if the widget was properly created. |
165 | */ | 171 | */ |
166 | virtual bool isValid() const; | 172 | virtual bool isValid() const; |
167 | 173 | ||
168 | /** | 174 | /** |
169 | * Returns the face type. | 175 | * Returns the face type. |
170 | * | 176 | * |
171 | * @return The face type. | 177 | * @return The face type. |
172 | */ | 178 | */ |
173 | virtual int face() const; | 179 | virtual int face() const; |
174 | 180 | ||
175 | /** | 181 | /** |
176 | * Returns the minimum size that must be made available for the widget | 182 | * Returns the minimum size that must be made available for the widget |
177 | * so that UIs can be displayed properly | 183 | * so that UIs can be displayed properly |
178 | * | 184 | * |
179 | * @return The minimum size. | 185 | * @return The minimum size. |
180 | */ | 186 | */ |
181 | virtual QSize minimumSizeHint() const; | 187 | virtual QSize minimumSizeHint() const; |
182 | 188 | ||
183 | /** | 189 | /** |
184 | * Returns the recommended size for the widget in order to be displayed | 190 | * Returns the recommended size for the widget in order to be displayed |
185 | * properly. | 191 | * properly. |
186 | * | 192 | * |
187 | * @return The recommended size. | 193 | * @return The recommended size. |
188 | */ | 194 | */ |
189 | virtual QSize sizeHint() const; | 195 | virtual QSize sizeHint() const; |
190 | 196 | ||
191 | /** | 197 | /** |
192 | * Returns the empty widget that is available in Plain mode. | 198 | * Returns the empty widget that is available in Plain mode. |
193 | * | 199 | * |
194 | * @return The widget or 0 if the face in not Plain. | 200 | * @return The widget or 0 if the face in not Plain. |
195 | */ | 201 | */ |
196 | virtual QFrame *plainPage(); | 202 | virtual Q3Frame *plainPage(); |
197 | 203 | ||
198 | /** | 204 | /** |
199 | * Add a new page when the class is used in TreeList, IconList or Tabbed | 205 | * Add a new page when the class is used in TreeList, IconList or Tabbed |
200 | * mode. The returned widget is empty and you must add your widgets | 206 | * mode. The returned widget is empty and you must add your widgets |
201 | * as children to this widget. In most cases you must create a layout | 207 | * as children to this widget. In most cases you must create a layout |
202 | * manager and associate it with this widget as well. | 208 | * manager and associate it with this widget as well. |
203 | * | 209 | * |
204 | * Deleting the returned frame will cause the listitem or tab to be | 210 | * Deleting the returned frame will cause the listitem or tab to be |
205 | * removed (you can re-add a page with the same name later. | 211 | * removed (you can re-add a page with the same name later. |
206 | * | 212 | * |
207 | * @param item String used in the list or Tab item. | 213 | * @param item String used in the list or Tab item. |
208 | * @param header A longer string used in TreeList and IconList mode to | 214 | * @param header A longer string used in TreeList and IconList mode to |
209 | * describe the contents of a page. If empty, the item string | 215 | * describe the contents of a page. If empty, the item string |
210 | * will be used instead. | 216 | * will be used instead. |
211 | * @param pixmap Used in IconList mode or in TreeList mode. You should | 217 | * @param pixmap Used in IconList mode or in TreeList mode. You should |
212 | * prefer a pixmap with size 32x32 pixels. | 218 | * prefer a pixmap with size 32x32 pixels. |
213 | * | 219 | * |
214 | * @return The empty page or 0 if the face is not TreeList, IconList or | 220 | * @return The empty page or 0 if the face is not TreeList, IconList or |
215 | * Tabbed. | 221 | * Tabbed. |
216 | */ | 222 | */ |
217 | virtual QFrame *addPage(const QString &item,const QString &header=QString::null, | 223 | virtual Q3Frame *addPage(const QString &item,const QString &header=QString::null, |
218 | const QPixmap &pixmap=QPixmap() ); | 224 | const QPixmap &pixmap=QPixmap() ); |
219 | 225 | ||
220 | /** | 226 | /** |
221 | * This is like addPage just above, with the difference that the first | 227 | * This is like addPage just above, with the difference that the first |
222 | * element is a list of strings. These strings are used to form a path | 228 | * element is a list of strings. These strings are used to form a path |
223 | * of folders down to the given page. The initial elements are names | 229 | * of folders down to the given page. The initial elements are names |
224 | * for the folders, while the last element is the name of the page. | 230 | * for the folders, while the last element is the name of the page. |
225 | * Note: This does yet only work for the TreeList face. Later this may | 231 | * Note: This does yet only work for the TreeList face. Later this may |
226 | * be added for the IconList face too. In other faces than the | 232 | * be added for the IconList face too. In other faces than the |
227 | * TreeList, all the strings except the last one is ignored. | 233 | * TreeList, all the strings except the last one is ignored. |
228 | * Deleting the returned frame will cause the listitem or tab to be | 234 | * Deleting the returned frame will cause the listitem or tab to be |
229 | * removed (you can re-add a page with the same name later. | 235 | * removed (you can re-add a page with the same name later. |
230 | * | 236 | * |
231 | * Deleting the returned frame will cause the listitem or tab to be | 237 | * Deleting the returned frame will cause the listitem or tab to be |
232 | * removed (you can re-add a page with the same name later. | 238 | * removed (you can re-add a page with the same name later. |
233 | **/ | 239 | **/ |
234 | virtual QFrame *addPage(const QStringList &items, const QString &header=QString::null, | 240 | virtual Q3Frame *addPage(const QStringList &items, const QString &header=QString::null, |
235 | const QPixmap &pixmap=QPixmap() ); | 241 | const QPixmap &pixmap=QPixmap() ); |
236 | 242 | ||
237 | /** | 243 | /** |
238 | * Add a new page when the class is used in TreeList, IconList or Tabbed | 244 | * Add a new page when the class is used in TreeList, IconList or Tabbed |
239 | * mode. The returned widget is empty and you must add your widgets | 245 | * mode. The returned widget is empty and you must add your widgets |
240 | * as children to this widget. The returned widget is a @ref QVBox | 246 | * as children to this widget. The returned widget is a @ref QVBox |
241 | * so it contains a QVBoxLayout layout that lines up the child widgets | 247 | * so it contains a QVBoxLayout layout that lines up the child widgets |
242 | * are vertically. | 248 | * are vertically. |
243 | * | 249 | * |
244 | * Deleting the returned frame will cause the listitem or tab to be | 250 | * Deleting the returned frame will cause the listitem or tab to be |
245 | * removed (you can re-add a page with the same name later. | 251 | * removed (you can re-add a page with the same name later. |
246 | * | 252 | * |
247 | * @param item String used in the list or Tab item. | 253 | * @param item String used in the list or Tab item. |
248 | * @param header A longer string used in TreeList and IconList mode to | 254 | * @param header A longer string used in TreeList and IconList mode to |
249 | * describe the contents of a page. If empty, the item string | 255 | * describe the contents of a page. If empty, the item string |
250 | * will be used instead. | 256 | * will be used instead. |
251 | * @param pixmap Used in IconList mode or in TreeList mode. You should | 257 | * @param pixmap Used in IconList mode or in TreeList mode. You should |
252 | * prefer a pixmap with size 32x32 pixels. | 258 | * prefer a pixmap with size 32x32 pixels. |
253 | * | 259 | * |
254 | * @return The empty page or 0 if the face is not TreeList, IconList or | 260 | * @return The empty page or 0 if the face is not TreeList, IconList or |
255 | * Tabbed. */ | 261 | * Tabbed. */ |
256 | virtual QVBox *addVBoxPage( const QString &item, | 262 | virtual Q3VBox *addVBoxPage( const QString &item, |
257 | const QString &header=QString::null, | 263 | const QString &header=QString::null, |
258 | const QPixmap &pixmap=QPixmap() ); | 264 | const QPixmap &pixmap=QPixmap() ); |
259 | 265 | ||
260 | /** | 266 | /** |
261 | * This is like addVBoxPage just above, with the difference that the first | 267 | * This is like addVBoxPage just above, with the difference that the first |
262 | * element is a list of strings. These strings are used to form a path | 268 | * element is a list of strings. These strings are used to form a path |
263 | * of folders down to the given page. The initial elements are names | 269 | * of folders down to the given page. The initial elements are names |
264 | * for the folders, while the last element is the name of the page. | 270 | * for the folders, while the last element is the name of the page. |
265 | * Note: This does yet only work for the TreeList face. Later this may | 271 | * Note: This does yet only work for the TreeList face. Later this may |
266 | * be added for the IconList face too. In other faces than the | 272 | * be added for the IconList face too. In other faces than the |
267 | * TreeList, all the strings except the last one is ignored. | 273 | * TreeList, all the strings except the last one is ignored. |
268 | * | 274 | * |
269 | * Deleting the returned frame will cause the listitem or tab to be | 275 | * Deleting the returned frame will cause the listitem or tab to be |
270 | * removed (you can re-add a page with the same name later. | 276 | * removed (you can re-add a page with the same name later. |
271 | **/ | 277 | **/ |
272 | virtual QVBox *addVBoxPage( const QStringList &items, | 278 | virtual Q3VBox *addVBoxPage( const QStringList &items, |
273 | const QString &header=QString::null, | 279 | const QString &header=QString::null, |
274 | const QPixmap &pixmap=QPixmap() ); | 280 | const QPixmap &pixmap=QPixmap() ); |
275 | 281 | ||
276 | /** | 282 | /** |
277 | * Add a new page when the class is used in TreeList, IconList or Tabbed | 283 | * Add a new page when the class is used in TreeList, IconList or Tabbed |
278 | * mode. The returned widget is empty and you must add your widgets | 284 | * mode. The returned widget is empty and you must add your widgets |
279 | * as children to this widget. The returned widget is a @ref QHBox | 285 | * as children to this widget. The returned widget is a @ref QHBox |
280 | * so it contains a QHBoxLayout layout that lines up the child widgets | 286 | * so it contains a QHBoxLayout layout that lines up the child widgets |
281 | * are horizontally. | 287 | * are horizontally. |
282 | * | 288 | * |
283 | * Deleting the returned frame will cause the listitem or tab to be | 289 | * Deleting the returned frame will cause the listitem or tab to be |
284 | * removed (you can re-add a page with the same name later. | 290 | * removed (you can re-add a page with the same name later. |
285 | * | 291 | * |
286 | * @param item String used in the list or Tab item. | 292 | * @param item String used in the list or Tab item. |
287 | * @param header A longer string used in TreeList and IconList mode to | 293 | * @param header A longer string used in TreeList and IconList mode to |
288 | * describe the contents of a page. If empty, the item string | 294 | * describe the contents of a page. If empty, the item string |
289 | * will be used instead. | 295 | * will be used instead. |
290 | * @param pixmap Used in IconList mode or in TreeList mode. You should | 296 | * @param pixmap Used in IconList mode or in TreeList mode. You should |
291 | * prefer a pixmap with size 32x32 pixels. | 297 | * prefer a pixmap with size 32x32 pixels. |
292 | * | 298 | * |
293 | * @return The empty page or 0 if the face is not TreeList, IconList or | 299 | * @return The empty page or 0 if the face is not TreeList, IconList or |
294 | * Tabbed. | 300 | * Tabbed. |
295 | */ | 301 | */ |
296 | virtual QHBox *addHBoxPage( const QString &itemName, | 302 | virtual Q3HBox *addHBoxPage( const QString &itemName, |
297 | const QString &header=QString::null, | 303 | const QString &header=QString::null, |
298 | const QPixmap &pixmap=QPixmap() ); | 304 | const QPixmap &pixmap=QPixmap() ); |
299 | 305 | ||
300 | /** | 306 | /** |
301 | * This is like addHBoxPage just above, with the difference that the first | 307 | * This is like addHBoxPage just above, with the difference that the first |
302 | * element is a list of strings. These strings are used to form a path | 308 | * element is a list of strings. These strings are used to form a path |
303 | * of folders down to the given page. The initial elements are names | 309 | * of folders down to the given page. The initial elements are names |
304 | * for the folders, while the last element is the name of the page. | 310 | * for the folders, while the last element is the name of the page. |
305 | * Note: This does yet only work for the TreeList face. Later this may | 311 | * Note: This does yet only work for the TreeList face. Later this may |
306 | * be added for the IconList face too. In other faces than the | 312 | * be added for the IconList face too. In other faces than the |
307 | * TreeList, all the strings except the last one is ignored. | 313 | * TreeList, all the strings except the last one is ignored. |
308 | * | 314 | * |
309 | * Deleting the returned frame will cause the listitem or tab to be | 315 | * Deleting the returned frame will cause the listitem or tab to be |
310 | * removed (you can re-add a page with the same name later. | 316 | * removed (you can re-add a page with the same name later. |
311 | **/ | 317 | **/ |
312 | virtual QHBox *addHBoxPage( const QStringList &items, | 318 | virtual Q3HBox *addHBoxPage( const QStringList &items, |
313 | const QString &header=QString::null, | 319 | const QString &header=QString::null, |
314 | const QPixmap &pixmap=QPixmap() ); | 320 | const QPixmap &pixmap=QPixmap() ); |
315 | 321 | ||
316 | /** | 322 | /** |
317 | * Add a new page when the class is used in either TreeList or Tabbed | 323 | * Add a new page when the class is used in either TreeList or Tabbed |
318 | * mode. The returned widget is empty and you must add your widgets | 324 | * mode. The returned widget is empty and you must add your widgets |
319 | * as children to this widget. The returned widget is a @ref QGrid | 325 | * as children to this widget. The returned widget is a @ref QGrid |
320 | * so it contains a QGridLayout layout that places up the child widgets | 326 | * so it contains a QGridLayout layout that places up the child widgets |
321 | * in a grid. | 327 | * in a grid. |
322 | * | 328 | * |
323 | * Deleting the returned frame will cause the listitem or tab to be | 329 | * Deleting the returned frame will cause the listitem or tab to be |
324 | * removed (you can re-add a page with the same name later. | 330 | * removed (you can re-add a page with the same name later. |
325 | * | 331 | * |
326 | * @param n Specifies the number of columns if 'dir' is QGrid::Horizontal | 332 | * @param n Specifies the number of columns if 'dir' is QGrid::Horizontal |
327 | * or the number of rows if 'dir' is QGrid::Vertical. | 333 | * or the number of rows if 'dir' is QGrid::Vertical. |
328 | * @param dir Can be QGrid::Horizontal or QGrid::Vertical. | 334 | * @param dir Can be QGrid::Horizontal or QGrid::Vertical. |
329 | * @param item String used in the list or Tab item. | 335 | * @param item String used in the list or Tab item. |
330 | * @param header A longer string used in TreeList and IconList mode to | 336 | * @param header A longer string used in TreeList and IconList mode to |
331 | * describe the contents of a page. If empty, the item string | 337 | * describe the contents of a page. If empty, the item string |
332 | * will be used instead. | 338 | * will be used instead. |
333 | * @param pixmap Used in IconList mode or in TreeList mode. You should | 339 | * @param pixmap Used in IconList mode or in TreeList mode. You should |
334 | * prefer a pixmap with size 32x32 pixels. | 340 | * prefer a pixmap with size 32x32 pixels. |
335 | * | 341 | * |
336 | * @return The empty page or 0 if the face is not TreeList, IconList or | 342 | * @return The empty page or 0 if the face is not TreeList, IconList or |
337 | * Tabbed. | 343 | * Tabbed. |
338 | */ | 344 | */ |
339 | //US changed Orientation into Direction for compatibility | 345 | //US changed Orientation into Direction for compatibility |
340 | virtual QGrid *addGridPage( int n, QGrid::Direction dir, | 346 | virtual Q3Grid *addGridPage( int n, Qt::Orientation dir, |
341 | const QString &itemName, | 347 | const QString &itemName, |
342 | const QString &header=QString::null, | 348 | const QString &header=QString::null, |
343 | const QPixmap &pixmap=QPixmap() ); | 349 | const QPixmap &pixmap=QPixmap() ); |
344 | 350 | ||
345 | /** | 351 | /** |
346 | * This is like addGridPage just above, with the difference that the first | 352 | * This is like addGridPage just above, with the difference that the first |
347 | * element is a list of strings. These strings are used to form a path | 353 | * element is a list of strings. These strings are used to form a path |
348 | * of folders down to the given page. The initial elements are names | 354 | * of folders down to the given page. The initial elements are names |
349 | * for the folders, while the last element is the name of the page. | 355 | * for the folders, while the last element is the name of the page. |
350 | * Note: This does yet only work for the TreeList face. Later this may | 356 | * Note: This does yet only work for the TreeList face. Later this may |
351 | * be added for the IconList face too. In other faces than the | 357 | * be added for the IconList face too. In other faces than the |
352 | * TreeList, all the strings except the last one is ignored. | 358 | * TreeList, all the strings except the last one is ignored. |
353 | * | 359 | * |
354 | * Deleting the returned frame will cause the listitem or tab to be | 360 | * Deleting the returned frame will cause the listitem or tab to be |
355 | * removed (you can re-add a page with the same name later. | 361 | * removed (you can re-add a page with the same name later. |
356 | **/ | 362 | **/ |
357 | //US changed Orientation into Direction for compatibility | 363 | //US changed Orientation into Direction for compatibility |
358 | virtual QGrid *addGridPage( int n, QGrid::Direction dir, | 364 | virtual Q3Grid *addGridPage( int n, Qt::Orientation dir, |
359 | const QStringList &items, | 365 | const QStringList &items, |
360 | const QString &header=QString::null, | 366 | const QString &header=QString::null, |
361 | const QPixmap &pixmap=QPixmap() ); | 367 | const QPixmap &pixmap=QPixmap() ); |
362 | 368 | ||
363 | /** | 369 | /** |
364 | * @short Removes a page created with @ref addPage, @ref addVBoxPage, | 370 | * @short Removes a page created with @ref addPage, @ref addVBoxPage, |
365 | * @ref addHBoxPage or @ref addGridPage. If the page has already | 371 | * @ref addHBoxPage or @ref addGridPage. If the page has already |
366 | * been deleted or has already been removed, nothing happens. The widget | 372 | * been deleted or has already been removed, nothing happens. The widget |
367 | * itself is not deleted. | 373 | * itself is not deleted. |
368 | * | 374 | * |
369 | * @param page The widget returned by @ref addPage , @ref addVBoxPage , | 375 | * @param page The widget returned by @ref addPage , @ref addVBoxPage , |
370 | * @ref addHBoxPage or @ref addGridPage . | 376 | * @ref addHBoxPage or @ref addGridPage . |
371 | */ | 377 | */ |
372 | void removePage( QWidget *page ); | 378 | void removePage( QWidget *page ); |
373 | 379 | ||
374 | 380 | ||
375 | /** | 381 | /** |
376 | * Returns the index of a page created with @ref addPage , | 382 | * Returns the index of a page created with @ref addPage , |
377 | * @ref addVBoxPage , @ref addHBoxPage or @ref addGridPage . | 383 | * @ref addVBoxPage , @ref addHBoxPage or @ref addGridPage . |
378 | * You can can compare this index with the value returned from | 384 | * You can can compare this index with the value returned from |
379 | * @ref activePageIndex if you need to do some page specific actions | 385 | * @ref activePageIndex if you need to do some page specific actions |
380 | * in your code. | 386 | * in your code. |
381 | * | 387 | * |
382 | * The returned index will never change so you can safely use this | 388 | * The returned index will never change so you can safely use this |
383 | * function once and save the value. | 389 | * function once and save the value. |
384 | * | 390 | * |
385 | * @param widget The widget returned by @ref addPage , @ref addVBoxPage , | 391 | * @param widget The widget returned by @ref addPage , @ref addVBoxPage , |
386 | * @ref addHBoxPage or @ref addGridPage . | 392 | * @ref addHBoxPage or @ref addGridPage . |
387 | * | 393 | * |
388 | * @return The index or -1 if the face is not Tabbed, TreeList or | 394 | * @return The index or -1 if the face is not Tabbed, TreeList or |
389 | * IconList | 395 | * IconList |
390 | */ | 396 | */ |
391 | virtual int pageIndex( QWidget *widget ) const; | 397 | virtual int pageIndex( QWidget *widget ) const; |
392 | 398 | ||
393 | /** | 399 | /** |
394 | * Defines the widget to be swallowed. | 400 | * Defines the widget to be swallowed. |
395 | * | 401 | * |
396 | * This method can be used several | 402 | * This method can be used several |
397 | * times. Only the latest defined widget will be shown. | 403 | * times. Only the latest defined widget will be shown. |
398 | * | 404 | * |
399 | * @param widget The widget to be swallowed. If 0, then an empty rectangle | 405 | * @param widget The widget to be swallowed. If 0, then an empty rectangle |
400 | * is displayed. | 406 | * is displayed. |
401 | */ | 407 | */ |
402 | virtual bool setSwallowedWidget( QWidget *widget ); | 408 | virtual bool setSwallowedWidget( QWidget *widget ); |
403 | 409 | ||
404 | /** | 410 | /** |
405 | * This function has only effect in TreeList mode. | 411 | * This function has only effect in TreeList mode. |
406 | * | 412 | * |
407 | * Defines how the tree list is resized when the widget is resized | 413 | * Defines how the tree list is resized when the widget is resized |
408 | * horizontally. By default the tree list keeps its width when the | 414 | * horizontally. By default the tree list keeps its width when the |
409 | * widget becomes wider. | 415 | * widget becomes wider. |
410 | * | 416 | * |
411 | * @param state The resize mode. If false (default) the TreeList keeps | 417 | * @param state The resize mode. If false (default) the TreeList keeps |
412 | * its current width when the widget becomes wider. | 418 | * its current width when the widget becomes wider. |
413 | */ | 419 | */ |
414 | virtual void setTreeListAutoResize( bool state ); | 420 | virtual void setTreeListAutoResize( bool state ); |
415 | 421 | ||
416 | /** | 422 | /** |
417 | * This function has only effect in TreeList mode. | 423 | * This function has only effect in TreeList mode. |
418 | * | 424 | * |
419 | * This tells the widgets whether the icons given in the @ref addPage, | 425 | * This tells the widgets whether the icons given in the @ref addPage, |
420 | * @ref addVBoxPage, @ref addHBoxPage, or @ref addGridPage methods should | 426 | * @ref addVBoxPage, @ref addHBoxPage, or @ref addGridPage methods should |
421 | * be shown in the TreeList. | 427 | * be shown in the TreeList. |
422 | * | 428 | * |
423 | * Note: This method must be called before calling any of the methods | 429 | * Note: This method must be called before calling any of the methods |
424 | * which add icons to the page. | 430 | * which add icons to the page. |
425 | * | 431 | * |
426 | * @param state If true the icons are shown. | 432 | * @param state If true the icons are shown. |
427 | **/ | 433 | **/ |
428 | virtual void setShowIconsInTreeList(bool state); | 434 | virtual void setShowIconsInTreeList(bool state); |
429 | 435 | ||
430 | /** | 436 | /** |
431 | * This function has only effect in TreeList mode. | 437 | * This function has only effect in TreeList mode. |
432 | * | 438 | * |
433 | * This tells the widgets whether the root should be decorated. | 439 | * This tells the widgets whether the root should be decorated. |
434 | * For details see @ref QListView::setRootIsDecorated | 440 | * For details see @ref QListView::setRootIsDecorated |
435 | * | 441 | * |
436 | * @param state Root will be decorated if true. | 442 | * @param state Root will be decorated if true. |
437 | **/ | 443 | **/ |
438 | virtual void setRootIsDecorated( bool state ); | 444 | virtual void setRootIsDecorated( bool state ); |
439 | 445 | ||
440 | /** | 446 | /** |
441 | * This function has only effect in TreeList mode. | 447 | * This function has only effect in TreeList mode. |
442 | * | 448 | * |
443 | * This tells the TreeList to unfold the whole tree so that all entries | 449 | * This tells the TreeList to unfold the whole tree so that all entries |
444 | * are visible. | 450 | * are visible. |
445 | * | 451 | * |
446 | * If the list is empty when you call this method newly created entries | 452 | * If the list is empty when you call this method newly created entries |
447 | * will not automatically be opened. If the @p persist flag is set opened | 453 | * will not automatically be opened. If the @p persist flag is set opened |
448 | * entries cannot be closed again, though. | 454 | * entries cannot be closed again, though. |
449 | * | 455 | * |
450 | * @param persist If true the tree always stays unfolded. | 456 | * @param persist If true the tree always stays unfolded. |
451 | * @since 3.2 | 457 | * @since 3.2 |
452 | */ | 458 | */ |
453 | /*virtual*/ void unfoldTreeList( bool persist = false ); //### KDE4 BIC add virtual | 459 | /*virtual*/ void unfoldTreeList( bool persist = false ); //### KDE4 BIC add virtual |
454 | 460 | ||
455 | /** | 461 | /** |
456 | * This function has only effect in IconList mode. | 462 | * This function has only effect in IconList mode. |
457 | * | 463 | * |
458 | * Defines how the icon list widget is displayed. By default it is | 464 | * Defines how the icon list widget is displayed. By default it is |
459 | * the widgets in the pages that decide the minimum height | 465 | * the widgets in the pages that decide the minimum height |
460 | * of the toplevel widget. A vertical scrollbar can be used in | 466 | * of the toplevel widget. A vertical scrollbar can be used in |
461 | * the icon list area. | 467 | * the icon list area. |
462 | * | 468 | * |
463 | * @param state The visibility mode. If true, the minimum height is | 469 | * @param state The visibility mode. If true, the minimum height is |
464 | * adjusted so that every icon in the list is visible at the | 470 | * adjusted so that every icon in the list is visible at the |
465 | * same time. The vertical scrollbar will never be visible. | 471 | * same time. The vertical scrollbar will never be visible. |
466 | */ | 472 | */ |
467 | virtual void setIconListAllVisible( bool state ); | 473 | virtual void setIconListAllVisible( bool state ); |
468 | 474 | ||
469 | /** | 475 | /** |
470 | * Sets the icon used in TreeList Mode for the given path. | 476 | * Sets the icon used in TreeList Mode for the given path. |
471 | * @param path The path for which this icon should be shown. | 477 | * @param path The path for which this icon should be shown. |
472 | * @param pixmap The icon used. | 478 | * @param pixmap The icon used. |
473 | **/ | 479 | **/ |
474 | virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap); | 480 | virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap); |
475 | /** | 481 | /** |
476 | * Returns the title string associated with a page index in TreeList or IconList mode. | 482 | * Returns the title string associated with a page index in TreeList or IconList mode. |
477 | * @param index The index of the page or null if there is no such page. | 483 | * @param index The index of the page or null if there is no such page. |
478 | * @see @ref #pageIndex() | 484 | * @see @ref #pageIndex() |
479 | * @since 3.2 | 485 | * @since 3.2 |
480 | */ | 486 | */ |
481 | /*virtual*/ QString pageTitle(int index) const; | 487 | /*virtual*/ QString pageTitle(int index) const; |
482 | /** | 488 | /** |
483 | * Returns the page widget associated with a page index or null if there is | 489 | * Returns the page widget associated with a page index or null if there is |
484 | * no such page. | 490 | * no such page. |
485 | * @param index The index of the page. | 491 | * @param index The index of the page. |
486 | * @see @ref #pageIndex() | 492 | * @see @ref #pageIndex() |
487 | * @since 3.2 | 493 | * @since 3.2 |
488 | */ | 494 | */ |
489 | /*virtual*/ QWidget *pageWidget(int index) const; | 495 | /*virtual*/ QWidget *pageWidget(int index) const; |
490 | 496 | ||
491 | signals: | 497 | signals: |
492 | void aboutToShowPage(QWidget *page); | 498 | void aboutToShowPage(QWidget *page); |
493 | 499 | ||
494 | public slots: | 500 | public slots: |
495 | /** | 501 | /** |
496 | * Give the keyboard input focus to the widget. | 502 | * Give the keyboard input focus to the widget. |
497 | */ | 503 | */ |
498 | virtual void setFocus(); | 504 | virtual void setFocus(); |
499 | 505 | ||
500 | protected: | 506 | protected: |
501 | /** | 507 | /** |
502 | * Reimplemented to handle the splitter width when the the face | 508 | * Reimplemented to handle the splitter width when the the face |
503 | * is TreeList | 509 | * is TreeList |
504 | */ | 510 | */ |
505 | virtual void showEvent( QShowEvent * ); | 511 | virtual void showEvent( QShowEvent * ); |
506 | 512 | ||
507 | /** | 513 | /** |
508 | * This function is used internally when in IconList mode. If you | 514 | * This function is used internally when in IconList mode. If you |
509 | * reimplement this class a make your own event filter, make sure to | 515 | * reimplement this class a make your own event filter, make sure to |
510 | * call this function from your filter. | 516 | * call this function from your filter. |
511 | * | 517 | * |
512 | * @param o Object that has received an event. | 518 | * @param o Object that has received an event. |
513 | * @param e The event. | 519 | * @param e The event. |
514 | */ | 520 | */ |
515 | virtual bool eventFilter( QObject *o, QEvent *e ); | 521 | virtual bool eventFilter( QObject *o, QEvent *e ); |
516 | 522 | ||
517 | private slots: | 523 | private slots: |
518 | bool slotShowPage(); | 524 | bool slotShowPage(); |
519 | //US not yet implemented void slotFontChanged(); | 525 | //US not yet implemented void slotFontChanged(); |
520 | void slotItemClicked(QListViewItem *it); | 526 | void slotItemClicked(Q3ListViewItem *it); |
521 | void pageGone( QObject *obj); // signal from the added page's "destroyed" signal | 527 | void pageGone( QObject *obj); // signal from the added page's "destroyed" signal |
522 | void slotReopen(QListViewItem *item); | 528 | void slotReopen(Q3ListViewItem *item); |
523 | 529 | ||
524 | protected: | 530 | protected: |
525 | bool showPage( QWidget *w ); | 531 | bool showPage( QWidget *w ); |
526 | void addPageWidget( QFrame *page, const QStringList &items, | 532 | void addPageWidget( Q3Frame *page, const QStringList &items, |
527 | const QString &header, const QPixmap &pixmap ); | 533 | const QString &header, const QPixmap &pixmap ); |
528 | void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page); | 534 | void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, Q3Frame *page); |
529 | QWidget *FindParent(); | 535 | QWidget *FindParent(); |
530 | 536 | ||
531 | private: | 537 | private: |
532 | bool mValid; | 538 | bool mValid; |
533 | 539 | ||
534 | // Obsolete members. Remove in KDE 4. | 540 | // Obsolete members. Remove in KDE 4. |
535 | QPtrList<QWidget> *mPageList; | 541 | Q3PtrList<QWidget> *mPageList; |
536 | QStringList *mTitleList; | 542 | QStringList *mTitleList; |
537 | 543 | ||
538 | int mFace; | 544 | int mFace; |
539 | KListView *mTreeList; | 545 | KListView *mTreeList; |
540 | IconListBox *mIconList; | 546 | IconListBox *mIconList; |
541 | QWidgetStack *mPageStack; | 547 | Q3WidgetStack *mPageStack; |
542 | QLabel *mTitleLabel; | 548 | QLabel *mTitleLabel; |
543 | QTabWidget *mTabControl; | 549 | QTabWidget *mTabControl; |
544 | QFrame *mPlainPage; | 550 | Q3Frame *mPlainPage; |
545 | QWidget *mSwallowPage; | 551 | QWidget *mSwallowPage; |
546 | QWidget *mActivePageWidget; | 552 | QWidget *mActivePageWidget; |
547 | KSeparator *mTitleSep; | 553 | KSeparator *mTitleSep; |
548 | //US QSplitter::ResizeMode mTreeListResizeMode; | 554 | //US QSplitter::ResizeMode mTreeListResizeMode; |
549 | bool mShowIconsInTreeList; | 555 | bool mShowIconsInTreeList; |
550 | QMap<QListViewItem *, QWidget *> mTreeListToPageStack; | 556 | QMap<Q3ListViewItem *, QWidget *> mTreeListToPageStack; |
551 | QMap<QListBoxItem *, QWidget *> mIconListToPageStack; | 557 | QMap<Q3ListBoxItem *, QWidget *> mIconListToPageStack; |
552 | QMap<QString, QPixmap> mFolderIconMap; | 558 | QMap<QString, QPixmap> mFolderIconMap; |
553 | QMap<QString, QStringList> mChildrenNames; | 559 | QMap<QString, QStringList> mChildrenNames; |
554 | QMap<QString, QWidget *> mChildPages; | 560 | QMap<QString, QWidget *> mChildPages; |
555 | 561 | ||
556 | public: | 562 | public: |
557 | class IconListItem; | 563 | class IconListItem; |
558 | protected: | 564 | protected: |
559 | virtual void virtual_hook( int id, void* data ); | 565 | virtual void virtual_hook( int id, void* data ); |
560 | private: | 566 | private: |
561 | class KJanusWidgetPrivate; | 567 | class KJanusWidgetPrivate; |
562 | KJanusWidgetPrivate *d; | 568 | KJanusWidgetPrivate *d; |
563 | }; | 569 | }; |
564 | 570 | ||
565 | #endif | 571 | #endif |