-rw-r--r-- | libopie2/opieui/olistview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 0b3bdea..b90c786 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp | |||
@@ -1,449 +1,449 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003-2004 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 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | 40 | ||
41 | 41 | ||
42 | namespace Opie { | 42 | namespace Opie { |
43 | namespace Ui { | 43 | namespace Ui { |
44 | /*====================================================================================== | 44 | /*====================================================================================== |
45 | * OListView | 45 | * OListView |
46 | *======================================================================================*/ | 46 | *======================================================================================*/ |
47 | 47 | ||
48 | OListView::OListView( QWidget *parent, const char *name, WFlags fl ) | 48 | OListView::OListView( QWidget *parent, const char *name, WFlags fl ) |
49 | :QListView( parent, name, fl ) | 49 | :QListView( parent, name, fl ) |
50 | { | 50 | { |
51 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* | 51 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* |
52 | 52 | ||
53 | m_alternateBackground = QColor( 238, 246, 255 ); | 53 | m_alternateBackground = QColor( 238, 246, 255 ); |
54 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); | 54 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); |
55 | m_fullWidth = true; | 55 | m_fullWidth = true; |
56 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 56 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
57 | } | 57 | } |
58 | 58 | ||
59 | OListView::~OListView() | 59 | OListView::~OListView() |
60 | { | 60 | { |
61 | } | 61 | } |
62 | 62 | ||
63 | void OListView::setFullWidth( bool fullWidth ) | 63 | void OListView::setFullWidth( bool fullWidth ) |
64 | { | 64 | { |
65 | m_fullWidth = m_fullWidth; | 65 | m_fullWidth = fullWidth; |
66 | #if QT_VERSION > 290 | 66 | #if QT_VERSION > 290 |
67 | header()->setStretchEnabled( fullWidth, columns()-1 ); | 67 | header()->setStretchEnabled( fullWidth, columns()-1 ); |
68 | #endif | 68 | #endif |
69 | } | 69 | } |
70 | 70 | ||
71 | bool OListView::fullWidth() const | 71 | bool OListView::fullWidth() const |
72 | { | 72 | { |
73 | return m_fullWidth; | 73 | return m_fullWidth; |
74 | } | 74 | } |
75 | 75 | ||
76 | int OListView::addColumn( const QString& label, int width ) | 76 | int OListView::addColumn( const QString& label, int width ) |
77 | { | 77 | { |
78 | int result = QListView::addColumn( label, width ); | 78 | int result = QListView::addColumn( label, width ); |
79 | #if QT_VERSION > 290 | 79 | #if QT_VERSION > 290 |
80 | if (m_fullWidth) { | 80 | if (m_fullWidth) { |
81 | header()->setStretchEnabled( false, columns()-2 ); | 81 | header()->setStretchEnabled( false, columns()-2 ); |
82 | header()->setStretchEnabled( true, columns()-1 ); | 82 | header()->setStretchEnabled( true, columns()-1 ); |
83 | } | 83 | } |
84 | #endif | 84 | #endif |
85 | return result; | 85 | return result; |
86 | } | 86 | } |
87 | 87 | ||
88 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | 88 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) |
89 | { | 89 | { |
90 | int result = QListView::addColumn( iconset, label, width ); | 90 | int result = QListView::addColumn( iconset, label, width ); |
91 | #if QT_VERSION > 290 | 91 | #if QT_VERSION > 290 |
92 | if (m_fullWidth) { | 92 | if (m_fullWidth) { |
93 | header()->setStretchEnabled( false, columns()-2 ); | 93 | header()->setStretchEnabled( false, columns()-2 ); |
94 | header()->setStretchEnabled( true, columns()-1 ); | 94 | header()->setStretchEnabled( true, columns()-1 ); |
95 | } | 95 | } |
96 | #endif | 96 | #endif |
97 | return result; | 97 | return result; |
98 | } | 98 | } |
99 | 99 | ||
100 | void OListView::removeColumn( int index ) | 100 | void OListView::removeColumn( int index ) |
101 | { | 101 | { |
102 | QListView::removeColumn(index); | 102 | QListView::removeColumn(index); |
103 | #if QT_VERSION > 290 | 103 | #if QT_VERSION > 290 |
104 | if ( m_fullWidth && index == columns() ) | 104 | if ( m_fullWidth && index == columns() ) |
105 | { | 105 | { |
106 | header()->setStretchEnabled( true, columns()-1 ); | 106 | header()->setStretchEnabled( true, columns()-1 ); |
107 | } | 107 | } |
108 | #endif | 108 | #endif |
109 | } | 109 | } |
110 | 110 | ||
111 | const QColor& OListView::alternateBackground() const | 111 | const QColor& OListView::alternateBackground() const |
112 | { | 112 | { |
113 | return m_alternateBackground; | 113 | return m_alternateBackground; |
114 | } | 114 | } |
115 | 115 | ||
116 | void OListView::setAlternateBackground( const QColor &c ) | 116 | void OListView::setAlternateBackground( const QColor &c ) |
117 | { | 117 | { |
118 | m_alternateBackground = c; | 118 | m_alternateBackground = c; |
119 | repaint(); | 119 | repaint(); |
120 | } | 120 | } |
121 | 121 | ||
122 | const QPen& OListView::columnSeparator() const | 122 | const QPen& OListView::columnSeparator() const |
123 | { | 123 | { |
124 | return m_columnSeparator; | 124 | return m_columnSeparator; |
125 | } | 125 | } |
126 | 126 | ||
127 | void OListView::setColumnSeparator( const QPen& p ) | 127 | void OListView::setColumnSeparator( const QPen& p ) |
128 | { | 128 | { |
129 | m_columnSeparator = p; | 129 | m_columnSeparator = p; |
130 | repaint(); | 130 | repaint(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void OListView::expand(QListViewItem *item) | 133 | void OListView::expand(QListViewItem *item) |
134 | { | 134 | { |
135 | ((OListViewItem*)item)->expand(); | 135 | ((OListViewItem*)item)->expand(); |
136 | } | 136 | } |
137 | 137 | ||
138 | OListViewItem* OListView::childFactory() | 138 | OListViewItem* OListView::childFactory() |
139 | { | 139 | { |
140 | return new OListViewItem( this ); | 140 | return new OListViewItem( this ); |
141 | } | 141 | } |
142 | 142 | ||
143 | #ifndef QT_NO_DATASTREAM | 143 | #ifndef QT_NO_DATASTREAM |
144 | void OListView::serializeTo( QDataStream& s ) const | 144 | void OListView::serializeTo( QDataStream& s ) const |
145 | { | 145 | { |
146 | #warning Caution... the binary format is still under construction... | 146 | #warning Caution... the binary format is still under construction... |
147 | odebug << "storing OListView..." << oendl; | 147 | odebug << "storing OListView..." << oendl; |
148 | 148 | ||
149 | // store number of columns and the labels | 149 | // store number of columns and the labels |
150 | s << columns(); | 150 | s << columns(); |
151 | for ( int i = 0; i < columns(); ++i ) | 151 | for ( int i = 0; i < columns(); ++i ) |
152 | s << columnText( i ); | 152 | s << columnText( i ); |
153 | 153 | ||
154 | // calculate the number of top-level items to serialize | 154 | // calculate the number of top-level items to serialize |
155 | int items = 0; | 155 | int items = 0; |
156 | QListViewItem* item = firstChild(); | 156 | QListViewItem* item = firstChild(); |
157 | while ( item ) | 157 | while ( item ) |
158 | { | 158 | { |
159 | item = item->nextSibling(); | 159 | item = item->nextSibling(); |
160 | items++; | 160 | items++; |
161 | } | 161 | } |
162 | 162 | ||
163 | // store number of items and the items itself | 163 | // store number of items and the items itself |
164 | s << items; | 164 | s << items; |
165 | item = firstChild(); | 165 | item = firstChild(); |
166 | for ( int i = 0; i < items; ++i ) | 166 | for ( int i = 0; i < items; ++i ) |
167 | { | 167 | { |
168 | s << *static_cast<OListViewItem*>( item ); | 168 | s << *static_cast<OListViewItem*>( item ); |
169 | item = item->nextSibling(); | 169 | item = item->nextSibling(); |
170 | } | 170 | } |
171 | 171 | ||
172 | odebug << "OListview stored." << oendl; | 172 | odebug << "OListview stored." << oendl; |
173 | } | 173 | } |
174 | 174 | ||
175 | void OListView::serializeFrom( QDataStream& s ) | 175 | void OListView::serializeFrom( QDataStream& s ) |
176 | { | 176 | { |
177 | #warning Caution... the binary format is still under construction... | 177 | #warning Caution... the binary format is still under construction... |
178 | odebug << "loading OListView..." << oendl; | 178 | odebug << "loading OListView..." << oendl; |
179 | 179 | ||
180 | int cols; | 180 | int cols; |
181 | s >> cols; | 181 | s >> cols; |
182 | odebug << "read number of columns = " << cols << oendl; | 182 | odebug << "read number of columns = " << cols << oendl; |
183 | 183 | ||
184 | while ( columns() < cols ) addColumn( QString::null ); | 184 | while ( columns() < cols ) addColumn( QString::null ); |
185 | 185 | ||
186 | for ( int i = 0; i < cols; ++i ) | 186 | for ( int i = 0; i < cols; ++i ) |
187 | { | 187 | { |
188 | QString coltext; | 188 | QString coltext; |
189 | s >> coltext; | 189 | s >> coltext; |
190 | odebug << "read text '" << coltext << "' for column " << i << "" << oendl; | 190 | odebug << "read text '" << coltext << "' for column " << i << "" << oendl; |
191 | setColumnText( i, coltext ); | 191 | setColumnText( i, coltext ); |
192 | } | 192 | } |
193 | 193 | ||
194 | int items; | 194 | int items; |
195 | s >> items; | 195 | s >> items; |
196 | odebug << "read number of items = " << items << oendl; | 196 | odebug << "read number of items = " << items << oendl; |
197 | 197 | ||
198 | for ( int i = 0; i < items; ++i ) | 198 | for ( int i = 0; i < items; ++i ) |
199 | { | 199 | { |
200 | OListViewItem* item = childFactory(); | 200 | OListViewItem* item = childFactory(); |
201 | s >> *item; | 201 | s >> *item; |
202 | } | 202 | } |
203 | 203 | ||
204 | odebug << "OListView loaded." << oendl; | 204 | odebug << "OListView loaded." << oendl; |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | void OListView::expand() | 209 | void OListView::expand() |
210 | { | 210 | { |
211 | odebug << "OListView::expand" << oendl; | 211 | odebug << "OListView::expand" << oendl; |
212 | 212 | ||
213 | QListViewItemIterator it( this ); | 213 | QListViewItemIterator it( this ); |
214 | while ( it.current() ) { | 214 | while ( it.current() ) { |
215 | it.current()->setOpen( true ); | 215 | it.current()->setOpen( true ); |
216 | ++it; | 216 | ++it; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void OListView::collapse() | 221 | void OListView::collapse() |
222 | { | 222 | { |
223 | odebug << "OListView::collapse" << oendl; | 223 | odebug << "OListView::collapse" << oendl; |
224 | QListViewItemIterator it( this ); | 224 | QListViewItemIterator it( this ); |
225 | while ( it.current() ) { | 225 | while ( it.current() ) { |
226 | it.current()->setOpen( false ); | 226 | it.current()->setOpen( false ); |
227 | ++it; | 227 | ++it; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | 232 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) |
233 | { | 233 | { |
234 | lv.serializeTo( s ); | 234 | lv.serializeTo( s ); |
235 | } | 235 | } |
236 | 236 | ||
237 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | 237 | QDataStream& operator>>( QDataStream& s, OListView& lv ) |
238 | { | 238 | { |
239 | lv.serializeFrom( s ); | 239 | lv.serializeFrom( s ); |
240 | } | 240 | } |
241 | #endif // QT_NO_DATASTREAM | 241 | #endif // QT_NO_DATASTREAM |
242 | 242 | ||
243 | /*====================================================================================== | 243 | /*====================================================================================== |
244 | * OListViewItem | 244 | * OListViewItem |
245 | *======================================================================================*/ | 245 | *======================================================================================*/ |
246 | 246 | ||
247 | OListViewItem::OListViewItem(QListView *parent) | 247 | OListViewItem::OListViewItem(QListView *parent) |
248 | : QListViewItem(parent) | 248 | : QListViewItem(parent) |
249 | { | 249 | { |
250 | init(); | 250 | init(); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | OListViewItem::OListViewItem(QListViewItem *parent) | 254 | OListViewItem::OListViewItem(QListViewItem *parent) |
255 | : QListViewItem(parent) | 255 | : QListViewItem(parent) |
256 | { | 256 | { |
257 | init(); | 257 | init(); |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) | 261 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) |
262 | : QListViewItem(parent, after) | 262 | : QListViewItem(parent, after) |
263 | { | 263 | { |
264 | init(); | 264 | init(); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) | 268 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) |
269 | : QListViewItem(parent, after) | 269 | : QListViewItem(parent, after) |
270 | { | 270 | { |
271 | init(); | 271 | init(); |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | OListViewItem::OListViewItem(QListView *parent, | 275 | OListViewItem::OListViewItem(QListView *parent, |
276 | QString label1, QString label2, QString label3, QString label4, | 276 | QString label1, QString label2, QString label3, QString label4, |
277 | QString label5, QString label6, QString label7, QString label8) | 277 | QString label5, QString label6, QString label7, QString label8) |
278 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 278 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
279 | { | 279 | { |
280 | init(); | 280 | init(); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | OListViewItem::OListViewItem(QListViewItem *parent, | 284 | OListViewItem::OListViewItem(QListViewItem *parent, |
285 | QString label1, QString label2, QString label3, QString label4, | 285 | QString label1, QString label2, QString label3, QString label4, |
286 | QString label5, QString label6, QString label7, QString label8) | 286 | QString label5, QString label6, QString label7, QString label8) |
287 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 287 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
288 | { | 288 | { |
289 | init(); | 289 | init(); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, | 293 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, |
294 | QString label1, QString label2, QString label3, QString label4, | 294 | QString label1, QString label2, QString label3, QString label4, |
295 | QString label5, QString label6, QString label7, QString label8) | 295 | QString label5, QString label6, QString label7, QString label8) |
296 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 296 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
297 | { | 297 | { |
298 | init(); | 298 | init(); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, | 302 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, |
303 | QString label1, QString label2, QString label3, QString label4, | 303 | QString label1, QString label2, QString label3, QString label4, |
304 | QString label5, QString label6, QString label7, QString label8) | 304 | QString label5, QString label6, QString label7, QString label8) |
305 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 305 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
306 | { | 306 | { |
307 | init(); | 307 | init(); |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | OListViewItem::~OListViewItem() | 311 | OListViewItem::~OListViewItem() |
312 | { | 312 | { |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void OListViewItem::init() | 316 | void OListViewItem::init() |
317 | { | 317 | { |
318 | m_known = false; | 318 | m_known = false; |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | const QColor &OListViewItem::backgroundColor() | 322 | const QColor &OListViewItem::backgroundColor() |
323 | { | 323 | { |
324 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | 324 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : |
325 | listView()->viewport()->colorGroup().base(); | 325 | listView()->viewport()->colorGroup().base(); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | bool OListViewItem::isAlternate() | 329 | bool OListViewItem::isAlternate() |
330 | { | 330 | { |
331 | OListView *lv = static_cast<OListView*>( listView() ); | 331 | OListView *lv = static_cast<OListView*>( listView() ); |
332 | 332 | ||
333 | // check if the item above is an OListViewItem | 333 | // check if the item above is an OListViewItem |
334 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); | 334 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); |
335 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ | 335 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ |
336 | 336 | ||
337 | // check if we have a valid alternate background color | 337 | // check if we have a valid alternate background color |
338 | if (!(lv && lv->alternateBackground().isValid())) return false; | 338 | if (!(lv && lv->alternateBackground().isValid())) return false; |
339 | 339 | ||
340 | m_known = above ? above->m_known : true; | 340 | m_known = above ? above->m_known : true; |
341 | if (m_known) | 341 | if (m_known) |
342 | { | 342 | { |
343 | m_odd = above ? !above->m_odd : false; | 343 | m_odd = above ? !above->m_odd : false; |
344 | } | 344 | } |
345 | else | 345 | else |
346 | { | 346 | { |
347 | OListViewItem *item; | 347 | OListViewItem *item; |
348 | bool previous = true; | 348 | bool previous = true; |
349 | if (parent()) | 349 | if (parent()) |
350 | { | 350 | { |
351 | item = static_cast<OListViewItem *>(parent()); | 351 | item = static_cast<OListViewItem *>(parent()); |
352 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; | 352 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; |
353 | item = static_cast<OListViewItem *>(parent()->firstChild()); | 353 | item = static_cast<OListViewItem *>(parent()->firstChild()); |
354 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ | 354 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ |
355 | } | 355 | } |
356 | else | 356 | else |
357 | { | 357 | { |
358 | item = static_cast<OListViewItem *>(lv->firstChild()); | 358 | item = static_cast<OListViewItem *>(lv->firstChild()); |
359 | } | 359 | } |
360 | 360 | ||
361 | while(item) | 361 | while(item) |
362 | { | 362 | { |
363 | item->m_odd = previous = !previous; | 363 | item->m_odd = previous = !previous; |
364 | item->m_known = true; | 364 | item->m_known = true; |
365 | item = static_cast<OListViewItem *>(item->nextSibling()); | 365 | item = static_cast<OListViewItem *>(item->nextSibling()); |
366 | /* if (!item.inherits( "OListViewItem" ) ) break; */ | 366 | /* if (!item.inherits( "OListViewItem" ) ) break; */ |
367 | } | 367 | } |
368 | } | 368 | } |
369 | return m_odd; | 369 | return m_odd; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 373 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
374 | { | 374 | { |
375 | QColorGroup _cg = cg; | 375 | QColorGroup _cg = cg; |
376 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 376 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
377 | if (pm && !pm->isNull()) | 377 | if (pm && !pm->isNull()) |
378 | { | 378 | { |
379 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); | 379 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); |
380 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 380 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
381 | } | 381 | } |
382 | else if ( isAlternate() ) | 382 | else if ( isAlternate() ) |
383 | { | 383 | { |
384 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 384 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
385 | } | 385 | } |
386 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 386 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
387 | 387 | ||
388 | //FIXME: Use styling here! | 388 | //FIXME: Use styling here! |
389 | 389 | ||
390 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 390 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
391 | p->setPen( pen ); | 391 | p->setPen( pen ); |
392 | p->drawLine( width-1, 0, width-1, height() ); | 392 | p->drawLine( width-1, 0, width-1, height() ); |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | OListViewItem* OListViewItem::childFactory() | 396 | OListViewItem* OListViewItem::childFactory() |
397 | { | 397 | { |
398 | return new OListViewItem( this ); | 398 | return new OListViewItem( this ); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | #ifndef QT_NO_DATASTREAM | 402 | #ifndef QT_NO_DATASTREAM |
403 | void OListViewItem::serializeTo( QDataStream& s ) const | 403 | void OListViewItem::serializeTo( QDataStream& s ) const |
404 | { | 404 | { |
405 | #warning Caution... the binary format is still under construction... | 405 | #warning Caution... the binary format is still under construction... |
406 | odebug << "storing OListViewItem..." << oendl; | 406 | odebug << "storing OListViewItem..." << oendl; |
407 | 407 | ||
408 | // store item text | 408 | // store item text |
409 | for ( int i = 0; i < listView()->columns(); ++i ) | 409 | for ( int i = 0; i < listView()->columns(); ++i ) |
410 | { | 410 | { |
411 | s << text( i ); | 411 | s << text( i ); |
412 | } | 412 | } |
413 | 413 | ||
414 | // calculate the number of children to serialize | 414 | // calculate the number of children to serialize |
415 | int items = 0; | 415 | int items = 0; |
416 | QListViewItem* item = firstChild(); | 416 | QListViewItem* item = firstChild(); |
417 | while ( item ) | 417 | while ( item ) |
418 | { | 418 | { |
419 | item = item->nextSibling(); | 419 | item = item->nextSibling(); |
420 | items++; | 420 | items++; |
421 | } | 421 | } |
422 | 422 | ||
423 | // store number of items and the items itself | 423 | // store number of items and the items itself |
424 | s << items; | 424 | s << items; |
425 | item = firstChild(); | 425 | item = firstChild(); |
426 | for ( int i = 0; i < items; ++i ) | 426 | for ( int i = 0; i < items; ++i ) |
427 | { | 427 | { |
428 | s << *static_cast<OListViewItem*>( item ); | 428 | s << *static_cast<OListViewItem*>( item ); |
429 | item = item->nextSibling(); | 429 | item = item->nextSibling(); |
430 | } | 430 | } |
431 | 431 | ||
432 | odebug << "OListviewItem stored." << oendl; | 432 | odebug << "OListviewItem stored." << oendl; |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void OListViewItem::serializeFrom( QDataStream& s ) | 436 | void OListViewItem::serializeFrom( QDataStream& s ) |
437 | { | 437 | { |
438 | #warning Caution... the binary format is still under construction... | 438 | #warning Caution... the binary format is still under construction... |
439 | odebug << "loading OListViewItem..." << oendl; | 439 | odebug << "loading OListViewItem..." << oendl; |
440 | 440 | ||
441 | for ( int i = 0; i < listView()->columns(); ++i ) | 441 | for ( int i = 0; i < listView()->columns(); ++i ) |
442 | { | 442 | { |
443 | QString coltext; | 443 | QString coltext; |
444 | s >> coltext; | 444 | s >> coltext; |
445 | odebug << "read text '" << coltext << "' for column " << i << "" << oendl; | 445 | odebug << "read text '" << coltext << "' for column " << i << "" << oendl; |
446 | setText( i, coltext ); | 446 | setText( i, coltext ); |
447 | } | 447 | } |
448 | 448 | ||
449 | int items; | 449 | int items; |