QSize StatusBarLayout::minimumSize() const { if( mIsDirty ) updateLayoutStructs(); return QSize( 0, mSizeHint.height() ); }
QSize StatusBarLayout::sizeHint() const { if( mIsDirty ) updateLayoutStructs(); return mSizeHint; }
bool StatusBarLayout::isEmpty() const { if( mIsDirty ) updateLayoutStructs(); return mIsEmpty; }
void StatusBarLayout::setGeometry( const QRect& _rect ) { QLayout::setGeometry( _rect ); if( mIsDirty ) updateLayoutStructs(); QRect rect( 0, 0, _rect.width(), _rect.height() ); const int margin = 0;//this->margin(); const int spacing = this->spacing(); int availableWidth = rect.size().width() - 2*margin; const int availableHeight = rect.size().height() - 2*margin; int usedWidth = 0; int visibleCount = 0; int i; for( i = 0; i<mWidgetList.count(); ++i ) { QWidgetItem* item = mWidgetList.at( i ); QWidget* widget = item->widget(); // TODO: is there really no way to get to the geometry data if a widget is hidden? if( widget->isHidden() ) widget->show(); const int itemWidth = item->sizeHint().width(); const int itemSpacing = ( visibleCount == 0 ) ? 0 : spacing; const int newUsedWidth = usedWidth + itemSpacing + itemWidth; // kDebug()<<widget<<<<availableWidth<<usedWidth<<itemWidth<<itemSpacing<<newUsedWidth; const bool isTooWide = ( newUsedWidth > availableWidth ); if( isTooWide ) break; const QPoint pos( margin + usedWidth, margin ); const QSize size( itemWidth, availableHeight ); QRect r( pos, size ); r = QStyle::visualRect( parentWidget()->layoutDirection(), rect, r ); item->setGeometry( r ); usedWidth = newUsedWidth; ++visibleCount; } // hide the rest if needed for( ; i<mWidgetList.count(); ++i ) { QWidgetItem* item = mWidgetList.at( i ); QWidget* widget = item->widget(); if( ! widget->isHidden() ) widget->hide(); } }
QSize StatusBarLayout::sizeHint() const { updateLayoutStructs(); return mSizeHint; }