Diffstat (limited to 'noncore/net/wellenreiter/cornucopia/olistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp index f2d3730..c292eb9 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.cpp +++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp | |||
@@ -114,24 +114,29 @@ void OListView::setAlternateBackground( const QColor &c ) | |||
114 | 114 | ||
115 | const QPen& OListView::columnSeparator() const | 115 | const QPen& OListView::columnSeparator() const |
116 | { | 116 | { |
117 | return m_columnSeparator; | 117 | return m_columnSeparator; |
118 | } | 118 | } |
119 | 119 | ||
120 | void OListView::setColumnSeparator( const QPen& p ) | 120 | void OListView::setColumnSeparator( const QPen& p ) |
121 | { | 121 | { |
122 | m_columnSeparator = p; | 122 | m_columnSeparator = p; |
123 | repaint(); | 123 | repaint(); |
124 | } | 124 | } |
125 | 125 | ||
126 | OListViewItem* OListView::childFactory() | ||
127 | { | ||
128 | return new OListViewItem( this ); | ||
129 | } | ||
130 | |||
126 | #ifndef QT_NO_DATASTREAM | 131 | #ifndef QT_NO_DATASTREAM |
127 | void OListView::serializeTo( QDataStream& s ) const | 132 | void OListView::serializeTo( QDataStream& s ) const |
128 | { | 133 | { |
129 | #warning Caution... the binary format is still under construction... | 134 | #warning Caution... the binary format is still under construction... |
130 | qDebug( "storing OListView..." ); | 135 | qDebug( "storing OListView..." ); |
131 | 136 | ||
132 | // store number of columns and the labels | 137 | // store number of columns and the labels |
133 | s << columns(); | 138 | s << columns(); |
134 | for ( int i = 0; i < columns(); ++i ) | 139 | for ( int i = 0; i < columns(); ++i ) |
135 | s << columnText( i ); | 140 | s << columnText( i ); |
136 | 141 | ||
137 | // calculate the number of top-level items to serialize | 142 | // calculate the number of top-level items to serialize |
@@ -171,25 +176,25 @@ void OListView::serializeFrom( QDataStream& s ) | |||
171 | QString coltext; | 176 | QString coltext; |
172 | s >> coltext; | 177 | s >> coltext; |
173 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 178 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
174 | setColumnText( i, coltext ); | 179 | setColumnText( i, coltext ); |
175 | } | 180 | } |
176 | 181 | ||
177 | int items; | 182 | int items; |
178 | s >> items; | 183 | s >> items; |
179 | qDebug( "read number of items = %d", items ); | 184 | qDebug( "read number of items = %d", items ); |
180 | 185 | ||
181 | for ( int i = 0; i < items; ++i ) | 186 | for ( int i = 0; i < items; ++i ) |
182 | { | 187 | { |
183 | OListViewItem* item = new OListViewItem( this ); | 188 | OListViewItem* item = childFactory(); |
184 | s >> *item; | 189 | s >> *item; |
185 | } | 190 | } |
186 | 191 | ||
187 | qDebug( "OListView loaded." ); | 192 | qDebug( "OListView loaded." ); |
188 | 193 | ||
189 | } | 194 | } |
190 | 195 | ||
191 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | 196 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) |
192 | { | 197 | { |
193 | lv.serializeTo( s ); | 198 | lv.serializeTo( s ); |
194 | } | 199 | } |
195 | 200 | ||
@@ -328,24 +333,29 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in | |||
328 | { | 333 | { |
329 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 334 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
330 | } | 335 | } |
331 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 336 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
332 | 337 | ||
333 | //FIXME: Use styling here! | 338 | //FIXME: Use styling here! |
334 | 339 | ||
335 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 340 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
336 | p->setPen( pen ); | 341 | p->setPen( pen ); |
337 | p->drawLine( width-1, 0, width-1, height() ); | 342 | p->drawLine( width-1, 0, width-1, height() ); |
338 | } | 343 | } |
339 | 344 | ||
345 | OListViewItem* OListViewItem::childFactory() | ||
346 | { | ||
347 | return new OListViewItem( this ); | ||
348 | } | ||
349 | |||
340 | #ifndef QT_NO_DATASTREAM | 350 | #ifndef QT_NO_DATASTREAM |
341 | void OListViewItem::serializeTo( QDataStream& s ) const | 351 | void OListViewItem::serializeTo( QDataStream& s ) const |
342 | { | 352 | { |
343 | #warning Caution... the binary format is still under construction... | 353 | #warning Caution... the binary format is still under construction... |
344 | qDebug( "storing OListViewItem..." ); | 354 | qDebug( "storing OListViewItem..." ); |
345 | 355 | ||
346 | // store item text | 356 | // store item text |
347 | for ( int i = 0; i < listView()->columns(); ++i ) | 357 | for ( int i = 0; i < listView()->columns(); ++i ) |
348 | { | 358 | { |
349 | s << text( i ); | 359 | s << text( i ); |
350 | } | 360 | } |
351 | 361 | ||
@@ -379,25 +389,25 @@ void OListViewItem::serializeFrom( QDataStream& s ) | |||
379 | QString coltext; | 389 | QString coltext; |
380 | s >> coltext; | 390 | s >> coltext; |
381 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 391 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
382 | setText( i, coltext ); | 392 | setText( i, coltext ); |
383 | } | 393 | } |
384 | 394 | ||
385 | int items; | 395 | int items; |
386 | s >> items; | 396 | s >> items; |
387 | qDebug( "read number of items = %d", items ); | 397 | qDebug( "read number of items = %d", items ); |
388 | 398 | ||
389 | for ( int i = 0; i < items; ++i ) | 399 | for ( int i = 0; i < items; ++i ) |
390 | { | 400 | { |
391 | OListViewItem* item = new OListViewItem( this ); | 401 | OListViewItem* item = childFactory(); |
392 | s >> (*item); | 402 | s >> (*item); |
393 | } | 403 | } |
394 | 404 | ||
395 | qDebug( "OListViewItem loaded." ); | 405 | qDebug( "OListViewItem loaded." ); |
396 | } | 406 | } |
397 | 407 | ||
398 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) | 408 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) |
399 | { | 409 | { |
400 | lvi.serializeTo( s ); | 410 | lvi.serializeTo( s ); |
401 | } | 411 | } |
402 | 412 | ||
403 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) | 413 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) |