From ce4d0e6aea321870e171bbe910a898a9c2df8b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20M=C3=BCller?= Date: Sat, 2 Mar 2019 15:51:36 +0100 Subject: [PATCH] Revert "Merge branch 'issue-1098'" This reverts commit fdb4311a70ac7a63e8ba55d00b67033e78ce8cac, reversing changes made to 6b369dc5de8a597e7a72b25259f2466b9bcebf32. --- src/modules/partition/core/PartUtils.cpp | 31 +++--------- .../partition/core/PartitionCoreModule.h | 3 -- src/modules/partition/gui/PartitionPage.cpp | 49 +++++++++++-------- src/modules/partition/gui/PartitionPage.h | 10 +--- 4 files changed, 36 insertions(+), 57 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 5cf8101f9..4e8b7e8ba 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -43,25 +43,6 @@ namespace PartUtils { -static QString -convenienceName( const Partition* const candidate ) -{ - if ( !candidate->mountPoint().isEmpty() ) - return candidate->mountPoint(); - if ( !candidate->partitionPath().isEmpty() ) - return candidate->partitionPath(); - if ( !candidate->devicePath().isEmpty() ) - return candidate->devicePath(); - if ( !candidate->deviceNode().isEmpty() ) - return candidate->devicePath(); - - QString p; - QTextStream s( &p ); - s << (void *)candidate; - - return p; -} - bool canBeReplaced( Partition* candidate ) { @@ -83,12 +64,12 @@ canBeReplaced( Partition* candidate ) << QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 ); cDebug() << "Storage capacity B:" << availableStorageB << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 ) - << "for" << convenienceName( candidate ) << " length:" << candidate->length(); + << "for" << candidate->partitionPath() << " length:" << candidate->length(); if ( ok && availableStorageB > requiredStorageB ) { - cDebug() << "Partition" << convenienceName( candidate ) << "authorized for replace install."; + cDebug() << "Partition" << candidate->partitionPath() << "authorized for replace install."; return true; } @@ -105,7 +86,7 @@ canBeResized( Partition* candidate ) return false; } - cDebug() << "Checking if" << convenienceName( candidate ) << "can be resized."; + cDebug() << "Checking if" << candidate->partitionPath() << "can be resized."; if ( !candidate->fileSystem().supportGrow() || !candidate->fileSystem().supportShrink() ) { @@ -159,13 +140,13 @@ canBeResized( Partition* candidate ) << QString( "(%1GB)" ).arg( advisedStorageGB ); cDebug() << "Available storage B:" << availableStorageB << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 ) - << "for" << convenienceName( candidate ) << " length:" << candidate->length() + << "for" << candidate->partitionPath() << " length:" << candidate->length() << " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name(); if ( ok && availableStorageB > advisedStorageB ) { - cDebug() << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install."; + cDebug() << "Partition" << candidate->partitionPath() << "authorized for resize + autopartition install."; return true; } @@ -401,7 +382,7 @@ isEfiSystem() bool isEfiBootable( const Partition* candidate ) { - cDebug() << "Check EFI bootable" << convenienceName( candidate ) << candidate->devicePath(); + cDebug() << "Check EFI bootable" << candidate->partitionPath() << candidate->devicePath(); cDebug() << " .. flags" << candidate->activeFlags(); auto flags = PartitionInfo::flags( candidate ); diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index 743f9c178..c48c1562c 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -154,9 +154,6 @@ public: void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags ); - /// @brief Retrieve the path where the bootloader will be installed - QString bootLoaderInstallPath() const { return m_bootLoaderInstallPath; } - /// @brief Set the path where the bootloader will be installed void setBootLoaderInstallPath( const QString& path ); void initLayout(); diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index ba6845020..2743ec53a 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -56,6 +56,7 @@ #include // Qt +#include #include #include #include @@ -89,9 +90,22 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) updateFromCurrentDevice(); - connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateFromCurrentDevice ); - connect( m_ui->bootLoaderComboBox, QOverload::of(&QComboBox::activated), this, &PartitionPage::updateSelectedBootLoaderIndex ); - connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateBootLoaderInstallPath ); + connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged, + [ this ]( const QString& /* text */ ) + { + updateFromCurrentDevice(); + } ); + connect( m_ui->bootLoaderComboBox, static_cast(&QComboBox::activated), + [ this ]( const QString& /* text */ ) + { + m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex(); + } ); + + connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, + [ this ]( const QString& /* text */ ) + { + updateBootLoaderInstallPath(); + } ); connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled ); @@ -362,18 +376,18 @@ PartitionPage::onCreateClicked() if ( !checkCanCreate( model->device() ) ) return; - CreatePartitionDialog dlg( - model->device(), - partition->parent(), - nullptr, - getCurrentUsedMountpoints(), - this ); - dlg.initFromFreeSpace( partition ); - if ( dlg.exec() == QDialog::Accepted ) + QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(), + partition->parent(), + nullptr, + getCurrentUsedMountpoints(), + this ); + dlg->initFromFreeSpace( partition ); + if ( dlg->exec() == QDialog::Accepted ) { - Partition* newPart = dlg.createPartition(); - m_core->createPartition( model->device(), newPart, dlg.newFlags() ); + Partition* newPart = dlg->createPartition(); + m_core->createPartition( model->device(), newPart, dlg->newFlags() ); } + delete dlg; } void @@ -494,17 +508,10 @@ PartitionPage::updateBootLoaderInstallPath() QVariant var = m_ui->bootLoaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole ); if ( !var.isValid() ) return; - cDebug() << "PartitionPage::updateBootLoaderInstallPath" << var.toString(); + qDebug() << "PartitionPage::updateBootLoaderInstallPath" << var.toString(); m_core->setBootLoaderInstallPath( var.toString() ); } -void -PartitionPage::updateSelectedBootLoaderIndex() -{ - m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex(); - cDebug() << "Selected bootloader index" << m_lastSelectedBootLoaderIndex; -} - void PartitionPage::updateFromCurrentDevice() { diff --git a/src/modules/partition/gui/PartitionPage.h b/src/modules/partition/gui/PartitionPage.h index 75d39c9dc..8289f2cdd 100644 --- a/src/modules/partition/gui/PartitionPage.h +++ b/src/modules/partition/gui/PartitionPage.h @@ -50,14 +50,6 @@ public: int selectedDeviceIndex(); void selectDeviceByIndex( int index ); -private slots: - /// @brief Update everything when the base device changes - void updateFromCurrentDevice(); - /// @brief Update when the selected device for boot loader changes - void updateBootLoaderInstallPath(); - /// @brief Explicitly selected boot loader path - void updateSelectedBootLoaderIndex(); - private: QScopedPointer< Ui_PartitionPage > m_ui; PartitionCoreModule* m_core; @@ -75,6 +67,8 @@ private: void updatePartitionToCreate( Device*, Partition* ); void editExistingPartition( Device*, Partition* ); + void updateBootLoaderInstallPath(); + void updateFromCurrentDevice(); void updateBootLoaderIndex(); /**