minor changes

This commit is contained in:
Uwe Rathmann 2019-05-06 16:36:52 +02:00
parent 748bdebc61
commit aecd7406f3
5 changed files with 31 additions and 32 deletions

View File

@ -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 )
{

View File

@ -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;
}
}

View File

@ -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 );
}
}

View File

@ -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 );

View File

@ -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