From 9d1fec36688745f89fb206726e4f6085a1786368 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 22 Feb 2024 20:37:01 +0100 Subject: [PATCH] [partition] Use a "real" slot for UniqueConnection --- src/modules/partition/gui/PartitionPage.cpp | 25 +++++++++++---------- src/modules/partition/gui/PartitionPage.h | 4 +++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index bc845c535..28b4d8583 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -563,6 +563,14 @@ PartitionPage::restoreSelectedBootLoader() Calamares::restoreSelectedBootLoader( *( m_ui->bootLoaderComboBox ), m_core->bootLoaderInstallPath() ); } +void +PartitionPage::reconcileSelections() +{ + QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex(); + selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 ); + m_ui->partitionBarsView->setCurrentIndex( selectedIndex ); + m_ui->partitionLabelsView->setCurrentIndex( selectedIndex ); +} void PartitionPage::updateFromCurrentDevice() @@ -605,18 +613,11 @@ PartitionPage::updateFromCurrentDevice() // This is necessary because even with the same selection model it might happen that // a !=0 column is selected in the tree view, which for some reason doesn't trigger a // timely repaint in the bars view. - connect( - m_ui->partitionBarsView->selectionModel(), - &QItemSelectionModel::currentChanged, - this, - [ = ] - { - QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex(); - selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 ); - m_ui->partitionBarsView->setCurrentIndex( selectedIndex ); - m_ui->partitionLabelsView->setCurrentIndex( selectedIndex ); - }, - Qt::UniqueConnection ); + connect( m_ui->partitionBarsView->selectionModel(), + &QItemSelectionModel::currentChanged, + this, + &PartitionPage::reconcileSelections, + Qt::UniqueConnection ); // Must be done here because we need to have a model set to define // individual column resize mode diff --git a/src/modules/partition/gui/PartitionPage.h b/src/modules/partition/gui/PartitionPage.h index 462822346..d3ae60eb8 100644 --- a/src/modules/partition/gui/PartitionPage.h +++ b/src/modules/partition/gui/PartitionPage.h @@ -40,7 +40,7 @@ public: int selectedDeviceIndex(); void selectDeviceByIndex( int index ); -private slots: +private Q_SLOTS: /// @brief Update everything when the base device changes void updateFromCurrentDevice(); /// @brief Update when the selected device for boot loader changes @@ -49,6 +49,8 @@ private slots: void updateSelectedBootLoaderIndex(); /// @brief After boot loader model changes, try to preserve previously set value void restoreSelectedBootLoader(); + /// @brief Make the selections in each widget match + void reconcileSelections(); private: QScopedPointer< Ui_PartitionPage > m_ui;