Diffstat (limited to 'libopie2/opieui/olistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/olistview.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index ec503dd..38f3fe2 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp | |||
@@ -1,63 +1,63 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | =. (C) 2003 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 | /* QT */ | 30 | /* QT */ |
32 | 31 | ||
33 | #include <qcolor.h> | 32 | #include <qcolor.h> |
34 | #include <qheader.h> | 33 | #include <qheader.h> |
35 | #include <qpainter.h> | 34 | #include <qpainter.h> |
36 | #include <qpixmap.h> | 35 | #include <qpixmap.h> |
37 | 36 | ||
38 | /* OPIE */ | 37 | /* OPIE */ |
39 | 38 | ||
39 | #include <opie2/odebug.h> | ||
40 | #include <opie2/olistview.h> | 40 | #include <opie2/olistview.h> |
41 | 41 | ||
42 | /*====================================================================================== | 42 | /*====================================================================================== |
43 | * OListView | 43 | * OListView |
44 | *======================================================================================*/ | 44 | *======================================================================================*/ |
45 | 45 | ||
46 | OListView::OListView( QWidget *parent, const char *name ) | 46 | OListView::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 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
55 | } | 55 | } |
56 | 56 | ||
57 | OListView::~OListView() | 57 | OListView::~OListView() |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | void OListView::setFullWidth( bool fullWidth ) | 61 | void OListView::setFullWidth( bool fullWidth ) |
62 | { | 62 | { |
63 | m_fullWidth = m_fullWidth; | 63 | m_fullWidth = m_fullWidth; |
@@ -121,106 +121,106 @@ const QPen& OListView::columnSeparator() const | |||
121 | { | 121 | { |
122 | return m_columnSeparator; | 122 | return m_columnSeparator; |
123 | } | 123 | } |
124 | 124 | ||
125 | void OListView::setColumnSeparator( const QPen& p ) | 125 | void OListView::setColumnSeparator( const QPen& p ) |
126 | { | 126 | { |
127 | m_columnSeparator = p; | 127 | m_columnSeparator = p; |
128 | repaint(); | 128 | repaint(); |
129 | } | 129 | } |
130 | 130 | ||
131 | void OListView::expand(QListViewItem *item) | 131 | void OListView::expand(QListViewItem *item) |
132 | { | 132 | { |
133 | ((OListViewItem*)item)->expand(); | 133 | ((OListViewItem*)item)->expand(); |
134 | } | 134 | } |
135 | 135 | ||
136 | OListViewItem* OListView::childFactory() | 136 | OListViewItem* OListView::childFactory() |
137 | { | 137 | { |
138 | return new OListViewItem( this ); | 138 | return new OListViewItem( this ); |
139 | } | 139 | } |
140 | 140 | ||
141 | #ifndef QT_NO_DATASTREAM | 141 | #ifndef QT_NO_DATASTREAM |
142 | void OListView::serializeTo( QDataStream& s ) const | 142 | void OListView::serializeTo( QDataStream& s ) const |
143 | { | 143 | { |
144 | #warning Caution... the binary format is still under construction... | 144 | #warning Caution... the binary format is still under construction... |
145 | qDebug( "storing OListView..." ); | 145 | odebug << "storing OListView..." << oendl; |
146 | 146 | ||
147 | // store number of columns and the labels | 147 | // store number of columns and the labels |
148 | s << columns(); | 148 | s << columns(); |
149 | for ( int i = 0; i < columns(); ++i ) | 149 | for ( int i = 0; i < columns(); ++i ) |
150 | s << columnText( i ); | 150 | s << columnText( i ); |
151 | 151 | ||
152 | // calculate the number of top-level items to serialize | 152 | // calculate the number of top-level items to serialize |
153 | int items = 0; | 153 | int items = 0; |
154 | QListViewItem* item = firstChild(); | 154 | QListViewItem* item = firstChild(); |
155 | while ( item ) | 155 | while ( item ) |
156 | { | 156 | { |
157 | item = item->nextSibling(); | 157 | item = item->nextSibling(); |
158 | items++; | 158 | items++; |
159 | } | 159 | } |
160 | 160 | ||
161 | // store number of items and the items itself | 161 | // store number of items and the items itself |
162 | s << items; | 162 | s << items; |
163 | item = firstChild(); | 163 | item = firstChild(); |
164 | for ( int i = 0; i < items; ++i ) | 164 | for ( int i = 0; i < items; ++i ) |
165 | { | 165 | { |
166 | s << *static_cast<OListViewItem*>( item ); | 166 | s << *static_cast<OListViewItem*>( item ); |
167 | item = item->nextSibling(); | 167 | item = item->nextSibling(); |
168 | } | 168 | } |
169 | 169 | ||
170 | qDebug( "OListview stored." ); | 170 | odebug << "OListview stored." << oendl; |
171 | } | 171 | } |
172 | 172 | ||
173 | void OListView::serializeFrom( QDataStream& s ) | 173 | void OListView::serializeFrom( QDataStream& s ) |
174 | { | 174 | { |
175 | #warning Caution... the binary format is still under construction... | 175 | #warning Caution... the binary format is still under construction... |
176 | qDebug( "loading OListView..." ); | 176 | odebug << "loading OListView..." << oendl; |
177 | 177 | ||
178 | int cols; | 178 | int cols; |
179 | s >> cols; | 179 | s >> cols; |
180 | qDebug( "read number of columns = %d", cols ); | 180 | qDebug( "read number of columns = %d", cols ); |
181 | 181 | ||
182 | while ( columns() < cols ) addColumn( QString::null ); | 182 | while ( columns() < cols ) addColumn( QString::null ); |
183 | 183 | ||
184 | for ( int i = 0; i < cols; ++i ) | 184 | for ( int i = 0; i < cols; ++i ) |
185 | { | 185 | { |
186 | QString coltext; | 186 | QString coltext; |
187 | s >> coltext; | 187 | s >> coltext; |
188 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 188 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
189 | setColumnText( i, coltext ); | 189 | setColumnText( i, coltext ); |
190 | } | 190 | } |
191 | 191 | ||
192 | int items; | 192 | int items; |
193 | s >> items; | 193 | s >> items; |
194 | qDebug( "read number of items = %d", items ); | 194 | qDebug( "read number of items = %d", items ); |
195 | 195 | ||
196 | for ( int i = 0; i < items; ++i ) | 196 | for ( int i = 0; i < items; ++i ) |
197 | { | 197 | { |
198 | OListViewItem* item = childFactory(); | 198 | OListViewItem* item = childFactory(); |
199 | s >> *item; | 199 | s >> *item; |
200 | } | 200 | } |
201 | 201 | ||
202 | qDebug( "OListView loaded." ); | 202 | odebug << "OListView loaded." << oendl; |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | 206 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) |
207 | { | 207 | { |
208 | lv.serializeTo( s ); | 208 | lv.serializeTo( s ); |
209 | } | 209 | } |
210 | 210 | ||
211 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | 211 | QDataStream& operator>>( QDataStream& s, OListView& lv ) |
212 | { | 212 | { |
213 | lv.serializeFrom( s ); | 213 | lv.serializeFrom( s ); |
214 | } | 214 | } |
215 | #endif // QT_NO_DATASTREAM | 215 | #endif // QT_NO_DATASTREAM |
216 | 216 | ||
217 | /*====================================================================================== | 217 | /*====================================================================================== |
218 | * OListViewItem | 218 | * OListViewItem |
219 | *======================================================================================*/ | 219 | *======================================================================================*/ |
220 | 220 | ||
221 | OListViewItem::OListViewItem(QListView *parent) | 221 | OListViewItem::OListViewItem(QListView *parent) |
222 | : QListViewItem(parent) | 222 | : QListViewItem(parent) |
223 | { | 223 | { |
224 | init(); | 224 | init(); |
225 | } | 225 | } |
226 | 226 | ||
@@ -356,102 +356,102 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in | |||
356 | else if ( isAlternate() ) | 356 | else if ( isAlternate() ) |
357 | { | 357 | { |
358 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 358 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
359 | } | 359 | } |
360 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 360 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
361 | 361 | ||
362 | //FIXME: Use styling here! | 362 | //FIXME: Use styling here! |
363 | 363 | ||
364 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 364 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
365 | p->setPen( pen ); | 365 | p->setPen( pen ); |
366 | p->drawLine( width-1, 0, width-1, height() ); | 366 | p->drawLine( width-1, 0, width-1, height() ); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | OListViewItem* OListViewItem::childFactory() | 370 | OListViewItem* OListViewItem::childFactory() |
371 | { | 371 | { |
372 | return new OListViewItem( this ); | 372 | return new OListViewItem( this ); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | #ifndef QT_NO_DATASTREAM | 376 | #ifndef QT_NO_DATASTREAM |
377 | void OListViewItem::serializeTo( QDataStream& s ) const | 377 | void OListViewItem::serializeTo( QDataStream& s ) const |
378 | { | 378 | { |
379 | #warning Caution... the binary format is still under construction... | 379 | #warning Caution... the binary format is still under construction... |
380 | qDebug( "storing OListViewItem..." ); | 380 | odebug << "storing OListViewItem..." << oendl; |
381 | 381 | ||
382 | // store item text | 382 | // store item text |
383 | for ( int i = 0; i < listView()->columns(); ++i ) | 383 | for ( int i = 0; i < listView()->columns(); ++i ) |
384 | { | 384 | { |
385 | s << text( i ); | 385 | s << text( i ); |
386 | } | 386 | } |
387 | 387 | ||
388 | // calculate the number of children to serialize | 388 | // calculate the number of children to serialize |
389 | int items = 0; | 389 | int items = 0; |
390 | QListViewItem* item = firstChild(); | 390 | QListViewItem* item = firstChild(); |
391 | while ( item ) | 391 | while ( item ) |
392 | { | 392 | { |
393 | item = item->nextSibling(); | 393 | item = item->nextSibling(); |
394 | items++; | 394 | items++; |
395 | } | 395 | } |
396 | 396 | ||
397 | // store number of items and the items itself | 397 | // store number of items and the items itself |
398 | s << items; | 398 | s << items; |
399 | item = firstChild(); | 399 | item = firstChild(); |
400 | for ( int i = 0; i < items; ++i ) | 400 | for ( int i = 0; i < items; ++i ) |
401 | { | 401 | { |
402 | s << *static_cast<OListViewItem*>( item ); | 402 | s << *static_cast<OListViewItem*>( item ); |
403 | item = item->nextSibling(); | 403 | item = item->nextSibling(); |
404 | } | 404 | } |
405 | 405 | ||
406 | qDebug( "OListviewItem stored." ); | 406 | odebug << "OListviewItem stored." << oendl; |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
410 | void OListViewItem::serializeFrom( QDataStream& s ) | 410 | void OListViewItem::serializeFrom( QDataStream& s ) |
411 | { | 411 | { |
412 | #warning Caution... the binary format is still under construction... | 412 | #warning Caution... the binary format is still under construction... |
413 | qDebug( "loading OListViewItem..." ); | 413 | odebug << "loading OListViewItem..." << oendl; |
414 | 414 | ||
415 | for ( int i = 0; i < listView()->columns(); ++i ) | 415 | for ( int i = 0; i < listView()->columns(); ++i ) |
416 | { | 416 | { |
417 | QString coltext; | 417 | QString coltext; |
418 | s >> coltext; | 418 | s >> coltext; |
419 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 419 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
420 | setText( i, coltext ); | 420 | setText( i, coltext ); |
421 | } | 421 | } |
422 | 422 | ||
423 | int items; | 423 | int items; |
424 | s >> items; | 424 | s >> items; |
425 | qDebug( "read number of items = %d", items ); | 425 | qDebug( "read number of items = %d", items ); |
426 | 426 | ||
427 | for ( int i = 0; i < items; ++i ) | 427 | for ( int i = 0; i < items; ++i ) |
428 | { | 428 | { |
429 | OListViewItem* item = childFactory(); | 429 | OListViewItem* item = childFactory(); |
430 | s >> (*item); | 430 | s >> (*item); |
431 | } | 431 | } |
432 | 432 | ||
433 | qDebug( "OListViewItem loaded." ); | 433 | odebug << "OListViewItem loaded." << oendl; |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) | 437 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) |
438 | { | 438 | { |
439 | lvi.serializeTo( s ); | 439 | lvi.serializeTo( s ); |
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) | 443 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) |
444 | { | 444 | { |
445 | lvi.serializeFrom( s ); | 445 | lvi.serializeFrom( s ); |
446 | } | 446 | } |
447 | #endif // QT_NO_DATASTREAM | 447 | #endif // QT_NO_DATASTREAM |
448 | 448 | ||
449 | 449 | ||
450 | /*====================================================================================== | 450 | /*====================================================================================== |
451 | * ONamedListView | 451 | * ONamedListView |
452 | *======================================================================================*/ | 452 | *======================================================================================*/ |
453 | 453 | ||
454 | ONamedListView::ONamedListView( QWidget *parent, const char *name ) | 454 | ONamedListView::ONamedListView( QWidget *parent, const char *name ) |
455 | :OListView( parent, name ) | 455 | :OListView( parent, name ) |
456 | { | 456 | { |
457 | } | 457 | } |