Move init logic into PartitionSplitterWidget.
This commit is contained in:
parent
ca8b551fbd
commit
6a93f34c15
@ -163,30 +163,6 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex )
|
|||||||
qint64 requiredStorageB = ( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
|
qint64 requiredStorageB = ( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
|
||||||
|
|
||||||
// set up splitter widget here, then set up the split position
|
// 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 );
|
Device* deviceBefore = m_core->createImmutableDeviceCopy( dev );
|
||||||
|
|
||||||
@ -197,7 +173,7 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex )
|
|||||||
|
|
||||||
m_previewWidget->setModel( partitionModelBefore );
|
m_previewWidget->setModel( partitionModelBefore );
|
||||||
m_previewLabels->setModel( partitionModelBefore );
|
m_previewLabels->setModel( partitionModelBefore );
|
||||||
m_splitterWidget->init( allPartitionItems );
|
m_splitterWidget->init( dev );
|
||||||
|
|
||||||
m_splitterWidget->setSplitPartition( candidate->partitionPath(),
|
m_splitterWidget->setSplitPartition( candidate->partitionPath(),
|
||||||
candidate->used() * 1.1,
|
candidate->used() * 1.1,
|
||||||
|
@ -18,9 +18,15 @@
|
|||||||
|
|
||||||
#include "PartitionSplitterWidget.h"
|
#include "PartitionSplitterWidget.h"
|
||||||
|
|
||||||
|
#include "core/ColorUtils.h"
|
||||||
|
#include "core/PartitionIterator.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
|
||||||
|
#include <kpmcore/core/device.h>
|
||||||
|
#include <kpmcore/core/partition.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
@ -48,7 +54,36 @@ PartitionSplitterWidget::PartitionSplitterWidget( QWidget* parent )
|
|||||||
|
|
||||||
|
|
||||||
void
|
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_itemToResize = nullptr;
|
||||||
m_itemToResizeNext = nullptr;
|
m_itemToResizeNext = nullptr;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
struct PartitionSplitterItem
|
struct PartitionSplitterItem
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ class PartitionSplitterWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit PartitionSplitterWidget( QWidget* parent = nullptr );
|
explicit PartitionSplitterWidget( QWidget* parent = nullptr );
|
||||||
|
|
||||||
void init( const QList< PartitionSplitterItem >& items );
|
void init( Device* dev );
|
||||||
|
|
||||||
void setSplitPartition( const QString& path,
|
void setSplitPartition( const QString& path,
|
||||||
qint64 minSize,
|
qint64 minSize,
|
||||||
@ -61,6 +62,8 @@ protected:
|
|||||||
void mouseReleaseEvent( QMouseEvent* event ) override;
|
void mouseReleaseEvent( QMouseEvent* event ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupItems( const QList< PartitionSplitterItem >& items );
|
||||||
|
|
||||||
void drawPartitions( QPainter* painter,
|
void drawPartitions( QPainter* painter,
|
||||||
const QRect& rect,
|
const QRect& rect,
|
||||||
const QList< PartitionSplitterItem >& items );
|
const QList< PartitionSplitterItem >& items );
|
||||||
|
Loading…
Reference in New Issue
Block a user