diff --git a/src/layouts/QskGridBox.cpp b/src/layouts/QskGridBox.cpp index d180ea7c..dd327b23 100644 --- a/src/layouts/QskGridBox.cpp +++ b/src/layouts/QskGridBox.cpp @@ -425,39 +425,6 @@ bool QskGridBox::retainSizeWhenHidden( QQuickItem* item ) const return false; } -QSizeF QskGridBox::contentsSizeHint() const -{ - if ( !isActive() ) - return QSizeF( -1, -1 ); - - if ( itemCount() == 0 ) - return QSizeF( 0, 0 ); - - return engine().sizeHint( Qt::PreferredSize ); -} - -qreal QskGridBox::heightForWidth( qreal width ) const -{ - const auto m = margins(); - width -= m.left() + m.right(); - - qreal height = engine().heightForWidth( width ); - - height += m.top() + m.bottom(); - return height; -} - -qreal QskGridBox::widthForHeight( qreal height ) const -{ - const auto m = margins(); - height -= m.top() + m.bottom(); - - qreal width = engine().widthForHeight( height ); - - width += m.left() + m.right(); - return width; -} - void QskGridBox::setRowSizeHint( Qt::SizeHint which, int row, qreal size, Qt::Orientation orientation ) { diff --git a/src/layouts/QskGridBox.h b/src/layouts/QskGridBox.h index 22e3ee41..d3b6c577 100644 --- a/src/layouts/QskGridBox.h +++ b/src/layouts/QskGridBox.h @@ -113,11 +113,6 @@ class QSK_EXPORT QskGridBox : public QskLayoutBox Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* ) const; Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem*, bool on ); - qreal heightForWidth( qreal width ) const override; - qreal widthForHeight( qreal height ) const override; - - QSizeF contentsSizeHint() const override; - Q_SIGNALS: void verticalSpacingChanged(); void horizontalSpacingChanged(); diff --git a/src/layouts/QskLayoutBox.cpp b/src/layouts/QskLayoutBox.cpp index 7ca60599..447485bd 100644 --- a/src/layouts/QskLayoutBox.cpp +++ b/src/layouts/QskLayoutBox.cpp @@ -250,6 +250,44 @@ QRectF QskLayoutBox::alignedLayoutRect( const QRectF& rect ) const return rect; } +QSizeF QskLayoutBox::contentsSizeHint() const +{ + if ( !isActive() ) + return QSizeF( -1, -1 ); + + if ( itemCount() == 0 ) + return QSizeF( 0, 0 ); + + return layoutItemsSizeHint(); +} + +QSizeF QskLayoutBox::layoutItemsSizeHint() const +{ + return engine().sizeHint( Qt::PreferredSize ); +} + +qreal QskLayoutBox::heightForWidth( qreal width ) const +{ + const auto m = margins(); + width -= m.left() + m.right(); + + qreal height = engine().heightForWidth( width ); + + height += m.top() + m.bottom(); + return height; +} + +qreal QskLayoutBox::widthForHeight( qreal height ) const +{ + const auto m = margins(); + height -= m.top() + m.bottom(); + + qreal width = engine().widthForHeight( height ); + + width += m.left() + m.right(); + return width; +} + void QskLayoutBox::geometryChangeEvent( QskGeometryChangeEvent* event ) { Inherited::geometryChangeEvent( event ); diff --git a/src/layouts/QskLayoutBox.h b/src/layouts/QskLayoutBox.h index 0bac68a7..e80cc894 100644 --- a/src/layouts/QskLayoutBox.h +++ b/src/layouts/QskLayoutBox.h @@ -39,6 +39,11 @@ class QSK_EXPORT QskLayoutBox : public QskControl void adjustItem( const QQuickItem* ); void adjustItemAt( int index ); + QSizeF contentsSizeHint() const override; + + qreal heightForWidth( qreal width ) const override; + qreal widthForHeight( qreal height ) const override; + public Q_SLOTS: void activate(); void invalidate(); @@ -62,6 +67,7 @@ class QSK_EXPORT QskLayoutBox : public QskControl virtual void layoutItemRemoved( QskLayoutItem*, int index ); virtual QRectF alignedLayoutRect( const QRectF& ) const; + virtual QSizeF layoutItemsSizeHint() const; private: class PrivateData; diff --git a/src/layouts/QskLinearBox.cpp b/src/layouts/QskLinearBox.cpp index 2648e4f9..84ab5841 100644 --- a/src/layouts/QskLinearBox.cpp +++ b/src/layouts/QskLinearBox.cpp @@ -320,39 +320,6 @@ int QskLinearBox::columnStretchFactor( int column ) const return engine().rowStretchFactor( column, Qt::Horizontal ); } -QSizeF QskLinearBox::contentsSizeHint() const -{ - if ( !isActive() ) - return QSizeF( -1, -1 ); - - if ( itemCount() == 0 ) - return QSizeF( 0, 0 ); - - return engine().sizeHint( Qt::PreferredSize ); -} - -qreal QskLinearBox::heightForWidth( qreal width ) const -{ - const auto m = margins(); - width -= m.left() + m.right(); - - qreal height = engine().heightForWidth( width ); - - height += m.top() + m.bottom(); - return height; -} - -qreal QskLinearBox::widthForHeight( qreal height ) const -{ - const auto m = margins(); - height -= m.top() + m.bottom(); - - qreal width = engine().widthForHeight( height ); - - width += m.left() + m.right(); - return width; -} - void QskLinearBox::setupLayoutItem( QskLayoutItem* layoutItem, int index ) { int col = index % m_data->dimension; diff --git a/src/layouts/QskLinearBox.h b/src/layouts/QskLinearBox.h index be16d7ad..67181591 100644 --- a/src/layouts/QskLinearBox.h +++ b/src/layouts/QskLinearBox.h @@ -72,11 +72,6 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* ) const; Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem*, bool on ); - QSizeF contentsSizeHint() const override; - - qreal heightForWidth( qreal width ) const override; - qreal widthForHeight( qreal height ) const override; - #if 1 Q_INVOKABLE void setRowSpacing( int row, qreal spacing ); Q_INVOKABLE qreal rowSpacing( int row ) const; diff --git a/src/layouts/QskStackBox.cpp b/src/layouts/QskStackBox.cpp index c7529035..20ea3c1d 100644 --- a/src/layouts/QskStackBox.cpp +++ b/src/layouts/QskStackBox.cpp @@ -139,7 +139,7 @@ void QskStackBox::setCurrentIndex( int index ) return; // stop and complete the running transition - QskStackBoxAnimator* animator = effectiveAnimator(); + auto animator = effectiveAnimator(); if ( animator ) animator->stop(); @@ -158,8 +158,8 @@ void QskStackBox::setCurrentIndex( int index ) } else { - QQuickItem* item1 = itemAtIndex( m_data->currentIndex ); - QQuickItem* item2 = itemAtIndex( index ); + auto item1 = itemAtIndex( m_data->currentIndex ); + auto item2 = itemAtIndex( index ); if ( item1 ) item1->setVisible( false ); @@ -177,24 +177,18 @@ void QskStackBox::setCurrentItem( const QQuickItem* item ) setCurrentIndex( indexOf( item ) ); } -QSizeF QskStackBox::contentsSizeHint() const +QSizeF QskStackBox::layoutItemsSizeHint() const { - if ( !isActive() ) - return QSizeF( -1, -1 ); - - if ( itemCount() == 0 ) - return QSizeF( 0, 0 ); - qreal width = -1; qreal height = -1; QSizeF constraint( -1, -1 ); Qt::Orientations constraintOrientation = 0; - const QskLayoutEngine& engine = this->engine(); + const auto& engine = this->engine(); for ( int i = 0; i < engine.itemCount(); i++ ) { - const QskLayoutItem* layoutItem = engine.layoutItemAt( i ); + const auto layoutItem = engine.layoutItemAt( i ); if ( layoutItem->hasDynamicConstraint() ) { @@ -221,7 +215,7 @@ QSizeF QskStackBox::contentsSizeHint() const for ( int i = 0; i < engine.itemCount(); i++ ) { - const QskLayoutItem* layoutItem = engine.layoutItemAt( i ); + const auto layoutItem = engine.layoutItemAt( i ); if ( layoutItem->hasDynamicConstraint() && layoutItem->dynamicConstraintOrientation() == Qt::Horizontal ) @@ -240,7 +234,7 @@ QSizeF QskStackBox::contentsSizeHint() const for ( int i = 0; i < engine.itemCount(); i++ ) { - const QskLayoutItem* layoutItem = engine.layoutItemAt( i ); + const auto layoutItem = engine.layoutItemAt( i ); if ( layoutItem->hasDynamicConstraint() && layoutItem->dynamicConstraintOrientation() == Qt::Vertical ) diff --git a/src/layouts/QskStackBox.h b/src/layouts/QskStackBox.h index e138d2f5..fd7d2d25 100644 --- a/src/layouts/QskStackBox.h +++ b/src/layouts/QskStackBox.h @@ -31,8 +31,6 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox QQuickItem* currentItem() const; int currentIndex() const; - QSizeF contentsSizeHint() const override; - qreal heightForWidth( qreal width ) const override; qreal widthForHeight( qreal height ) const override; @@ -50,6 +48,7 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox protected: QskStackBoxAnimator* effectiveAnimator(); + QSizeF layoutItemsSizeHint() const override; private: friend class QskStackBoxAnimator;