summaryrefslogtreecommitdiffstats
path: root/kworldwatch/flow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kworldwatch/flow.cpp')
-rw-r--r--kworldwatch/flow.cpp66
1 files changed, 53 insertions, 13 deletions
diff --git a/kworldwatch/flow.cpp b/kworldwatch/flow.cpp
index adce999..c511919 100644
--- a/kworldwatch/flow.cpp
+++ b/kworldwatch/flow.cpp
@@ -1,18 +1,18 @@
/****************************************************************************
** $Id$
**
-** 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.
**
*****************************************************************************/
#include "flow.h"
-class SimpleFlowIterator :public QGLayoutIterator
+class SimpleFlowIterator :public TQGLayoutIterator
{
public:
SimpleFlowIterator( TQPtrList<TQLayoutItem> *l ) :idx(0), list(l) {}
@@ -66,9 +66,9 @@ int SimpleFlow::heightForWidth( int w ) const
return cached_hfw;
}
-void SimpleFlow::addItem( TQLayoutItem *item)
+void SimpleFlow::addItem( QLayoutItem *item)
{
- list.append( item );
+ list.append( TQT_TQLAYOUTITEM(item) );
}
bool SimpleFlow::hasHeightForWidth() const
@@ -76,19 +76,29 @@ bool SimpleFlow::hasHeightForWidth() const
return TRUE;
}
-TQSize SimpleFlow::sizeHint() const
+TQSize SimpleFlow::tqsizeHint() const
{
- return minimumSize();
+ return tqminimumSize();
}
TQSizePolicy::ExpandData SimpleFlow::expanding() const
{
+#ifdef USE_QT4
+ return (Qt::Orientation)TQSizePolicy::NoDirection;
+#else // USE_QT4
return TQSizePolicy::NoDirection;
+#endif // USE_QT4
}
TQLayoutIterator SimpleFlow::iterator()
{
+ // [FIXME]
+#ifdef USE_QT4
+ #warning [FIXME] ContainerAreaLayout iterators may not function correctly under Qt4
+ return TQLayoutIterator(this); // [FIXME]
+#else // USE_QT4
return TQLayoutIterator( new SimpleFlowIterator( &list ) );
+#endif // USE_QT4
}
void SimpleFlow::setGeometry( const TQRect &r )
@@ -106,30 +116,60 @@ int SimpleFlow::doLayout( const TQRect &r, bool testonly )
TQLayoutItem *o;
while ( (o=it.current()) != 0 ) {
++it;
- int nextX = x + o->sizeHint().width() + spacing();
+ int nextX = x + o->tqsizeHint().width() + spacing();
if ( nextX - spacing() > r.right() && h > 0 ) {
x = r.x();
y = y + h + spacing();
- nextX = x + o->sizeHint().width() + spacing();
+ nextX = x + o->tqsizeHint().width() + spacing();
h = 0;
}
if ( !testonly )
- o->setGeometry( TQRect( TQPoint( x, y ), o->sizeHint() ) );
+ o->setGeometry( TQRect( TQPoint( x, y ), o->tqsizeHint() ) );
x = nextX;
- h = QMAX( h, o->sizeHint().height() );
+ h = TQMAX( h, o->tqsizeHint().height() );
}
return y + h - r.y();
}
-TQSize SimpleFlow::minimumSize() const
+TQSize SimpleFlow::tqminimumSize() const
{
TQSize s(0,0);
TQPtrListIterator<TQLayoutItem> it(list);
TQLayoutItem *o;
while ( (o=it.current()) != 0 ) {
++it;
- s = s.expandedTo( o->minimumSize() );
+ s = s.expandedTo( o->tqminimumSize() );
}
return s;
}
+#ifdef USE_QT4
+/*!
+ \reimp
+*/
+int SimpleFlow::count() const {
+ return list.count();
+}
+
+/*!
+ \reimp
+*/
+TQLayoutItem* SimpleFlow::itemAt(int index) const {
+ return index >= 0 && index < list.count() ? (const_cast<TQPtrList<TQLayoutItem>&>(list).tqat(index)) : 0;
+}
+
+/*!
+ \reimp
+*/
+TQLayoutItem* SimpleFlow::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
+