From aecd7406f3ef6719d61ff4958c48247095485f9b Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 6 May 2019 16:36:52 +0200 Subject: [PATCH] minor changes --- src/layouts/QskLayoutBox.cpp | 18 +++++++++--------- src/layouts/QskLayoutConstraint.cpp | 6 +++--- src/layouts/QskLayoutEngine.cpp | 22 +++++++++++----------- src/layouts/QskLinearBox.cpp | 9 ++++----- src/layouts/QskStackBox.cpp | 8 ++++---- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/layouts/QskLayoutBox.cpp b/src/layouts/QskLayoutBox.cpp index 5dd0eb8f..0d3a5fc4 100644 --- a/src/layouts/QskLayoutBox.cpp +++ b/src/layouts/QskLayoutBox.cpp @@ -250,7 +250,7 @@ QRectF QskLayoutBox::alignedLayoutRect( const QRectF& rect ) const } QSizeF QskLayoutBox::contentsSizeHint() const -{ +{ if ( !isActive() ) return QSizeF( -1, -1 ); @@ -269,25 +269,25 @@ qreal QskLayoutBox::heightForWidth( qreal width ) const { auto constrainedHeight = [this]( QskLayoutConstraint::Type, const QskControl*, qreal width ) - { - return engine().heightForWidth( width ); - }; + { + return engine().heightForWidth( width ); + }; return QskLayoutConstraint::constrainedMetric( QskLayoutConstraint::HeightForWidth, this, width, constrainedHeight ); -} +} qreal QskLayoutBox::widthForHeight( qreal height ) const { auto constrainedWidth = [this]( QskLayoutConstraint::Type, const QskControl*, qreal height ) - { - return engine().widthForHeight( height ); - }; + { + return engine().widthForHeight( height ); + }; return QskLayoutConstraint::constrainedMetric( QskLayoutConstraint::WidthForHeight, this, height, constrainedWidth ); -} +} void QskLayoutBox::geometryChangeEvent( QskGeometryChangeEvent* event ) { diff --git a/src/layouts/QskLayoutConstraint.cpp b/src/layouts/QskLayoutConstraint.cpp index 863ccdba..310eb64c 100644 --- a/src/layouts/QskLayoutConstraint.cpp +++ b/src/layouts/QskLayoutConstraint.cpp @@ -117,12 +117,12 @@ qreal QskLayoutConstraint::constrainedMetric( { const QSizeF outer( widthOrHeight, upperLimit ); const QSizeF inner = control->layoutRectForSize( outer ).size(); - + qreal height = constrainFunction( type, control, inner.width() ); - + if ( height >= 0.0 ) height += outer.height() - inner.height(); - + return height; } } diff --git a/src/layouts/QskLayoutEngine.cpp b/src/layouts/QskLayoutEngine.cpp index 6c5829a9..9aca315f 100644 --- a/src/layouts/QskLayoutEngine.cpp +++ b/src/layouts/QskLayoutEngine.cpp @@ -202,18 +202,18 @@ QSize QskLayoutEngine::requiredCells() const for ( int i = 0; i < itemCount(); i++ ) { - const QskLayoutItem* l = layoutItemAt( i ); - if ( l->isIgnored() ) + const auto layoutItem = layoutItemAt( i ); + if ( layoutItem->isIgnored() ) continue; - const int col = l->hasUnlimitedSpan( Qt::Horizontal ) - ? l->firstColumn() + 1 : l->lastColumn(); + const int col = layoutItem->hasUnlimitedSpan( Qt::Horizontal ) + ? layoutItem->firstColumn() + 1 : layoutItem->lastColumn(); if ( col > lastColumn ) lastColumn = col; - const int row = l->hasUnlimitedSpan( Qt::Vertical ) - ? l->firstRow() + 1 : l->lastRow(); + const int row = layoutItem->hasUnlimitedSpan( Qt::Vertical ) + ? layoutItem->firstRow() + 1 : layoutItem->lastRow(); if ( row > lastRow ) lastRow = row; @@ -226,13 +226,13 @@ void QskLayoutEngine::adjustSpans( int numRows, int numColumns ) { for ( int i = 0; i < itemCount(); i++ ) { - QskLayoutItem* l = layoutItemAt( i ); + auto layoutItem = layoutItemAt( i ); - if ( l->hasUnlimitedSpan( Qt::Horizontal ) ) - l->setRowSpan( numColumns - l->firstColumn(), Qt::Horizontal ); + if ( layoutItem->hasUnlimitedSpan( Qt::Horizontal ) ) + layoutItem->setRowSpan( numColumns - layoutItem->firstColumn(), Qt::Horizontal ); - if ( l->hasUnlimitedSpan( Qt::Vertical ) ) - l->setRowSpan( numRows - l->firstRow(), Qt::Vertical ); + if ( layoutItem->hasUnlimitedSpan( Qt::Vertical ) ) + layoutItem->setRowSpan( numRows - layoutItem->firstRow(), Qt::Vertical ); } } diff --git a/src/layouts/QskLinearBox.cpp b/src/layouts/QskLinearBox.cpp index 84ab5841..a10a25ab 100644 --- a/src/layouts/QskLinearBox.cpp +++ b/src/layouts/QskLinearBox.cpp @@ -90,8 +90,8 @@ void QskLinearBox::transpose() { QskLayoutItem* layoutItem = engine().layoutItemAt( i ); - const int row = layoutItem->firstRow( Qt::Horizontal ); - const int col = layoutItem->firstRow( Qt::Vertical ); + const int row = layoutItem->firstColumn(); + const int col = layoutItem->firstRow(); engine().removeItem( layoutItem ); @@ -358,10 +358,9 @@ void QskLinearBox::rearrange() if ( m_data->orientation == Qt::Vertical ) qSwap( col, row ); - QskLayoutItem* layoutItem = engine().layoutItemAt( i ); + auto layoutItem = engine().layoutItemAt( i ); - if ( layoutItem->firstRow( Qt::Horizontal ) != col || - layoutItem->firstRow( Qt::Vertical ) != row ) + if ( layoutItem->firstColumn() != col || layoutItem->firstRow() != row ) { engine().removeItem( layoutItem ); diff --git a/src/layouts/QskStackBox.cpp b/src/layouts/QskStackBox.cpp index c7ffd46d..c31353ab 100644 --- a/src/layouts/QskStackBox.cpp +++ b/src/layouts/QskStackBox.cpp @@ -30,7 +30,7 @@ static qreal qskConstrainedValue( QskLayoutConstraint::Type type, if ( v > constrainedValue ) constrainedValue = v; } - } + } return constrainedValue; } @@ -139,12 +139,12 @@ void QskStackBox::layoutItemRemoved( QskLayoutItem*, int index ) Using QGridLayoutEngine for a stack layout is actually not a good ideas. Until we have a new implementation, we need to work around situations, where the layout does - not work properly with having several items in the - same cell. + not work properly with having several items in the + same cell. In this particular situation we need to fix, that we lost the item from engine.q_grid[0]. Calling transpose has this side effect. - + */ engine.transpose(); engine.transpose(); // reverting the call before