[qt] Fixed qt build.

This commit is contained in:
VladiMihaylenko 2016-04-08 16:36:20 +03:00
parent f1b72d5f73
commit 9bf220a613

View file

@ -81,15 +81,18 @@ EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo)
if (emo.IsAddressEditable())
{ // Address rows.
vector<string> nearbyStreets = emo.GetNearbyStreets();
auto nearbyStreets = emo.GetNearbyStreets();
// If feature does not have a specified street, display empty combo box.
if (emo.GetStreet().empty())
nearbyStreets.insert(nearbyStreets.begin(), "");
if (emo.GetStreet().m_defaultName.empty())
nearbyStreets.insert(nearbyStreets.begin(), {});
grid->addWidget(new QLabel(kStreetObjectName), row, 0);
QComboBox * cmb = new QComboBox();
for (int i = 0; i < nearbyStreets.size(); ++i)
{
cmb->addItem(nearbyStreets[i].c_str());
string street = nearbyStreets[i].m_defaultName;
if (!nearbyStreets[i].m_localizedName.empty())
street += " / " + nearbyStreets[i].m_localizedName;
cmb->addItem(street.c_str());
if (emo.GetStreet() == nearbyStreets[i])
cmb->setCurrentIndex(i);
}
@ -195,7 +198,10 @@ void EditorDialog::OnSave()
if (m_feature.IsAddressEditable())
{
m_feature.SetHouseNumber(findChild<QLineEdit *>(kHouseNumberObjectName)->text().toStdString());
m_feature.SetStreet(findChild<QComboBox *>(kStreetObjectName)->currentText().toStdString());
QString const editedStreet = findChild<QComboBox *>(kStreetObjectName)->currentText();
QStringList const names = editedStreet.split(" / ", QString::SkipEmptyParts);
QString const localized = names.size() > 1 ? names.at(1) : QString();
m_feature.SetStreet({names.at(0).toStdString(), localized.toStdString()});
m_feature.SetPostcode(findChild<QLineEdit *>(kPostcodeObjectName)->text().toStdString());
}