From 085034ddf7e148bd1d77cd8442af8cbb33794cae Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Fri, 25 Feb 2011 12:04:10 +0200 Subject: [PATCH] GUI: Fix for removing application. The default application was not handled correctly when removing application from the list. If the default application is removed then we reset the default application to unknown. Otherwise we make sure the default application is correct after the removal of other application. --- gui/settingsdialog.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index a3e48d919..d3a42857a 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -209,16 +209,21 @@ void SettingsDialog::AddApplication() void SettingsDialog::RemoveApplication() { - QList selected = mUI.mListWidget->selectedItems(); - QListWidgetItem *item = 0; - - foreach(item, selected) + foreach(QListWidgetItem *item, selected) { - mTempApplications->RemoveApplication(mUI.mListWidget->row(item)); - mUI.mListWidget->clear(); - PopulateApplicationList(); + const int removeIndex = mUI.mListWidget->row(item); + const int currentDefault = mTempApplications->GetDefaultApplication(); + mTempApplications->RemoveApplication(removeIndex); + if (removeIndex == currentDefault) + // If default app is removed set default to unknown + mTempApplications->SetDefault(-1); + else if (removeIndex < currentDefault) + // Move default app one up if earlier app was removed + mTempApplications->SetDefault(currentDefault - 1); } + mUI.mListWidget->clear(); + PopulateApplicationList(); } void SettingsDialog::EditApplication()