-rw-r--r-- | libopie2/opieui/olistview.cpp | 153 | ||||
-rw-r--r-- | libopie2/opieui/olistview.h | 71 |
2 files changed, 213 insertions, 11 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 84617f8..0ee2fde 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
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. |
@@ -161,58 +161,82 @@ void OListView::serializeTo( QDataStream& s ) const | |||
161 | for ( int i = 0; i < items; ++i ) | 161 | for ( int i = 0; i < items; ++i ) |
162 | { | 162 | { |
163 | s << *static_cast<OListViewItem*>( item ); | 163 | s << *static_cast<OListViewItem*>( item ); |
164 | item = item->nextSibling(); | 164 | item = item->nextSibling(); |
165 | } | 165 | } |
166 | 166 | ||
167 | odebug << "OListview stored." << oendl; | 167 | odebug << "OListview stored." << oendl; |
168 | } | 168 | } |
169 | 169 | ||
170 | void OListView::serializeFrom( QDataStream& s ) | 170 | void OListView::serializeFrom( QDataStream& s ) |
171 | { | 171 | { |
172 | #warning Caution... the binary format is still under construction... | 172 | #warning Caution... the binary format is still under construction... |
173 | odebug << "loading OListView..." << oendl; | 173 | odebug << "loading OListView..." << oendl; |
174 | 174 | ||
175 | int cols; | 175 | int cols; |
176 | s >> cols; | 176 | s >> cols; |
177 | qDebug( "read number of columns = %d", cols ); | 177 | odebug << "read number of columns = " << cols << oendl; |
178 | 178 | ||
179 | while ( columns() < cols ) addColumn( QString::null ); | 179 | while ( columns() < cols ) addColumn( QString::null ); |
180 | 180 | ||
181 | for ( int i = 0; i < cols; ++i ) | 181 | for ( int i = 0; i < cols; ++i ) |
182 | { | 182 | { |
183 | QString coltext; | 183 | QString coltext; |
184 | s >> coltext; | 184 | s >> coltext; |
185 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 185 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
186 | setColumnText( i, coltext ); | 186 | setColumnText( i, coltext ); |
187 | } | 187 | } |
188 | 188 | ||
189 | int items; | 189 | int items; |
190 | s >> items; | 190 | s >> items; |
191 | qDebug( "read number of items = %d", items ); | 191 | odebug << "read number of items = " << items << oendl; |
192 | 192 | ||
193 | for ( int i = 0; i < items; ++i ) | 193 | for ( int i = 0; i < items; ++i ) |
194 | { | 194 | { |
195 | OListViewItem* item = childFactory(); | 195 | OListViewItem* item = childFactory(); |
196 | s >> *item; | 196 | s >> *item; |
197 | } | 197 | } |
198 | 198 | ||
199 | odebug << "OListView loaded." << oendl; | 199 | odebug << "OListView loaded." << oendl; |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | |||
204 | void OListView::expand() | ||
205 | { | ||
206 | odebug << "OListView::expand" << oendl; | ||
207 | |||
208 | QListViewItemIterator it( this ); | ||
209 | while ( it.current() ) { | ||
210 | it.current()->setOpen( true ); | ||
211 | ++it; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | |||
216 | void OListView::collapse() | ||
217 | { | ||
218 | odebug << "OListView::collapse" << oendl; | ||
219 | QListViewItemIterator it( this ); | ||
220 | while ( it.current() ) { | ||
221 | it.current()->setOpen( false ); | ||
222 | ++it; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | |||
203 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | 227 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) |
204 | { | 228 | { |
205 | lv.serializeTo( s ); | 229 | lv.serializeTo( s ); |
206 | } | 230 | } |
207 | 231 | ||
208 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | 232 | QDataStream& operator>>( QDataStream& s, OListView& lv ) |
209 | { | 233 | { |
210 | lv.serializeFrom( s ); | 234 | lv.serializeFrom( s ); |
211 | } | 235 | } |
212 | #endif // QT_NO_DATASTREAM | 236 | #endif // QT_NO_DATASTREAM |
213 | 237 | ||
214 | /*====================================================================================== | 238 | /*====================================================================================== |
215 | * OListViewItem | 239 | * OListViewItem |
216 | *======================================================================================*/ | 240 | *======================================================================================*/ |
217 | 241 | ||
218 | OListViewItem::OListViewItem(QListView *parent) | 242 | OListViewItem::OListViewItem(QListView *parent) |
@@ -432,32 +456,155 @@ void OListViewItem::serializeFrom( QDataStream& s ) | |||
432 | 456 | ||
433 | 457 | ||
434 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) | 458 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) |
435 | { | 459 | { |
436 | lvi.serializeTo( s ); | 460 | lvi.serializeTo( s ); |
437 | } | 461 | } |
438 | 462 | ||
439 | 463 | ||
440 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) | 464 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) |
441 | { | 465 | { |
442 | lvi.serializeFrom( s ); | 466 | lvi.serializeFrom( s ); |
443 | } | 467 | } |
444 | #endif // QT_NO_DATASTREAM | 468 | #endif // QT_NO_DATASTREAM |
445 | 469 | ||
446 | 470 | ||
447 | /*====================================================================================== | 471 | /*====================================================================================== |
472 | * OCheckListItem | ||
473 | *======================================================================================*/ | ||
474 | |||
475 | OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) | ||
476 | :QCheckListItem( parent, text, t ) | ||
477 | { | ||
478 | init(); | ||
479 | } | ||
480 | |||
481 | |||
482 | OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) | ||
483 | :QCheckListItem( parent, text, t ) | ||
484 | { | ||
485 | init(); | ||
486 | } | ||
487 | |||
488 | |||
489 | OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) | ||
490 | :QCheckListItem( parent, text, t ) | ||
491 | { | ||
492 | init(); | ||
493 | } | ||
494 | |||
495 | |||
496 | OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) | ||
497 | :QCheckListItem( parent, text, p ) | ||
498 | { | ||
499 | init(); | ||
500 | } | ||
501 | |||
502 | |||
503 | OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) | ||
504 | :QCheckListItem( parent, text, p ) | ||
505 | { | ||
506 | init(); | ||
507 | } | ||
508 | |||
509 | |||
510 | OCheckListItem::~OCheckListItem() | ||
511 | { | ||
512 | } | ||
513 | |||
514 | void OCheckListItem::init() | ||
515 | { | ||
516 | m_known = false; | ||
517 | } | ||
518 | |||
519 | |||
520 | const QColor &OCheckListItem::backgroundColor() | ||
521 | { | ||
522 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | ||
523 | listView()->viewport()->colorGroup().base(); | ||
524 | } | ||
525 | |||
526 | |||
527 | bool OCheckListItem::isAlternate() | ||
528 | { | ||
529 | OListView *lv = static_cast<OListView*>( listView() ); | ||
530 | |||
531 | // check if the item above is an OCheckListItem | ||
532 | OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); | ||
533 | /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ | ||
534 | |||
535 | // check if we have a valid alternate background color | ||
536 | if (!(lv && lv->alternateBackground().isValid())) return false; | ||
537 | |||
538 | m_known = above ? above->m_known : true; | ||
539 | if (m_known) | ||
540 | { | ||
541 | m_odd = above ? !above->m_odd : false; | ||
542 | } | ||
543 | else | ||
544 | { | ||
545 | OCheckListItem *item; | ||
546 | bool previous = true; | ||
547 | if (parent()) | ||
548 | { | ||
549 | item = static_cast<OCheckListItem *>(parent()); | ||
550 | if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; | ||
551 | item = static_cast<OCheckListItem *>(parent()->firstChild()); | ||
552 | /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ | ||
553 | } | ||
554 | else | ||
555 | { | ||
556 | item = static_cast<OCheckListItem *>(lv->firstChild()); | ||
557 | } | ||
558 | |||
559 | while(item) | ||
560 | { | ||
561 | item->m_odd = previous = !previous; | ||
562 | item->m_known = true; | ||
563 | item = static_cast<OCheckListItem *>(item->nextSibling()); | ||
564 | /* if (!item.inherits( "OCheckListItem" ) ) break; */ | ||
565 | } | ||
566 | } | ||
567 | return m_odd; | ||
568 | } | ||
569 | |||
570 | |||
571 | void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | ||
572 | { | ||
573 | QColorGroup _cg = cg; | ||
574 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | ||
575 | if (pm && !pm->isNull()) | ||
576 | { | ||
577 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); | ||
578 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | ||
579 | } | ||
580 | else if ( isAlternate() ) | ||
581 | { | ||
582 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | ||
583 | } | ||
584 | QCheckListItem::paintCell( p, _cg, column, width, alignment ); | ||
585 | |||
586 | //FIXME: Use styling here! | ||
587 | |||
588 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | ||
589 | p->setPen( pen ); | ||
590 | p->drawLine( width-1, 0, width-1, height() ); | ||
591 | } | ||
592 | |||
593 | |||
594 | /*====================================================================================== | ||
448 | * ONamedListView | 595 | * ONamedListView |
449 | *======================================================================================*/ | 596 | *======================================================================================*/ |
450 | 597 | ||
451 | ONamedListView::ONamedListView( QWidget *parent, const char *name ) | 598 | ONamedListView::ONamedListView( QWidget *parent, const char *name ) |
452 | :OListView( parent, name ) | 599 | :OListView( parent, name ) |
453 | { | 600 | { |
454 | } | 601 | } |
455 | 602 | ||
456 | 603 | ||
457 | ONamedListView::~ONamedListView() | 604 | ONamedListView::~ONamedListView() |
458 | { | 605 | { |
459 | } | 606 | } |
460 | 607 | ||
461 | 608 | ||
462 | void ONamedListView::addColumns( const QStringList& columns ) | 609 | void ONamedListView::addColumns( const QStringList& columns ) |
463 | { | 610 | { |
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index a00b43a..59b0973 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h | |||
@@ -1,20 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> | |
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 12 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
@@ -38,33 +37,33 @@ | |||
38 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
39 | 38 | ||
40 | class OListViewItem; | 39 | class OListViewItem; |
41 | 40 | ||
42 | 41 | ||
43 | /*====================================================================================== | 42 | /*====================================================================================== |
44 | * OListView | 43 | * OListView |
45 | *======================================================================================*/ | 44 | *======================================================================================*/ |
46 | 45 | ||
47 | /** | 46 | /** |
48 | * @brief A list/tree widget. | 47 | * @brief A list/tree widget. |
49 | * | 48 | * |
50 | * A @ref QListView variant featuring visual and functional enhancements | 49 | * A @ref QListView variant featuring visual and functional enhancements |
51 | * like an alternate background for odd rows, an autostretch mode | 50 | * like an alternate background for odd rows, an autostretch mode |
52 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | 51 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
53 | * | 52 | * |
54 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 53 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
55 | */ | 54 | */ |
56 | class OListView: public QListView | 55 | class OListView: public QListView |
57 | { | 56 | { |
58 | public: | 57 | public: |
59 | /** | 58 | /** |
60 | * Constructor. | 59 | * Constructor. |
61 | * | 60 | * |
62 | * The parameters @a parent and @a name are handled by | 61 | * The parameters @a parent and @a name are handled by |
63 | * @ref QListView, as usual. | 62 | * @ref QListView, as usual. |
64 | */ | 63 | */ |
65 | OListView( QWidget* parent = 0, const char* name = 0 ); | 64 | OListView( QWidget* parent = 0, const char* name = 0 ); |
66 | /** | 65 | /** |
67 | * Destructor. | 66 | * Destructor. |
68 | */ | 67 | */ |
69 | virtual ~OListView(); | 68 | virtual ~OListView(); |
70 | /** | 69 | /** |
@@ -109,63 +108,74 @@ class OListView: public QListView | |||
109 | /** | 108 | /** |
110 | * Create a list view item as child of this object | 109 | * Create a list view item as child of this object |
111 | * @returns the new object | 110 | * @returns the new object |
112 | */ | 111 | */ |
113 | virtual OListViewItem* childFactory(); | 112 | virtual OListViewItem* childFactory(); |
114 | #ifndef QT_NO_DATASTREAM | 113 | #ifndef QT_NO_DATASTREAM |
115 | /** | 114 | /** |
116 | * Serialize this object to @ref QDataStream @a stream | 115 | * Serialize this object to @ref QDataStream @a stream |
117 | */ | 116 | */ |
118 | virtual void serializeTo( QDataStream& stream ) const; | 117 | virtual void serializeTo( QDataStream& stream ) const; |
119 | /** | 118 | /** |
120 | * Serialize this object from a @ref QDataStream @a stream | 119 | * Serialize this object from a @ref QDataStream @a stream |
121 | */ | 120 | */ |
122 | virtual void serializeFrom( QDataStream& s ); | 121 | virtual void serializeFrom( QDataStream& s ); |
123 | #endif | 122 | #endif |
124 | 123 | ||
125 | protected slots: | 124 | public slots: |
126 | /** | 125 | /** |
126 | * Expand all items | ||
127 | */ | ||
128 | void expand(); | ||
129 | /** | ||
130 | * Collapse all items | ||
131 | */ | ||
132 | void collapse(); | ||
133 | |||
134 | protected slots: | ||
135 | /** | ||
127 | * expand the current OListViewItem | 136 | * expand the current OListViewItem |
128 | */ | 137 | */ |
129 | void expand(QListViewItem*); | 138 | void expand(QListViewItem*); |
130 | 139 | ||
131 | private: | 140 | private: |
132 | QColor m_alternateBackground; | 141 | QColor m_alternateBackground; |
133 | bool m_fullWidth; | 142 | bool m_fullWidth; |
134 | QPen m_columnSeparator; | 143 | QPen m_columnSeparator; |
135 | }; | 144 | }; |
136 | 145 | ||
137 | #ifndef QT_NO_DATASTREAM | 146 | #ifndef QT_NO_DATASTREAM |
138 | /** | 147 | /** |
139 | * @relates OListView | 148 | * @relates OListView |
140 | * Writes @a listview to the @a stream and returns a reference to the stream. | 149 | * Writes @a listview to the @a stream and returns a reference to the stream. |
141 | */ | 150 | */ |
142 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); | 151 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); |
143 | /** | 152 | /** |
144 | * @relates OListView | 153 | * @relates OListView |
145 | * Reads @a listview from the @a stream and returns a reference to the stream. | 154 | * Reads @a listview from the @a stream and returns a reference to the stream. |
146 | */ | 155 | */ |
147 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); | 156 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); |
148 | #endif // QT_NO_DATASTREAM | 157 | #endif // QT_NO_DATASTREAM |
149 | 158 | ||
150 | /*====================================================================================== | 159 | /*====================================================================================== |
151 | * OListViewItem | 160 | * OListViewItem |
152 | *======================================================================================*/ | 161 | *======================================================================================*/ |
153 | 162 | ||
154 | class OListViewItem: public QListViewItem | 163 | class OListViewItem: public QListViewItem |
155 | { | 164 | { |
165 | friend class OCheckListItem; | ||
156 | public: | 166 | public: |
157 | /** | 167 | /** |
158 | * Constructors. | 168 | * Constructors. |
159 | */ | 169 | */ |
160 | OListViewItem( QListView * parent ); | 170 | OListViewItem( QListView * parent ); |
161 | OListViewItem( QListViewItem * parent ); | 171 | OListViewItem( QListViewItem * parent ); |
162 | OListViewItem( QListView * parent, QListViewItem * after ); | 172 | OListViewItem( QListView * parent, QListViewItem * after ); |
163 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | 173 | OListViewItem( QListViewItem * parent, QListViewItem * after ); |
164 | 174 | ||
165 | OListViewItem( QListView * parent, | 175 | OListViewItem( QListView * parent, |
166 | QString, QString = QString::null, | 176 | QString, QString = QString::null, |
167 | QString = QString::null, QString = QString::null, | 177 | QString = QString::null, QString = QString::null, |
168 | QString = QString::null, QString = QString::null, | 178 | QString = QString::null, QString = QString::null, |
169 | QString = QString::null, QString = QString::null ); | 179 | QString = QString::null, QString = QString::null ); |
170 | 180 | ||
171 | OListViewItem( QListViewItem * parent, | 181 | OListViewItem( QListViewItem * parent, |
@@ -237,44 +247,89 @@ class OListViewItem: public QListViewItem | |||
237 | }; | 247 | }; |
238 | 248 | ||
239 | #ifndef QT_NO_DATASTREAM | 249 | #ifndef QT_NO_DATASTREAM |
240 | /** | 250 | /** |
241 | * @relates QListViewItem | 251 | * @relates QListViewItem |
242 | * Writes listview @a item and all subitems recursively to @a stream | 252 | * Writes listview @a item and all subitems recursively to @a stream |
243 | * and returns a reference to the stream. | 253 | * and returns a reference to the stream. |
244 | */ | 254 | */ |
245 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); | 255 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); |
246 | /** | 256 | /** |
247 | * @relates QListViewItem | 257 | * @relates QListViewItem |
248 | * Reads listview @a item from @a stream and returns a reference to the stream. | 258 | * Reads listview @a item from @a stream and returns a reference to the stream. |
249 | */ | 259 | */ |
250 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); | 260 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); |
251 | #endif // QT_NO_DATASTREAM | 261 | #endif // QT_NO_DATASTREAM |
252 | 262 | ||
263 | |||
264 | /*====================================================================================== | ||
265 | * OCheckListItem | ||
266 | *======================================================================================*/ | ||
267 | |||
268 | class OCheckListItem : public QCheckListItem | ||
269 | { | ||
270 | public: | ||
271 | |||
272 | OCheckListItem( QCheckListItem *parent, const QString &text, | ||
273 | Type = Controller ); | ||
274 | OCheckListItem( QListViewItem *parent, const QString &text, | ||
275 | Type = Controller ); | ||
276 | OCheckListItem( QListView *parent, const QString &text, | ||
277 | Type = Controller ); | ||
278 | OCheckListItem( QListViewItem *parent, const QString &text, | ||
279 | const QPixmap & ); | ||
280 | OCheckListItem( QListView *parent, const QString &text, | ||
281 | const QPixmap & ); | ||
282 | ~OCheckListItem(); | ||
283 | /** | ||
284 | * @returns the background color of the list item. | ||
285 | */ | ||
286 | const QColor& backgroundColor(); | ||
287 | /** | ||
288 | * @returns true, if the item is at an odd position and | ||
289 | * thus have to be painted with the alternate background color. | ||
290 | */ | ||
291 | bool isAlternate(); | ||
292 | /** | ||
293 | * @note: Reimplemented for internal purposes - the API is not affected | ||
294 | * | ||
295 | */ | ||
296 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | ||
297 | /** | ||
298 | * Perform object initialization. | ||
299 | */ | ||
300 | void init(); | ||
301 | |||
302 | private: | ||
303 | bool m_known; | ||
304 | bool m_odd; | ||
305 | }; | ||
306 | |||
307 | |||
253 | /*====================================================================================== | 308 | /*====================================================================================== |
254 | * ONamedListView | 309 | * ONamedListView |
255 | *======================================================================================*/ | 310 | *======================================================================================*/ |
256 | 311 | ||
257 | class ONamedListViewItem; | 312 | class ONamedListViewItem; |
258 | 313 | ||
259 | /** | 314 | /** |
260 | * @brief An OListView variant with named columns. | 315 | * @brief An OListView variant with named columns. |
261 | * | 316 | * |
262 | * This class provides a higher-level interface to an OListView. | 317 | * This class provides a higher-level interface to an OListView. |
263 | * | 318 | * |
264 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 319 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
265 | */ | 320 | */ |
266 | class ONamedListView: public OListView | 321 | class ONamedListView: public OListView |
267 | { | 322 | { |
268 | public: | 323 | public: |
269 | /** | 324 | /** |
270 | * Constructor. | 325 | * Constructor. |
271 | * | 326 | * |
272 | * The parameters @a parent and @a name are handled by | 327 | * The parameters @a parent and @a name are handled by |
273 | * @ref OListView, as usual. | 328 | * @ref OListView, as usual. |
274 | */ | 329 | */ |
275 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); | 330 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); |
276 | /** | 331 | /** |
277 | * Destructor. | 332 | * Destructor. |
278 | */ | 333 | */ |
279 | virtual ~ONamedListView(); | 334 | virtual ~ONamedListView(); |
280 | /** | 335 | /** |
@@ -297,33 +352,33 @@ class ONamedListView: public OListView | |||
297 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; | 352 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; |
298 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 353 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
299 | 354 | ||
300 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; | 355 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; |
301 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 356 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
302 | }; | 357 | }; |
303 | 358 | ||
304 | /*====================================================================================== | 359 | /*====================================================================================== |
305 | * ONamedListViewItem | 360 | * ONamedListViewItem |
306 | *======================================================================================*/ | 361 | *======================================================================================*/ |
307 | 362 | ||
308 | /** | 363 | /** |
309 | * @brief An OListView variant with named columns. | 364 | * @brief An OListView variant with named columns. |
310 | * | 365 | * |
311 | * This class provides a higher-level interface to an OListViewItem. | 366 | * This class provides a higher-level interface to an OListViewItem. |
312 | * | 367 | * |
313 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 368 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
314 | */ | 369 | */ |
315 | class ONamedListViewItem: public OListViewItem | 370 | class ONamedListViewItem: public OListViewItem |
316 | { | 371 | { |
317 | public: | 372 | public: |
318 | /** | 373 | /** |
319 | * Constructor. Accepts the same parameters as a @ref OListViewItem, | 374 | * Constructor. Accepts the same parameters as a @ref OListViewItem, |
320 | * plus a @ref QStringList which holds an arbitrary number of @a texts. | 375 | * plus a @ref QStringList which holds an arbitrary number of @a texts. |
321 | */ | 376 | */ |
322 | ONamedListViewItem( QListView* parent, const QStringList& texts ); | 377 | ONamedListViewItem( QListView* parent, const QStringList& texts ); |
323 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); | 378 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); |
324 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); | 379 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); |
325 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); | 380 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); |
326 | /** | 381 | /** |
327 | * Destructor. | 382 | * Destructor. |
328 | */ | 383 | */ |
329 | virtual ~ONamedListViewItem(); | 384 | virtual ~ONamedListViewItem(); |