From 27d69502a3ebb249093538e43bfd53e90f2e4e61 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 13 Jan 2016 17:43:59 +0100 Subject: [PATCH] Alongside apply slot. --- src/modules/partition/gui/ChoicePage.cpp | 69 +++++++++++++++++++++++- src/modules/partition/gui/ChoicePage.h | 1 + 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 89b0c4476..adaec7e1e 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -41,6 +41,7 @@ #include "core/KPMHelpers.h" #include "JobQueue.h" #include "GlobalStorage.h" +#include "core/PartitionInfo.h" #include #include @@ -514,8 +515,74 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current, Calamares::Branding::instance()-> string( Calamares::Branding::ProductName ) ); - cDebug() << "Partition selected for Alongside."; + setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() ); + cDebug() << "Partition selected for Alongside."; +} + + +void +ChoicePage::doAlongsideApply() +{ + Q_ASSERT( m_afterPartitionSplitterWidget->splitPartitionSize() >= 0 ); + Q_ASSERT( m_afterPartitionSplitterWidget->newPartitionSize() >= 0 ); + + QString path = m_beforePartitionBarsView-> + selectionModel()-> + currentIndex().data( PartitionModel::PartitionPathRole ).toString(); + + DeviceModel* dm = m_core->deviceModel(); + for ( int i = 0; i < dm->rowCount(); ++i ) + { + Device* dev = dm->deviceForIndex( dm->index( i ) ); + Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, path ); + if ( candidate ) + { + qint64 firstSector = candidate->firstSector(); + qint64 oldLastSector = candidate->lastSector(); + qint64 newLastSector = m_afterPartitionSplitterWidget->splitPartitionSize() / + dev->logicalSectorSize(); + + m_core->resizePartition( dev, candidate, firstSector, newLastSector ); + Partition* newPartition = KPMHelpers::createNewPartition( + candidate->parent(), + *dev, + candidate->roles(), + FileSystem::Ext4, + newLastSector + 1, + oldLastSector ); + PartitionInfo::setMountPoint( newPartition, "/" ); + PartitionInfo::setFormat( newPartition, true ); + + m_core->createPartition( dev, newPartition ); + m_core->setBootLoaderInstallPath( dev->deviceNode() ); + + /*if ( m_isEfi ) + { + QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions(); + if ( efiSystemPartitions.count() == 1 ) + { + PartitionInfo::setMountPoint( + efiSystemPartitions.first(), + Calamares::JobQueue::instance()-> + globalStorage()-> + value( "efiSystemPartition" ).toString() ); + } + else if ( efiSystemPartitions.count() > 1 ) + { + PartitionInfo::setMountPoint( + efiSystemPartitions.at( m_efiComboBox->currentIndex() ), + Calamares::JobQueue::instance()-> + globalStorage()-> + value( "efiSystemPartition" ).toString() ); + } + }*/ + + m_core->dumpQueue(); + + break; + } + } } diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index b09d25dd6..6bc4cd26f 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -73,6 +73,7 @@ signals: private slots: void doReplaceSelectedPartition( const QModelIndex& current, const QModelIndex& previous ); void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous ); + void doAlongsideApply(); private: void setNextEnabled( bool enabled );