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