author | mickeyl <mickeyl> | 2003-05-01 14:00:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-01 14:00:37 (UTC) |
commit | 95e533a6ac257d3b95cd8905660008fb7dcd33f1 (patch) (side-by-side diff) | |
tree | c671954f59eaa70db2285f9abe49fd8b4512dd12 /libopie2/opieui/olistview.cpp | |
parent | 1d721ddb247e9000e29fba3150e0cce5f59f543e (diff) | |
download | opie-95e533a6ac257d3b95cd8905660008fb7dcd33f1.zip opie-95e533a6ac257d3b95cd8905660008fb7dcd33f1.tar.gz opie-95e533a6ac257d3b95cd8905660008fb7dcd33f1.tar.bz2 |
- restructure opieui example directory
- start work on ONamedListViewItem providing a slightly higher level interface
-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 @@ -219,4 +219,5 @@ OListViewItem::OListViewItem(QListView *parent) } + OListViewItem::OListViewItem(QListViewItem *parent) : QListViewItem(parent) @@ -225,4 +226,5 @@ OListViewItem::OListViewItem(QListViewItem *parent) } + OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) : QListViewItem(parent, after) @@ -231,4 +233,5 @@ OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) } + OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) : QListViewItem(parent, after) @@ -237,4 +240,5 @@ OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) } + OListViewItem::OListViewItem(QListView *parent, QString label1, QString label2, QString label3, QString label4, @@ -245,4 +249,5 @@ OListViewItem::OListViewItem(QListView *parent, } + OListViewItem::OListViewItem(QListViewItem *parent, QString label1, QString label2, QString label3, QString label4, @@ -253,4 +258,5 @@ OListViewItem::OListViewItem(QListViewItem *parent, } + OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, @@ -261,4 +267,5 @@ OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, } + OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, @@ -269,8 +276,10 @@ OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, } + OListViewItem::~OListViewItem() { } + void OListViewItem::init() { @@ -278,4 +287,5 @@ void OListViewItem::init() } + const QColor &OListViewItem::backgroundColor() { @@ -284,4 +294,5 @@ const QColor &OListViewItem::backgroundColor() } + bool OListViewItem::isAlternate() { @@ -327,4 +338,5 @@ bool OListViewItem::isAlternate() } + void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { @@ -349,4 +361,5 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in } + OListViewItem* OListViewItem::childFactory() { @@ -354,4 +367,5 @@ OListViewItem* OListViewItem::childFactory() } + #ifndef QT_NO_DATASTREAM void OListViewItem::serializeTo( QDataStream& s ) const @@ -386,4 +400,6 @@ void OListViewItem::serializeTo( QDataStream& s ) const qDebug( "OListviewItem stored." ); } + + void OListViewItem::serializeFrom( QDataStream& s ) { @@ -412,4 +428,5 @@ void OListViewItem::serializeFrom( QDataStream& s ) } + QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) { @@ -417,4 +434,5 @@ QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) } + QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) { @@ -422,2 +440,93 @@ QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) } #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 ); +} |