|
|
|
@ -156,7 +156,7 @@ bool FlowLayout::moveItem(const TQLayoutItem* which, const TQLayoutItem* relate,
|
|
|
|
|
newPos += direction;
|
|
|
|
|
// actually reinsert the item
|
|
|
|
|
mLayoutItems.insert(newPos, which);
|
|
|
|
|
activate(); // relayout
|
|
|
|
|
activate(); // retqlayout
|
|
|
|
|
// kdDebug() << "oldPos: " << oldPos << ", newPos: " << newPos << endl;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -181,25 +181,25 @@ bool FlowLayout::hasWidthForHeight() const{
|
|
|
|
|
return mOrientation == Qt::Horizontal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQSize FlowLayout::sizeHint() const{
|
|
|
|
|
//return minimumSize();
|
|
|
|
|
TQSize FlowLayout::tqsizeHint() const{
|
|
|
|
|
//return tqminimumSize();
|
|
|
|
|
TQSize size(0,0);
|
|
|
|
|
TQPtrListIterator<TQLayoutItem> it(mLayoutItems);
|
|
|
|
|
TQLayoutItem *o;
|
|
|
|
|
while((o=it.current()) != 0){
|
|
|
|
|
++it;
|
|
|
|
|
size = size.expandedTo( o->sizeHint() );
|
|
|
|
|
size = size.expandedTo( o->tqsizeHint() );
|
|
|
|
|
}
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQSize FlowLayout::minimumSize() const{
|
|
|
|
|
TQSize FlowLayout::tqminimumSize() const{
|
|
|
|
|
TQSize size(0,0);
|
|
|
|
|
TQPtrListIterator<TQLayoutItem> it(mLayoutItems);
|
|
|
|
|
TQLayoutItem *o;
|
|
|
|
|
while((o=it.current()) != 0){
|
|
|
|
|
++it;
|
|
|
|
|
size = size.expandedTo(o->minimumSize());
|
|
|
|
|
size = size.expandedTo(o->tqminimumSize());
|
|
|
|
|
}
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
@ -250,32 +250,32 @@ int FlowLayout::doLayoutHorizontal( const TQRect& rect, bool testOnly ){
|
|
|
|
|
TQPtrList<TQLayoutItem> column; // stores the items of one column
|
|
|
|
|
while((layoutItem = it.current()) != 0){
|
|
|
|
|
++it;
|
|
|
|
|
//int nextY = y + layoutItem->sizeHint().height() + spacing(); // next y
|
|
|
|
|
int nextY = y + layoutItem->sizeHint().height(); // next y
|
|
|
|
|
//int nextY = y + layoutItem->tqsizeHint().height() + spacing(); // next y
|
|
|
|
|
int nextY = y + layoutItem->tqsizeHint().height(); // next y
|
|
|
|
|
//if( nextY - spacing() > rect.bottom() && width > 0 ) {
|
|
|
|
|
if( nextY > rect.bottom() && width > 0 ) {
|
|
|
|
|
// next column
|
|
|
|
|
y = rect.y(); // reset y
|
|
|
|
|
x = x + width + spacing(); // new x
|
|
|
|
|
//nextY = y + layoutItem->sizeHint().height() + spacing(); // next y with changed y
|
|
|
|
|
nextY = y + layoutItem->sizeHint().height(); // next y with changed y
|
|
|
|
|
//nextY = y + layoutItem->tqsizeHint().height() + spacing(); // next y with changed y
|
|
|
|
|
nextY = y + layoutItem->tqsizeHint().height(); // next y with changed y
|
|
|
|
|
width = 0; // reset width for the next column
|
|
|
|
|
}
|
|
|
|
|
if(!testOnly){
|
|
|
|
|
layoutItem->setGeometry( TQRect( TQPoint( x, y ), layoutItem->sizeHint() ) );
|
|
|
|
|
layoutItem->setGeometry( TQRect( TQPoint( x, y ), layoutItem->tqsizeHint() ) );
|
|
|
|
|
column.append(layoutItem);
|
|
|
|
|
height += layoutItem->sizeHint().height(); // add the height of the current item to the column height
|
|
|
|
|
if( it.current() == 0 || nextY + it.current()->sizeHint().height() > rect.bottom() ){ // test it it's the last item (of this column)
|
|
|
|
|
height += layoutItem->tqsizeHint().height(); // add the height of the current item to the column height
|
|
|
|
|
if( it.current() == 0 || nextY + it.current()->tqsizeHint().height() > rect.bottom() ){ // test it it's the last item (of this column)
|
|
|
|
|
// calculate real needed width
|
|
|
|
|
int rWidth = 0;
|
|
|
|
|
for(TQLayoutItem* item = column.first(); item; item = column.next()){
|
|
|
|
|
rWidth = TQMAX( rWidth, item->widget()->sizeHint().width() );
|
|
|
|
|
rWidth = TQMAX( rWidth, item->widget()->tqsizeHint().width() );
|
|
|
|
|
}
|
|
|
|
|
// relayout the items of the former column
|
|
|
|
|
// retqlayout the items of the former column
|
|
|
|
|
int space = (rect.height() - height) / (column.count() + 1);
|
|
|
|
|
int i = 0; // counts the items of this column
|
|
|
|
|
for(TQLayoutItem* item = column.first(); item; item = column.next()){
|
|
|
|
|
TQRect r = item->geometry();
|
|
|
|
|
TQRect r = item->tqgeometry();
|
|
|
|
|
item->setGeometry( TQRect(r.left(), r.top() + ((++i) * space), rWidth, r.height()) );
|
|
|
|
|
}
|
|
|
|
|
column.clear(); // remove the items of the former column
|
|
|
|
@ -283,7 +283,7 @@ int FlowLayout::doLayoutHorizontal( const TQRect& rect, bool testOnly ){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
y = nextY;
|
|
|
|
|
width = TQMAX( width, layoutItem->sizeHint().width() );
|
|
|
|
|
width = TQMAX( width, layoutItem->tqsizeHint().width() );
|
|
|
|
|
}
|
|
|
|
|
return x + width - rect.x(); // width
|
|
|
|
|
}
|
|
|
|
@ -296,18 +296,18 @@ int FlowLayout::doLayoutVertical( const TQRect& rect, bool testOnly ){
|
|
|
|
|
TQLayoutItem* layoutItem;
|
|
|
|
|
while((layoutItem = it.current() ) != 0){
|
|
|
|
|
++it;
|
|
|
|
|
//int nextX = x + layoutItem->sizeHint().width() + spacing();
|
|
|
|
|
int nextX = x + layoutItem->sizeHint().width();
|
|
|
|
|
//int nextX = x + layoutItem->tqsizeHint().width() + spacing();
|
|
|
|
|
int nextX = x + layoutItem->tqsizeHint().width();
|
|
|
|
|
if(nextX - spacing() > rect.right() && height > 0) {
|
|
|
|
|
// next line
|
|
|
|
|
x = rect.x(); // reset x
|
|
|
|
|
//y = y + height + spacing(); // new y
|
|
|
|
|
y = y + height; // new y
|
|
|
|
|
//nextX = x + layoutItem->sizeHint().width() + spacing(); // next x
|
|
|
|
|
nextX = x + layoutItem->sizeHint().width(); // next x
|
|
|
|
|
//nextX = x + layoutItem->tqsizeHint().width() + spacing(); // next x
|
|
|
|
|
nextX = x + layoutItem->tqsizeHint().width(); // next x
|
|
|
|
|
height = 0; // reset height for the next line
|
|
|
|
|
}
|
|
|
|
|
const int itemHeight = layoutItem->sizeHint().height();
|
|
|
|
|
const int itemHeight = layoutItem->tqsizeHint().height();
|
|
|
|
|
if(!testOnly)
|
|
|
|
|
layoutItem->setGeometry(TQRect(x, y, rect.right(), itemHeight));
|
|
|
|
|
x = nextX;
|
|
|
|
@ -328,7 +328,7 @@ int FlowLayout::count() const {
|
|
|
|
|
\reimp
|
|
|
|
|
*/
|
|
|
|
|
TQLayoutItem* FlowLayout::itemAt(int index) const {
|
|
|
|
|
return index >= 0 && index < mLayoutItems.count() ? (const_cast<TQPtrList<TQLayoutItem>&>(mLayoutItems).at(index)) : 0;
|
|
|
|
|
return index >= 0 && index < mLayoutItems.count() ? (const_cast<TQPtrList<TQLayoutItem>&>(mLayoutItems).tqat(index)) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@ -337,8 +337,8 @@ TQLayoutItem* FlowLayout::itemAt(int index) const {
|
|
|
|
|
TQLayoutItem* FlowLayout::takeAt(int index) {
|
|
|
|
|
if (index < 0 || index >= mLayoutItems.count())
|
|
|
|
|
return 0;
|
|
|
|
|
TQLayoutItem *item = mLayoutItems.at(index);
|
|
|
|
|
mLayoutItems.remove(mLayoutItems.at(index));
|
|
|
|
|
TQLayoutItem *item = mLayoutItems.tqat(index);
|
|
|
|
|
mLayoutItems.remove(mLayoutItems.tqat(index));
|
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
|
|
invalidate();
|
|
|
|
|