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.
This commit is contained in:
Kimmo Varis 2011-02-25 12:04:10 +02:00
parent eabec80154
commit 085034ddf7
1 changed files with 12 additions and 7 deletions

View File

@ -209,16 +209,21 @@ void SettingsDialog::AddApplication()
void SettingsDialog::RemoveApplication() void SettingsDialog::RemoveApplication()
{ {
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems(); QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
QListWidgetItem *item = 0; foreach(QListWidgetItem *item, selected)
foreach(item, selected)
{ {
mTempApplications->RemoveApplication(mUI.mListWidget->row(item)); const int removeIndex = mUI.mListWidget->row(item);
mUI.mListWidget->clear(); const int currentDefault = mTempApplications->GetDefaultApplication();
PopulateApplicationList(); 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() void SettingsDialog::EditApplication()