QskLinearLayoutEngine setter indicating changes
This commit is contained in:
parent
16a67678f3
commit
4f48a3ab92
|
@ -290,15 +290,8 @@ bool QskLinearBox::event( QEvent* event )
|
|||
|
||||
void QskLinearBox::setDimension( uint dimension )
|
||||
{
|
||||
if ( dimension < 1 )
|
||||
dimension = 1;
|
||||
|
||||
auto& engine = m_data->engine;
|
||||
|
||||
if ( dimension != engine.dimension() )
|
||||
if ( m_data->engine.setDimension( dimension ) )
|
||||
{
|
||||
engine.setDimension( dimension );
|
||||
|
||||
polish();
|
||||
resetImplicitSize();
|
||||
|
||||
|
@ -313,12 +306,8 @@ uint QskLinearBox::dimension() const
|
|||
|
||||
void QskLinearBox::setOrientation( Qt::Orientation orientation )
|
||||
{
|
||||
auto& engine = m_data->engine;
|
||||
|
||||
if ( engine.orientation() != orientation )
|
||||
if ( m_data->engine.setOrientation( orientation ) )
|
||||
{
|
||||
engine.setOrientation( orientation );
|
||||
|
||||
polish();
|
||||
resetImplicitSize();
|
||||
|
||||
|
@ -356,13 +345,8 @@ void QskLinearBox::transpose()
|
|||
|
||||
void QskLinearBox::setDefaultAlignment( Qt::Alignment alignment )
|
||||
{
|
||||
auto& engine = m_data->engine;
|
||||
|
||||
if ( alignment != engine.defaultAlignment() )
|
||||
{
|
||||
engine.setDefaultAlignment( alignment );
|
||||
if ( m_data->engine.setDefaultAlignment( alignment ) )
|
||||
Q_EMIT defaultAlignmentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::Alignment QskLinearBox::defaultAlignment() const
|
||||
|
@ -377,15 +361,11 @@ void QskLinearBox::setSpacing( qreal spacing )
|
|||
but need to create an API for Qml in QskQml
|
||||
using qmlAttachedPropertiesObject then. TODO ...
|
||||
*/
|
||||
spacing = qMax( spacing, 0.0 );
|
||||
|
||||
auto& engine = m_data->engine;
|
||||
|
||||
if ( spacing != engine.spacing( Qt::Horizontal ) )
|
||||
if ( m_data->engine.setSpacing(
|
||||
spacing, Qt::Horizontal | Qt::Vertical ) )
|
||||
{
|
||||
engine.setSpacing( spacing, Qt::Horizontal | Qt::Vertical );
|
||||
polish();
|
||||
|
||||
Q_EMIT spacingChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -620,10 +620,13 @@ QskLinearLayoutEngine::~QskLinearLayoutEngine()
|
|||
{
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setOrientation( Qt::Orientation orientation )
|
||||
bool QskLinearLayoutEngine::setOrientation( Qt::Orientation orientation )
|
||||
{
|
||||
if ( m_data->entryTable.setOrientation( orientation ) )
|
||||
const bool isModified = m_data->entryTable.setOrientation( orientation );
|
||||
if ( isModified )
|
||||
invalidate( CellCache | LayoutCache );
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
Qt::Orientation QskLinearLayoutEngine::orientation() const
|
||||
|
@ -631,13 +634,18 @@ Qt::Orientation QskLinearLayoutEngine::orientation() const
|
|||
return m_data->entryTable.orientation();
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setDimension( uint dimension )
|
||||
bool QskLinearLayoutEngine::setDimension( uint dimension )
|
||||
{
|
||||
if ( dimension < 1 )
|
||||
dimension = 1;
|
||||
|
||||
if ( m_data->entryTable.setDimension( dimension ) )
|
||||
const bool isModified =
|
||||
m_data->entryTable.setDimension( dimension );
|
||||
|
||||
if ( isModified )
|
||||
invalidate( CellCache | LayoutCache );
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
uint QskLinearLayoutEngine::dimension() const
|
||||
|
@ -660,10 +668,15 @@ int QskLinearLayoutEngine::columnCount() const
|
|||
return m_data->entryTable.effectiveCount( Qt::Horizontal );
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setRetainSizeWhenHiddenAt( int index, bool on )
|
||||
bool QskLinearLayoutEngine::setRetainSizeWhenHiddenAt( int index, bool on )
|
||||
{
|
||||
if ( m_data->entryTable.setRetainSizeWhenHiddenAt( index, on ) )
|
||||
const bool isModified =
|
||||
m_data->entryTable.setRetainSizeWhenHiddenAt( index, on );
|
||||
|
||||
if ( isModified )
|
||||
invalidate( CellCache | LayoutCache );
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
bool QskLinearLayoutEngine::retainSizeWhenHiddenAt( int index ) const
|
||||
|
@ -671,10 +684,15 @@ bool QskLinearLayoutEngine::retainSizeWhenHiddenAt( int index ) const
|
|||
return m_data->entryTable.retainSizeWhenHiddenAt( index );
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setStretchFactorAt( int index, int stretchFactor )
|
||||
bool QskLinearLayoutEngine::setStretchFactorAt( int index, int stretchFactor )
|
||||
{
|
||||
if ( m_data->entryTable.setStretchFactorAt( index, stretchFactor ) )
|
||||
const bool isModified =
|
||||
m_data->entryTable.setStretchFactorAt( index, stretchFactor );
|
||||
|
||||
if ( isModified )
|
||||
invalidate( CellCache | LayoutCache );
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
int QskLinearLayoutEngine::stretchFactorAt( int index ) const
|
||||
|
@ -682,9 +700,9 @@ int QskLinearLayoutEngine::stretchFactorAt( int index ) const
|
|||
return m_data->entryTable.stretchFactorAt( index );
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setAlignmentAt( int index, Qt::Alignment alignment )
|
||||
bool QskLinearLayoutEngine::setAlignmentAt( int index, Qt::Alignment alignment )
|
||||
{
|
||||
m_data->entryTable.setAlignmentAt( index, alignment );
|
||||
return m_data->entryTable.setAlignmentAt( index, alignment );
|
||||
}
|
||||
|
||||
Qt::Alignment QskLinearLayoutEngine::alignmentAt( int index ) const
|
||||
|
@ -692,21 +710,23 @@ Qt::Alignment QskLinearLayoutEngine::alignmentAt( int index ) const
|
|||
return m_data->entryTable.alignmentAt( index );
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setSpacing( qreal spacing, Qt::Orientations orientations )
|
||||
bool QskLinearLayoutEngine::setSpacing( qreal spacing, Qt::Orientations orientations )
|
||||
{
|
||||
if ( spacing < 0.0 )
|
||||
spacing = 0.0;
|
||||
|
||||
bool doInvalidate = false;
|
||||
bool isModified = false;
|
||||
|
||||
if ( orientations & Qt::Horizontal )
|
||||
doInvalidate |= m_data->colChain.setSpacing( spacing );
|
||||
isModified |= m_data->colChain.setSpacing( spacing );
|
||||
|
||||
if ( orientations & Qt::Vertical )
|
||||
doInvalidate |= m_data->rowChain.setSpacing( spacing );
|
||||
isModified |= m_data->rowChain.setSpacing( spacing );
|
||||
|
||||
if ( doInvalidate )
|
||||
if ( isModified )
|
||||
invalidate( CellCache | LayoutCache );
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
qreal QskLinearLayoutEngine::spacing( Qt::Orientation orientation ) const
|
||||
|
@ -717,10 +737,10 @@ qreal QskLinearLayoutEngine::spacing( Qt::Orientation orientation ) const
|
|||
return m_data->rowChain.spacing();
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setExtraSpacingAt( Qt::Edges edges )
|
||||
bool QskLinearLayoutEngine::setExtraSpacingAt( Qt::Edges edges )
|
||||
{
|
||||
if ( edges == m_data->extraSpacingAt )
|
||||
return;
|
||||
return false;
|
||||
|
||||
m_data->extraSpacingAt = edges;
|
||||
|
||||
|
@ -743,6 +763,7 @@ void QskLinearLayoutEngine::setExtraSpacingAt( Qt::Edges edges )
|
|||
m_data->rowChain.setExtraSpacingAt( rowEdges );
|
||||
|
||||
invalidate( LayoutCache );
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::Edges QskLinearLayoutEngine::extraSpacingAt() const
|
||||
|
@ -750,9 +771,9 @@ Qt::Edges QskLinearLayoutEngine::extraSpacingAt() const
|
|||
return m_data->extraSpacingAt;
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setDefaultAlignment( Qt::Alignment alignment )
|
||||
bool QskLinearLayoutEngine::setDefaultAlignment( Qt::Alignment alignment )
|
||||
{
|
||||
m_data->entryTable.setDefaultAlignment( alignment );
|
||||
return m_data->entryTable.setDefaultAlignment( alignment );
|
||||
}
|
||||
|
||||
Qt::Alignment QskLinearLayoutEngine::defaultAlignment() const
|
||||
|
@ -935,9 +956,15 @@ qreal QskLinearLayoutEngine::heightForWidth( qreal width ) const
|
|||
return sizeHint( Qt::PreferredSize, constraint ).height();
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::setVisualDirection(Qt::LayoutDirection direction)
|
||||
bool QskLinearLayoutEngine::setVisualDirection(Qt::LayoutDirection direction)
|
||||
{
|
||||
m_data->visualDirection = direction;
|
||||
if ( m_data->visualDirection != direction )
|
||||
{
|
||||
m_data->visualDirection = direction;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::LayoutDirection QskLinearLayoutEngine::visualDirection() const
|
||||
|
|
|
@ -19,26 +19,30 @@ class QskLinearLayoutEngine
|
|||
~QskLinearLayoutEngine();
|
||||
|
||||
Qt::Orientation orientation() const;
|
||||
void setOrientation( Qt::Orientation );
|
||||
bool setOrientation( Qt::Orientation );
|
||||
|
||||
void setDimension( uint dimension );
|
||||
bool setDimension( uint dimension );
|
||||
uint dimension() const;
|
||||
|
||||
void setDefaultAlignment( Qt::Alignment );
|
||||
bool setDefaultAlignment( Qt::Alignment );
|
||||
Qt::Alignment defaultAlignment() const;
|
||||
|
||||
void setExtraSpacingAt( Qt::Edges );
|
||||
bool setExtraSpacingAt( Qt::Edges );
|
||||
Qt::Edges extraSpacingAt() const;
|
||||
|
||||
bool setVisualDirection( Qt::LayoutDirection );
|
||||
Qt::LayoutDirection visualDirection() const;
|
||||
|
||||
bool setSpacing( qreal spacing, Qt::Orientations );
|
||||
qreal spacing( Qt::Orientation ) const;
|
||||
|
||||
qreal defaultSpacing( Qt::Orientation ) const;
|
||||
|
||||
int count() const;
|
||||
|
||||
int rowCount() const;
|
||||
int columnCount() const;
|
||||
|
||||
void setSpacing( qreal spacing, Qt::Orientations );
|
||||
qreal spacing( Qt::Orientation ) const;
|
||||
qreal defaultSpacing( Qt::Orientation ) const;
|
||||
|
||||
void insertItem( QQuickItem*, int index );
|
||||
void addItem( QQuickItem* );
|
||||
|
||||
|
@ -50,13 +54,13 @@ class QskLinearLayoutEngine
|
|||
QQuickItem* itemAt( int index ) const;
|
||||
int spacerAt( int index ) const;
|
||||
|
||||
void setRetainSizeWhenHiddenAt( int index, bool on );
|
||||
bool setRetainSizeWhenHiddenAt( int index, bool on );
|
||||
bool retainSizeWhenHiddenAt( int index ) const;
|
||||
|
||||
void setAlignmentAt( int index, Qt::Alignment );
|
||||
bool setAlignmentAt( int index, Qt::Alignment );
|
||||
Qt::Alignment alignmentAt( int index ) const;
|
||||
|
||||
void setStretchFactorAt( int index, int stretchFactor );
|
||||
bool setStretchFactorAt( int index, int stretchFactor );
|
||||
int stretchFactorAt( int index ) const;
|
||||
|
||||
void setGeometries( const QRectF& );
|
||||
|
@ -66,9 +70,6 @@ class QskLinearLayoutEngine
|
|||
|
||||
QSizeF sizeHint( Qt::SizeHint, const QSizeF& contraint ) const;
|
||||
|
||||
void setVisualDirection( Qt::LayoutDirection );
|
||||
Qt::LayoutDirection visualDirection() const;
|
||||
|
||||
enum
|
||||
{
|
||||
EntryCache = 1 << 0,
|
||||
|
|
Loading…
Reference in New Issue