-rw-r--r-- | libopie2/opieui/olistview.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index 59b0973..8195a62 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h | |||
@@ -15,66 +15,70 @@ | |||
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OLISTVIEW_H | 30 | #ifndef OLISTVIEW_H |
31 | #define OLISTVIEW_H | 31 | #define OLISTVIEW_H |
32 | 32 | ||
33 | #include <qcolor.h> | 33 | #include <qcolor.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qpen.h> | 35 | #include <qpen.h> |
36 | #include <qdatastream.h> | 36 | #include <qdatastream.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | 38 | ||
39 | |||
40 | namespace Opie { | ||
41 | namespace Ui { | ||
39 | class OListViewItem; | 42 | class OListViewItem; |
40 | 43 | ||
41 | 44 | ||
42 | /*====================================================================================== | 45 | /*====================================================================================== |
43 | * OListView | 46 | * OListView |
44 | *======================================================================================*/ | 47 | *======================================================================================*/ |
45 | 48 | ||
46 | /** | 49 | /** |
47 | * @brief A list/tree widget. | 50 | * @brief A list/tree widget. |
48 | * | 51 | * |
49 | * A @ref QListView variant featuring visual and functional enhancements | 52 | * A @ref QListView variant featuring visual and functional enhancements |
50 | * like an alternate background for odd rows, an autostretch mode | 53 | * like an alternate background for odd rows, an autostretch mode |
51 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | 54 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
52 | * | 55 | * |
53 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 56 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
54 | */ | 57 | */ |
55 | class OListView: public QListView | 58 | class OListView: public QListView |
56 | { | 59 | { |
60 | Q_OBJECT | ||
57 | public: | 61 | public: |
58 | /** | 62 | /** |
59 | * Constructor. | 63 | * Constructor. |
60 | * | 64 | * |
61 | * The parameters @a parent and @a name are handled by | 65 | * The parameters @a parent and @a name are handled by |
62 | * @ref QListView, as usual. | 66 | * @ref QListView, as usual. |
63 | */ | 67 | */ |
64 | OListView( QWidget* parent = 0, const char* name = 0 ); | 68 | OListView( QWidget* parent = 0, const char* name = 0 ); |
65 | /** | 69 | /** |
66 | * Destructor. | 70 | * Destructor. |
67 | */ | 71 | */ |
68 | virtual ~OListView(); | 72 | virtual ~OListView(); |
69 | /** | 73 | /** |
70 | * Let the last column fit exactly all the available width. | 74 | * Let the last column fit exactly all the available width. |
71 | */ | 75 | */ |
72 | void setFullWidth( bool fullWidth ); | 76 | void setFullWidth( bool fullWidth ); |
73 | /** | 77 | /** |
74 | * Returns whether the last column is set to fit the available width. | 78 | * Returns whether the last column is set to fit the available width. |
75 | */ | 79 | */ |
76 | bool fullWidth() const; | 80 | bool fullWidth() const; |
77 | /** | 81 | /** |
78 | * Reimplemented for full width support | 82 | * Reimplemented for full width support |
79 | */ | 83 | */ |
80 | virtual int addColumn( const QString& label, int width = -1 ); | 84 | virtual int addColumn( const QString& label, int width = -1 ); |
@@ -118,50 +122,52 @@ class OListView: public QListView | |||
118 | /** | 122 | /** |
119 | * Serialize this object from a @ref QDataStream @a stream | 123 | * Serialize this object from a @ref QDataStream @a stream |
120 | */ | 124 | */ |
121 | virtual void serializeFrom( QDataStream& s ); | 125 | virtual void serializeFrom( QDataStream& s ); |
122 | #endif | 126 | #endif |
123 | 127 | ||
124 | public slots: | 128 | public slots: |
125 | /** | 129 | /** |
126 | * Expand all items | 130 | * Expand all items |
127 | */ | 131 | */ |
128 | void expand(); | 132 | void expand(); |
129 | /** | 133 | /** |
130 | * Collapse all items | 134 | * Collapse all items |
131 | */ | 135 | */ |
132 | void collapse(); | 136 | void collapse(); |
133 | 137 | ||
134 | protected slots: | 138 | protected slots: |
135 | /** | 139 | /** |
136 | * expand the current OListViewItem | 140 | * expand the current OListViewItem |
137 | */ | 141 | */ |
138 | void expand(QListViewItem*); | 142 | void expand(QListViewItem*); |
139 | 143 | ||
140 | private: | 144 | private: |
141 | QColor m_alternateBackground; | 145 | QColor m_alternateBackground; |
142 | bool m_fullWidth; | 146 | bool m_fullWidth : 1; |
143 | QPen m_columnSeparator; | 147 | QPen m_columnSeparator; |
148 | class Private; | ||
149 | Private *d; | ||
144 | }; | 150 | }; |
145 | 151 | ||
146 | #ifndef QT_NO_DATASTREAM | 152 | #ifndef QT_NO_DATASTREAM |
147 | /** | 153 | /** |
148 | * @relates OListView | 154 | * @relates OListView |
149 | * Writes @a listview to the @a stream and returns a reference to the stream. | 155 | * Writes @a listview to the @a stream and returns a reference to the stream. |
150 | */ | 156 | */ |
151 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); | 157 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); |
152 | /** | 158 | /** |
153 | * @relates OListView | 159 | * @relates OListView |
154 | * Reads @a listview from the @a stream and returns a reference to the stream. | 160 | * Reads @a listview from the @a stream and returns a reference to the stream. |
155 | */ | 161 | */ |
156 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); | 162 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); |
157 | #endif // QT_NO_DATASTREAM | 163 | #endif // QT_NO_DATASTREAM |
158 | 164 | ||
159 | /*====================================================================================== | 165 | /*====================================================================================== |
160 | * OListViewItem | 166 | * OListViewItem |
161 | *======================================================================================*/ | 167 | *======================================================================================*/ |
162 | 168 | ||
163 | class OListViewItem: public QListViewItem | 169 | class OListViewItem: public QListViewItem |
164 | { | 170 | { |
165 | friend class OCheckListItem; | 171 | friend class OCheckListItem; |
166 | public: | 172 | public: |
167 | /** | 173 | /** |
@@ -221,50 +227,52 @@ class OListViewItem: public QListViewItem | |||
221 | * create a list view item as child of this object | 227 | * create a list view item as child of this object |
222 | * @returns the new object | 228 | * @returns the new object |
223 | */ | 229 | */ |
224 | virtual OListViewItem* childFactory(); | 230 | virtual OListViewItem* childFactory(); |
225 | #ifndef QT_NO_DATASTREAM | 231 | #ifndef QT_NO_DATASTREAM |
226 | /** | 232 | /** |
227 | * serialize this object to or from a @ref QDataStream | 233 | * serialize this object to or from a @ref QDataStream |
228 | * @param s the stream used to serialize this object. | 234 | * @param s the stream used to serialize this object. |
229 | */ | 235 | */ |
230 | virtual void serializeTo( QDataStream& s ) const; | 236 | virtual void serializeTo( QDataStream& s ) const; |
231 | 237 | ||
232 | /** | 238 | /** |
233 | * serialize this object to or from a @ref QDataStream | 239 | * serialize this object to or from a @ref QDataStream |
234 | * @param s the stream used to serialize this object. | 240 | * @param s the stream used to serialize this object. |
235 | */ | 241 | */ |
236 | virtual void serializeFrom( QDataStream& s ); | 242 | virtual void serializeFrom( QDataStream& s ); |
237 | #endif | 243 | #endif |
238 | 244 | ||
239 | /** | 245 | /** |
240 | * expand the the item | 246 | * expand the the item |
241 | */ | 247 | */ |
242 | virtual void expand(){}; | 248 | virtual void expand(){}; |
243 | 249 | ||
244 | private: | 250 | private: |
245 | bool m_known; | 251 | bool m_known : 1; |
246 | bool m_odd; | 252 | bool m_odd : 1; |
253 | class Private; | ||
254 | Private *d; | ||
247 | }; | 255 | }; |
248 | 256 | ||
249 | #ifndef QT_NO_DATASTREAM | 257 | #ifndef QT_NO_DATASTREAM |
250 | /** | 258 | /** |
251 | * @relates QListViewItem | 259 | * @relates QListViewItem |
252 | * Writes listview @a item and all subitems recursively to @a stream | 260 | * Writes listview @a item and all subitems recursively to @a stream |
253 | * and returns a reference to the stream. | 261 | * and returns a reference to the stream. |
254 | */ | 262 | */ |
255 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); | 263 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); |
256 | /** | 264 | /** |
257 | * @relates QListViewItem | 265 | * @relates QListViewItem |
258 | * Reads listview @a item from @a stream and returns a reference to the stream. | 266 | * Reads listview @a item from @a stream and returns a reference to the stream. |
259 | */ | 267 | */ |
260 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); | 268 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); |
261 | #endif // QT_NO_DATASTREAM | 269 | #endif // QT_NO_DATASTREAM |
262 | 270 | ||
263 | 271 | ||
264 | /*====================================================================================== | 272 | /*====================================================================================== |
265 | * OCheckListItem | 273 | * OCheckListItem |
266 | *======================================================================================*/ | 274 | *======================================================================================*/ |
267 | 275 | ||
268 | class OCheckListItem : public QCheckListItem | 276 | class OCheckListItem : public QCheckListItem |
269 | { | 277 | { |
270 | public: | 278 | public: |
@@ -333,48 +341,51 @@ class ONamedListView: public OListView | |||
333 | */ | 341 | */ |
334 | virtual ~ONamedListView(); | 342 | virtual ~ONamedListView(); |
335 | /** | 343 | /** |
336 | * Add a number of @a columns to the listview. | 344 | * Add a number of @a columns to the listview. |
337 | */ | 345 | */ |
338 | virtual void addColumns( const QStringList& columns ); | 346 | virtual void addColumns( const QStringList& columns ); |
339 | /** | 347 | /** |
340 | * @returns the column index matching to @a text or -1 if not found. | 348 | * @returns the column index matching to @a text or -1 if not found. |
341 | */ | 349 | */ |
342 | virtual int findColumn( const QString& text ) const; | 350 | virtual int findColumn( const QString& text ) const; |
343 | /** | 351 | /** |
344 | * @returns the first item which has a @a text in column @a column. | 352 | * @returns the first item which has a @a text in column @a column. |
345 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 353 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
346 | * <li>set it to 0 to search only among direct childs, | 354 | * <li>set it to 0 to search only among direct childs, |
347 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 355 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
348 | * <li>set it to -1 for maximum recursion. | 356 | * <li>set it to -1 for maximum recursion. |
349 | * </ul> | 357 | * </ul> |
350 | * @sa ONamedListViewItem::find() | 358 | * @sa ONamedListViewItem::find() |
351 | */ | 359 | */ |
352 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; | 360 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; |
353 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 361 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
354 | 362 | ||
355 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; | 363 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; |
356 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 364 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
365 | private: | ||
366 | class Private; | ||
367 | Private *d; | ||
357 | }; | 368 | }; |
358 | 369 | ||
359 | /*====================================================================================== | 370 | /*====================================================================================== |
360 | * ONamedListViewItem | 371 | * ONamedListViewItem |
361 | *======================================================================================*/ | 372 | *======================================================================================*/ |
362 | 373 | ||
363 | /** | 374 | /** |
364 | * @brief An OListView variant with named columns. | 375 | * @brief An OListView variant with named columns. |
365 | * | 376 | * |
366 | * This class provides a higher-level interface to an OListViewItem. | 377 | * This class provides a higher-level interface to an OListViewItem. |
367 | * | 378 | * |
368 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 379 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
369 | */ | 380 | */ |
370 | class ONamedListViewItem: public OListViewItem | 381 | class ONamedListViewItem: public OListViewItem |
371 | { | 382 | { |
372 | public: | 383 | public: |
373 | /** | 384 | /** |
374 | * Constructor. Accepts the same parameters as a @ref OListViewItem, | 385 | * Constructor. Accepts the same parameters as a @ref OListViewItem, |
375 | * plus a @ref QStringList which holds an arbitrary number of @a texts. | 386 | * plus a @ref QStringList which holds an arbitrary number of @a texts. |
376 | */ | 387 | */ |
377 | ONamedListViewItem( QListView* parent, const QStringList& texts ); | 388 | ONamedListViewItem( QListView* parent, const QStringList& texts ); |
378 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); | 389 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); |
379 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); | 390 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); |
380 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); | 391 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); |
@@ -382,28 +393,34 @@ class ONamedListViewItem: public OListViewItem | |||
382 | * Destructor. | 393 | * Destructor. |
383 | */ | 394 | */ |
384 | virtual ~ONamedListViewItem(); | 395 | virtual ~ONamedListViewItem(); |
385 | /** | 396 | /** |
386 | * Sets the text in column @a column to @a text. | 397 | * Sets the text in column @a column to @a text. |
387 | * This method differs from @ref QListViewItem::setText() in that it | 398 | * This method differs from @ref QListViewItem::setText() in that it |
388 | * accepts a string as column indicator instead of an int. | 399 | * accepts a string as column indicator instead of an int. |
389 | */ | 400 | */ |
390 | virtual void setText( const QString& column, const QString& text ); | 401 | virtual void setText( const QString& column, const QString& text ); |
391 | /** | 402 | /** |
392 | * Sets a number of @a texts for this item. | 403 | * Sets a number of @a texts for this item. |
393 | */ | 404 | */ |
394 | virtual void setText( const QStringList& texts ); | 405 | virtual void setText( const QStringList& texts ); |
395 | /** | 406 | /** |
396 | * @returns the first child which has a @a text in column @a column. | 407 | * @returns the first child which has a @a text in column @a column. |
397 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 408 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
398 | * <li>set it to 0 to search only among direct childs, | 409 | * <li>set it to 0 to search only among direct childs, |
399 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 410 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
400 | * <li>set it to -1 for maximum recursion. | 411 | * <li>set it to -1 for maximum recursion. |
401 | * </ul> | 412 | * </ul> |
402 | * @sa ONamedListView::find() | 413 | * @sa ONamedListView::find() |
403 | */ | 414 | */ |
404 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 415 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
405 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 416 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
406 | }; | ||
407 | 417 | ||
418 | private: | ||
419 | class Private; | ||
420 | Private *d; | ||
421 | |||
422 | }; | ||
423 | } | ||
424 | } | ||
408 | 425 | ||
409 | #endif // OLISTVIEW_H | 426 | #endif // OLISTVIEW_H |