diff options
-rw-r--r-- | Swift/QtUI/QtContactEditWidget.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index 5e2915f..9d071b9 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -115,23 +115,28 @@ void QtContactEditWidget::setNameSuggestions(const std::vector<std::string>& sug throbberLabel_->hide(); foreach(const std::string& name, suggestions) { suggestionsLayout_->insertWidget(nameLayout_->count() - 2, new QRadioButton(P2QSTRING(name), this)); } nameRadioButton_ = new QRadioButton(tr("Name:"), this); suggestionsLayout_->insertWidget(nameLayout_->count(), nameRadioButton_); - if (name_->text().isEmpty()) { - QRadioButton* suggestedRadioButton = dynamic_cast<QRadioButton*>(suggestionsLayout_->itemAt(0)->widget()); - if (suggestedRadioButton) { - suggestedRadioButton->setChecked(true); + QRadioButton* suggestedRadioButton = 0; + QList<QRadioButton*> radioButtons = findChildren<QRadioButton*>(); + foreach (QRadioButton* candidate, radioButtons) { + if (candidate->text() == name_->text()) { + suggestedRadioButton = candidate; + break; } + } + if (suggestedRadioButton) { + suggestedRadioButton->setChecked(true); } else { nameRadioButton_->setChecked(true); } } void QtContactEditWidget::clear() { name_->clear(); setSelectedGroups(std::vector<std::string>()); newGroup_->setChecked(false); |