code duplication removed
This commit is contained in:
parent
44368f97a8
commit
f1600a396d
|
@ -425,39 +425,6 @@ bool QskGridBox::retainSizeWhenHidden( QQuickItem* item ) const
|
||||||
return false;
|
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(
|
void QskGridBox::setRowSizeHint(
|
||||||
Qt::SizeHint which, int row, qreal size, Qt::Orientation orientation )
|
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 bool retainSizeWhenHidden( QQuickItem* ) const;
|
||||||
Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem*, bool on );
|
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:
|
Q_SIGNALS:
|
||||||
void verticalSpacingChanged();
|
void verticalSpacingChanged();
|
||||||
void horizontalSpacingChanged();
|
void horizontalSpacingChanged();
|
||||||
|
|
|
@ -250,6 +250,44 @@ QRectF QskLayoutBox::alignedLayoutRect( const QRectF& rect ) const
|
||||||
return rect;
|
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 )
|
void QskLayoutBox::geometryChangeEvent( QskGeometryChangeEvent* event )
|
||||||
{
|
{
|
||||||
Inherited::geometryChangeEvent( event );
|
Inherited::geometryChangeEvent( event );
|
||||||
|
|
|
@ -39,6 +39,11 @@ class QSK_EXPORT QskLayoutBox : public QskControl
|
||||||
void adjustItem( const QQuickItem* );
|
void adjustItem( const QQuickItem* );
|
||||||
void adjustItemAt( int index );
|
void adjustItemAt( int index );
|
||||||
|
|
||||||
|
QSizeF contentsSizeHint() const override;
|
||||||
|
|
||||||
|
qreal heightForWidth( qreal width ) const override;
|
||||||
|
qreal widthForHeight( qreal height ) const override;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void activate();
|
void activate();
|
||||||
void invalidate();
|
void invalidate();
|
||||||
|
@ -62,6 +67,7 @@ class QSK_EXPORT QskLayoutBox : public QskControl
|
||||||
virtual void layoutItemRemoved( QskLayoutItem*, int index );
|
virtual void layoutItemRemoved( QskLayoutItem*, int index );
|
||||||
|
|
||||||
virtual QRectF alignedLayoutRect( const QRectF& ) const;
|
virtual QRectF alignedLayoutRect( const QRectF& ) const;
|
||||||
|
virtual QSizeF layoutItemsSizeHint() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
|
|
|
@ -320,39 +320,6 @@ int QskLinearBox::columnStretchFactor( int column ) const
|
||||||
return engine().rowStretchFactor( column, Qt::Horizontal );
|
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 )
|
void QskLinearBox::setupLayoutItem( QskLayoutItem* layoutItem, int index )
|
||||||
{
|
{
|
||||||
int col = index % m_data->dimension;
|
int col = index % m_data->dimension;
|
||||||
|
|
|
@ -72,11 +72,6 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
|
||||||
Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* ) const;
|
Q_INVOKABLE bool retainSizeWhenHidden( QQuickItem* ) const;
|
||||||
Q_INVOKABLE void setRetainSizeWhenHidden( QQuickItem*, bool on );
|
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
|
#if 1
|
||||||
Q_INVOKABLE void setRowSpacing( int row, qreal spacing );
|
Q_INVOKABLE void setRowSpacing( int row, qreal spacing );
|
||||||
Q_INVOKABLE qreal rowSpacing( int row ) const;
|
Q_INVOKABLE qreal rowSpacing( int row ) const;
|
||||||
|
|
|
@ -139,7 +139,7 @@ void QskStackBox::setCurrentIndex( int index )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// stop and complete the running transition
|
// stop and complete the running transition
|
||||||
QskStackBoxAnimator* animator = effectiveAnimator();
|
auto animator = effectiveAnimator();
|
||||||
if ( animator )
|
if ( animator )
|
||||||
animator->stop();
|
animator->stop();
|
||||||
|
|
||||||
|
@ -158,8 +158,8 @@ void QskStackBox::setCurrentIndex( int index )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QQuickItem* item1 = itemAtIndex( m_data->currentIndex );
|
auto item1 = itemAtIndex( m_data->currentIndex );
|
||||||
QQuickItem* item2 = itemAtIndex( index );
|
auto item2 = itemAtIndex( index );
|
||||||
|
|
||||||
if ( item1 )
|
if ( item1 )
|
||||||
item1->setVisible( false );
|
item1->setVisible( false );
|
||||||
|
@ -177,24 +177,18 @@ void QskStackBox::setCurrentItem( const QQuickItem* item )
|
||||||
setCurrentIndex( indexOf( 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 width = -1;
|
||||||
qreal height = -1;
|
qreal height = -1;
|
||||||
|
|
||||||
QSizeF constraint( -1, -1 );
|
QSizeF constraint( -1, -1 );
|
||||||
Qt::Orientations constraintOrientation = 0;
|
Qt::Orientations constraintOrientation = 0;
|
||||||
|
|
||||||
const QskLayoutEngine& engine = this->engine();
|
const auto& engine = this->engine();
|
||||||
for ( int i = 0; i < engine.itemCount(); i++ )
|
for ( int i = 0; i < engine.itemCount(); i++ )
|
||||||
{
|
{
|
||||||
const QskLayoutItem* layoutItem = engine.layoutItemAt( i );
|
const auto layoutItem = engine.layoutItemAt( i );
|
||||||
|
|
||||||
if ( layoutItem->hasDynamicConstraint() )
|
if ( layoutItem->hasDynamicConstraint() )
|
||||||
{
|
{
|
||||||
|
@ -221,7 +215,7 @@ QSizeF QskStackBox::contentsSizeHint() const
|
||||||
|
|
||||||
for ( int i = 0; i < engine.itemCount(); i++ )
|
for ( int i = 0; i < engine.itemCount(); i++ )
|
||||||
{
|
{
|
||||||
const QskLayoutItem* layoutItem = engine.layoutItemAt( i );
|
const auto layoutItem = engine.layoutItemAt( i );
|
||||||
|
|
||||||
if ( layoutItem->hasDynamicConstraint() &&
|
if ( layoutItem->hasDynamicConstraint() &&
|
||||||
layoutItem->dynamicConstraintOrientation() == Qt::Horizontal )
|
layoutItem->dynamicConstraintOrientation() == Qt::Horizontal )
|
||||||
|
@ -240,7 +234,7 @@ QSizeF QskStackBox::contentsSizeHint() const
|
||||||
|
|
||||||
for ( int i = 0; i < engine.itemCount(); i++ )
|
for ( int i = 0; i < engine.itemCount(); i++ )
|
||||||
{
|
{
|
||||||
const QskLayoutItem* layoutItem = engine.layoutItemAt( i );
|
const auto layoutItem = engine.layoutItemAt( i );
|
||||||
|
|
||||||
if ( layoutItem->hasDynamicConstraint() &&
|
if ( layoutItem->hasDynamicConstraint() &&
|
||||||
layoutItem->dynamicConstraintOrientation() == Qt::Vertical )
|
layoutItem->dynamicConstraintOrientation() == Qt::Vertical )
|
||||||
|
|
|
@ -31,8 +31,6 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox
|
||||||
QQuickItem* currentItem() const;
|
QQuickItem* currentItem() const;
|
||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
|
|
||||||
QSizeF contentsSizeHint() const override;
|
|
||||||
|
|
||||||
qreal heightForWidth( qreal width ) const override;
|
qreal heightForWidth( qreal width ) const override;
|
||||||
qreal widthForHeight( qreal height ) const override;
|
qreal widthForHeight( qreal height ) const override;
|
||||||
|
|
||||||
|
@ -50,6 +48,7 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QskStackBoxAnimator* effectiveAnimator();
|
QskStackBoxAnimator* effectiveAnimator();
|
||||||
|
QSizeF layoutItemsSizeHint() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QskStackBoxAnimator;
|
friend class QskStackBoxAnimator;
|
||||||
|
|
Loading…
Reference in New Issue