summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/cornucopia
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/cornucopia') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.cpp14
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.h26
2 files changed, 25 insertions, 15 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
@@ -120,12 +120,17 @@ const QPen& OListView::columnSeparator() const
120void OListView::setColumnSeparator( const QPen& p ) 120void OListView::setColumnSeparator( const QPen& p )
121{ 121{
122 m_columnSeparator = p; 122 m_columnSeparator = p;
123 repaint(); 123 repaint();
124} 124}
125 125
126OListViewItem* OListView::childFactory()
127{
128 return new OListViewItem( this );
129}
130
126#ifndef QT_NO_DATASTREAM 131#ifndef QT_NO_DATASTREAM
127void OListView::serializeTo( QDataStream& s ) const 132void 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
@@ -177,13 +182,13 @@ void OListView::serializeFrom( QDataStream& s )
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}
@@ -334,12 +339,17 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in
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
345OListViewItem* OListViewItem::childFactory()
346{
347 return new OListViewItem( this );
348}
349
340#ifndef QT_NO_DATASTREAM 350#ifndef QT_NO_DATASTREAM
341void OListViewItem::serializeTo( QDataStream& s ) const 351void 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
@@ -385,13 +395,13 @@ void OListViewItem::serializeFrom( QDataStream& s )
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
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h
index 9df5500..8911e22 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.h
+++ b/noncore/net/wellenreiter/cornucopia/olistview.h
@@ -35,13 +35,13 @@
35 35
36#include <qcolor.h> 36#include <qcolor.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <qpen.h> 38#include <qpen.h>
39#include <qdatastream.h> 39#include <qdatastream.h>
40 40
41class OListViewFactory; 41class OListViewItem;
42 42
43/** 43/**
44 * A @ref QListView variant featuring visual and functional enhancements 44 * A @ref QListView variant featuring visual and functional enhancements
45 * like an alternate background for odd rows, an autostretch mode 45 * like an alternate background for odd rows, an autostretch mode
46 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. 46 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
47 * 47 *
@@ -112,12 +112,18 @@ class OListViewFactory;
112 112
113 /** 113 /**
114 * @return the column separator pen 114 * @return the column separator pen
115 */ 115 */
116 const QPen& columnSeparator() const; 116 const QPen& columnSeparator() const;
117 117
118 /**
119 * create a list view item as child of this object
120 * @return the new object
121 */
122 virtual OListViewItem* childFactory();
123
118 #ifndef QT_NO_DATASTREAM 124 #ifndef QT_NO_DATASTREAM
119 /** 125 /**
120 * serialize this object to a @ref QDataStream 126 * serialize this object to a @ref QDataStream
121 * @param s the stream used to serialize this object. 127 * @param s the stream used to serialize this object.
122 */ 128 */
123 virtual void serializeTo( QDataStream& s ) const; 129 virtual void serializeTo( QDataStream& s ) const;
@@ -126,28 +132,16 @@ class OListViewFactory;
126 * serialize this object from a @ref QDataStream 132 * serialize this object from a @ref QDataStream
127 * @param s the stream used to serialize this object. 133 * @param s the stream used to serialize this object.
128 */ 134 */
129 virtual void serializeFrom( QDataStream& s ); 135 virtual void serializeFrom( QDataStream& s );
130 #endif 136 #endif
131 137
132 /**
133 * returns a factory for OListView classes
134 * creates one on the fly if it doesn't exist
135 * @return the XML Factory
136 */
137 #ifndef QT_NO_XML
138 //OListViewFactory* Factory();
139 #endif
140
141 private: 138 private:
142 QColor m_alternateBackground; 139 QColor m_alternateBackground;
143 bool m_fullWidth; 140 bool m_fullWidth;
144 QPen m_columnSeparator; 141 QPen m_columnSeparator;
145 #ifndef QT_NO_XML
146 //OListViewFactory* m_Factory;
147 #endif
148}; 142};
149 143
150#ifndef QT_NO_DATASTREAM 144#ifndef QT_NO_DATASTREAM
151/** 145/**
152 * \relates QListView 146 * \relates QListView
153 * Writes a listview to the stream and returns a reference to the stream. 147 * Writes a listview to the stream and returns a reference to the stream.
@@ -198,12 +192,18 @@ class OListViewItem: public QListViewItem
198 192
199 const QColor& backgroundColor(); 193 const QColor& backgroundColor();
200 bool isAlternate(); 194 bool isAlternate();
201 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); 195 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
202 void init(); 196 void init();
203 197
198 /**
199 * create a list view item as child of this object
200 * @return the new object
201 */
202 virtual OListViewItem* childFactory();
203
204 #ifndef QT_NO_DATASTREAM 204 #ifndef QT_NO_DATASTREAM
205 /** 205 /**
206 * serialize this object to or from a @ref QDataStream 206 * serialize this object to or from a @ref QDataStream
207 * @param s the stream used to serialize this object. 207 * @param s the stream used to serialize this object.
208 */ 208 */
209 virtual void serializeTo( QDataStream& s ) const; 209 virtual void serializeTo( QDataStream& s ) const;