[partition] Use a "real" slot for UniqueConnection

This commit is contained in:
Adriaan de Groot 2024-02-22 20:37:01 +01:00
parent c69e229be0
commit 9d1fec3668
2 changed files with 16 additions and 13 deletions

View File

@ -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

View File

@ -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;