1
0
mirror of git://projects.qi-hardware.com/nanomap.git synced 2024-11-22 07:06:15 +02:00

draw icons of the points of interest loaded from a .osm file

This commit is contained in:
Niels 2010-11-17 10:58:22 +01:00
parent 5e06ce0453
commit bdecafa5bd
19 changed files with 22 additions and 5 deletions

BIN
icons/atm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

BIN
icons/bank.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

BIN
icons/bus_stop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
icons/cinema.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

BIN
icons/drinking_water.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

BIN
icons/fuel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

BIN
icons/hospital.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

BIN
icons/hostel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

BIN
icons/hotel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

BIN
icons/museum.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

BIN
icons/parking.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

BIN
icons/pharmacy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

BIN
icons/recycling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

BIN
icons/speed_camera.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

BIN
icons/telephone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

BIN
icons/toilets.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

BIN
icons/viewpoint.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

View File

@ -22,7 +22,9 @@
#include "mapwidget.h" #include "mapwidget.h"
#include "projection.h" #include "projection.h"
#include <QtCore/QDir>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QSettings>
#include <QtXml/QXmlStreamReader> #include <QtXml/QXmlStreamReader>
PoiLayer::PoiLayer(MapWidget *map) : PoiLayer::PoiLayer(MapWidget *map) :
@ -30,8 +32,15 @@ PoiLayer::PoiLayer(MapWidget *map) :
m_points(), m_points(),
m_pointsOnScreen(), m_pointsOnScreen(),
m_icons(), m_icons(),
m_pointsOffset(0, 0) m_pointsOffset(0, 0),
m_iconPath(),
m_iconCache()
{ {
QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat);
set.beginGroup("poi");
m_iconPath = set.value("iconpath", "/usr/share/NanoMap/icons").toString();
set.endGroup();
} }
void PoiLayer::load(const QString &filename) void PoiLayer::load(const QString &filename)
@ -83,9 +92,15 @@ void PoiLayer::load(const QString &filename)
foreach (const QString &c, categories) { foreach (const QString &c, categories) {
QString t = tags.value(c, ""); QString t = tags.value(c, "");
if (!t.isEmpty()) { if (!t.isEmpty()) {
m_points << pos; QString icon = m_iconPath+"/"+t+".png";
m_icons << t; if (QFile::exists(icon)) {
break; if (!m_iconCache.contains(t)) {
m_iconCache.insert(t, new QPixmap(icon));
}
m_points << pos;
m_icons << t;
break;
}
} }
} }
tags.clear(); tags.clear();
@ -120,7 +135,7 @@ void PoiLayer::paint(QPainter *painter)
QPoint p; QPoint p;
for (int i = 0; i < m_pointsOnScreen.count(); ++i) { for (int i = 0; i < m_pointsOnScreen.count(); ++i) {
p = m_pointsOnScreen.at(i); p = m_pointsOnScreen.at(i);
painter->drawEllipse(p + m_pointsOffset, 5, 5); painter->drawPixmap(p + m_pointsOffset, *m_iconCache.value(m_icons.at(i)));
} }
} }

View File

@ -42,6 +42,8 @@ private:
QList<QPoint> m_pointsOnScreen; QList<QPoint> m_pointsOnScreen;
QStringList m_icons; QStringList m_icons;
QPoint m_pointsOffset; QPoint m_pointsOffset;
QString m_iconPath;
QHash<QString, QPixmap*> m_iconCache;
}; };