Diffstat (limited to 'noncore/net/wellenreiter/cornucopia') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.cpp | 14 | ||||
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.h | 26 |
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 void OListView::setColumnSeparator( const QPen& p ) { m_columnSeparator = p; repaint(); } +OListViewItem* OListView::childFactory() +{ + return new OListViewItem( this ); +} + #ifndef QT_NO_DATASTREAM void OListView::serializeTo( QDataStream& s ) const { #warning Caution... the binary format is still under construction... qDebug( "storing OListView..." ); @@ -177,13 +182,13 @@ void OListView::serializeFrom( QDataStream& s ) int items; s >> items; qDebug( "read number of items = %d", items ); for ( int i = 0; i < items; ++i ) { - OListViewItem* item = new OListViewItem( this ); + OListViewItem* item = childFactory(); s >> *item; } qDebug( "OListView loaded." ); } @@ -334,12 +339,17 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); p->setPen( pen ); p->drawLine( width-1, 0, width-1, height() ); } +OListViewItem* OListViewItem::childFactory() +{ + return new OListViewItem( this ); +} + #ifndef QT_NO_DATASTREAM void OListViewItem::serializeTo( QDataStream& s ) const { #warning Caution... the binary format is still under construction... qDebug( "storing OListViewItem..." ); @@ -385,13 +395,13 @@ void OListViewItem::serializeFrom( QDataStream& s ) int items; s >> items; qDebug( "read number of items = %d", items ); for ( int i = 0; i < items; ++i ) { - OListViewItem* item = new OListViewItem( this ); + OListViewItem* item = childFactory(); s >> (*item); } qDebug( "OListViewItem loaded." ); } 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 @@ #include <qcolor.h> #include <qlistview.h> #include <qpen.h> #include <qdatastream.h> -class OListViewFactory; +class OListViewItem; /** * A @ref QListView variant featuring visual and functional enhancements * like an alternate background for odd rows, an autostretch mode * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. * @@ -112,12 +112,18 @@ class OListViewFactory; /** * @return the column separator pen */ const QPen& columnSeparator() const; + /** + * create a list view item as child of this object + * @return the new object + */ + virtual OListViewItem* childFactory(); + #ifndef QT_NO_DATASTREAM /** * serialize this object to a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeTo( QDataStream& s ) const; @@ -126,28 +132,16 @@ class OListViewFactory; * serialize this object from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeFrom( QDataStream& s ); #endif - /** - * returns a factory for OListView classes - * creates one on the fly if it doesn't exist - * @return the XML Factory - */ - #ifndef QT_NO_XML - //OListViewFactory* Factory(); - #endif - private: QColor m_alternateBackground; bool m_fullWidth; QPen m_columnSeparator; - #ifndef QT_NO_XML - //OListViewFactory* m_Factory; - #endif }; #ifndef QT_NO_DATASTREAM /** * \relates QListView * Writes a listview to the stream and returns a reference to the stream. @@ -198,12 +192,18 @@ class OListViewItem: public QListViewItem const QColor& backgroundColor(); bool isAlternate(); void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); void init(); + /** + * create a list view item as child of this object + * @return the new object + */ + virtual OListViewItem* childFactory(); + #ifndef QT_NO_DATASTREAM /** * serialize this object to or from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeTo( QDataStream& s ) const; |