author | zecke <zecke> | 2004-03-26 22:36:43 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-26 22:36:43 (UTC) |
commit | c54a3c8cc47258743381d4dee4200304d247182d (patch) (side-by-side diff) | |
tree | bc96497821743c7b7789004fd700f58f10f0f772 | |
parent | 2487838d0f9358d6efdf714e9dfd892f92802b46 (diff) | |
download | opie-c54a3c8cc47258743381d4dee4200304d247182d.zip opie-c54a3c8cc47258743381d4dee4200304d247182d.tar.gz opie-c54a3c8cc47258743381d4dee4200304d247182d.tar.bz2 |
Add WFlags to the c'tor so we eventually can use this
in the designer... but anyway making it more consistent with Qt
Ah and this is binary incompatible but the API isn't marked as stable
anyway
-rw-r--r-- | libopie2/opieui/olistview.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/olistview.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 38670b4..d7c92fd 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp @@ -1,764 +1,764 @@ /* This file is part of the Opie Project =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* QT */ #include <qpixmap.h> /* OPIE */ #include <opie2/odebug.h> #include <opie2/olistview.h> using namespace Opie::Core; namespace Opie { namespace Ui { /*====================================================================================== * OListView *======================================================================================*/ -OListView::OListView( QWidget *parent, const char *name ) - :QListView( parent, name ) +OListView::OListView( QWidget *parent, const char *name, WFlags fl ) + :QListView( parent, name, fl ) { //FIXME: get from global settings and calculate ==> see oglobalsettings.* m_alternateBackground = QColor( 238, 246, 255 ); m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); m_fullWidth = true; connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); } OListView::~OListView() { } void OListView::setFullWidth( bool fullWidth ) { m_fullWidth = m_fullWidth; #if QT_VERSION > 290 header()->setStretchEnabled( fullWidth, columns()-1 ); #endif } bool OListView::fullWidth() const { return m_fullWidth; } int OListView::addColumn( const QString& label, int width ) { int result = QListView::addColumn( label, width ); #if QT_VERSION > 290 if (m_fullWidth) { header()->setStretchEnabled( false, columns()-2 ); header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) { int result = QListView::addColumn( iconset, label, width ); #if QT_VERSION > 290 if (m_fullWidth) { header()->setStretchEnabled( false, columns()-2 ); header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } void OListView::removeColumn( int index ) { QListView::removeColumn(index); #if QT_VERSION > 290 if ( m_fullWidth && index == columns() ) { header()->setStretchEnabled( true, columns()-1 ); } #endif } const QColor& OListView::alternateBackground() const { return m_alternateBackground; } void OListView::setAlternateBackground( const QColor &c ) { m_alternateBackground = c; repaint(); } const QPen& OListView::columnSeparator() const { return m_columnSeparator; } void OListView::setColumnSeparator( const QPen& p ) { m_columnSeparator = p; repaint(); } void OListView::expand(QListViewItem *item) { ((OListViewItem*)item)->expand(); } 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... odebug << "storing OListView..." << oendl; // store number of columns and the labels s << columns(); for ( int i = 0; i < columns(); ++i ) s << columnText( i ); // calculate the number of top-level items to serialize int items = 0; QListViewItem* item = firstChild(); while ( item ) { item = item->nextSibling(); items++; } // store number of items and the items itself s << items; item = firstChild(); for ( int i = 0; i < items; ++i ) { s << *static_cast<OListViewItem*>( item ); item = item->nextSibling(); } odebug << "OListview stored." << oendl; } void OListView::serializeFrom( QDataStream& s ) { #warning Caution... the binary format is still under construction... odebug << "loading OListView..." << oendl; int cols; s >> cols; odebug << "read number of columns = " << cols << oendl; while ( columns() < cols ) addColumn( QString::null ); for ( int i = 0; i < cols; ++i ) { QString coltext; s >> coltext; qDebug( "read text '%s' for column %d", (const char*) coltext, i ); setColumnText( i, coltext ); } int items; s >> items; odebug << "read number of items = " << items << oendl; for ( int i = 0; i < items; ++i ) { OListViewItem* item = childFactory(); s >> *item; } odebug << "OListView loaded." << oendl; } void OListView::expand() { odebug << "OListView::expand" << oendl; QListViewItemIterator it( this ); while ( it.current() ) { it.current()->setOpen( true ); ++it; } } void OListView::collapse() { odebug << "OListView::collapse" << oendl; QListViewItemIterator it( this ); while ( it.current() ) { it.current()->setOpen( false ); ++it; } } QDataStream& operator<<( QDataStream& s, const OListView& lv ) { lv.serializeTo( s ); } QDataStream& operator>>( QDataStream& s, OListView& lv ) { lv.serializeFrom( s ); } #endif // QT_NO_DATASTREAM /*====================================================================================== * OListViewItem *======================================================================================*/ OListViewItem::OListViewItem(QListView *parent) : QListViewItem(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() ); // check if the item above is an OListViewItem OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ // check if we have a valid alternate background color if (!(lv && lv->alternateBackground().isValid())) return false; m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { OListViewItem *item; bool previous = true; if (parent()) { item = static_cast<OListViewItem *>(parent()); if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; item = static_cast<OListViewItem *>(parent()->firstChild()); /* if ( !item.inherits( "OListViewItem" ) item = 0; */ } else { item = static_cast<OListViewItem *>(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = static_cast<OListViewItem *>(item->nextSibling()); /* if (!item.inherits( "OListViewItem" ) ) break; */ } } 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(); if (pm && !pm->isNull()) { _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); } else if ( isAlternate() ) { _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); } QListViewItem::paintCell( p, _cg, column, width, alignment ); //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... odebug << "storing OListViewItem..." << oendl; // store item text for ( int i = 0; i < listView()->columns(); ++i ) { s << text( i ); } // calculate the number of children to serialize int items = 0; QListViewItem* item = firstChild(); while ( item ) { item = item->nextSibling(); items++; } // store number of items and the items itself s << items; item = firstChild(); for ( int i = 0; i < items; ++i ) { s << *static_cast<OListViewItem*>( item ); item = item->nextSibling(); } odebug << "OListviewItem stored." << oendl; } void OListViewItem::serializeFrom( QDataStream& s ) { #warning Caution... the binary format is still under construction... odebug << "loading OListViewItem..." << oendl; for ( int i = 0; i < listView()->columns(); ++i ) { QString coltext; s >> coltext; qDebug( "read text '%s' for column %d", (const char*) coltext, i ); setText( i, coltext ); } int items; s >> items; qDebug( "read number of items = %d", items ); for ( int i = 0; i < items; ++i ) { OListViewItem* item = childFactory(); s >> (*item); } odebug << "OListViewItem loaded." << oendl; } QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) { lvi.serializeTo( s ); } QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) { lvi.serializeFrom( s ); } #endif // QT_NO_DATASTREAM /*====================================================================================== * OCheckListItem *======================================================================================*/ OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) :QCheckListItem( parent, text, t ) { init(); } OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) :QCheckListItem( parent, text, t ) { init(); } OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) :QCheckListItem( parent, text, t ) { init(); } OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) :QCheckListItem( parent, text, p ) { init(); } OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) :QCheckListItem( parent, text, p ) { init(); } OCheckListItem::~OCheckListItem() { } void OCheckListItem::init() { m_known = false; } const QColor &OCheckListItem::backgroundColor() { return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : listView()->viewport()->colorGroup().base(); } bool OCheckListItem::isAlternate() { OListView *lv = static_cast<OListView*>( listView() ); // check if the item above is an OCheckListItem OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ // check if we have a valid alternate background color if (!(lv && lv->alternateBackground().isValid())) return false; m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { OCheckListItem *item; bool previous = true; if (parent()) { item = static_cast<OCheckListItem *>(parent()); if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; item = static_cast<OCheckListItem *>(parent()->firstChild()); /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ } else { item = static_cast<OCheckListItem *>(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = static_cast<OCheckListItem *>(item->nextSibling()); /* if (!item.inherits( "OCheckListItem" ) ) break; */ } } return m_odd; } void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if (pm && !pm->isNull()) { _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); } else if ( isAlternate() ) { _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); } QCheckListItem::paintCell( p, _cg, column, width, alignment ); //FIXME: Use styling here! const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); p->setPen( pen ); p->drawLine( width-1, 0, width-1, height() ); } /*====================================================================================== * 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 ); } } int ONamedListView::findColumn( const QString& text ) const { //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 < columns(); ++i ) if ( columnText( i ) == text ) return i; return -1; } ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const { return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); } ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const { ONamedListViewItem* result; while ( item && item->text( column ) != text ) { qDebug( "checked %s", (const char*) item->text( column ) ); if ( recurse < 0 || recurse > 0 ) { qDebug( "recursion is %d - recursing into...", recurse ); result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); if ( result ) return result; } item = (ONamedListViewItem*) item->itemBelow(); } if ( item && item->text( column ) == text ) return item; else return 0; } ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const { int col = findColumn( column ); if ( col != -1 ) return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); else return 0; } ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const { int col = findColumn( column ); if ( col != -1 ) return find( item, col, text, recurse ); else return 0; } /*====================================================================================== * 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. int col = ( (ONamedListView*) listView() )->findColumn( column ); if ( col != -1 ) OListViewItem::setText( col, text ); else qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); } ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const { return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); } ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const { int col = ( (ONamedListView*) listView() )->findColumn( column ); if ( col != -1 ) return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); else return 0; } } } diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index 8195a62..3ff11ef 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h @@ -1,426 +1,426 @@ /* This file is part of the Opie Project =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OLISTVIEW_H #define OLISTVIEW_H #include <qcolor.h> #include <qlistview.h> #include <qpen.h> #include <qdatastream.h> #include <qstringlist.h> namespace Opie { namespace Ui { class OListViewItem; /*====================================================================================== * OListView *======================================================================================*/ /** * @brief A list/tree widget. * * 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. * * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class OListView: public QListView { Q_OBJECT public: /** * Constructor. * * The parameters @a parent and @a name are handled by * @ref QListView, as usual. */ - OListView( QWidget* parent = 0, const char* name = 0 ); + OListView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); /** * Destructor. */ virtual ~OListView(); /** * Let the last column fit exactly all the available width. */ void setFullWidth( bool fullWidth ); /** * Returns whether the last column is set to fit the available width. */ bool fullWidth() const; /** * Reimplemented for full width support */ virtual int addColumn( const QString& label, int width = -1 ); /** * Reimplemented for full width support */ virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); /** * Reimplemented for full width support */ virtual void removeColumn(int index); /** * Set the alternate background background @a color. * Set to an invalid color to disable alternate colors. * This only has an effect if the items are OListViewItems */ void setAlternateBackground( const QColor& color ); /** * Sets the column separator @a pen. */ void setColumnSeparator( const QPen& pen ); /** * @returns the alternate background color */ const QColor& alternateBackground() const; /** * @return the column separator pen */ const QPen& columnSeparator() const; /** * Create a list view item as child of this object * @returns the new object */ virtual OListViewItem* childFactory(); #ifndef QT_NO_DATASTREAM /** * Serialize this object to @ref QDataStream @a stream */ virtual void serializeTo( QDataStream& stream ) const; /** * Serialize this object from a @ref QDataStream @a stream */ virtual void serializeFrom( QDataStream& s ); #endif public slots: /** * Expand all items */ void expand(); /** * Collapse all items */ void collapse(); protected slots: /** * expand the current OListViewItem */ void expand(QListViewItem*); private: QColor m_alternateBackground; bool m_fullWidth : 1; QPen m_columnSeparator; class Private; Private *d; }; #ifndef QT_NO_DATASTREAM /** * @relates OListView * Writes @a listview to the @a stream and returns a reference to the stream. */ QDataStream& operator<<( QDataStream& stream, const OListView& listview ); /** * @relates OListView * Reads @a listview from the @a stream and returns a reference to the stream. */ QDataStream& operator>>( QDataStream& stream, OListView& listview ); #endif // QT_NO_DATASTREAM /*====================================================================================== * OListViewItem *======================================================================================*/ class OListViewItem: public QListViewItem { friend class OCheckListItem; public: /** * Constructors. */ OListViewItem( QListView * parent ); OListViewItem( QListViewItem * parent ); OListViewItem( QListView * parent, QListViewItem * after ); OListViewItem( QListViewItem * parent, QListViewItem * after ); OListViewItem( QListView * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListViewItem * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListView * parent, QListViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListViewItem * parent, QListViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); /** * Destructor. */ virtual ~OListViewItem(); /** * @returns the background color of the list item. */ const QColor& backgroundColor(); /** * @returns true, if the item is at an odd position and * thus have to be painted with the alternate background color. */ bool isAlternate(); /** * @note: Reimplemented for internal purposes - the API is not affected * */ void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); /** * Perform object initialization. */ void init(); /** * create a list view item as child of this object * @returns 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; /** * serialize this object to or from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeFrom( QDataStream& s ); #endif /** * expand the the item */ virtual void expand(){}; private: bool m_known : 1; bool m_odd : 1; class Private; Private *d; }; #ifndef QT_NO_DATASTREAM /** * @relates QListViewItem * Writes listview @a item and all subitems recursively to @a stream * and returns a reference to the stream. */ QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); /** * @relates QListViewItem * Reads listview @a item from @a stream and returns a reference to the stream. */ QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); #endif // QT_NO_DATASTREAM /*====================================================================================== * OCheckListItem *======================================================================================*/ class OCheckListItem : public QCheckListItem { public: OCheckListItem( QCheckListItem *parent, const QString &text, Type = Controller ); OCheckListItem( QListViewItem *parent, const QString &text, Type = Controller ); OCheckListItem( QListView *parent, const QString &text, Type = Controller ); OCheckListItem( QListViewItem *parent, const QString &text, const QPixmap & ); OCheckListItem( QListView *parent, const QString &text, const QPixmap & ); ~OCheckListItem(); /** * @returns the background color of the list item. */ const QColor& backgroundColor(); /** * @returns true, if the item is at an odd position and * thus have to be painted with the alternate background color. */ bool isAlternate(); /** * @note: Reimplemented for internal purposes - the API is not affected * */ void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); /** * Perform object initialization. */ void init(); private: bool m_known; bool m_odd; }; /*====================================================================================== * ONamedListView *======================================================================================*/ class ONamedListViewItem; /** * @brief An OListView variant with named columns. * * This class provides a higher-level interface to an OListView. * * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class ONamedListView: public OListView { public: /** * Constructor. * * The parameters @a parent and @a name are handled by * @ref OListView, as usual. */ ONamedListView( QWidget* parent = 0, const char* name = 0 ); /** * Destructor. */ virtual ~ONamedListView(); /** * Add a number of @a columns to the listview. */ virtual void addColumns( const QStringList& columns ); /** * @returns the column index matching to @a text or -1 if not found. */ virtual int findColumn( const QString& text ) const; /** * @returns the first item which has a @a text in column @a column. * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> * <li>set it to 0 to search only among direct childs, * <li>set it to 1 to search direct childs and all 1st order subchilds * <li>set it to -1 for maximum recursion. * </ul> * @sa ONamedListViewItem::find() */ virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; private: class Private; Private *d; }; /*====================================================================================== * ONamedListViewItem *======================================================================================*/ /** * @brief An OListView variant with named columns. * * This class provides a higher-level interface to an OListViewItem. * * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class ONamedListViewItem: public OListViewItem { public: /** * Constructor. Accepts the same parameters as a @ref OListViewItem, * plus a @ref QStringList which holds an arbitrary number of @a texts. */ ONamedListViewItem( QListView* parent, const QStringList& texts ); ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); /** * Destructor. */ virtual ~ONamedListViewItem(); /** * Sets the text in column @a column to @a text. * This method differs from @ref QListViewItem::setText() in that it * accepts a string as column indicator instead of an int. */ virtual void setText( const QString& column, const QString& text ); /** * Sets a number of @a texts for this item. */ virtual void setText( const QStringList& texts ); /** * @returns the first child which has a @a text in column @a column. * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> * <li>set it to 0 to search only among direct childs, * <li>set it to 1 to search direct childs and all 1st order subchilds * <li>set it to -1 for maximum recursion. * </ul> * @sa ONamedListView::find() */ virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; private: class Private; Private *d; }; } } #endif // OLISTVIEW_H |