Move init logic into PartitionSplitterWidget.

main
Teo Mrnjavac 9 years ago
parent ca8b551fbd
commit 6a93f34c15

@ -163,30 +163,6 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex )
qint64 requiredStorageB = ( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
// set up splitter widget here, then set up the split position
QList< PartitionSplitterItem > allPartitionItems;
{
PartitionSplitterItem* extendedPartitionItem = nullptr;
for ( auto it = PartitionIterator::begin( dev );
it != PartitionIterator::end( dev ); ++it )
{
PartitionSplitterItem newItem = {
( *it )->partitionPath(),
ColorUtils::colorForPartition( *it ),
false,
( *it )->capacity(),
{}
};
if ( ( *it )->roles().has( PartitionRole::Logical ) && extendedPartitionItem )
extendedPartitionItem->children.append( newItem );
else
{
allPartitionItems.append( newItem );
if ( ( *it )->roles().has( PartitionRole::Extended ) )
extendedPartitionItem = &allPartitionItems.last();
}
}
}
Device* deviceBefore = m_core->createImmutableDeviceCopy( dev );
@ -197,7 +173,7 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex )
m_previewWidget->setModel( partitionModelBefore );
m_previewLabels->setModel( partitionModelBefore );
m_splitterWidget->init( allPartitionItems );
m_splitterWidget->init( dev );
m_splitterWidget->setSplitPartition( candidate->partitionPath(),
candidate->used() * 1.1,

@ -18,9 +18,15 @@
#include "PartitionSplitterWidget.h"
#include "core/ColorUtils.h"
#include "core/PartitionIterator.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtilsGui.h"
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <QApplication>
#include <QPainter>
#include <QMouseEvent>
@ -48,7 +54,36 @@ PartitionSplitterWidget::PartitionSplitterWidget( QWidget* parent )
void
PartitionSplitterWidget::init( const QList<PartitionSplitterItem>& items )
PartitionSplitterWidget::init( Device* dev )
{
QList< PartitionSplitterItem > allPartitionItems;
PartitionSplitterItem* extendedPartitionItem = nullptr;
for ( auto it = PartitionIterator::begin( dev );
it != PartitionIterator::end( dev ); ++it )
{
PartitionSplitterItem newItem = {
( *it )->partitionPath(),
ColorUtils::colorForPartition( *it ),
false,
( *it )->capacity(),
{}
};
if ( ( *it )->roles().has( PartitionRole::Logical ) && extendedPartitionItem )
extendedPartitionItem->children.append( newItem );
else
{
allPartitionItems.append( newItem );
if ( ( *it )->roles().has( PartitionRole::Extended ) )
extendedPartitionItem = &allPartitionItems.last();
}
}
setupItems( allPartitionItems );
}
void
PartitionSplitterWidget::setupItems( const QList<PartitionSplitterItem>& items )
{
m_itemToResize = nullptr;
m_itemToResizeNext = nullptr;

@ -21,6 +21,7 @@
#include <QWidget>
class Device;
struct PartitionSplitterItem
{
@ -38,7 +39,7 @@ class PartitionSplitterWidget : public QWidget
public:
explicit PartitionSplitterWidget( QWidget* parent = nullptr );
void init( const QList< PartitionSplitterItem >& items );
void init( Device* dev );
void setSplitPartition( const QString& path,
qint64 minSize,
@ -61,6 +62,8 @@ protected:
void mouseReleaseEvent( QMouseEvent* event ) override;
private:
void setupItems( const QList< PartitionSplitterItem >& items );
void drawPartitions( QPainter* painter,
const QRect& rect,
const QList< PartitionSplitterItem >& items );

Loading…
Cancel
Save