mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-02 20:05:37 -04:00
Better way to compute items in nested/non-nested partitions mode.
This commit is contained in:
parent
d2600bc5dc
commit
3d5753e97c
1 changed files with 45 additions and 64 deletions
|
@ -225,34 +225,18 @@ PartitionBarsView::drawPartitions( QPainter* painter, const QRect& rect, const Q
|
||||||
// Make sure we fill the last pixel column
|
// Make sure we fill the last pixel column
|
||||||
width = rect.right() - x + 1;
|
width = rect.right() - x + 1;
|
||||||
|
|
||||||
if ( m_nestedPartitionsMode == DrawNestedPartitions )
|
drawSection( painter, rect, x, width, item.index );
|
||||||
|
|
||||||
|
if ( m_nestedPartitionsMode == DrawNestedPartitions &&
|
||||||
|
modl->hasChildren( item.index ) )
|
||||||
{
|
{
|
||||||
drawSection( painter, rect, x, width, item.index );
|
QRect subRect(
|
||||||
if ( modl->hasChildren( item.index ) )
|
x + EXTENDED_PARTITION_MARGIN,
|
||||||
{
|
rect.y() + EXTENDED_PARTITION_MARGIN,
|
||||||
QRect subRect(
|
width - 2 * EXTENDED_PARTITION_MARGIN,
|
||||||
x + EXTENDED_PARTITION_MARGIN,
|
rect.height() - 2 * EXTENDED_PARTITION_MARGIN
|
||||||
rect.y() + EXTENDED_PARTITION_MARGIN,
|
);
|
||||||
width - 2 * EXTENDED_PARTITION_MARGIN,
|
drawPartitions( painter, subRect, item.index );
|
||||||
rect.height() - 2 * EXTENDED_PARTITION_MARGIN
|
|
||||||
);
|
|
||||||
drawPartitions( painter, subRect, item.index );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( modl->hasChildren( item.index ) )
|
|
||||||
{
|
|
||||||
QRect subRect(
|
|
||||||
x,
|
|
||||||
rect.y(),
|
|
||||||
width,
|
|
||||||
rect.height()
|
|
||||||
);
|
|
||||||
drawPartitions( painter, subRect, item.index );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
drawSection( painter, rect, x, width, item.index );
|
|
||||||
}
|
}
|
||||||
x += width;
|
x += width;
|
||||||
}
|
}
|
||||||
|
@ -301,23 +285,15 @@ PartitionBarsView::indexAt( const QPoint &point,
|
||||||
QRect thisItemRect( x, rect.y(), width, rect.height() );
|
QRect thisItemRect( x, rect.y(), width, rect.height() );
|
||||||
if ( thisItemRect.contains( point ) )
|
if ( thisItemRect.contains( point ) )
|
||||||
{
|
{
|
||||||
if ( modl->hasChildren( item.index ) )
|
if ( m_nestedPartitionsMode == DrawNestedPartitions &&
|
||||||
|
modl->hasChildren( item.index ) )
|
||||||
{
|
{
|
||||||
QRect subRect;
|
QRect subRect(
|
||||||
if ( m_nestedPartitionsMode == DrawNestedPartitions )
|
x + EXTENDED_PARTITION_MARGIN,
|
||||||
subRect = QRect(
|
rect.y() + EXTENDED_PARTITION_MARGIN,
|
||||||
x + EXTENDED_PARTITION_MARGIN,
|
width - 2 * EXTENDED_PARTITION_MARGIN,
|
||||||
rect.y() + EXTENDED_PARTITION_MARGIN,
|
rect.height() - 2 * EXTENDED_PARTITION_MARGIN
|
||||||
width - 2 * EXTENDED_PARTITION_MARGIN,
|
);
|
||||||
rect.height() - 2 * EXTENDED_PARTITION_MARGIN
|
|
||||||
);
|
|
||||||
else
|
|
||||||
subRect = QRect(
|
|
||||||
x,
|
|
||||||
rect.y(),
|
|
||||||
width,
|
|
||||||
rect.height()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( subRect.contains( point ) )
|
if ( subRect.contains( point ) )
|
||||||
{
|
{
|
||||||
|
@ -373,24 +349,16 @@ PartitionBarsView::visualRect( const QModelIndex& index,
|
||||||
if ( item.index == index )
|
if ( item.index == index )
|
||||||
return thisItemRect;
|
return thisItemRect;
|
||||||
|
|
||||||
if ( modl->hasChildren( item.index ) &&
|
if ( m_nestedPartitionsMode == DrawNestedPartitions &&
|
||||||
|
modl->hasChildren( item.index ) &&
|
||||||
index.parent() == item.index )
|
index.parent() == item.index )
|
||||||
{
|
{
|
||||||
QRect subRect;
|
QRect subRect(
|
||||||
if ( m_nestedPartitionsMode == DrawNestedPartitions )
|
x + EXTENDED_PARTITION_MARGIN,
|
||||||
subRect = QRect(
|
rect.y() + EXTENDED_PARTITION_MARGIN,
|
||||||
x + EXTENDED_PARTITION_MARGIN,
|
width - 2 * EXTENDED_PARTITION_MARGIN,
|
||||||
rect.y() + EXTENDED_PARTITION_MARGIN,
|
rect.height() - 2 * EXTENDED_PARTITION_MARGIN
|
||||||
width - 2 * EXTENDED_PARTITION_MARGIN,
|
);
|
||||||
rect.height() - 2 * EXTENDED_PARTITION_MARGIN
|
|
||||||
);
|
|
||||||
else
|
|
||||||
subRect = QRect(
|
|
||||||
x,
|
|
||||||
rect.y(),
|
|
||||||
width,
|
|
||||||
rect.height()
|
|
||||||
);
|
|
||||||
|
|
||||||
QRect candidateVisualRect = visualRect( index, subRect, item.index );
|
QRect candidateVisualRect = visualRect( index, subRect, item.index );
|
||||||
if ( !candidateVisualRect.isNull() )
|
if ( !candidateVisualRect.isNull() )
|
||||||
|
@ -545,18 +513,31 @@ PartitionBarsView::updateGeometries()
|
||||||
QPair< QVector< PartitionBarsView::Item >, qreal >
|
QPair< QVector< PartitionBarsView::Item >, qreal >
|
||||||
PartitionBarsView::computeItemsVector( const QModelIndex& parent ) const
|
PartitionBarsView::computeItemsVector( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
const int count = model()->rowCount( parent );
|
int count = model()->rowCount( parent );
|
||||||
QVector< PartitionBarsView::Item > items( count );
|
QVector< PartitionBarsView::Item > items;
|
||||||
|
|
||||||
qreal total = 0;
|
qreal total = 0;
|
||||||
for ( int row = 0; row < count; ++row )
|
for ( int row = 0; row < count; ++row )
|
||||||
{
|
{
|
||||||
QModelIndex index = model()->index( row, 0, parent );
|
QModelIndex index = model()->index( row, 0, parent );
|
||||||
qreal size = index.data( PartitionModel::SizeRole ).toLongLong();
|
if ( m_nestedPartitionsMode == NoNestedPartitions &&
|
||||||
total += size;
|
model()->hasChildren( index ) )
|
||||||
items[ row ] = { size, index };
|
{
|
||||||
|
QPair< QVector< PartitionBarsView::Item >, qreal > childVect =
|
||||||
|
computeItemsVector( index );
|
||||||
|
items += childVect.first;
|
||||||
|
total += childVect.second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qreal size = index.data( PartitionModel::SizeRole ).toLongLong();
|
||||||
|
total += size;
|
||||||
|
items.append( { size, index } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count = items.count();
|
||||||
|
|
||||||
// The sizes we have are perfect, but now we have to hardcode a minimum size for small
|
// The sizes we have are perfect, but now we have to hardcode a minimum size for small
|
||||||
// partitions and compensate for it in the total.
|
// partitions and compensate for it in the total.
|
||||||
qreal adjustedTotal = total;
|
qreal adjustedTotal = total;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue