-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,610 +1,757 @@ | |||
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. |
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 | /* QT */ | 30 | /* QT */ |
31 | 31 | ||
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
37 | #include <opie2/olistview.h> | 37 | #include <opie2/olistview.h> |
38 | 38 | ||
39 | /*====================================================================================== | 39 | /*====================================================================================== |
40 | * OListView | 40 | * OListView |
41 | *======================================================================================*/ | 41 | *======================================================================================*/ |
42 | 42 | ||
43 | OListView::OListView( QWidget *parent, const char *name ) | 43 | OListView::OListView( QWidget *parent, const char *name ) |
44 | :QListView( parent, name ) | 44 | :QListView( parent, name ) |
45 | { | 45 | { |
46 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* | 46 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* |
47 | 47 | ||
48 | m_alternateBackground = QColor( 238, 246, 255 ); | 48 | m_alternateBackground = QColor( 238, 246, 255 ); |
49 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); | 49 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); |
50 | m_fullWidth = true; | 50 | m_fullWidth = true; |
51 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 51 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
52 | } | 52 | } |
53 | 53 | ||
54 | OListView::~OListView() | 54 | OListView::~OListView() |
55 | { | 55 | { |
56 | } | 56 | } |
57 | 57 | ||
58 | void OListView::setFullWidth( bool fullWidth ) | 58 | void OListView::setFullWidth( bool fullWidth ) |
59 | { | 59 | { |
60 | m_fullWidth = m_fullWidth; | 60 | m_fullWidth = m_fullWidth; |
61 | #if QT_VERSION > 290 | 61 | #if QT_VERSION > 290 |
62 | header()->setStretchEnabled( fullWidth, columns()-1 ); | 62 | header()->setStretchEnabled( fullWidth, columns()-1 ); |
63 | #endif | 63 | #endif |
64 | } | 64 | } |
65 | 65 | ||
66 | bool OListView::fullWidth() const | 66 | bool OListView::fullWidth() const |
67 | { | 67 | { |
68 | return m_fullWidth; | 68 | return m_fullWidth; |
69 | } | 69 | } |
70 | 70 | ||
71 | int OListView::addColumn( const QString& label, int width ) | 71 | int OListView::addColumn( const QString& label, int width ) |
72 | { | 72 | { |
73 | int result = QListView::addColumn( label, width ); | 73 | int result = QListView::addColumn( label, width ); |
74 | #if QT_VERSION > 290 | 74 | #if QT_VERSION > 290 |
75 | if (m_fullWidth) { | 75 | if (m_fullWidth) { |
76 | header()->setStretchEnabled( false, columns()-2 ); | 76 | header()->setStretchEnabled( false, columns()-2 ); |
77 | header()->setStretchEnabled( true, columns()-1 ); | 77 | header()->setStretchEnabled( true, columns()-1 ); |
78 | } | 78 | } |
79 | #endif | 79 | #endif |
80 | return result; | 80 | return result; |
81 | } | 81 | } |
82 | 82 | ||
83 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | 83 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) |
84 | { | 84 | { |
85 | int result = QListView::addColumn( iconset, label, width ); | 85 | int result = QListView::addColumn( iconset, label, width ); |
86 | #if QT_VERSION > 290 | 86 | #if QT_VERSION > 290 |
87 | if (m_fullWidth) { | 87 | if (m_fullWidth) { |
88 | header()->setStretchEnabled( false, columns()-2 ); | 88 | header()->setStretchEnabled( false, columns()-2 ); |
89 | header()->setStretchEnabled( true, columns()-1 ); | 89 | header()->setStretchEnabled( true, columns()-1 ); |
90 | } | 90 | } |
91 | #endif | 91 | #endif |
92 | return result; | 92 | return result; |
93 | } | 93 | } |
94 | 94 | ||
95 | void OListView::removeColumn( int index ) | 95 | void OListView::removeColumn( int index ) |
96 | { | 96 | { |
97 | QListView::removeColumn(index); | 97 | QListView::removeColumn(index); |
98 | #if QT_VERSION > 290 | 98 | #if QT_VERSION > 290 |
99 | if ( m_fullWidth && index == columns() ) | 99 | if ( m_fullWidth && index == columns() ) |
100 | { | 100 | { |
101 | header()->setStretchEnabled( true, columns()-1 ); | 101 | header()->setStretchEnabled( true, columns()-1 ); |
102 | } | 102 | } |
103 | #endif | 103 | #endif |
104 | } | 104 | } |
105 | 105 | ||
106 | const QColor& OListView::alternateBackground() const | 106 | const QColor& OListView::alternateBackground() const |
107 | { | 107 | { |
108 | return m_alternateBackground; | 108 | return m_alternateBackground; |
109 | } | 109 | } |
110 | 110 | ||
111 | void OListView::setAlternateBackground( const QColor &c ) | 111 | void OListView::setAlternateBackground( const QColor &c ) |
112 | { | 112 | { |
113 | m_alternateBackground = c; | 113 | m_alternateBackground = c; |
114 | repaint(); | 114 | repaint(); |
115 | } | 115 | } |
116 | 116 | ||
117 | const QPen& OListView::columnSeparator() const | 117 | const QPen& OListView::columnSeparator() const |
118 | { | 118 | { |
119 | return m_columnSeparator; | 119 | return m_columnSeparator; |
120 | } | 120 | } |
121 | 121 | ||
122 | void OListView::setColumnSeparator( const QPen& p ) | 122 | void OListView::setColumnSeparator( const QPen& p ) |
123 | { | 123 | { |
124 | m_columnSeparator = p; | 124 | m_columnSeparator = p; |
125 | repaint(); | 125 | repaint(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void OListView::expand(QListViewItem *item) | 128 | void OListView::expand(QListViewItem *item) |
129 | { | 129 | { |
130 | ((OListViewItem*)item)->expand(); | 130 | ((OListViewItem*)item)->expand(); |
131 | } | 131 | } |
132 | 132 | ||
133 | OListViewItem* OListView::childFactory() | 133 | OListViewItem* OListView::childFactory() |
134 | { | 134 | { |
135 | return new OListViewItem( this ); | 135 | return new OListViewItem( this ); |
136 | } | 136 | } |
137 | 137 | ||
138 | #ifndef QT_NO_DATASTREAM | 138 | #ifndef QT_NO_DATASTREAM |
139 | void OListView::serializeTo( QDataStream& s ) const | 139 | void OListView::serializeTo( QDataStream& s ) const |
140 | { | 140 | { |
141 | #warning Caution... the binary format is still under construction... | 141 | #warning Caution... the binary format is still under construction... |
142 | odebug << "storing OListView..." << oendl; | 142 | odebug << "storing OListView..." << oendl; |
143 | 143 | ||
144 | // store number of columns and the labels | 144 | // store number of columns and the labels |
145 | s << columns(); | 145 | s << columns(); |
146 | for ( int i = 0; i < columns(); ++i ) | 146 | for ( int i = 0; i < columns(); ++i ) |
147 | s << columnText( i ); | 147 | s << columnText( i ); |
148 | 148 | ||
149 | // calculate the number of top-level items to serialize | 149 | // calculate the number of top-level items to serialize |
150 | int items = 0; | 150 | int items = 0; |
151 | QListViewItem* item = firstChild(); | 151 | QListViewItem* item = firstChild(); |
152 | while ( item ) | 152 | while ( item ) |
153 | { | 153 | { |
154 | item = item->nextSibling(); | 154 | item = item->nextSibling(); |
155 | items++; | 155 | items++; |
156 | } | 156 | } |
157 | 157 | ||
158 | // store number of items and the items itself | 158 | // store number of items and the items itself |
159 | s << items; | 159 | s << items; |
160 | item = firstChild(); | 160 | item = firstChild(); |
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) |
219 | : QListViewItem(parent) | 243 | : QListViewItem(parent) |
220 | { | 244 | { |
221 | init(); | 245 | init(); |
222 | } | 246 | } |
223 | 247 | ||
224 | 248 | ||
225 | OListViewItem::OListViewItem(QListViewItem *parent) | 249 | OListViewItem::OListViewItem(QListViewItem *parent) |
226 | : QListViewItem(parent) | 250 | : QListViewItem(parent) |
227 | { | 251 | { |
228 | init(); | 252 | init(); |
229 | } | 253 | } |
230 | 254 | ||
231 | 255 | ||
232 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) | 256 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) |
233 | : QListViewItem(parent, after) | 257 | : QListViewItem(parent, after) |
234 | { | 258 | { |
235 | init(); | 259 | init(); |
236 | } | 260 | } |
237 | 261 | ||
238 | 262 | ||
239 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) | 263 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) |
240 | : QListViewItem(parent, after) | 264 | : QListViewItem(parent, after) |
241 | { | 265 | { |
242 | init(); | 266 | init(); |
243 | } | 267 | } |
244 | 268 | ||
245 | 269 | ||
246 | OListViewItem::OListViewItem(QListView *parent, | 270 | OListViewItem::OListViewItem(QListView *parent, |
247 | QString label1, QString label2, QString label3, QString label4, | 271 | QString label1, QString label2, QString label3, QString label4, |
248 | QString label5, QString label6, QString label7, QString label8) | 272 | QString label5, QString label6, QString label7, QString label8) |
249 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 273 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
250 | { | 274 | { |
251 | init(); | 275 | init(); |
252 | } | 276 | } |
253 | 277 | ||
254 | 278 | ||
255 | OListViewItem::OListViewItem(QListViewItem *parent, | 279 | OListViewItem::OListViewItem(QListViewItem *parent, |
256 | QString label1, QString label2, QString label3, QString label4, | 280 | QString label1, QString label2, QString label3, QString label4, |
257 | QString label5, QString label6, QString label7, QString label8) | 281 | QString label5, QString label6, QString label7, QString label8) |
258 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 282 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
259 | { | 283 | { |
260 | init(); | 284 | init(); |
261 | } | 285 | } |
262 | 286 | ||
263 | 287 | ||
264 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, | 288 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, |
265 | QString label1, QString label2, QString label3, QString label4, | 289 | QString label1, QString label2, QString label3, QString label4, |
266 | QString label5, QString label6, QString label7, QString label8) | 290 | QString label5, QString label6, QString label7, QString label8) |
267 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 291 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
268 | { | 292 | { |
269 | init(); | 293 | init(); |
270 | } | 294 | } |
271 | 295 | ||
272 | 296 | ||
273 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, | 297 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, |
274 | QString label1, QString label2, QString label3, QString label4, | 298 | QString label1, QString label2, QString label3, QString label4, |
275 | QString label5, QString label6, QString label7, QString label8) | 299 | QString label5, QString label6, QString label7, QString label8) |
276 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 300 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
277 | { | 301 | { |
278 | init(); | 302 | init(); |
279 | } | 303 | } |
280 | 304 | ||
281 | 305 | ||
282 | OListViewItem::~OListViewItem() | 306 | OListViewItem::~OListViewItem() |
283 | { | 307 | { |
284 | } | 308 | } |
285 | 309 | ||
286 | 310 | ||
287 | void OListViewItem::init() | 311 | void OListViewItem::init() |
288 | { | 312 | { |
289 | m_known = false; | 313 | m_known = false; |
290 | } | 314 | } |
291 | 315 | ||
292 | 316 | ||
293 | const QColor &OListViewItem::backgroundColor() | 317 | const QColor &OListViewItem::backgroundColor() |
294 | { | 318 | { |
295 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | 319 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : |
296 | listView()->viewport()->colorGroup().base(); | 320 | listView()->viewport()->colorGroup().base(); |
297 | } | 321 | } |
298 | 322 | ||
299 | 323 | ||
300 | bool OListViewItem::isAlternate() | 324 | bool OListViewItem::isAlternate() |
301 | { | 325 | { |
302 | OListView *lv = static_cast<OListView*>( listView() ); | 326 | OListView *lv = static_cast<OListView*>( listView() ); |
303 | 327 | ||
304 | // check if the item above is an OListViewItem | 328 | // check if the item above is an OListViewItem |
305 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); | 329 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); |
306 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ | 330 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ |
307 | 331 | ||
308 | // check if we have a valid alternate background color | 332 | // check if we have a valid alternate background color |
309 | if (!(lv && lv->alternateBackground().isValid())) return false; | 333 | if (!(lv && lv->alternateBackground().isValid())) return false; |
310 | 334 | ||
311 | m_known = above ? above->m_known : true; | 335 | m_known = above ? above->m_known : true; |
312 | if (m_known) | 336 | if (m_known) |
313 | { | 337 | { |
314 | m_odd = above ? !above->m_odd : false; | 338 | m_odd = above ? !above->m_odd : false; |
315 | } | 339 | } |
316 | else | 340 | else |
317 | { | 341 | { |
318 | OListViewItem *item; | 342 | OListViewItem *item; |
319 | bool previous = true; | 343 | bool previous = true; |
320 | if (parent()) | 344 | if (parent()) |
321 | { | 345 | { |
322 | item = static_cast<OListViewItem *>(parent()); | 346 | item = static_cast<OListViewItem *>(parent()); |
323 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; | 347 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; |
324 | item = static_cast<OListViewItem *>(parent()->firstChild()); | 348 | item = static_cast<OListViewItem *>(parent()->firstChild()); |
325 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ | 349 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ |
326 | } | 350 | } |
327 | else | 351 | else |
328 | { | 352 | { |
329 | item = static_cast<OListViewItem *>(lv->firstChild()); | 353 | item = static_cast<OListViewItem *>(lv->firstChild()); |
330 | } | 354 | } |
331 | 355 | ||
332 | while(item) | 356 | while(item) |
333 | { | 357 | { |
334 | item->m_odd = previous = !previous; | 358 | item->m_odd = previous = !previous; |
335 | item->m_known = true; | 359 | item->m_known = true; |
336 | item = static_cast<OListViewItem *>(item->nextSibling()); | 360 | item = static_cast<OListViewItem *>(item->nextSibling()); |
337 | /* if (!item.inherits( "OListViewItem" ) ) break; */ | 361 | /* if (!item.inherits( "OListViewItem" ) ) break; */ |
338 | } | 362 | } |
339 | } | 363 | } |
340 | return m_odd; | 364 | return m_odd; |
341 | } | 365 | } |
342 | 366 | ||
343 | 367 | ||
344 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 368 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
345 | { | 369 | { |
346 | QColorGroup _cg = cg; | 370 | QColorGroup _cg = cg; |
347 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 371 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
348 | if (pm && !pm->isNull()) | 372 | if (pm && !pm->isNull()) |
349 | { | 373 | { |
350 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); | 374 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); |
351 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 375 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
352 | } | 376 | } |
353 | else if ( isAlternate() ) | 377 | else if ( isAlternate() ) |
354 | { | 378 | { |
355 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 379 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
356 | } | 380 | } |
357 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 381 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
358 | 382 | ||
359 | //FIXME: Use styling here! | 383 | //FIXME: Use styling here! |
360 | 384 | ||
361 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 385 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
362 | p->setPen( pen ); | 386 | p->setPen( pen ); |
363 | p->drawLine( width-1, 0, width-1, height() ); | 387 | p->drawLine( width-1, 0, width-1, height() ); |
364 | } | 388 | } |
365 | 389 | ||
366 | 390 | ||
367 | OListViewItem* OListViewItem::childFactory() | 391 | OListViewItem* OListViewItem::childFactory() |
368 | { | 392 | { |
369 | return new OListViewItem( this ); | 393 | return new OListViewItem( this ); |
370 | } | 394 | } |
371 | 395 | ||
372 | 396 | ||
373 | #ifndef QT_NO_DATASTREAM | 397 | #ifndef QT_NO_DATASTREAM |
374 | void OListViewItem::serializeTo( QDataStream& s ) const | 398 | void OListViewItem::serializeTo( QDataStream& s ) const |
375 | { | 399 | { |
376 | #warning Caution... the binary format is still under construction... | 400 | #warning Caution... the binary format is still under construction... |
377 | odebug << "storing OListViewItem..." << oendl; | 401 | odebug << "storing OListViewItem..." << oendl; |
378 | 402 | ||
379 | // store item text | 403 | // store item text |
380 | for ( int i = 0; i < listView()->columns(); ++i ) | 404 | for ( int i = 0; i < listView()->columns(); ++i ) |
381 | { | 405 | { |
382 | s << text( i ); | 406 | s << text( i ); |
383 | } | 407 | } |
384 | 408 | ||
385 | // calculate the number of children to serialize | 409 | // calculate the number of children to serialize |
386 | int items = 0; | 410 | int items = 0; |
387 | QListViewItem* item = firstChild(); | 411 | QListViewItem* item = firstChild(); |
388 | while ( item ) | 412 | while ( item ) |
389 | { | 413 | { |
390 | item = item->nextSibling(); | 414 | item = item->nextSibling(); |
391 | items++; | 415 | items++; |
392 | } | 416 | } |
393 | 417 | ||
394 | // store number of items and the items itself | 418 | // store number of items and the items itself |
395 | s << items; | 419 | s << items; |
396 | item = firstChild(); | 420 | item = firstChild(); |
397 | for ( int i = 0; i < items; ++i ) | 421 | for ( int i = 0; i < items; ++i ) |
398 | { | 422 | { |
399 | s << *static_cast<OListViewItem*>( item ); | 423 | s << *static_cast<OListViewItem*>( item ); |
400 | item = item->nextSibling(); | 424 | item = item->nextSibling(); |
401 | } | 425 | } |
402 | 426 | ||
403 | odebug << "OListviewItem stored." << oendl; | 427 | odebug << "OListviewItem stored." << oendl; |
404 | } | 428 | } |
405 | 429 | ||
406 | 430 | ||
407 | void OListViewItem::serializeFrom( QDataStream& s ) | 431 | void OListViewItem::serializeFrom( QDataStream& s ) |
408 | { | 432 | { |
409 | #warning Caution... the binary format is still under construction... | 433 | #warning Caution... the binary format is still under construction... |
410 | odebug << "loading OListViewItem..." << oendl; | 434 | odebug << "loading OListViewItem..." << oendl; |
411 | 435 | ||
412 | for ( int i = 0; i < listView()->columns(); ++i ) | 436 | for ( int i = 0; i < listView()->columns(); ++i ) |
413 | { | 437 | { |
414 | QString coltext; | 438 | QString coltext; |
415 | s >> coltext; | 439 | s >> coltext; |
416 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 440 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
417 | setText( i, coltext ); | 441 | setText( i, coltext ); |
418 | } | 442 | } |
419 | 443 | ||
420 | int items; | 444 | int items; |
421 | s >> items; | 445 | s >> items; |
422 | qDebug( "read number of items = %d", items ); | 446 | qDebug( "read number of items = %d", items ); |
423 | 447 | ||
424 | for ( int i = 0; i < items; ++i ) | 448 | for ( int i = 0; i < items; ++i ) |
425 | { | 449 | { |
426 | OListViewItem* item = childFactory(); | 450 | OListViewItem* item = childFactory(); |
427 | s >> (*item); | 451 | s >> (*item); |
428 | } | 452 | } |
429 | 453 | ||
430 | odebug << "OListViewItem loaded." << oendl; | 454 | odebug << "OListViewItem loaded." << oendl; |
431 | } | 455 | } |
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 | { |
464 | for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) | 611 | for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) |
465 | { | 612 | { |
466 | qDebug( "adding column %s", (const char*) *it ); | 613 | qDebug( "adding column %s", (const char*) *it ); |
467 | addColumn( *it ); | 614 | addColumn( *it ); |
468 | } | 615 | } |
469 | } | 616 | } |
470 | 617 | ||
471 | 618 | ||
472 | int ONamedListView::findColumn( const QString& text ) const | 619 | int ONamedListView::findColumn( const QString& text ) const |
473 | { | 620 | { |
474 | //FIXME: If used excessively, this will slow down performance of updates | 621 | //FIXME: If used excessively, this will slow down performance of updates |
475 | //FIXME: because of the linear search over all column texts. | 622 | //FIXME: because of the linear search over all column texts. |
476 | //FIXME: I will optimize later by using a hash map. | 623 | //FIXME: I will optimize later by using a hash map. |
477 | for ( int i = 0; i < columns(); ++i ) | 624 | for ( int i = 0; i < columns(); ++i ) |
478 | if ( columnText( i ) == text ) | 625 | if ( columnText( i ) == text ) |
479 | return i; | 626 | return i; |
480 | return -1; | 627 | return -1; |
481 | } | 628 | } |
482 | 629 | ||
483 | 630 | ||
484 | ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const | 631 | ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const |
485 | { | 632 | { |
486 | return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); | 633 | return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); |
487 | } | 634 | } |
488 | 635 | ||
489 | 636 | ||
490 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const | 637 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const |
491 | { | 638 | { |
492 | ONamedListViewItem* result; | 639 | ONamedListViewItem* result; |
493 | while ( item && item->text( column ) != text ) | 640 | while ( item && item->text( column ) != text ) |
494 | { | 641 | { |
495 | qDebug( "checked %s", (const char*) item->text( column ) ); | 642 | qDebug( "checked %s", (const char*) item->text( column ) ); |
496 | 643 | ||
497 | if ( recurse < 0 || recurse > 0 ) | 644 | if ( recurse < 0 || recurse > 0 ) |
498 | { | 645 | { |
499 | qDebug( "recursion is %d - recursing into...", recurse ); | 646 | qDebug( "recursion is %d - recursing into...", recurse ); |
500 | result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); | 647 | result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); |
501 | if ( result ) return result; | 648 | if ( result ) return result; |
502 | } | 649 | } |
503 | 650 | ||
504 | 651 | ||
505 | item = (ONamedListViewItem*) item->itemBelow(); | 652 | item = (ONamedListViewItem*) item->itemBelow(); |
506 | } | 653 | } |
507 | if ( item && item->text( column ) == text ) | 654 | if ( item && item->text( column ) == text ) |
508 | return item; | 655 | return item; |
509 | else | 656 | else |
510 | return 0; | 657 | return 0; |
511 | } | 658 | } |
512 | 659 | ||
513 | 660 | ||
514 | ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const | 661 | ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const |
515 | { | 662 | { |
516 | int col = findColumn( column ); | 663 | int col = findColumn( column ); |
517 | if ( col != -1 ) | 664 | if ( col != -1 ) |
518 | return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); | 665 | return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); |
519 | else | 666 | else |
520 | return 0; | 667 | return 0; |
521 | } | 668 | } |
522 | 669 | ||
523 | 670 | ||
524 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const | 671 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const |
525 | { | 672 | { |
526 | int col = findColumn( column ); | 673 | int col = findColumn( column ); |
527 | if ( col != -1 ) | 674 | if ( col != -1 ) |
528 | return find( item, col, text, recurse ); | 675 | return find( item, col, text, recurse ); |
529 | else | 676 | else |
530 | return 0; | 677 | return 0; |
531 | } | 678 | } |
532 | 679 | ||
533 | 680 | ||
534 | /*====================================================================================== | 681 | /*====================================================================================== |
535 | * ONamedListViewItem | 682 | * ONamedListViewItem |
536 | *======================================================================================*/ | 683 | *======================================================================================*/ |
537 | 684 | ||
538 | ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) | 685 | ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) |
539 | :OListViewItem( parent ) | 686 | :OListViewItem( parent ) |
540 | { | 687 | { |
541 | setText( texts ); | 688 | setText( texts ); |
542 | } | 689 | } |
543 | 690 | ||
544 | 691 | ||
545 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) | 692 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) |
546 | :OListViewItem( parent ) | 693 | :OListViewItem( parent ) |
547 | { | 694 | { |
548 | setText( texts ); | 695 | setText( texts ); |
549 | } | 696 | } |
550 | 697 | ||
551 | 698 | ||
552 | ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) | 699 | ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) |
553 | :OListViewItem( parent, after ) | 700 | :OListViewItem( parent, after ) |
554 | { | 701 | { |
555 | setText( texts ); | 702 | setText( texts ); |
556 | } | 703 | } |
557 | 704 | ||
558 | 705 | ||
559 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) | 706 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) |
560 | :OListViewItem( parent, after ) | 707 | :OListViewItem( parent, after ) |
561 | { | 708 | { |
562 | setText( texts ); | 709 | setText( texts ); |
563 | } | 710 | } |
564 | 711 | ||
565 | 712 | ||
566 | ONamedListViewItem::~ONamedListViewItem() | 713 | ONamedListViewItem::~ONamedListViewItem() |
567 | { | 714 | { |
568 | } | 715 | } |
569 | 716 | ||
570 | 717 | ||
571 | void ONamedListViewItem::setText( const QStringList& texts ) | 718 | void ONamedListViewItem::setText( const QStringList& texts ) |
572 | { | 719 | { |
573 | int col = 0; | 720 | int col = 0; |
574 | for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) | 721 | for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) |
575 | { | 722 | { |
576 | qDebug( "setting column %d = text %s", col, (const char*) *it ); | 723 | qDebug( "setting column %d = text %s", col, (const char*) *it ); |
577 | OListViewItem::setText( col++, *it ); | 724 | OListViewItem::setText( col++, *it ); |
578 | } | 725 | } |
579 | 726 | ||
580 | } | 727 | } |
581 | 728 | ||
582 | 729 | ||
583 | void ONamedListViewItem::setText( const QString& column, const QString& text ) | 730 | void ONamedListViewItem::setText( const QString& column, const QString& text ) |
584 | { | 731 | { |
585 | //FIXME: If used excessively, this will slow down performance of updates | 732 | //FIXME: If used excessively, this will slow down performance of updates |
586 | //FIXME: because of the linear search over all column texts. | 733 | //FIXME: because of the linear search over all column texts. |
587 | //FIXME: I will optimize later by using a hash map. | 734 | //FIXME: I will optimize later by using a hash map. |
588 | int col = ( (ONamedListView*) listView() )->findColumn( column ); | 735 | int col = ( (ONamedListView*) listView() )->findColumn( column ); |
589 | if ( col != -1 ) | 736 | if ( col != -1 ) |
590 | OListViewItem::setText( col, text ); | 737 | OListViewItem::setText( col, text ); |
591 | else | 738 | else |
592 | qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); | 739 | qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); |
593 | } | 740 | } |
594 | 741 | ||
595 | 742 | ||
596 | ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const | 743 | ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const |
597 | { | 744 | { |
598 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); | 745 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); |
599 | } | 746 | } |
600 | 747 | ||
601 | 748 | ||
602 | ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const | 749 | ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const |
603 | { | 750 | { |
604 | int col = ( (ONamedListView*) listView() )->findColumn( column ); | 751 | int col = ( (ONamedListView*) listView() )->findColumn( column ); |
605 | if ( col != -1 ) | 752 | if ( col != -1 ) |
606 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); | 753 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); |
607 | else | 754 | else |
608 | return 0; | 755 | return 0; |
609 | } | 756 | } |
610 | 757 | ||
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,354 +1,409 @@ | |||
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. |
21 | : = ...= . :.=- | 20 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
28 | 27 | ||
29 | */ | 28 | */ |
30 | 29 | ||
31 | #ifndef OLISTVIEW_H | 30 | #ifndef OLISTVIEW_H |
32 | #define OLISTVIEW_H | 31 | #define OLISTVIEW_H |
33 | 32 | ||
34 | #include <qcolor.h> | 33 | #include <qcolor.h> |
35 | #include <qlistview.h> | 34 | #include <qlistview.h> |
36 | #include <qpen.h> | 35 | #include <qpen.h> |
37 | #include <qdatastream.h> | 36 | #include <qdatastream.h> |
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 | /** |
71 | * Let the last column fit exactly all the available width. | 70 | * Let the last column fit exactly all the available width. |
72 | */ | 71 | */ |
73 | void setFullWidth( bool fullWidth ); | 72 | void setFullWidth( bool fullWidth ); |
74 | /** | 73 | /** |
75 | * Returns whether the last column is set to fit the available width. | 74 | * Returns whether the last column is set to fit the available width. |
76 | */ | 75 | */ |
77 | bool fullWidth() const; | 76 | bool fullWidth() const; |
78 | /** | 77 | /** |
79 | * Reimplemented for full width support | 78 | * Reimplemented for full width support |
80 | */ | 79 | */ |
81 | virtual int addColumn( const QString& label, int width = -1 ); | 80 | virtual int addColumn( const QString& label, int width = -1 ); |
82 | /** | 81 | /** |
83 | * Reimplemented for full width support | 82 | * Reimplemented for full width support |
84 | */ | 83 | */ |
85 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | 84 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); |
86 | /** | 85 | /** |
87 | * Reimplemented for full width support | 86 | * Reimplemented for full width support |
88 | */ | 87 | */ |
89 | virtual void removeColumn(int index); | 88 | virtual void removeColumn(int index); |
90 | /** | 89 | /** |
91 | * Set the alternate background background @a color. | 90 | * Set the alternate background background @a color. |
92 | * Set to an invalid color to disable alternate colors. | 91 | * Set to an invalid color to disable alternate colors. |
93 | * This only has an effect if the items are OListViewItems | 92 | * This only has an effect if the items are OListViewItems |
94 | */ | 93 | */ |
95 | void setAlternateBackground( const QColor& color ); | 94 | void setAlternateBackground( const QColor& color ); |
96 | /** | 95 | /** |
97 | * Sets the column separator @a pen. | 96 | * Sets the column separator @a pen. |
98 | */ | 97 | */ |
99 | void setColumnSeparator( const QPen& pen ); | 98 | void setColumnSeparator( const QPen& pen ); |
100 | 99 | ||
101 | /** | 100 | /** |
102 | * @returns the alternate background color | 101 | * @returns the alternate background color |
103 | */ | 102 | */ |
104 | const QColor& alternateBackground() const; | 103 | const QColor& alternateBackground() const; |
105 | /** | 104 | /** |
106 | * @return the column separator pen | 105 | * @return the column separator pen |
107 | */ | 106 | */ |
108 | const QPen& columnSeparator() const; | 107 | const QPen& columnSeparator() const; |
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, |
172 | QString, QString = QString::null, | 182 | QString, QString = QString::null, |
173 | QString = QString::null, QString = QString::null, | 183 | QString = QString::null, QString = QString::null, |
174 | QString = QString::null, QString = QString::null, | 184 | QString = QString::null, QString = QString::null, |
175 | QString = QString::null, QString = QString::null ); | 185 | QString = QString::null, QString = QString::null ); |
176 | 186 | ||
177 | OListViewItem( QListView * parent, QListViewItem * after, | 187 | OListViewItem( QListView * parent, QListViewItem * after, |
178 | QString, QString = QString::null, | 188 | QString, QString = QString::null, |
179 | QString = QString::null, QString = QString::null, | 189 | QString = QString::null, QString = QString::null, |
180 | QString = QString::null, QString = QString::null, | 190 | QString = QString::null, QString = QString::null, |
181 | QString = QString::null, QString = QString::null ); | 191 | QString = QString::null, QString = QString::null ); |
182 | 192 | ||
183 | OListViewItem( QListViewItem * parent, QListViewItem * after, | 193 | OListViewItem( QListViewItem * parent, QListViewItem * after, |
184 | QString, QString = QString::null, | 194 | QString, QString = QString::null, |
185 | QString = QString::null, QString = QString::null, | 195 | QString = QString::null, QString = QString::null, |
186 | QString = QString::null, QString = QString::null, | 196 | QString = QString::null, QString = QString::null, |
187 | QString = QString::null, QString = QString::null ); | 197 | QString = QString::null, QString = QString::null ); |
188 | /** | 198 | /** |
189 | * Destructor. | 199 | * Destructor. |
190 | */ | 200 | */ |
191 | virtual ~OListViewItem(); | 201 | virtual ~OListViewItem(); |
192 | /** | 202 | /** |
193 | * @returns the background color of the list item. | 203 | * @returns the background color of the list item. |
194 | */ | 204 | */ |
195 | const QColor& backgroundColor(); | 205 | const QColor& backgroundColor(); |
196 | /** | 206 | /** |
197 | * @returns true, if the item is at an odd position and | 207 | * @returns true, if the item is at an odd position and |
198 | * thus have to be painted with the alternate background color. | 208 | * thus have to be painted with the alternate background color. |
199 | */ | 209 | */ |
200 | bool isAlternate(); | 210 | bool isAlternate(); |
201 | /** | 211 | /** |
202 | * @note: Reimplemented for internal purposes - the API is not affected | 212 | * @note: Reimplemented for internal purposes - the API is not affected |
203 | * | 213 | * |
204 | */ | 214 | */ |
205 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 215 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
206 | /** | 216 | /** |
207 | * Perform object initialization. | 217 | * Perform object initialization. |
208 | */ | 218 | */ |
209 | void init(); | 219 | void init(); |
210 | /** | 220 | /** |
211 | * create a list view item as child of this object | 221 | * create a list view item as child of this object |
212 | * @returns the new object | 222 | * @returns the new object |
213 | */ | 223 | */ |
214 | virtual OListViewItem* childFactory(); | 224 | virtual OListViewItem* childFactory(); |
215 | #ifndef QT_NO_DATASTREAM | 225 | #ifndef QT_NO_DATASTREAM |
216 | /** | 226 | /** |
217 | * serialize this object to or from a @ref QDataStream | 227 | * serialize this object to or from a @ref QDataStream |
218 | * @param s the stream used to serialize this object. | 228 | * @param s the stream used to serialize this object. |
219 | */ | 229 | */ |
220 | virtual void serializeTo( QDataStream& s ) const; | 230 | virtual void serializeTo( QDataStream& s ) const; |
221 | 231 | ||
222 | /** | 232 | /** |
223 | * serialize this object to or from a @ref QDataStream | 233 | * serialize this object to or from a @ref QDataStream |
224 | * @param s the stream used to serialize this object. | 234 | * @param s the stream used to serialize this object. |
225 | */ | 235 | */ |
226 | virtual void serializeFrom( QDataStream& s ); | 236 | virtual void serializeFrom( QDataStream& s ); |
227 | #endif | 237 | #endif |
228 | 238 | ||
229 | /** | 239 | /** |
230 | * expand the the item | 240 | * expand the the item |
231 | */ | 241 | */ |
232 | virtual void expand(){}; | 242 | virtual void expand(){}; |
233 | 243 | ||
234 | private: | 244 | private: |
235 | bool m_known; | 245 | bool m_known; |
236 | bool m_odd; | 246 | bool m_odd; |
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 | /** |
281 | * Add a number of @a columns to the listview. | 336 | * Add a number of @a columns to the listview. |
282 | */ | 337 | */ |
283 | virtual void addColumns( const QStringList& columns ); | 338 | virtual void addColumns( const QStringList& columns ); |
284 | /** | 339 | /** |
285 | * @returns the column index matching to @a text or -1 if not found. | 340 | * @returns the column index matching to @a text or -1 if not found. |
286 | */ | 341 | */ |
287 | virtual int findColumn( const QString& text ) const; | 342 | virtual int findColumn( const QString& text ) const; |
288 | /** | 343 | /** |
289 | * @returns the first item which has a @a text in column @a column. | 344 | * @returns the first item which has a @a text in column @a column. |
290 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 345 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
291 | * <li>set it to 0 to search only among direct childs, | 346 | * <li>set it to 0 to search only among direct childs, |
292 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 347 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
293 | * <li>set it to -1 for maximum recursion. | 348 | * <li>set it to -1 for maximum recursion. |
294 | * </ul> | 349 | * </ul> |
295 | * @sa ONamedListViewItem::find() | 350 | * @sa ONamedListViewItem::find() |
296 | */ | 351 | */ |
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(); |
330 | /** | 385 | /** |
331 | * Sets the text in column @a column to @a text. | 386 | * Sets the text in column @a column to @a text. |
332 | * This method differs from @ref QListViewItem::setText() in that it | 387 | * This method differs from @ref QListViewItem::setText() in that it |
333 | * accepts a string as column indicator instead of an int. | 388 | * accepts a string as column indicator instead of an int. |
334 | */ | 389 | */ |
335 | virtual void setText( const QString& column, const QString& text ); | 390 | virtual void setText( const QString& column, const QString& text ); |
336 | /** | 391 | /** |
337 | * Sets a number of @a texts for this item. | 392 | * Sets a number of @a texts for this item. |
338 | */ | 393 | */ |
339 | virtual void setText( const QStringList& texts ); | 394 | virtual void setText( const QStringList& texts ); |
340 | /** | 395 | /** |
341 | * @returns the first child which has a @a text in column @a column. | 396 | * @returns the first child which has a @a text in column @a column. |
342 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 397 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
343 | * <li>set it to 0 to search only among direct childs, | 398 | * <li>set it to 0 to search only among direct childs, |
344 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 399 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
345 | * <li>set it to -1 for maximum recursion. | 400 | * <li>set it to -1 for maximum recursion. |
346 | * </ul> | 401 | * </ul> |
347 | * @sa ONamedListView::find() | 402 | * @sa ONamedListView::find() |
348 | */ | 403 | */ |
349 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 404 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
350 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 405 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
351 | }; | 406 | }; |
352 | 407 | ||
353 | 408 | ||
354 | #endif // OLISTVIEW_H | 409 | #endif // OLISTVIEW_H |