mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Refactoring
This commit is contained in:
parent
0f03ef4af7
commit
22fb6071f7
@ -2,6 +2,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
|
#include "mapaction.h"
|
||||||
#include "popup.h"
|
#include "popup.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "mapitem.h"
|
#include "mapitem.h"
|
||||||
@ -19,14 +20,19 @@ QString MapItem::info() const
|
|||||||
return tt.toString();
|
return tt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem::MapItem(Map *src, Map *map, GraphicsItem *parent)
|
MapItem::MapItem(MapAction *action, Map *map, GraphicsItem *parent)
|
||||||
: PlaneItem(parent)
|
: PlaneItem(parent)
|
||||||
{
|
{
|
||||||
|
Map *src = action->data().value<Map*>();
|
||||||
|
Q_ASSERT(map->isReady());
|
||||||
|
|
||||||
_name = src->name();
|
_name = src->name();
|
||||||
_fileName = src->path();
|
_fileName = src->path();
|
||||||
_bounds = RectC(src->xy2ll(src->bounds().topLeft()),
|
_bounds = RectC(src->xy2ll(src->bounds().topLeft()),
|
||||||
src->xy2ll(src->bounds().bottomRight()));
|
src->xy2ll(src->bounds().bottomRight()));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(triggered()), action, SLOT(trigger()));
|
||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
|
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
#include "planeitem.h"
|
#include "planeitem.h"
|
||||||
|
|
||||||
|
class MapAction;
|
||||||
|
|
||||||
class MapItem : public QObject, public PlaneItem
|
class MapItem : public QObject, public PlaneItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapItem(Map *src, Map *map, GraphicsItem *parent = 0);
|
MapItem(MapAction *action, Map *map, GraphicsItem *parent = 0);
|
||||||
|
|
||||||
QPainterPath shape() const {return _painterPath;}
|
QPainterPath shape() const {return _painterPath;}
|
||||||
QRectF boundingRect() const {return _painterPath.boundingRect();}
|
QRectF boundingRect() const {return _painterPath.boundingRect();}
|
||||||
|
@ -222,7 +222,7 @@ void MapView::addWaypoints(const QVector<Waypoint> &waypoints)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem *MapView::addMap(Map *map)
|
MapItem *MapView::addMap(MapAction *map)
|
||||||
{
|
{
|
||||||
MapItem *mi = new MapItem(map, _map);
|
MapItem *mi = new MapItem(map, _map);
|
||||||
mi->setColor(_palette.nextColor());
|
mi->setColor(_palette.nextColor());
|
||||||
@ -276,13 +276,8 @@ void MapView::loadMaps(const QList<MapAction *> &maps)
|
|||||||
{
|
{
|
||||||
int zoom = _map->zoom();
|
int zoom = _map->zoom();
|
||||||
|
|
||||||
for (int i = 0; i < maps.size(); i++) {
|
for (int i = 0; i < maps.size(); i++)
|
||||||
MapAction *a = maps.at(i);
|
addMap(maps.at(i));
|
||||||
Map *map = a->data().value<Map*>();
|
|
||||||
Q_ASSERT(map->isReady());
|
|
||||||
MapItem *mi = addMap(map);
|
|
||||||
connect(mi, SIGNAL(triggered()), a, SLOT(trigger()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fitMapZoom() != zoom)
|
if (fitMapZoom() != zoom)
|
||||||
rescale();
|
rescale();
|
||||||
|
@ -111,7 +111,7 @@ private:
|
|||||||
|
|
||||||
PathItem *addTrack(const Track &track);
|
PathItem *addTrack(const Track &track);
|
||||||
PathItem *addRoute(const Route &route);
|
PathItem *addRoute(const Route &route);
|
||||||
MapItem *addMap(Map *map);
|
MapItem *addMap(MapAction *map);
|
||||||
void addArea(const Area &area);
|
void addArea(const Area &area);
|
||||||
void addWaypoints(const QVector<Waypoint> &waypoints);
|
void addWaypoints(const QVector<Waypoint> &waypoints);
|
||||||
void addPOI(const QList<Waypoint> &waypoints);
|
void addPOI(const QList<Waypoint> &waypoints);
|
||||||
|
Loading…
Reference in New Issue
Block a user