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