code duplication removed
This commit is contained in:
parent
44368f97a8
commit
f1600a396d
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue