summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/olistview.cpp6
-rw-r--r--libopie2/opieui/olistview.h11
2 files changed, 17 insertions, 0 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index 8f290d3..ec503dd 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -1,607 +1,613 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* QT */ 31/* QT */
32 32
33#include <qcolor.h> 33#include <qcolor.h>
34#include <qheader.h> 34#include <qheader.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qpixmap.h> 36#include <qpixmap.h>
37 37
38/* OPIE */ 38/* OPIE */
39 39
40#include <opie2/olistview.h> 40#include <opie2/olistview.h>
41 41
42/*====================================================================================== 42/*======================================================================================
43 * OListView 43 * OListView
44 *======================================================================================*/ 44 *======================================================================================*/
45 45
46OListView::OListView( QWidget *parent, const char *name ) 46OListView::OListView( QWidget *parent, const char *name )
47 :QListView( parent, name ) 47 :QListView( parent, name )
48{ 48{
49 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 49 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
50 50
51 m_alternateBackground = QColor( 238, 246, 255 ); 51 m_alternateBackground = QColor( 238, 246, 255 );
52 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 52 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
53 m_fullWidth = true; 53 m_fullWidth = true;
54 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
54} 55}
55 56
56OListView::~OListView() 57OListView::~OListView()
57{ 58{
58} 59}
59 60
60void OListView::setFullWidth( bool fullWidth ) 61void OListView::setFullWidth( bool fullWidth )
61{ 62{
62 m_fullWidth = m_fullWidth; 63 m_fullWidth = m_fullWidth;
63 #if QT_VERSION > 290 64 #if QT_VERSION > 290
64 header()->setStretchEnabled( fullWidth, columns()-1 ); 65 header()->setStretchEnabled( fullWidth, columns()-1 );
65 #endif 66 #endif
66} 67}
67 68
68bool OListView::fullWidth() const 69bool OListView::fullWidth() const
69{ 70{
70 return m_fullWidth; 71 return m_fullWidth;
71} 72}
72 73
73int OListView::addColumn( const QString& label, int width ) 74int OListView::addColumn( const QString& label, int width )
74{ 75{
75 int result = QListView::addColumn( label, width ); 76 int result = QListView::addColumn( label, width );
76 #if QT_VERSION > 290 77 #if QT_VERSION > 290
77 if (m_fullWidth) { 78 if (m_fullWidth) {
78 header()->setStretchEnabled( false, columns()-2 ); 79 header()->setStretchEnabled( false, columns()-2 );
79 header()->setStretchEnabled( true, columns()-1 ); 80 header()->setStretchEnabled( true, columns()-1 );
80 } 81 }
81 #endif 82 #endif
82 return result; 83 return result;
83} 84}
84 85
85int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) 86int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
86{ 87{
87 int result = QListView::addColumn( iconset, label, width ); 88 int result = QListView::addColumn( iconset, label, width );
88 #if QT_VERSION > 290 89 #if QT_VERSION > 290
89 if (m_fullWidth) { 90 if (m_fullWidth) {
90 header()->setStretchEnabled( false, columns()-2 ); 91 header()->setStretchEnabled( false, columns()-2 );
91 header()->setStretchEnabled( true, columns()-1 ); 92 header()->setStretchEnabled( true, columns()-1 );
92 } 93 }
93 #endif 94 #endif
94 return result; 95 return result;
95} 96}
96 97
97void OListView::removeColumn( int index ) 98void OListView::removeColumn( int index )
98{ 99{
99 QListView::removeColumn(index); 100 QListView::removeColumn(index);
100 #if QT_VERSION > 290 101 #if QT_VERSION > 290
101 if ( m_fullWidth && index == columns() ) 102 if ( m_fullWidth && index == columns() )
102 { 103 {
103 header()->setStretchEnabled( true, columns()-1 ); 104 header()->setStretchEnabled( true, columns()-1 );
104 } 105 }
105 #endif 106 #endif
106} 107}
107 108
108const QColor& OListView::alternateBackground() const 109const QColor& OListView::alternateBackground() const
109{ 110{
110 return m_alternateBackground; 111 return m_alternateBackground;
111} 112}
112 113
113void OListView::setAlternateBackground( const QColor &c ) 114void OListView::setAlternateBackground( const QColor &c )
114{ 115{
115 m_alternateBackground = c; 116 m_alternateBackground = c;
116 repaint(); 117 repaint();
117} 118}
118 119
119const QPen& OListView::columnSeparator() const 120const QPen& OListView::columnSeparator() const
120{ 121{
121 return m_columnSeparator; 122 return m_columnSeparator;
122} 123}
123 124
124void OListView::setColumnSeparator( const QPen& p ) 125void OListView::setColumnSeparator( const QPen& p )
125{ 126{
126 m_columnSeparator = p; 127 m_columnSeparator = p;
127 repaint(); 128 repaint();
128} 129}
129 130
131void OListView::expand(QListViewItem *item)
132{
133 ((OListViewItem*)item)->expand();
134}
135
130OListViewItem* OListView::childFactory() 136OListViewItem* OListView::childFactory()
131{ 137{
132 return new OListViewItem( this ); 138 return new OListViewItem( this );
133} 139}
134 140
135#ifndef QT_NO_DATASTREAM 141#ifndef QT_NO_DATASTREAM
136void OListView::serializeTo( QDataStream& s ) const 142void OListView::serializeTo( QDataStream& s ) const
137{ 143{
138 #warning Caution... the binary format is still under construction... 144 #warning Caution... the binary format is still under construction...
139 qDebug( "storing OListView..." ); 145 qDebug( "storing OListView..." );
140 146
141 // store number of columns and the labels 147 // store number of columns and the labels
142 s << columns(); 148 s << columns();
143 for ( int i = 0; i < columns(); ++i ) 149 for ( int i = 0; i < columns(); ++i )
144 s << columnText( i ); 150 s << columnText( i );
145 151
146 // calculate the number of top-level items to serialize 152 // calculate the number of top-level items to serialize
147 int items = 0; 153 int items = 0;
148 QListViewItem* item = firstChild(); 154 QListViewItem* item = firstChild();
149 while ( item ) 155 while ( item )
150 { 156 {
151 item = item->nextSibling(); 157 item = item->nextSibling();
152 items++; 158 items++;
153 } 159 }
154 160
155 // store number of items and the items itself 161 // store number of items and the items itself
156 s << items; 162 s << items;
157 item = firstChild(); 163 item = firstChild();
158 for ( int i = 0; i < items; ++i ) 164 for ( int i = 0; i < items; ++i )
159 { 165 {
160 s << *static_cast<OListViewItem*>( item ); 166 s << *static_cast<OListViewItem*>( item );
161 item = item->nextSibling(); 167 item = item->nextSibling();
162 } 168 }
163 169
164 qDebug( "OListview stored." ); 170 qDebug( "OListview stored." );
165} 171}
166 172
167void OListView::serializeFrom( QDataStream& s ) 173void OListView::serializeFrom( QDataStream& s )
168{ 174{
169 #warning Caution... the binary format is still under construction... 175 #warning Caution... the binary format is still under construction...
170 qDebug( "loading OListView..." ); 176 qDebug( "loading OListView..." );
171 177
172 int cols; 178 int cols;
173 s >> cols; 179 s >> cols;
174 qDebug( "read number of columns = %d", cols ); 180 qDebug( "read number of columns = %d", cols );
175 181
176 while ( columns() < cols ) addColumn( QString::null ); 182 while ( columns() < cols ) addColumn( QString::null );
177 183
178 for ( int i = 0; i < cols; ++i ) 184 for ( int i = 0; i < cols; ++i )
179 { 185 {
180 QString coltext; 186 QString coltext;
181 s >> coltext; 187 s >> coltext;
182 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 188 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
183 setColumnText( i, coltext ); 189 setColumnText( i, coltext );
184 } 190 }
185 191
186 int items; 192 int items;
187 s >> items; 193 s >> items;
188 qDebug( "read number of items = %d", items ); 194 qDebug( "read number of items = %d", items );
189 195
190 for ( int i = 0; i < items; ++i ) 196 for ( int i = 0; i < items; ++i )
191 { 197 {
192 OListViewItem* item = childFactory(); 198 OListViewItem* item = childFactory();
193 s >> *item; 199 s >> *item;
194 } 200 }
195 201
196 qDebug( "OListView loaded." ); 202 qDebug( "OListView loaded." );
197 203
198} 204}
199 205
200QDataStream& operator<<( QDataStream& s, const OListView& lv ) 206QDataStream& operator<<( QDataStream& s, const OListView& lv )
201{ 207{
202 lv.serializeTo( s ); 208 lv.serializeTo( s );
203} 209}
204 210
205QDataStream& operator>>( QDataStream& s, OListView& lv ) 211QDataStream& operator>>( QDataStream& s, OListView& lv )
206{ 212{
207 lv.serializeFrom( s ); 213 lv.serializeFrom( s );
208} 214}
209#endif // QT_NO_DATASTREAM 215#endif // QT_NO_DATASTREAM
210 216
211/*====================================================================================== 217/*======================================================================================
212 * OListViewItem 218 * OListViewItem
213 *======================================================================================*/ 219 *======================================================================================*/
214 220
215OListViewItem::OListViewItem(QListView *parent) 221OListViewItem::OListViewItem(QListView *parent)
216 : QListViewItem(parent) 222 : QListViewItem(parent)
217{ 223{
218 init(); 224 init();
219} 225}
220 226
221 227
222OListViewItem::OListViewItem(QListViewItem *parent) 228OListViewItem::OListViewItem(QListViewItem *parent)
223 : QListViewItem(parent) 229 : QListViewItem(parent)
224{ 230{
225 init(); 231 init();
226} 232}
227 233
228 234
229OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) 235OListViewItem::OListViewItem(QListView *parent, QListViewItem *after)
230 : QListViewItem(parent, after) 236 : QListViewItem(parent, after)
231{ 237{
232 init(); 238 init();
233} 239}
234 240
235 241
236OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) 242OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after)
237 : QListViewItem(parent, after) 243 : QListViewItem(parent, after)
238{ 244{
239 init(); 245 init();
240} 246}
241 247
242 248
243OListViewItem::OListViewItem(QListView *parent, 249OListViewItem::OListViewItem(QListView *parent,
244 QString label1, QString label2, QString label3, QString label4, 250 QString label1, QString label2, QString label3, QString label4,
245 QString label5, QString label6, QString label7, QString label8) 251 QString label5, QString label6, QString label7, QString label8)
246 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 252 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
247{ 253{
248 init(); 254 init();
249} 255}
250 256
251 257
252OListViewItem::OListViewItem(QListViewItem *parent, 258OListViewItem::OListViewItem(QListViewItem *parent,
253 QString label1, QString label2, QString label3, QString label4, 259 QString label1, QString label2, QString label3, QString label4,
254 QString label5, QString label6, QString label7, QString label8) 260 QString label5, QString label6, QString label7, QString label8)
255 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 261 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
256{ 262{
257 init(); 263 init();
258} 264}
259 265
260 266
261OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, 267OListViewItem::OListViewItem(QListView *parent, QListViewItem *after,
262 QString label1, QString label2, QString label3, QString label4, 268 QString label1, QString label2, QString label3, QString label4,
263 QString label5, QString label6, QString label7, QString label8) 269 QString label5, QString label6, QString label7, QString label8)
264 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 270 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
265{ 271{
266 init(); 272 init();
267} 273}
268 274
269 275
270OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, 276OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after,
271 QString label1, QString label2, QString label3, QString label4, 277 QString label1, QString label2, QString label3, QString label4,
272 QString label5, QString label6, QString label7, QString label8) 278 QString label5, QString label6, QString label7, QString label8)
273 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 279 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
274{ 280{
275 init(); 281 init();
276} 282}
277 283
278 284
279OListViewItem::~OListViewItem() 285OListViewItem::~OListViewItem()
280{ 286{
281} 287}
282 288
283 289
284void OListViewItem::init() 290void OListViewItem::init()
285{ 291{
286 m_known = false; 292 m_known = false;
287} 293}
288 294
289 295
290const QColor &OListViewItem::backgroundColor() 296const QColor &OListViewItem::backgroundColor()
291{ 297{
292 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 298 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
293 listView()->viewport()->colorGroup().base(); 299 listView()->viewport()->colorGroup().base();
294} 300}
295 301
296 302
297bool OListViewItem::isAlternate() 303bool OListViewItem::isAlternate()
298{ 304{
299 OListView *lv = static_cast<OListView*>( listView() ); 305 OListView *lv = static_cast<OListView*>( listView() );
300 306
301 // check if the item above is an OListViewItem 307 // check if the item above is an OListViewItem
302 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); 308 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() );
303 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ 309 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/
304 310
305 // check if we have a valid alternate background color 311 // check if we have a valid alternate background color
306 if (!(lv && lv->alternateBackground().isValid())) return false; 312 if (!(lv && lv->alternateBackground().isValid())) return false;
307 313
308 m_known = above ? above->m_known : true; 314 m_known = above ? above->m_known : true;
309 if (m_known) 315 if (m_known)
310 { 316 {
311 m_odd = above ? !above->m_odd : false; 317 m_odd = above ? !above->m_odd : false;
312 } 318 }
313 else 319 else
314 { 320 {
315 OListViewItem *item; 321 OListViewItem *item;
316 bool previous = true; 322 bool previous = true;
317 if (parent()) 323 if (parent())
318 { 324 {
319 item = static_cast<OListViewItem *>(parent()); 325 item = static_cast<OListViewItem *>(parent());
320 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; 326 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
321 item = static_cast<OListViewItem *>(parent()->firstChild()); 327 item = static_cast<OListViewItem *>(parent()->firstChild());
322 /* if ( !item.inherits( "OListViewItem" ) item = 0; */ 328 /* if ( !item.inherits( "OListViewItem" ) item = 0; */
323 } 329 }
324 else 330 else
325 { 331 {
326 item = static_cast<OListViewItem *>(lv->firstChild()); 332 item = static_cast<OListViewItem *>(lv->firstChild());
327 } 333 }
328 334
329 while(item) 335 while(item)
330 { 336 {
331 item->m_odd = previous = !previous; 337 item->m_odd = previous = !previous;
332 item->m_known = true; 338 item->m_known = true;
333 item = static_cast<OListViewItem *>(item->nextSibling()); 339 item = static_cast<OListViewItem *>(item->nextSibling());
334 /* if (!item.inherits( "OListViewItem" ) ) break; */ 340 /* if (!item.inherits( "OListViewItem" ) ) break; */
335 } 341 }
336 } 342 }
337 return m_odd; 343 return m_odd;
338} 344}
339 345
340 346
341void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 347void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
342{ 348{
343 QColorGroup _cg = cg; 349 QColorGroup _cg = cg;
344 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 350 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
345 if (pm && !pm->isNull()) 351 if (pm && !pm->isNull())
346 { 352 {
347 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 353 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
348 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 354 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
349 } 355 }
350 else if ( isAlternate() ) 356 else if ( isAlternate() )
351 { 357 {
352 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 358 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
353 } 359 }
354 QListViewItem::paintCell( p, _cg, column, width, alignment ); 360 QListViewItem::paintCell( p, _cg, column, width, alignment );
355 361
356 //FIXME: Use styling here! 362 //FIXME: Use styling here!
357 363
358 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 364 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
359 p->setPen( pen ); 365 p->setPen( pen );
360 p->drawLine( width-1, 0, width-1, height() ); 366 p->drawLine( width-1, 0, width-1, height() );
361} 367}
362 368
363 369
364OListViewItem* OListViewItem::childFactory() 370OListViewItem* OListViewItem::childFactory()
365{ 371{
366 return new OListViewItem( this ); 372 return new OListViewItem( this );
367} 373}
368 374
369 375
370#ifndef QT_NO_DATASTREAM 376#ifndef QT_NO_DATASTREAM
371void OListViewItem::serializeTo( QDataStream& s ) const 377void OListViewItem::serializeTo( QDataStream& s ) const
372{ 378{
373 #warning Caution... the binary format is still under construction... 379 #warning Caution... the binary format is still under construction...
374 qDebug( "storing OListViewItem..." ); 380 qDebug( "storing OListViewItem..." );
375 381
376 // store item text 382 // store item text
377 for ( int i = 0; i < listView()->columns(); ++i ) 383 for ( int i = 0; i < listView()->columns(); ++i )
378 { 384 {
379 s << text( i ); 385 s << text( i );
380 } 386 }
381 387
382 // calculate the number of children to serialize 388 // calculate the number of children to serialize
383 int items = 0; 389 int items = 0;
384 QListViewItem* item = firstChild(); 390 QListViewItem* item = firstChild();
385 while ( item ) 391 while ( item )
386 { 392 {
387 item = item->nextSibling(); 393 item = item->nextSibling();
388 items++; 394 items++;
389 } 395 }
390 396
391 // store number of items and the items itself 397 // store number of items and the items itself
392 s << items; 398 s << items;
393 item = firstChild(); 399 item = firstChild();
394 for ( int i = 0; i < items; ++i ) 400 for ( int i = 0; i < items; ++i )
395 { 401 {
396 s << *static_cast<OListViewItem*>( item ); 402 s << *static_cast<OListViewItem*>( item );
397 item = item->nextSibling(); 403 item = item->nextSibling();
398 } 404 }
399 405
400 qDebug( "OListviewItem stored." ); 406 qDebug( "OListviewItem stored." );
401} 407}
402 408
403 409
404void OListViewItem::serializeFrom( QDataStream& s ) 410void OListViewItem::serializeFrom( QDataStream& s )
405{ 411{
406 #warning Caution... the binary format is still under construction... 412 #warning Caution... the binary format is still under construction...
407 qDebug( "loading OListViewItem..." ); 413 qDebug( "loading OListViewItem..." );
408 414
409 for ( int i = 0; i < listView()->columns(); ++i ) 415 for ( int i = 0; i < listView()->columns(); ++i )
410 { 416 {
411 QString coltext; 417 QString coltext;
412 s >> coltext; 418 s >> coltext;
413 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 419 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
414 setText( i, coltext ); 420 setText( i, coltext );
415 } 421 }
416 422
417 int items; 423 int items;
418 s >> items; 424 s >> items;
419 qDebug( "read number of items = %d", items ); 425 qDebug( "read number of items = %d", items );
420 426
421 for ( int i = 0; i < items; ++i ) 427 for ( int i = 0; i < items; ++i )
422 { 428 {
423 OListViewItem* item = childFactory(); 429 OListViewItem* item = childFactory();
424 s >> (*item); 430 s >> (*item);
425 } 431 }
426 432
427 qDebug( "OListViewItem loaded." ); 433 qDebug( "OListViewItem loaded." );
428} 434}
429 435
430 436
431QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) 437QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
432{ 438{
433 lvi.serializeTo( s ); 439 lvi.serializeTo( s );
434} 440}
435 441
436 442
437QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) 443QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
438{ 444{
439 lvi.serializeFrom( s ); 445 lvi.serializeFrom( s );
440} 446}
441#endif // QT_NO_DATASTREAM 447#endif // QT_NO_DATASTREAM
442 448
443 449
444/*====================================================================================== 450/*======================================================================================
445 * ONamedListView 451 * ONamedListView
446 *======================================================================================*/ 452 *======================================================================================*/
447 453
448ONamedListView::ONamedListView( QWidget *parent, const char *name ) 454ONamedListView::ONamedListView( QWidget *parent, const char *name )
449 :OListView( parent, name ) 455 :OListView( parent, name )
450{ 456{
451} 457}
452 458
453 459
454ONamedListView::~ONamedListView() 460ONamedListView::~ONamedListView()
455{ 461{
456} 462}
457 463
458 464
459void ONamedListView::addColumns( const QStringList& columns ) 465void ONamedListView::addColumns( const QStringList& columns )
460{ 466{
461 for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) 467 for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it )
462 { 468 {
463 qDebug( "adding column %s", (const char*) *it ); 469 qDebug( "adding column %s", (const char*) *it );
464 addColumn( *it ); 470 addColumn( *it );
465 } 471 }
466} 472}
467 473
468 474
469int ONamedListView::findColumn( const QString& text ) const 475int ONamedListView::findColumn( const QString& text ) const
470{ 476{
471 //FIXME: If used excessively, this will slow down performance of updates 477 //FIXME: If used excessively, this will slow down performance of updates
472 //FIXME: because of the linear search over all column texts. 478 //FIXME: because of the linear search over all column texts.
473 //FIXME: I will optimize later by using a hash map. 479 //FIXME: I will optimize later by using a hash map.
474 for ( int i = 0; i < columns(); ++i ) 480 for ( int i = 0; i < columns(); ++i )
475 if ( columnText( i ) == text ) 481 if ( columnText( i ) == text )
476 return i; 482 return i;
477 return -1; 483 return -1;
478} 484}
479 485
480 486
481ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const 487ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const
482{ 488{
483 return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 489 return find( (ONamedListViewItem*) firstChild(), column, text, recurse );
484} 490}
485 491
486 492
487ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const 493ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const
488{ 494{
489 ONamedListViewItem* result; 495 ONamedListViewItem* result;
490 while ( item && item->text( column ) != text ) 496 while ( item && item->text( column ) != text )
491 { 497 {
492 qDebug( "checked %s", (const char*) item->text( column ) ); 498 qDebug( "checked %s", (const char*) item->text( column ) );
493 499
494 if ( recurse < 0 || recurse > 0 ) 500 if ( recurse < 0 || recurse > 0 )
495 { 501 {
496 qDebug( "recursion is %d - recursing into...", recurse ); 502 qDebug( "recursion is %d - recursing into...", recurse );
497 result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); 503 result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 );
498 if ( result ) return result; 504 if ( result ) return result;
499 } 505 }
500 506
501 507
502 item = (ONamedListViewItem*) item->itemBelow(); 508 item = (ONamedListViewItem*) item->itemBelow();
503 } 509 }
504 if ( item && item->text( column ) == text ) 510 if ( item && item->text( column ) == text )
505 return item; 511 return item;
506 else 512 else
507 return 0; 513 return 0;
508} 514}
509 515
510 516
511ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const 517ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const
512{ 518{
513 int col = findColumn( column ); 519 int col = findColumn( column );
514 if ( col != -1 ) 520 if ( col != -1 )
515 return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 521 return find( (ONamedListViewItem*) firstChild(), col, text, recurse );
516 else 522 else
517 return 0; 523 return 0;
518} 524}
519 525
520 526
521ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const 527ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const
522{ 528{
523 int col = findColumn( column ); 529 int col = findColumn( column );
524 if ( col != -1 ) 530 if ( col != -1 )
525 return find( item, col, text, recurse ); 531 return find( item, col, text, recurse );
526 else 532 else
527 return 0; 533 return 0;
528} 534}
529 535
530 536
531/*====================================================================================== 537/*======================================================================================
532 * ONamedListViewItem 538 * ONamedListViewItem
533 *======================================================================================*/ 539 *======================================================================================*/
534 540
535ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) 541ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts )
536 :OListViewItem( parent ) 542 :OListViewItem( parent )
537{ 543{
538 setText( texts ); 544 setText( texts );
539} 545}
540 546
541 547
542ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) 548ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts )
543 :OListViewItem( parent ) 549 :OListViewItem( parent )
544{ 550{
545 setText( texts ); 551 setText( texts );
546} 552}
547 553
548 554
549ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) 555ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts )
550 :OListViewItem( parent, after ) 556 :OListViewItem( parent, after )
551{ 557{
552 setText( texts ); 558 setText( texts );
553} 559}
554 560
555 561
556ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) 562ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts )
557 :OListViewItem( parent, after ) 563 :OListViewItem( parent, after )
558{ 564{
559 setText( texts ); 565 setText( texts );
560} 566}
561 567
562 568
563ONamedListViewItem::~ONamedListViewItem() 569ONamedListViewItem::~ONamedListViewItem()
564{ 570{
565} 571}
566 572
567 573
568void ONamedListViewItem::setText( const QStringList& texts ) 574void ONamedListViewItem::setText( const QStringList& texts )
569{ 575{
570 int col = 0; 576 int col = 0;
571 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) 577 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it )
572 { 578 {
573 qDebug( "setting column %d = text %s", col, (const char*) *it ); 579 qDebug( "setting column %d = text %s", col, (const char*) *it );
574 OListViewItem::setText( col++, *it ); 580 OListViewItem::setText( col++, *it );
575 } 581 }
576 582
577} 583}
578 584
579 585
580void ONamedListViewItem::setText( const QString& column, const QString& text ) 586void ONamedListViewItem::setText( const QString& column, const QString& text )
581{ 587{
582 //FIXME: If used excessively, this will slow down performance of updates 588 //FIXME: If used excessively, this will slow down performance of updates
583 //FIXME: because of the linear search over all column texts. 589 //FIXME: because of the linear search over all column texts.
584 //FIXME: I will optimize later by using a hash map. 590 //FIXME: I will optimize later by using a hash map.
585 int col = ( (ONamedListView*) listView() )->findColumn( column ); 591 int col = ( (ONamedListView*) listView() )->findColumn( column );
586 if ( col != -1 ) 592 if ( col != -1 )
587 OListViewItem::setText( col, text ); 593 OListViewItem::setText( col, text );
588 else 594 else
589 qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); 595 qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column );
590} 596}
591 597
592 598
593ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const 599ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const
594{ 600{
595 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 601 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse );
596} 602}
597 603
598 604
599ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const 605ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const
600{ 606{
601 int col = ( (ONamedListView*) listView() )->findColumn( column ); 607 int col = ( (ONamedListView*) listView() )->findColumn( column );
602 if ( col != -1 ) 608 if ( col != -1 )
603 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 609 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse );
604 else 610 else
605 return 0; 611 return 0;
606} 612}
607 613
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h
index 109e309..a00b43a 100644
--- a/libopie2/opieui/olistview.h
+++ b/libopie2/opieui/olistview.h
@@ -1,343 +1,354 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OLISTVIEW_H 31#ifndef OLISTVIEW_H
32#define OLISTVIEW_H 32#define OLISTVIEW_H
33 33
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <qpen.h> 36#include <qpen.h>
37#include <qdatastream.h> 37#include <qdatastream.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39 39
40class OListViewItem; 40class OListViewItem;
41 41
42 42
43/*====================================================================================== 43/*======================================================================================
44 * OListView 44 * OListView
45 *======================================================================================*/ 45 *======================================================================================*/
46 46
47/** 47/**
48 * @brief A list/tree widget. 48 * @brief A list/tree widget.
49 * 49 *
50 * A @ref QListView variant featuring visual and functional enhancements 50 * A @ref QListView variant featuring visual and functional enhancements
51 * like an alternate background for odd rows, an autostretch mode 51 * like an alternate background for odd rows, an autostretch mode
52 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. 52 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
53 * 53 *
54 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 54 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
55 */ 55 */
56class OListView: public QListView 56class OListView: public QListView
57{ 57{
58 public: 58 public:
59 /** 59 /**
60 * Constructor. 60 * Constructor.
61 * 61 *
62 * The parameters @a parent and @a name are handled by 62 * The parameters @a parent and @a name are handled by
63 * @ref QListView, as usual. 63 * @ref QListView, as usual.
64 */ 64 */
65 OListView( QWidget* parent = 0, const char* name = 0 ); 65 OListView( QWidget* parent = 0, const char* name = 0 );
66 /** 66 /**
67 * Destructor. 67 * Destructor.
68 */ 68 */
69 virtual ~OListView(); 69 virtual ~OListView();
70 /** 70 /**
71 * Let the last column fit exactly all the available width. 71 * Let the last column fit exactly all the available width.
72 */ 72 */
73 void setFullWidth( bool fullWidth ); 73 void setFullWidth( bool fullWidth );
74 /** 74 /**
75 * Returns whether the last column is set to fit the available width. 75 * Returns whether the last column is set to fit the available width.
76 */ 76 */
77 bool fullWidth() const; 77 bool fullWidth() const;
78 /** 78 /**
79 * Reimplemented for full width support 79 * Reimplemented for full width support
80 */ 80 */
81 virtual int addColumn( const QString& label, int width = -1 ); 81 virtual int addColumn( const QString& label, int width = -1 );
82 /** 82 /**
83 * Reimplemented for full width support 83 * Reimplemented for full width support
84 */ 84 */
85 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); 85 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
86 /** 86 /**
87 * Reimplemented for full width support 87 * Reimplemented for full width support
88 */ 88 */
89 virtual void removeColumn(int index); 89 virtual void removeColumn(int index);
90 /** 90 /**
91 * Set the alternate background background @a color. 91 * Set the alternate background background @a color.
92 * Set to an invalid color to disable alternate colors. 92 * Set to an invalid color to disable alternate colors.
93 * This only has an effect if the items are OListViewItems 93 * This only has an effect if the items are OListViewItems
94 */ 94 */
95 void setAlternateBackground( const QColor& color ); 95 void setAlternateBackground( const QColor& color );
96 /** 96 /**
97 * Sets the column separator @a pen. 97 * Sets the column separator @a pen.
98 */ 98 */
99 void setColumnSeparator( const QPen& pen ); 99 void setColumnSeparator( const QPen& pen );
100 100
101 /** 101 /**
102 * @returns the alternate background color 102 * @returns the alternate background color
103 */ 103 */
104 const QColor& alternateBackground() const; 104 const QColor& alternateBackground() const;
105 /** 105 /**
106 * @return the column separator pen 106 * @return the column separator pen
107 */ 107 */
108 const QPen& columnSeparator() const; 108 const QPen& columnSeparator() const;
109 /** 109 /**
110 * Create a list view item as child of this object 110 * Create a list view item as child of this object
111 * @returns the new object 111 * @returns the new object
112 */ 112 */
113 virtual OListViewItem* childFactory(); 113 virtual OListViewItem* childFactory();
114#ifndef QT_NO_DATASTREAM 114#ifndef QT_NO_DATASTREAM
115 /** 115 /**
116 * Serialize this object to @ref QDataStream @a stream 116 * Serialize this object to @ref QDataStream @a stream
117 */ 117 */
118 virtual void serializeTo( QDataStream& stream ) const; 118 virtual void serializeTo( QDataStream& stream ) const;
119 /** 119 /**
120 * Serialize this object from a @ref QDataStream @a stream 120 * Serialize this object from a @ref QDataStream @a stream
121 */ 121 */
122 virtual void serializeFrom( QDataStream& s ); 122 virtual void serializeFrom( QDataStream& s );
123#endif 123#endif
124 124
125protected slots:
126 /**
127 * expand the current OListViewItem
128 */
129 void expand(QListViewItem*);
130
125 private: 131 private:
126 QColor m_alternateBackground; 132 QColor m_alternateBackground;
127 bool m_fullWidth; 133 bool m_fullWidth;
128 QPen m_columnSeparator; 134 QPen m_columnSeparator;
129}; 135};
130 136
131#ifndef QT_NO_DATASTREAM 137#ifndef QT_NO_DATASTREAM
132/** 138/**
133 * @relates OListView 139 * @relates OListView
134 * Writes @a listview to the @a stream and returns a reference to the stream. 140 * Writes @a listview to the @a stream and returns a reference to the stream.
135 */ 141 */
136QDataStream& operator<<( QDataStream& stream, const OListView& listview ); 142QDataStream& operator<<( QDataStream& stream, const OListView& listview );
137/** 143/**
138 * @relates OListView 144 * @relates OListView
139 * Reads @a listview from the @a stream and returns a reference to the stream. 145 * Reads @a listview from the @a stream and returns a reference to the stream.
140 */ 146 */
141QDataStream& operator>>( QDataStream& stream, OListView& listview ); 147QDataStream& operator>>( QDataStream& stream, OListView& listview );
142#endif // QT_NO_DATASTREAM 148#endif // QT_NO_DATASTREAM
143 149
144/*====================================================================================== 150/*======================================================================================
145 * OListViewItem 151 * OListViewItem
146 *======================================================================================*/ 152 *======================================================================================*/
147 153
148class OListViewItem: public QListViewItem 154class OListViewItem: public QListViewItem
149{ 155{
150 public: 156 public:
151 /** 157 /**
152 * Constructors. 158 * Constructors.
153 */ 159 */
154 OListViewItem( QListView * parent ); 160 OListViewItem( QListView * parent );
155 OListViewItem( QListViewItem * parent ); 161 OListViewItem( QListViewItem * parent );
156 OListViewItem( QListView * parent, QListViewItem * after ); 162 OListViewItem( QListView * parent, QListViewItem * after );
157 OListViewItem( QListViewItem * parent, QListViewItem * after ); 163 OListViewItem( QListViewItem * parent, QListViewItem * after );
158 164
159 OListViewItem( QListView * parent, 165 OListViewItem( QListView * parent,
160 QString, QString = QString::null, 166 QString, QString = QString::null,
161 QString = QString::null, QString = QString::null, 167 QString = QString::null, QString = QString::null,
162 QString = QString::null, QString = QString::null, 168 QString = QString::null, QString = QString::null,
163 QString = QString::null, QString = QString::null ); 169 QString = QString::null, QString = QString::null );
164 170
165 OListViewItem( QListViewItem * parent, 171 OListViewItem( QListViewItem * parent,
166 QString, QString = QString::null, 172 QString, QString = QString::null,
167 QString = QString::null, QString = QString::null, 173 QString = QString::null, QString = QString::null,
168 QString = QString::null, QString = QString::null, 174 QString = QString::null, QString = QString::null,
169 QString = QString::null, QString = QString::null ); 175 QString = QString::null, QString = QString::null );
170 176
171 OListViewItem( QListView * parent, QListViewItem * after, 177 OListViewItem( QListView * parent, QListViewItem * after,
172 QString, QString = QString::null, 178 QString, QString = QString::null,
173 QString = QString::null, QString = QString::null, 179 QString = QString::null, QString = QString::null,
174 QString = QString::null, QString = QString::null, 180 QString = QString::null, QString = QString::null,
175 QString = QString::null, QString = QString::null ); 181 QString = QString::null, QString = QString::null );
176 182
177 OListViewItem( QListViewItem * parent, QListViewItem * after, 183 OListViewItem( QListViewItem * parent, QListViewItem * after,
178 QString, QString = QString::null, 184 QString, QString = QString::null,
179 QString = QString::null, QString = QString::null, 185 QString = QString::null, QString = QString::null,
180 QString = QString::null, QString = QString::null, 186 QString = QString::null, QString = QString::null,
181 QString = QString::null, QString = QString::null ); 187 QString = QString::null, QString = QString::null );
182 /** 188 /**
183 * Destructor. 189 * Destructor.
184 */ 190 */
185 virtual ~OListViewItem(); 191 virtual ~OListViewItem();
186 /** 192 /**
187 * @returns the background color of the list item. 193 * @returns the background color of the list item.
188 */ 194 */
189 const QColor& backgroundColor(); 195 const QColor& backgroundColor();
190 /** 196 /**
191 * @returns true, if the item is at an odd position and 197 * @returns true, if the item is at an odd position and
192 * thus have to be painted with the alternate background color. 198 * thus have to be painted with the alternate background color.
193 */ 199 */
194 bool isAlternate(); 200 bool isAlternate();
195 /** 201 /**
196 * @note: Reimplemented for internal purposes - the API is not affected 202 * @note: Reimplemented for internal purposes - the API is not affected
197 * 203 *
198 */ 204 */
199 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); 205 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
200 /** 206 /**
201 * Perform object initialization. 207 * Perform object initialization.
202 */ 208 */
203 void init(); 209 void init();
204 /** 210 /**
205 * create a list view item as child of this object 211 * create a list view item as child of this object
206 * @returns the new object 212 * @returns the new object
207 */ 213 */
208 virtual OListViewItem* childFactory(); 214 virtual OListViewItem* childFactory();
209 #ifndef QT_NO_DATASTREAM 215 #ifndef QT_NO_DATASTREAM
210 /** 216 /**
211 * serialize this object to or from a @ref QDataStream 217 * serialize this object to or from a @ref QDataStream
212 * @param s the stream used to serialize this object. 218 * @param s the stream used to serialize this object.
213 */ 219 */
214 virtual void serializeTo( QDataStream& s ) const; 220 virtual void serializeTo( QDataStream& s ) const;
215 221
216 /** 222 /**
217 * serialize this object to or from a @ref QDataStream 223 * serialize this object to or from a @ref QDataStream
218 * @param s the stream used to serialize this object. 224 * @param s the stream used to serialize this object.
219 */ 225 */
220 virtual void serializeFrom( QDataStream& s ); 226 virtual void serializeFrom( QDataStream& s );
221 #endif 227 #endif
222 228
229 /**
230 * expand the the item
231 */
232 virtual void expand(){};
233
223 private: 234 private:
224 bool m_known; 235 bool m_known;
225 bool m_odd; 236 bool m_odd;
226}; 237};
227 238
228#ifndef QT_NO_DATASTREAM 239#ifndef QT_NO_DATASTREAM
229/** 240/**
230 * @relates QListViewItem 241 * @relates QListViewItem
231 * Writes listview @a item and all subitems recursively to @a stream 242 * Writes listview @a item and all subitems recursively to @a stream
232 * and returns a reference to the stream. 243 * and returns a reference to the stream.
233 */ 244 */
234QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); 245QDataStream& operator<<( QDataStream& stream, const OListViewItem& item );
235/** 246/**
236 * @relates QListViewItem 247 * @relates QListViewItem
237 * Reads listview @a item from @a stream and returns a reference to the stream. 248 * Reads listview @a item from @a stream and returns a reference to the stream.
238 */ 249 */
239QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); 250QDataStream& operator>>( QDataStream& stream, OListViewItem& item );
240#endif // QT_NO_DATASTREAM 251#endif // QT_NO_DATASTREAM
241 252
242/*====================================================================================== 253/*======================================================================================
243 * ONamedListView 254 * ONamedListView
244 *======================================================================================*/ 255 *======================================================================================*/
245 256
246class ONamedListViewItem; 257class ONamedListViewItem;
247 258
248/** 259/**
249 * @brief An OListView variant with named columns. 260 * @brief An OListView variant with named columns.
250 * 261 *
251 * This class provides a higher-level interface to an OListView. 262 * This class provides a higher-level interface to an OListView.
252 * 263 *
253 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 264 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
254 */ 265 */
255class ONamedListView: public OListView 266class ONamedListView: public OListView
256{ 267{
257 public: 268 public:
258 /** 269 /**
259 * Constructor. 270 * Constructor.
260 * 271 *
261 * The parameters @a parent and @a name are handled by 272 * The parameters @a parent and @a name are handled by
262 * @ref OListView, as usual. 273 * @ref OListView, as usual.
263 */ 274 */
264 ONamedListView( QWidget* parent = 0, const char* name = 0 ); 275 ONamedListView( QWidget* parent = 0, const char* name = 0 );
265 /** 276 /**
266 * Destructor. 277 * Destructor.
267 */ 278 */
268 virtual ~ONamedListView(); 279 virtual ~ONamedListView();
269 /** 280 /**
270 * Add a number of @a columns to the listview. 281 * Add a number of @a columns to the listview.
271 */ 282 */
272 virtual void addColumns( const QStringList& columns ); 283 virtual void addColumns( const QStringList& columns );
273 /** 284 /**
274 * @returns the column index matching to @a text or -1 if not found. 285 * @returns the column index matching to @a text or -1 if not found.
275 */ 286 */
276 virtual int findColumn( const QString& text ) const; 287 virtual int findColumn( const QString& text ) const;
277 /** 288 /**
278 * @returns the first item which has a @a text in column @a column. 289 * @returns the first item which has a @a text in column @a column.
279 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> 290 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul>
280 * <li>set it to 0 to search only among direct childs, 291 * <li>set it to 0 to search only among direct childs,
281 * <li>set it to 1 to search direct childs and all 1st order subchilds 292 * <li>set it to 1 to search direct childs and all 1st order subchilds
282 * <li>set it to -1 for maximum recursion. 293 * <li>set it to -1 for maximum recursion.
283 * </ul> 294 * </ul>
284 * @sa ONamedListViewItem::find() 295 * @sa ONamedListViewItem::find()
285 */ 296 */
286 virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; 297 virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const;
287 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; 298 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const;
288 299
289 virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; 300 virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const;
290 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; 301 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const;
291}; 302};
292 303
293/*====================================================================================== 304/*======================================================================================
294 * ONamedListViewItem 305 * ONamedListViewItem
295 *======================================================================================*/ 306 *======================================================================================*/
296 307
297/** 308/**
298 * @brief An OListView variant with named columns. 309 * @brief An OListView variant with named columns.
299 * 310 *
300 * This class provides a higher-level interface to an OListViewItem. 311 * This class provides a higher-level interface to an OListViewItem.
301 * 312 *
302 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 313 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
303 */ 314 */
304class ONamedListViewItem: public OListViewItem 315class ONamedListViewItem: public OListViewItem
305{ 316{
306 public: 317 public:
307 /** 318 /**
308 * Constructor. Accepts the same parameters as a @ref OListViewItem, 319 * Constructor. Accepts the same parameters as a @ref OListViewItem,
309 * plus a @ref QStringList which holds an arbitrary number of @a texts. 320 * plus a @ref QStringList which holds an arbitrary number of @a texts.
310 */ 321 */
311 ONamedListViewItem( QListView* parent, const QStringList& texts ); 322 ONamedListViewItem( QListView* parent, const QStringList& texts );
312 ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); 323 ONamedListViewItem( QListViewItem* parent, const QStringList& texts );
313 ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); 324 ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts );
314 ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); 325 ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts );
315 /** 326 /**
316 * Destructor. 327 * Destructor.
317 */ 328 */
318 virtual ~ONamedListViewItem(); 329 virtual ~ONamedListViewItem();
319 /** 330 /**
320 * Sets the text in column @a column to @a text. 331 * Sets the text in column @a column to @a text.
321 * This method differs from @ref QListViewItem::setText() in that it 332 * This method differs from @ref QListViewItem::setText() in that it
322 * accepts a string as column indicator instead of an int. 333 * accepts a string as column indicator instead of an int.
323 */ 334 */
324 virtual void setText( const QString& column, const QString& text ); 335 virtual void setText( const QString& column, const QString& text );
325 /** 336 /**
326 * Sets a number of @a texts for this item. 337 * Sets a number of @a texts for this item.
327 */ 338 */
328 virtual void setText( const QStringList& texts ); 339 virtual void setText( const QStringList& texts );
329 /** 340 /**
330 * @returns the first child which has a @a text in column @a column. 341 * @returns the first child which has a @a text in column @a column.
331 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> 342 * Set @a recurse to indicate how much subchild levels to search, e.g.<ul>
332 * <li>set it to 0 to search only among direct childs, 343 * <li>set it to 0 to search only among direct childs,
333 * <li>set it to 1 to search direct childs and all 1st order subchilds 344 * <li>set it to 1 to search direct childs and all 1st order subchilds
334 * <li>set it to -1 for maximum recursion. 345 * <li>set it to -1 for maximum recursion.
335 * </ul> 346 * </ul>
336 * @sa ONamedListView::find() 347 * @sa ONamedListView::find()
337 */ 348 */
338 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; 349 virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const;
339 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; 350 virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const;
340}; 351};
341 352
342 353
343#endif // OLISTVIEW_H 354#endif // OLISTVIEW_H