Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/declarative/Placemark.cpp
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | 66 | if (m_description.isEmpty()) { | |||
---|---|---|---|---|---|
318 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("private"), tr("Private", "Only with permission of the owner on an individual basis.")); | 318 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("private"), tr("Private", "Only with permission of the owner on an individual basis.")); | ||
319 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("permissive"), tr("Open to general traffic", "Open to general traffic but permission can be revoked by the owner")); | 319 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("permissive"), tr("Open to general traffic", "Open to general traffic but permission can be revoked by the owner")); | ||
320 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("no"), tr("No access", "No access for the general public")); | 320 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("no"), tr("No access", "No access for the general public")); | ||
321 | 321 | | |||
322 | 322 | | |||
323 | addTagDescription(m_description, QStringLiteral("fee"), QStringLiteral("no"), tr("no fee")); | 323 | addTagDescription(m_description, QStringLiteral("fee"), QStringLiteral("no"), tr("no fee")); | ||
324 | addTagValue(m_description, QStringLiteral("description")); | 324 | addTagValue(m_description, QStringLiteral("description")); | ||
325 | addTagValue(m_description, QStringLiteral("old_name"), tr("formerly <i>%1</i>")); | 325 | addTagValue(m_description, QStringLiteral("old_name"), tr("formerly <i>%1</i>")); | ||
326 | | ||||
327 | addTagDescription(m_description, QStringLiteral("wheelchair"), QStringLiteral("yes"), tr("Wheelchair accessible")); | | |||
328 | addTagDescription(m_description, QStringLiteral("wheelchair"), QStringLiteral("no"), tr("Not wheelchair accessible")); | | |||
329 | addTagDescription(m_description, QStringLiteral("wheelchair"), QStringLiteral("limited"), tr("Limited wheelchair accessibility")); | | |||
330 | } | 326 | } | ||
331 | 327 | | |||
332 | return m_description; | 328 | return m_description; | ||
333 | } | 329 | } | ||
334 | 330 | | |||
335 | QString Placemark::address() const | 331 | QString Placemark::address() const | ||
336 | { | 332 | { | ||
337 | if (m_address.isEmpty()) { | 333 | if (m_address.isEmpty()) { | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 395 | { | |||
405 | return m_openingHours; | 401 | return m_openingHours; | ||
406 | } | 402 | } | ||
407 | 403 | | |||
408 | QString Placemark::coordinates() const | 404 | QString Placemark::coordinates() const | ||
409 | { | 405 | { | ||
410 | return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed(); | 406 | return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed(); | ||
411 | } | 407 | } | ||
412 | 408 | | |||
409 | QString Placemark::wheelchairInfo() const | ||||
410 | { | ||||
411 | if (!m_wheelchairInfo.isEmpty()) | ||||
412 | return m_wheelchairInfo; | ||||
413 | | ||||
414 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("yes"), tr("Wheelchair accessible")); | ||||
415 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("no"), tr("Wheelchair inaccessible")); | ||||
416 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("limited"), tr("Limited wheelchair accessibility")); | ||||
417 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("designated"), tr("Wheelchair access only")); | ||||
418 | | ||||
419 | // Check if there is localized description | ||||
420 | auto const & osmData = m_placemark.osmData(); | ||||
421 | QStringList const uiLanguages = QLocale::system().uiLanguages(); | ||||
422 | foreach (const QString &uiLanguage, uiLanguages) { | ||||
423 | for (auto tagIter = osmData.tagsBegin(), end = osmData.tagsEnd(); tagIter != end; ++tagIter) { | ||||
424 | if (tagIter.key().startsWith(QLatin1String("wheelchair:description:"))) { | ||||
425 | QStringRef const tagLanguage = tagIter.key().midRef(23); | ||||
rahn: Any better approach to circumvent the 23 magic number (e.g. by evaluating the string snippet… | |||||
426 | if (tagLanguage == uiLanguage) { | ||||
427 | append(m_wheelchairInfo, tagIter.value()); | ||||
428 | return m_wheelchairInfo; | ||||
429 | } | ||||
430 | } | ||||
431 | } | ||||
432 | } | ||||
433 | | ||||
434 | addTagValue(m_wheelchairInfo, "wheelchair:description"); | ||||
435 | | ||||
436 | return m_wheelchairInfo; | ||||
437 | } | ||||
438 | | ||||
413 | void Placemark::setName(const QString & name) | 439 | void Placemark::setName(const QString & name) | ||
414 | { | 440 | { | ||
415 | if (m_placemark.displayName() == name) { | 441 | if (m_placemark.displayName() == name) { | ||
416 | return; | 442 | return; | ||
417 | } | 443 | } | ||
418 | 444 | | |||
419 | m_placemark.setName(name); | 445 | m_placemark.setName(name); | ||
420 | emit nameChanged(); | 446 | emit nameChanged(); | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
Any better approach to circumvent the 23 magic number (e.g. by evaluating the string snippet length before the foreach loop).