Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/declarative/Placemark.cpp
Show All 29 Lines | |||||
30 | void Placemark::setGeoDataPlacemark( const Marble::GeoDataPlacemark &placemark ) | 30 | void Placemark::setGeoDataPlacemark( const Marble::GeoDataPlacemark &placemark ) | ||
31 | { | 31 | { | ||
32 | m_placemark = placemark; | 32 | m_placemark = placemark; | ||
33 | m_address = QString(); | 33 | m_address = QString(); | ||
34 | m_description = QString(); | 34 | m_description = QString(); | ||
35 | m_website = QString(); | 35 | m_website = QString(); | ||
36 | m_wikipedia = QString(); | 36 | m_wikipedia = QString(); | ||
37 | m_openingHours = QString(); | 37 | m_openingHours = QString(); | ||
38 | m_wheelchairInfo = QString(); | ||||
38 | updateTags(); | 39 | updateTags(); | ||
39 | emit coordinatesChanged(); | 40 | emit coordinatesChanged(); | ||
40 | emit nameChanged(); | 41 | emit nameChanged(); | ||
41 | emit descriptionChanged(); | 42 | emit descriptionChanged(); | ||
42 | emit addressChanged(); | 43 | emit addressChanged(); | ||
43 | emit websiteChanged(); | 44 | emit websiteChanged(); | ||
44 | emit wikipediaChanged(); | 45 | emit wikipediaChanged(); | ||
45 | emit openingHoursChanged(); | 46 | emit openingHoursChanged(); | ||
47 | emit wheelchairInfoChanged(); | ||||
46 | emit tagsChanged(); | 48 | emit tagsChanged(); | ||
47 | } | 49 | } | ||
48 | 50 | | |||
49 | Marble::GeoDataPlacemark & Placemark::placemark() | 51 | Marble::GeoDataPlacemark & Placemark::placemark() | ||
50 | { | 52 | { | ||
51 | return m_placemark; | 53 | return m_placemark; | ||
52 | } | 54 | } | ||
53 | 55 | | |||
▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Line(s) | 68 | if (m_description.isEmpty()) { | |||
318 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("private"), tr("Private", "Only with permission of the owner on an individual basis.")); | 320 | 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")); | 321 | 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")); | 322 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("no"), tr("No access", "No access for the general public")); | ||
321 | 323 | | |||
322 | 324 | | |||
323 | addTagDescription(m_description, QStringLiteral("fee"), QStringLiteral("no"), tr("no fee")); | 325 | addTagDescription(m_description, QStringLiteral("fee"), QStringLiteral("no"), tr("no fee")); | ||
324 | addTagValue(m_description, QStringLiteral("description")); | 326 | addTagValue(m_description, QStringLiteral("description")); | ||
325 | addTagValue(m_description, QStringLiteral("old_name"), tr("formerly <i>%1</i>")); | 327 | 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 | } | 328 | } | ||
331 | 329 | | |||
332 | return m_description; | 330 | return m_description; | ||
333 | } | 331 | } | ||
334 | 332 | | |||
335 | QString Placemark::address() const | 333 | QString Placemark::address() const | ||
336 | { | 334 | { | ||
337 | if (m_address.isEmpty()) { | 335 | if (m_address.isEmpty()) { | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 397 | { | |||
405 | return m_openingHours; | 403 | return m_openingHours; | ||
406 | } | 404 | } | ||
407 | 405 | | |||
408 | QString Placemark::coordinates() const | 406 | QString Placemark::coordinates() const | ||
409 | { | 407 | { | ||
410 | return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed(); | 408 | return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed(); | ||
411 | } | 409 | } | ||
412 | 410 | | |||
411 | QString Placemark::wheelchairInfo() const | ||||
412 | { | ||||
413 | if (!m_wheelchairInfo.isEmpty()) | ||||
414 | return m_wheelchairInfo; | ||||
415 | | ||||
416 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("yes"), tr("Wheelchair accessible")); | ||||
417 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("no"), tr("Wheelchair inaccessible")); | ||||
418 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("limited"), tr("Limited wheelchair accessibility")); | ||||
419 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("designated"), tr("Wheelchair access only")); | ||||
420 | | ||||
421 | // Check if there is localized description | ||||
422 | auto const & osmData = m_placemark.osmData(); | ||||
423 | QStringList const uiLanguages = QLocale::system().uiLanguages(); | ||||
424 | foreach (const QString &uiLanguage, uiLanguages) { | ||||
425 | for (auto tagIter = osmData.tagsBegin(), end = osmData.tagsEnd(); tagIter != end; ++tagIter) { | ||||
426 | if (tagIter.key().startsWith(QLatin1String("wheelchair:description:"))) { | ||||
427 | QStringRef const tagLanguage = tagIter.key().midRef(23); | ||||
rahn: Any better approach to circumvent the 23 magic number (e.g. by evaluating the string snippet… | |||||
428 | if (tagLanguage == uiLanguage) { | ||||
429 | append(m_wheelchairInfo, tagIter.value()); | ||||
430 | return m_wheelchairInfo; | ||||
431 | } | ||||
432 | } | ||||
433 | } | ||||
434 | } | ||||
435 | | ||||
436 | addTagValue(m_wheelchairInfo, "wheelchair:description"); | ||||
437 | | ||||
438 | return m_wheelchairInfo; | ||||
439 | } | ||||
440 | | ||||
413 | void Placemark::setName(const QString & name) | 441 | void Placemark::setName(const QString & name) | ||
414 | { | 442 | { | ||
415 | if (m_placemark.displayName() == name) { | 443 | if (m_placemark.displayName() == name) { | ||
416 | return; | 444 | return; | ||
417 | } | 445 | } | ||
418 | 446 | | |||
419 | m_placemark.setName(name); | 447 | m_placemark.setName(name); | ||
420 | emit nameChanged(); | 448 | 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).