summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/cornucopia/olistview.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/cornucopia/olistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.cpp147
1 files changed, 146 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp
index 8bc59de..f2d3730 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.cpp
+++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp
@@ -125,2 +125,78 @@ void OListView::setColumnSeparator( const QPen& p )
125 125
126#ifndef QT_NO_DATASTREAM
127void OListView::serializeTo( QDataStream& s ) const
128{
129 #warning Caution... the binary format is still under construction...
130 qDebug( "storing OListView..." );
131
132 // store number of columns and the labels
133 s << columns();
134 for ( int i = 0; i < columns(); ++i )
135 s << columnText( i );
136
137 // calculate the number of top-level items to serialize
138 int items = 0;
139 QListViewItem* item = firstChild();
140 while ( item )
141 {
142 item = item->nextSibling();
143 items++;
144 }
145
146 // store number of items and the items itself
147 s << items;
148 item = firstChild();
149 for ( int i = 0; i < items; ++i )
150 {
151 s << *static_cast<OListViewItem*>( item );
152 item = item->nextSibling();
153 }
154
155 qDebug( "OListview stored." );
156}
157
158void OListView::serializeFrom( QDataStream& s )
159{
160 #warning Caution... the binary format is still under construction...
161 qDebug( "loading OListView..." );
162
163 int cols;
164 s >> cols;
165 qDebug( "read number of columns = %d", cols );
166
167 while ( columns() < cols ) addColumn( QString::null );
168
169 for ( int i = 0; i < cols; ++i )
170 {
171 QString coltext;
172 s >> coltext;
173 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
174 setColumnText( i, coltext );
175 }
176
177 int items;
178 s >> items;
179 qDebug( "read number of items = %d", items );
180
181 for ( int i = 0; i < items; ++i )
182 {
183 OListViewItem* item = new OListViewItem( this );
184 s >> *item;
185 }
186
187 qDebug( "OListView loaded." );
188
189}
190
191QDataStream& operator<<( QDataStream& s, const OListView& lv )
192{
193 lv.serializeTo( s );
194}
195
196QDataStream& operator>>( QDataStream& s, OListView& lv )
197{
198 lv.serializeFrom( s );
199}
200#endif // QT_NO_DATASTREAM
201
126//****************************** OListViewItem *********************************************************************** 202//****************************** OListViewItem ***********************************************************************
@@ -256,3 +332,3 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in
256 332
257 //FIXME: Use styling here? 333 //FIXME: Use styling here!
258 334
@@ -262 +338,70 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in
262} 338}
339
340#ifndef QT_NO_DATASTREAM
341void OListViewItem::serializeTo( QDataStream& s ) const
342{
343 #warning Caution... the binary format is still under construction...
344 qDebug( "storing OListViewItem..." );
345
346 // store item text
347 for ( int i = 0; i < listView()->columns(); ++i )
348 {
349 s << text( i );
350 }
351
352 // calculate the number of children to serialize
353 int items = 0;
354 QListViewItem* item = firstChild();
355 while ( item )
356 {
357 item = item->nextSibling();
358 items++;
359 }
360
361 // store number of items and the items itself
362 s << items;
363 item = firstChild();
364 for ( int i = 0; i < items; ++i )
365 {
366 s << *static_cast<OListViewItem*>( item );
367 item = item->nextSibling();
368 }
369
370 qDebug( "OListviewItem stored." );
371}
372void OListViewItem::serializeFrom( QDataStream& s )
373{
374 #warning Caution... the binary format is still under construction...
375 qDebug( "loading OListViewItem..." );
376
377 for ( int i = 0; i < listView()->columns(); ++i )
378 {
379 QString coltext;
380 s >> coltext;
381 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
382 setText( i, coltext );
383 }
384
385 int items;
386 s >> items;
387 qDebug( "read number of items = %d", items );
388
389 for ( int i = 0; i < items; ++i )
390 {
391 OListViewItem* item = new OListViewItem( this );
392 s >> (*item);
393 }
394
395 qDebug( "OListViewItem loaded." );
396}
397
398QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
399{
400 lvi.serializeTo( s );
401}
402
403QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
404{
405 lvi.serializeFrom( s );
406}
407#endif // QT_NO_DATASTREAM