Change Details
poilayer.cpp |
22 | 22 | #include "mapwidget.h" |
23 | 23 | #include "projection.h" |
24 | 24 | |
| 25 | #include <QtCore/QDir> |
25 | 26 | #include <QtCore/QFile> |
| 27 | #include <QtCore/QSettings> |
26 | 28 | #include <QtXml/QXmlStreamReader> |
27 | 29 | |
28 | 30 | PoiLayer::PoiLayer(MapWidget *map) : |
... | ... | |
30 | 32 | m_points(), |
31 | 33 | m_pointsOnScreen(), |
32 | 34 | m_icons(), |
33 | | m_pointsOffset(0, 0) |
| 35 | m_pointsOffset(0, 0), |
| 36 | m_iconPath(), |
| 37 | m_iconCache() |
34 | 38 | { |
| 39 | QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat); |
| 40 | |
| 41 | set.beginGroup("poi"); |
| 42 | m_iconPath = set.value("iconpath", "/usr/share/NanoMap/icons").toString(); |
| 43 | set.endGroup(); |
35 | 44 | } |
36 | 45 | |
37 | 46 | void PoiLayer::load(const QString &filename) |
... | ... | |
83 | 92 | foreach (const QString &c, categories) { |
84 | 93 | QString t = tags.value(c, ""); |
85 | 94 | if (!t.isEmpty()) { |
86 | | m_points << pos; |
87 | | m_icons << t; |
88 | | break; |
| 95 | QString icon = m_iconPath+"/"+t+".png"; |
| 96 | if (QFile::exists(icon)) { |
| 97 | if (!m_iconCache.contains(t)) { |
| 98 | m_iconCache.insert(t, new QPixmap(icon)); |
| 99 | } |
| 100 | m_points << pos; |
| 101 | m_icons << t; |
| 102 | break; |
| 103 | } |
89 | 104 | } |
90 | 105 | } |
91 | 106 | tags.clear(); |
... | ... | |
120 | 135 | QPoint p; |
121 | 136 | for (int i = 0; i < m_pointsOnScreen.count(); ++i) { |
122 | 137 | p = m_pointsOnScreen.at(i); |
123 | | painter->drawEllipse(p + m_pointsOffset, 5, 5); |
| 138 | painter->drawPixmap(p + m_pointsOffset, *m_iconCache.value(m_icons.at(i))); |
124 | 139 | } |
125 | 140 | } |
126 | 141 | |
poilayer.h |
42 | 42 | QList<QPoint> m_pointsOnScreen; |
43 | 43 | QStringList m_icons; |
44 | 44 | QPoint m_pointsOffset; |
| 45 | QString m_iconPath; |
| 46 | QHash<QString, QPixmap*> m_iconCache; |
45 | 47 | |
46 | 48 | }; |
47 | 49 | |
Download the corresponding diff file