From 59f1bfcf315a77834ddbce20cc05892d211ab55c Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 31 May 2012 10:22:18 +0100 Subject: Render & in group names correctly in edit dialog. Resolves: #1117 diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index 9d071b9..a347a00 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -52,8 +52,9 @@ QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, QVBoxLayout* scrollLayout = new QVBoxLayout(groups); foreach (std::string group, allGroups) { + QString groupName = doubleAmpersand(group); QCheckBox* check = new QCheckBox(groups); - check->setText(P2QSTRING(group)); + check->setText(groupName); check->setCheckState(Qt::Unchecked); checkBoxes_[group] = check; scrollLayout->addWidget(check); @@ -83,7 +84,7 @@ std::string QtContactEditWidget::getName() const { if (button == nameRadioButton_) { name = Q2PSTRING(name_->text()); } else { - name = Q2PSTRING(button->text()); + name = singleAmpersand(button->text()); } break; } @@ -115,7 +116,7 @@ void QtContactEditWidget::setNameSuggestions(const std::vector& sug throbberLabel_->hide(); foreach(const std::string& name, suggestions) { - suggestionsLayout_->insertWidget(nameLayout_->count() - 2, new QRadioButton(P2QSTRING(name), this)); + suggestionsLayout_->insertWidget(nameLayout_->count() - 2, new QRadioButton(doubleAmpersand(name), this)); } nameRadioButton_ = new QRadioButton(tr("Name:"), this); @@ -135,6 +136,15 @@ void QtContactEditWidget::setNameSuggestions(const std::vector& sug nameRadioButton_->setChecked(true); } } +QString QtContactEditWidget::doubleAmpersand(const std::string& name) const { + return P2QSTRING(name).replace("&", "&&"); + +} + +std::string QtContactEditWidget::singleAmpersand(const QString& name) const { + return Q2PSTRING(QString(name).replace("&&", "&")); +} + void QtContactEditWidget::clear() { name_->clear(); diff --git a/Swift/QtUI/QtContactEditWidget.h b/Swift/QtUI/QtContactEditWidget.h index 5350762..6d55b80 100644 --- a/Swift/QtUI/QtContactEditWidget.h +++ b/Swift/QtUI/QtContactEditWidget.h @@ -38,6 +38,10 @@ namespace Swift { void clear(); + + private: + QString doubleAmpersand(const std::string& name) const; + std::string singleAmpersand(const QString& name) const; private: typedef std::map CheckBoxMap; CheckBoxMap checkBoxes_; -- cgit v0.10.2-6-g49f6