author | mickeyl <mickeyl> | 2003-03-02 17:35:53 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-02 17:35:53 (UTC) |
commit | b3b0d6ec136e550029b9cae7fb714d47071ea5b4 (patch) (side-by-side diff) | |
tree | 9cc1fb741bb548c90915487572c49a1ae48e33eb /noncore/net/wellenreiter/cornucopia/olistview.cpp | |
parent | d0e64d0c7961de1c3ecb886ae76c6701f268d767 (diff) | |
download | opie-b3b0d6ec136e550029b9cae7fb714d47071ea5b4.zip opie-b3b0d6ec136e550029b9cae7fb714d47071ea5b4.tar.gz opie-b3b0d6ec136e550029b9cae7fb714d47071ea5b4.tar.bz2 |
add child item factory to allow subclasses adding custom data items
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 @@ -118,16 +118,21 @@ 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..." ); // store number of columns and the labels s << columns(); @@ -175,17 +180,17 @@ 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." ); } QDataStream& operator<<( QDataStream& s, const OListView& lv ) @@ -332,16 +337,21 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in //FIXME: Use styling here! 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..." ); // store item text for ( int i = 0; i < listView()->columns(); ++i ) @@ -383,17 +393,17 @@ 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." ); } QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) { |