diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-01 03:43:07 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-01 03:43:07 +0000 |
commit | 70b9eea2ba01c3691497f49e4c45cb070c16193c (patch) | |
tree | 9a6df61aa247a27275aad9c5245e419e89c2c640 /kradio3/plugins/gui-quickbar/buttonflowlayout.cpp | |
parent | 998c1384ace4ae4655997c181fa33242148cd0a4 (diff) | |
download | tderadio-70b9eea2ba01c3691497f49e4c45cb070c16193c.tar.gz tderadio-70b9eea2ba01c3691497f49e4c45cb070c16193c.zip |
TQt4 port kradio
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kradio@1238952 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kradio3/plugins/gui-quickbar/buttonflowlayout.cpp')
-rw-r--r-- | kradio3/plugins/gui-quickbar/buttonflowlayout.cpp | 122 |
1 files changed, 79 insertions, 43 deletions
diff --git a/kradio3/plugins/gui-quickbar/buttonflowlayout.cpp b/kradio3/plugins/gui-quickbar/buttonflowlayout.cpp index 40d7da4..419fd10 100644 --- a/kradio3/plugins/gui-quickbar/buttonflowlayout.cpp +++ b/kradio3/plugins/gui-quickbar/buttonflowlayout.cpp @@ -1,11 +1,11 @@ /**************************************************************************** -** $Id: buttonflowlayout.cpp 272 2005-05-18 08:12:51Z emw $ +** $Id: buttonflowtqlayout.cpp 272 2005-05-18 08:12:51Z emw $ ** -** Implementing your own layout: flow example +** Implementing your own tqlayout: flow example ** ** Copyright (C) 1996 by Trolltech AS. All rights reserved. ** -** This file is part of an example program for Qt. This example +** This file is part of an example program for TQt. This example ** program may be used, distributed and modified without limitation. ** *****************************************************************************/ @@ -19,18 +19,18 @@ /*********************************************/ /* Iterator */ -class ButtonFlowLayoutIterator :public QGLayoutIterator +class ButtonFlowLayoutIterator :public TQGLayoutIterator { public: - ButtonFlowLayoutIterator( QPtrList<QLayoutItem> *l ) :idx(0), list(l) {} + ButtonFlowLayoutIterator( TQPtrList<TQLayoutItem> *l ) :idx(0), list(l) {} uint count() const; - QLayoutItem *current(); - QLayoutItem *next(); - QLayoutItem *takeCurrent(); + TQLayoutItem *current(); + TQLayoutItem *next(); + TQLayoutItem *takeCurrent(); private: int idx; - QPtrList<QLayoutItem> *list; + TQPtrList<TQLayoutItem> *list; }; @@ -39,38 +39,38 @@ uint ButtonFlowLayoutIterator::count() const return list->count(); } -QLayoutItem *ButtonFlowLayoutIterator::current() +TQLayoutItem *ButtonFlowLayoutIterator::current() { return idx < int(count()) ? list->at(idx) : 0; } -QLayoutItem *ButtonFlowLayoutIterator::next() +TQLayoutItem *ButtonFlowLayoutIterator::next() { idx++; return current(); } -QLayoutItem *ButtonFlowLayoutIterator::takeCurrent() +TQLayoutItem *ButtonFlowLayoutIterator::takeCurrent() { return idx < int(count()) ? list->take( idx ) : 0; } /**************************************************************/ -ButtonFlowLayout::ButtonFlowLayout( QWidget *parent, int margin, int spacing, +ButtonFlowLayout::ButtonFlowLayout( TQWidget *tqparent, int margin, int spacing, const char *name ) - : QLayout( parent, margin, spacing, name ), + : TQLayout( tqparent, margin, spacing, name ), cached_width(0) { } -ButtonFlowLayout::ButtonFlowLayout( QLayout* parentLayout, int spacing, const char *name ) - : QLayout( parentLayout, spacing, name ), +ButtonFlowLayout::ButtonFlowLayout( TQLayout* tqparentLayout, int spacing, const char *name ) + : TQLayout( tqparentLayout, spacing, name ), cached_width(0) { } ButtonFlowLayout::ButtonFlowLayout( int spacing, const char *name ) - : QLayout( spacing, name ), + : TQLayout( spacing, name ), cached_width(0) { } @@ -86,7 +86,7 @@ int ButtonFlowLayout::heightForWidth( int w ) const if ( cached_width != w ) { //Not all C++ compilers support "mutable" yet: ButtonFlowLayout * mthis = (ButtonFlowLayout*)this; - int h = mthis->doLayout( QRect(0,0,w,0), TRUE ); + int h = mthis->doLayout( TQRect(0,0,w,0), TRUE ); mthis->cached_hfw = h; mthis->cached_width = w; return h; @@ -96,7 +96,7 @@ int ButtonFlowLayout::heightForWidth( int w ) const void ButtonFlowLayout::addItem( QLayoutItem *item) { - list.append( item ); + list.append( TQT_TQLAYOUTITEM(item) ); } bool ButtonFlowLayout::hasHeightForWidth() const @@ -104,30 +104,36 @@ bool ButtonFlowLayout::hasHeightForWidth() const return TRUE; } -QSize ButtonFlowLayout::sizeHint() const +TQSize ButtonFlowLayout::tqsizeHint() const { - return minimumSize(); + return tqminimumSize(); } -QSizePolicy::ExpandData ButtonFlowLayout::expanding() const +TQSizePolicy::ExpandData ButtonFlowLayout::expanding() const { - return QSizePolicy::NoDirection; + return TQ_SPNoDirection; } -QLayoutIterator ButtonFlowLayout::iterator() +TQLayoutIterator ButtonFlowLayout::iterator() { - return QLayoutIterator( new ButtonFlowLayoutIterator( &list ) ); + // [FIXME] +#ifdef USE_QT4 + #warning [FIXME] ContainerAreaLayout iterators may not function correctly under Qt4 + return TQLayoutIterator( this ); // [FIXME] +#else // USE_QT4 + return TQLayoutIterator( new ButtonFlowLayoutIterator( &list ) ); +#endif // USE_QT4 } -void ButtonFlowLayout::setGeometry( const QRect &r ) +void ButtonFlowLayout::setGeometry( const TQRect &r ) { - QLayout::setGeometry( r ); + TQLayout::setGeometry( r ); doLayout( r ); } -int ButtonFlowLayout::doLayout( const QRect &r, bool testonly ) +int ButtonFlowLayout::doLayout( const TQRect &r, bool testonly ) { -/* kdDebug() << "buttonflowlayout::doLayout (" +/* kdDebug() << "buttonflowtqlayout::doLayout (" << r.x() << "," << r.y() << "," << r.width() << "," << r.height() << ", " << testonly << ")\n"; */ @@ -140,16 +146,16 @@ int ButtonFlowLayout::doLayout( const QRect &r, bool testonly ) int totalWidth = r.width(); int totalHeight = r.height(); - QPtrListIterator<QLayoutItem> it(list); - QLayoutItem *o; + TQPtrListIterator<TQLayoutItem> it(list); + TQLayoutItem *o; // get the width of the biggest Button it.toFirst(); while ( (o=it.current()) != 0 ) { ++it; - buttonWidth = QMAX( buttonWidth, o->sizeHint().width() ); - buttonHeight = QMAX( buttonHeight, o->sizeHint().height() ); + buttonWidth = TQMAX( buttonWidth, o->tqsizeHint().width() ); + buttonHeight = TQMAX( buttonHeight, o->tqsizeHint().height() ); } // calculate the optimal width @@ -195,13 +201,13 @@ int ButtonFlowLayout::doLayout( const QRect &r, bool testonly ) linecount++; } if (!testonly) - o->setGeometry( QRect( QPoint( btnLeft, (int)rint(y) ), - QSize( btnRight - btnLeft + 1, + o->setGeometry( TQRect( TQPoint( btnLeft, (int)rint(y) ), + TQSize( btnRight - btnLeft + 1, buttonHeight) ) ); x += buttonWidth + spacing(); - h = QMAX( h, buttonHeight ); + h = TQMAX( h, buttonHeight ); } int ret = (int)rint(y + h + deltaH) - r.y(); @@ -211,22 +217,52 @@ int ButtonFlowLayout::doLayout( const QRect &r, bool testonly ) } -QSize ButtonFlowLayout::minimumSize() const +TQSize ButtonFlowLayout::tqminimumSize() const { - return minimumSize(geometry().size()); + return tqminimumSize(tqgeometry().size()); } -QSize ButtonFlowLayout::minimumSize(const QSize &r) const +TQSize ButtonFlowLayout::tqminimumSize(const TQSize &r) const { - QSize s(0, 0); + TQSize s(0, 0); - for (QPtrListIterator<QLayoutItem> it(list); it.current(); ++it) { - QLayoutItem *o = it.current(); - s = s.expandedTo( o->sizeHint()); //minimumSize() ); + for (TQPtrListIterator<TQLayoutItem> it(list); it.current(); ++it) { + TQLayoutItem *o = it.current(); + s = s.expandedTo( o->tqsizeHint()); //tqminimumSize() ); } s.setHeight(heightForWidth(r.width())); return s; } + +#ifdef USE_QT4 +/*! + \reimp +*/ +int ButtonFlowLayout::count() const { + return list.count(); +} + +/*! + \reimp +*/ +TQLayoutItem* ButtonFlowLayout::itemAt(int index) const { + return index >= 0 && index < list.count() ? (const_cast<TQPtrList<TQLayoutItem>&>(list).tqat(index)) : 0; +} + +/*! + \reimp +*/ +TQLayoutItem* ButtonFlowLayout::takeAt(int index) { + if (index < 0 || index >= list.count()) + return 0; + TQLayoutItem *item = list.tqat(index); + list.remove(list.tqat(index)); + delete item; + + invalidate(); + return item; +} +#endif // USE_QT4
\ No newline at end of file |