[10] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
[9] | 5 | #include "Landmark.h"
|
---|
| 6 | #include <QPen>
|
---|
| 7 | #include <QGeoMapTextObject>
|
---|
| 8 | #include <QGeoMapPixmapObject>
|
---|
| 9 | #include <QGraphicsGeoMap>
|
---|
| 10 |
|
---|
| 11 | using namespace QtMobility;
|
---|
| 12 |
|
---|
| 13 | Landmark::Landmark(QGraphicsGeoMap *geoMap, const QGeoCoordinate &coordinate,QString name,QString type)
|
---|
| 14 | {
|
---|
| 15 | geoMap->addMapObject(this);
|
---|
| 16 | this->geoMap=geoMap;
|
---|
| 17 | pixmap = new QGeoMapPixmapObject();
|
---|
| 18 | pixmap->setCoordinate(coordinate);
|
---|
| 19 |
|
---|
| 20 | if(type=="cross")
|
---|
| 21 | {
|
---|
| 22 | pixmap->setOffset(QPoint(-16, -16));
|
---|
| 23 | pixmap->setPixmap(QPixmap(":cross.png"));
|
---|
| 24 | }
|
---|
| 25 | else
|
---|
| 26 | {
|
---|
| 27 | pixmap->setOffset(QPoint(-2, -30));
|
---|
| 28 | pixmap->setPixmap(QPixmap(":landmark.png"));
|
---|
| 29 | }
|
---|
| 30 | addChildObject(pixmap);
|
---|
| 31 |
|
---|
| 32 | QFont font;
|
---|
| 33 | font.setWeight(QFont::Bold);
|
---|
| 34 | text = new QGeoMapTextObject(coordinate,name, font, QPoint(0, 10));
|
---|
| 35 | text->setPen(QPen(Qt::NoPen));
|
---|
| 36 | text->setBrush(QBrush(Qt::red));
|
---|
| 37 | addChildObject(text);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | Landmark::~Landmark()
|
---|
| 41 | {
|
---|
| 42 | geoMap->removeMapObject(this);
|
---|
| 43 | clearChildObjects();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | void Landmark::setText(QString string)
|
---|
| 47 | {
|
---|
| 48 | text->setText(string);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | void Landmark::setColor(Qt::GlobalColor color)
|
---|
| 52 | {
|
---|
| 53 | text->setBrush(QBrush(color));
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | void Landmark::setCoordinate(const QGeoCoordinate &coordinate)
|
---|
| 57 | {
|
---|
| 58 | pixmap->setCoordinate(coordinate);
|
---|
| 59 | text->setCoordinate(coordinate);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | QGeoCoordinate Landmark::coordinate(void)
|
---|
| 63 | {
|
---|
| 64 | return pixmap->coordinate();
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | void Landmark::RemoveLandmark(void)
|
---|
| 68 | {
|
---|
| 69 | geoMap->removeMapObject(this);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | void Landmark::AddLandmark(QGraphicsGeoMap *geoMap)
|
---|
| 73 | {
|
---|
| 74 | geoMap->addMapObject(this);
|
---|
| 75 | this->geoMap=geoMap;
|
---|
| 76 | }
|
---|