summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtContactEditWidget.cpp9
1 files changed, 9 insertions, 0 deletions
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
@@ -112,12 +112,21 @@ std::set<std::string> QtContactEditWidget::getSelectedGroups() const {
}
void QtContactEditWidget::setNameSuggestions(const std::vector<std::string>& suggestions) {
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));
}
nameRadioButton_ = new QRadioButton(tr("Name:"), this);
suggestionsLayout_->insertWidget(nameLayout_->count(), nameRadioButton_);