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 280 Lines • ▼ Show 20 Line(s) | 68 | if (m_description.isEmpty()) { | |||
334 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("private"), tr("Private", "Only with permission of the owner on an individual basis.")); | 336 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("private"), tr("Private", "Only with permission of the owner on an individual basis.")); | ||
335 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("permissive"), tr("Open to general traffic", "Open to general traffic but permission can be revoked by the owner")); | 337 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("permissive"), tr("Open to general traffic", "Open to general traffic but permission can be revoked by the owner")); | ||
336 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("no"), tr("No access", "No access for the general public")); | 338 | addTagDescription(m_description, QStringLiteral("access"), QStringLiteral("no"), tr("No access", "No access for the general public")); | ||
337 | 339 | | |||
338 | 340 | | |||
339 | addTagDescription(m_description, QStringLiteral("fee"), QStringLiteral("no"), tr("no fee")); | 341 | addTagDescription(m_description, QStringLiteral("fee"), QStringLiteral("no"), tr("no fee")); | ||
340 | addTagValue(m_description, QStringLiteral("description")); | 342 | addTagValue(m_description, QStringLiteral("description")); | ||
341 | addTagValue(m_description, QStringLiteral("old_name"), tr("formerly <i>%1</i>")); | 343 | addTagValue(m_description, QStringLiteral("old_name"), tr("formerly <i>%1</i>")); | ||
342 | | ||||
343 | addTagDescription(m_description, QStringLiteral("wheelchair"), QStringLiteral("yes"), tr("Wheelchair accessible")); | | |||
344 | addTagDescription(m_description, QStringLiteral("wheelchair"), QStringLiteral("no"), tr("Not wheelchair accessible")); | | |||
345 | addTagDescription(m_description, QStringLiteral("wheelchair"), QStringLiteral("limited"), tr("Limited wheelchair accessibility")); | | |||
346 | } | 344 | } | ||
347 | 345 | | |||
348 | return m_description; | 346 | return m_description; | ||
349 | } | 347 | } | ||
350 | 348 | | |||
351 | QString Placemark::address() const | 349 | QString Placemark::address() const | ||
352 | { | 350 | { | ||
353 | if (m_address.isEmpty()) { | 351 | if (m_address.isEmpty()) { | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 413 | { | |||
421 | return m_openingHours; | 419 | return m_openingHours; | ||
422 | } | 420 | } | ||
423 | 421 | | |||
424 | QString Placemark::coordinates() const | 422 | QString Placemark::coordinates() const | ||
425 | { | 423 | { | ||
426 | return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed(); | 424 | return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed(); | ||
427 | } | 425 | } | ||
428 | 426 | | |||
427 | QString Placemark::wheelchairInfo() const | ||||
428 | { | ||||
429 | if (!m_wheelchairInfo.isEmpty()) | ||||
430 | return m_wheelchairInfo; | ||||
431 | | ||||
432 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("yes"), tr("Wheelchair accessible")); | ||||
433 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("no"), tr("Wheelchair inaccessible")); | ||||
434 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("limited"), tr("Limited wheelchair accessibility")); | ||||
435 | addTagDescription(m_wheelchairInfo, QStringLiteral("wheelchair"), QStringLiteral("designated"), tr("Wheelchair access only")); | ||||
436 | | ||||
437 | // Check if there is localized description | ||||
438 | auto const & osmData = m_placemark.osmData(); | ||||
439 | QStringList const uiLanguages = QLocale::system().uiLanguages(); | ||||
440 | const QString tag = QLatin1String("wheelchair:description:"); | ||||
441 | foreach (const QString &uiLanguage, uiLanguages) { | ||||
442 | for (auto tagIter = osmData.tagsBegin(), end = osmData.tagsEnd(); tagIter != end; ++tagIter) { | ||||
443 | if (tagIter.key().startsWith(tag)) { | ||||
rahn: Any better approach to circumvent the 23 magic number (e.g. by evaluating the string snippet… | |||||
444 | QStringRef const tagLanguage = tagIter.key().midRef(tag.length()); | ||||
445 | if (tagLanguage == uiLanguage) { | ||||
446 | append(m_wheelchairInfo, tagIter.value()); | ||||
447 | return m_wheelchairInfo; | ||||
448 | } | ||||
449 | } | ||||
450 | } | ||||
451 | } | ||||
452 | | ||||
453 | addTagValue(m_wheelchairInfo, "wheelchair:description"); | ||||
454 | | ||||
455 | return m_wheelchairInfo; | ||||
456 | } | ||||
457 | | ||||
429 | void Placemark::setName(const QString & name) | 458 | void Placemark::setName(const QString & name) | ||
430 | { | 459 | { | ||
431 | if (m_placemark.displayName() == name) { | 460 | if (m_placemark.displayName() == name) { | ||
432 | return; | 461 | return; | ||
433 | } | 462 | } | ||
434 | 463 | | |||
435 | m_placemark.setName(name); | 464 | m_placemark.setName(name); | ||
436 | emit nameChanged(); | 465 | 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).