summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-11-04 09:20:39 (GMT)
committerSwift Review <review@swift.im>2014-11-04 17:48:20 (GMT)
commitf06f0113a7dd492de23beca02890fb57e4670b3c (patch)
treeb0b17b8b703633861a5424e16574e90ecfbcb1da
parenta13511f0fc7998ab1350b3549f42c3e2eef04be3 (diff)
downloadswift-f06f0113a7dd492de23beca02890fb57e4670b3c.zip
swift-f06f0113a7dd492de23beca02890fb57e4670b3c.tar.bz2
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
-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
@@ -115,6 +115,15 @@ void QtContactEditWidget::setNameSuggestions(const std::vector<std::string>& 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));
}