| 159 | } |
| 160 | |
| 161 | void EditorDialog::OnSave() |
| 162 | { |
| 163 | // Store names. |
| 164 | if (m_feature.IsNameEditable()) |
| 165 | { |
| 166 | StringUtf8Multilang names; |
| 167 | for (localisation::LanguageIndex languageIndex = localisation::kDefaultNameIndex; languageIndex < localisation::kMaxSupportedLanguages; |
| 168 | ++languageIndex) |
| 169 | { |
| 170 | localisation::LanguageCode const languageCode = localisation::ConvertLanguageIndexToLanguageCode(languageIndex); |
| 171 | QLineEdit * le = findChild<QLineEdit *>(QString::fromUtf8(languageCode.data(), languageCode.size())); |
| 172 | if (!le) |
| 173 | continue; |
| 174 | |
| 175 | std::string const name = le->text().toStdString(); |
| 176 | if (!name.empty()) |
| 177 | names.AddString(languageIndex, name); |
| 178 | } |
| 179 | |
| 180 | m_feature.SetName(names); |
| 181 | } |
| 182 | |
| 183 | using PropID = osm::MapObject::MetadataID; |
| 184 | |
| 185 | // Store address. |
| 186 | if (m_feature.IsAddressEditable()) |
| 187 | { |
| 188 | m_feature.SetHouseNumber(findChild<QLineEdit *>(kHouseNumberObjectName)->text().toStdString()); |
| 189 | QString const editedStreet = findChild<QComboBox *>(kStreetObjectName)->currentText(); |
| 190 | QStringList const names = editedStreet.split(" / ", Qt::SkipEmptyParts); |
| 191 | QString const localized = names.size() > 1 ? names.at(1) : QString(); |
| 192 | if (!names.empty()) |
| 193 | m_feature.SetStreet({names.at(0).toStdString(), localized.toStdString()}); |
| 194 | else |
| 195 | m_feature.SetStreet({}); |
| 196 | |
| 197 | QLineEdit * editor = findChild<QLineEdit *>(kPostcodeObjectName); |
| 198 | std::string v = editor->text().toStdString(); |
| 199 | if (osm::EditableMapObject::ValidatePostCode(v)) |
| 200 | m_feature.SetPostcode(v); |
| 201 | } |
| 202 | |
| 203 | // Store other props. |
| 204 | for (auto const prop : m_feature.GetEditableProperties()) |
| 205 | { |
| 206 | if (prop == PropID::FMD_INTERNET) |
| 207 | { |
| 208 | QComboBox * cmb = findChild<QComboBox *>(kInternetObjectName); |
| 209 | m_feature.SetInternet(feature::InternetFromString(cmb->currentText().toStdString())); |
| 210 | continue; |
| 211 | } |
| 212 | if (prop == PropID::FMD_POSTCODE) // already set above |
| 213 | continue; |
| 214 | |
| 215 | QLineEdit * editor = findChild<QLineEdit *>(QString::fromStdString(DebugPrint(prop))); |
| 216 | if (!editor) |
| 217 | continue; |
| 218 |
nothing calls this directly
no test coverage detected