From f06f0113a7dd492de23beca02890fb57e4670b3c Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 4 Nov 2014 09:20:39 +0000 Subject: Remove old suggestions from contact edit dialog before adding new ones. Previously if we received an updated VCard after the suggestions have already been set we would have duplicate suggestions. Test-Information: Tested by running Swift and editing a contact. Change-Id: I960392fb76a574304d75a358af3f3cfcc9ca3adb diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index a347a00..84cbf6b 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -115,6 +115,15 @@ void QtContactEditWidget::setNameSuggestions(const std::vector& sug throbberLabel_->movie()->stop(); throbberLabel_->hide(); + // remove old suggestions except for the user input text field + QLayoutItem* suggestionItem = NULL; + while ((suggestionItem = suggestionsLayout_->itemAt(0)) && suggestionItem->widget() != name_) { + QWidget* suggestionWidget = suggestionItem->widget(); + suggestionsLayout_->removeWidget(suggestionWidget); + delete suggestionWidget; + } + + // populate new suggestions foreach(const std::string& name, suggestions) { suggestionsLayout_->insertWidget(nameLayout_->count() - 2, new QRadioButton(doubleAmpersand(name), this)); } -- cgit v0.10.2-6-g49f6