Diffstat (limited to 'libopie2/opieui/olistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/olistview.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 2b2f09a..8f97cc6 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp @@ -217,73 +217,84 @@ OListViewItem::OListViewItem(QListView *parent) { init(); } + OListViewItem::OListViewItem(QListViewItem *parent) : QListViewItem(parent) { init(); } + OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } + OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } + OListViewItem::OListViewItem(QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } + OListViewItem::OListViewItem(QListViewItem *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } + OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } + OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } + OListViewItem::~OListViewItem() { } + void OListViewItem::init() { m_known = false; } + const QColor &OListViewItem::backgroundColor() { return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : listView()->viewport()->colorGroup().base(); } + bool OListViewItem::isAlternate() { OListView *lv = static_cast<OListView*>( listView() ); @@ -325,8 +336,9 @@ bool OListViewItem::isAlternate() } return m_odd; } + void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); @@ -347,13 +359,15 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in 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... @@ -384,8 +398,10 @@ void OListViewItem::serializeTo( QDataStream& s ) const } qDebug( "OListviewItem stored." ); } + + void OListViewItem::serializeFrom( QDataStream& s ) { #warning Caution... the binary format is still under construction... qDebug( "loading OListViewItem..." ); @@ -410,14 +426,107 @@ void OListViewItem::serializeFrom( QDataStream& s ) qDebug( "OListViewItem loaded." ); } + QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) { lvi.serializeTo( s ); } + QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) { lvi.serializeFrom( s ); } #endif // QT_NO_DATASTREAM + + +/*====================================================================================== + * ONamedListView + *======================================================================================*/ + +ONamedListView::ONamedListView( QWidget *parent, const char *name ) + :OListView( parent, name ) +{ +} + + +ONamedListView::~ONamedListView() +{ +} + + +void ONamedListView::addColumns( const QStringList& columns ) +{ + for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) + { + qDebug( "adding column %s", (const char*) *it ); + addColumn( *it ); + } +} + + +/*====================================================================================== + * ONamedListViewItem + *======================================================================================*/ + +ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) + :OListViewItem( parent ) +{ + setText( texts ); +} + + +ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) + :OListViewItem( parent ) +{ + setText( texts ); +} + + +ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) + :OListViewItem( parent, after ) +{ + setText( texts ); +} + + +ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) + :OListViewItem( parent, after ) +{ + setText( texts ); +} + + +ONamedListViewItem::~ONamedListViewItem() +{ +} + + +void ONamedListViewItem::setText( const QStringList& texts ) +{ + int col = 0; + for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) + { + qDebug( "setting column %d = text %s", col, (const char*) *it ); + OListViewItem::setText( col++, *it ); + } + +} + + +void ONamedListViewItem::setText( const QString& column, const QString& text ) +{ + //FIXME: If used excessively, this will slow down performance of updates + //FIXME: because of the linear search over all column texts. + //FIXME: I will optimize later by using a hash map. + for ( int i = 0; i < listView()->columns(); ++i ) + { + if ( listView()->columnText( i ) == column ) + { + OListViewItem::setText( i, text ); + return; + } + } + qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); +} |