1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Fixed some more track display corner cases + refactoring

This commit is contained in:
Martin Tůma 2017-12-01 00:22:16 +01:00
parent e30078a63e
commit 00acd48009
5 changed files with 134 additions and 133 deletions

View File

@ -43,7 +43,6 @@ HEADERS += src/config.h \
src/GUI/routeitem.h \
src/GUI/graphitem.h \
src/GUI/pathitem.h \
src/GUI/pathview.h \
src/GUI/griditem.h \
src/GUI/format.h \
src/GUI/cadencegraph.h \
@ -65,6 +64,7 @@ HEADERS += src/config.h \
src/GUI/nicenum.h \
src/GUI/cpuarch.h \
src/GUI/searchpointer.h \
src/GUI/mapview.h \
src/map/projection.h \
src/map/ellipsoid.h \
src/map/datum.h \
@ -135,7 +135,6 @@ SOURCES += src/main.cpp \
src/GUI/routeitem.cpp \
src/GUI/graphitem.cpp \
src/GUI/pathitem.cpp \
src/GUI/pathview.cpp \
src/GUI/griditem.cpp \
src/GUI/format.cpp \
src/GUI/cadencegraph.cpp \
@ -152,6 +151,7 @@ SOURCES += src/main.cpp \
src/GUI/cadencegraphitem.cpp \
src/GUI/powergraphitem.cpp \
src/GUI/nicenum.cpp \
src/GUI/mapview.cpp \
src/map/maplist.cpp \
src/map/onlinemap.cpp \
src/map/downloader.cpp \

View File

@ -36,7 +36,7 @@
#include "temperaturegraph.h"
#include "cadencegraph.h"
#include "powergraph.h"
#include "pathview.h"
#include "mapview.h"
#include "trackinfo.h"
#include "filebrowser.h"
#include "cpuarch.h"
@ -50,7 +50,7 @@ GUI::GUI()
loadMaps();
loadPOIs();
createPathView();
createMapView();
createGraphTabs();
createStatusBar();
createActions();
@ -62,7 +62,7 @@ GUI::GUI()
QSplitter *splitter = new QSplitter();
splitter->setOrientation(Qt::Vertical);
splitter->setChildrenCollapsible(false);
splitter->addWidget(_pathView);
splitter->addWidget(_mapView);
splitter->addWidget(_graphTabWidget);
splitter->setContentsMargins(0, 0, 0, 0);
splitter->setStretchFactor(0, 255);
@ -85,7 +85,7 @@ GUI::GUI()
_sliderPos = 0;
updateGraphTabs();
updatePathView();
updateMapView();
updateStatusBarInfo();
readSettings();
@ -287,17 +287,17 @@ void GUI::createActions()
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
_overlapPOIAction->setCheckable(true);
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _pathView,
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _mapView,
SLOT(setPOIOverlap(bool)));
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
_showPOILabelsAction->setCheckable(true);
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _pathView,
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showPOILabels(bool)));
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
tr("Show POIs"), this);
_showPOIAction->setCheckable(true);
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
connect(_showPOIAction, SIGNAL(triggered(bool)), _pathView,
connect(_showPOIAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showPOI(bool)));
addAction(_showPOIAction);
createPOIFilesActions();
@ -307,14 +307,14 @@ void GUI::createActions()
this);
_showMapAction->setCheckable(true);
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
connect(_showMapAction, SIGNAL(triggered(bool)), _pathView,
connect(_showMapAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showMap(bool)));
addAction(_showMapAction);
_loadMapAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
tr("Load map..."), this);
connect(_loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap()));
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
connect(_clearMapCacheAction, SIGNAL(triggered()), _pathView,
connect(_clearMapCacheAction, SIGNAL(triggered()), _mapView,
SLOT(clearMapCache()));
createMapActions();
_nextMapAction = new QAction(tr("Next map"), this);
@ -341,15 +341,15 @@ void GUI::createActions()
SLOT(showRoutes(bool)));
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
_showWaypointsAction->setCheckable(true);
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _pathView,
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showWaypoints(bool)));
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
_showWaypointLabelsAction->setCheckable(true);
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _pathView,
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showWaypointLabels(bool)));
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
_showRouteWaypointsAction->setCheckable(true);
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _pathView,
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showRouteWaypoints(bool)));
// Graph actions
@ -539,14 +539,14 @@ void GUI::createToolBars()
_navigationToolBar->addAction(_lastAction);
}
void GUI::createPathView()
void GUI::createMapView()
{
_pathView = new PathView(_map, _poi, this);
_pathView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
_mapView = new MapView(_map, _poi, this);
_mapView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
QSizePolicy::Expanding));
_pathView->setMinimumHeight(200);
_mapView->setMinimumHeight(200);
#ifdef Q_OS_WIN32
_pathView->setFrameShape(QFrame::NoFrame);
_mapView->setFrameShape(QFrame::NoFrame);
#endif // Q_OS_WIN32
}
@ -708,7 +708,7 @@ bool GUI::openFile(const QString &fileName)
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updatePathView();
updateMapView();
} else {
if (_files.isEmpty())
_fileActionGroup->setEnabled(false);
@ -724,7 +724,7 @@ bool GUI::loadFile(const QString &fileName)
QList<PathItem*> paths;
if (data.loadFile(fileName)) {
paths = _pathView->loadData(data);
paths = _mapView->loadData(data);
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->loadData(data, paths);
@ -760,7 +760,7 @@ bool GUI::loadFile(const QString &fileName)
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updatePathView();
updateMapView();
QString error = tr("Error loading data file:") + "\n\n"
+ fileName + "\n\n" + data.errorString();
@ -795,7 +795,7 @@ bool GUI::openPOIFile(const QString &fileName)
return false;
} else {
_pathView->showPOI(true);
_mapView->showPOI(true);
_showPOIAction->setChecked(true);
QAction *action = createPOIFileAction(_poi->files().indexOf(fileName));
action->setChecked(true);
@ -820,7 +820,7 @@ void GUI::openOptions()
{
#define SET_VIEW_OPTION(option, action) \
if (options.option != _options.option) \
_pathView->action(options.option)
_mapView->action(options.option)
#define SET_TAB_OPTION(option, action) \
if (options.option != _options.option) \
for (int i = 0; i < _tabs.count(); i++) \
@ -919,11 +919,11 @@ void GUI::plot(QPrinter *printer)
info.insert(tr("Name"), _pathName);
if (_options.printItemCount) {
if (_trackCount > 1)
if (_showTracksAction->isChecked() && _trackCount > 1)
info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount > 1)
if (_showRoutesAction->isChecked() && _routeCount > 1)
info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount > 2)
if (_showWaypointsAction->isChecked() && _waypointCount > 2)
info.insert(tr("Waypoints"), QString::number(_waypointCount));
}
@ -967,7 +967,7 @@ void GUI::plot(QPrinter *printer)
ratio);
} else
gh = 0;
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
_mapView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
- (ih + 2*mh + gh)), ratio, _options.hiresPrint);
if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
@ -1007,7 +1007,7 @@ void GUI::reloadFile()
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear();
_pathView->clear();
_mapView->clear();
_sliderPos = 0;
@ -1021,7 +1021,7 @@ void GUI::reloadFile()
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updatePathView();
updateMapView();
if (_files.isEmpty())
_fileActionGroup->setEnabled(false);
else
@ -1044,7 +1044,7 @@ void GUI::closeFiles()
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear();
_pathView->clear();
_mapView->clear();
_files.clear();
}
@ -1057,7 +1057,7 @@ void GUI::closeAll()
updateStatusBarInfo();
updateWindowTitle();
updateGraphTabs();
updatePathView();
updateMapView();
}
void GUI::showGraphs(bool show)
@ -1084,7 +1084,7 @@ void GUI::showToolbars(bool show)
void GUI::showFullscreen(bool show)
{
if (show) {
_frameStyle = _pathView->frameStyle();
_frameStyle = _mapView->frameStyle();
_showGraphs = _showGraphsAction->isChecked();
statusBar()->hide();
@ -1092,7 +1092,7 @@ void GUI::showFullscreen(bool show)
showToolbars(false);
showGraphs(false);
_showGraphsAction->setChecked(false);
_pathView->setFrameStyle(QFrame::NoFrame);
_mapView->setFrameStyle(QFrame::NoFrame);
showFullScreen();
} else {
@ -1103,7 +1103,7 @@ void GUI::showFullscreen(bool show)
_showGraphsAction->setChecked(_showGraphs);
if (_showGraphsAction->isEnabled())
showGraphs(_showGraphs);
_pathView->setFrameStyle(_frameStyle);
_mapView->setFrameStyle(_frameStyle);
showNormal();
}
@ -1111,22 +1111,24 @@ void GUI::showFullscreen(bool show)
void GUI::showTracks(bool show)
{
_pathView->showTracks(show);
_mapView->showTracks(show);
for (int i = 0; i < _tabs.size(); i++)
_tabs.at(i)->showTracks(show);
updateStatusBarInfo();
updateGraphTabs();
}
void GUI::showRoutes(bool show)
{
_pathView->showRoutes(show);
_mapView->showRoutes(show);
for (int i = 0; i < _tabs.size(); i++)
_tabs.at(i)->showRoutes(show);
updateStatusBarInfo();
updateGraphTabs();
}
void GUI::showGraphGrids(bool show)
@ -1211,7 +1213,7 @@ void GUI::updateWindowTitle()
void GUI::mapChanged(int index)
{
_map = _ml->maps().at(index);
_pathView->setMap(_map);
_mapView->setMap(_map);
}
void GUI::nextMap()
@ -1291,7 +1293,9 @@ void GUI::updateGraphTabs()
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
}
if (_graphTabWidget->count()) {
if (_graphTabWidget->count() &&
((_showTracksAction->isChecked() && _trackCount)
|| (_showRoutesAction->isChecked() && _routeCount))) {
if (_showGraphsAction->isChecked())
_graphTabWidget->setHidden(false);
_showGraphsAction->setEnabled(true);
@ -1301,10 +1305,9 @@ void GUI::updateGraphTabs()
}
}
void GUI::updatePathView()
void GUI::updateMapView()
{
_pathView->setHidden(!(_pathView->trackCount() + _pathView->routeCount()
+ _pathView->waypointCount()));
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount));
}
void GUI::setTimeType(TimeType type)
@ -1320,7 +1323,7 @@ void GUI::setUnits(Units units)
_export.units = units;
_options.units = units;
_pathView->setUnits(units);
_mapView->setUnits(units);
for (int i = 0; i <_tabs.count(); i++)
_tabs.at(i)->setUnits(units);
updateStatusBarInfo();
@ -1693,17 +1696,17 @@ void GUI::readSettings()
settings.beginGroup(POI_SETTINGS_GROUP);
if (!settings.value(OVERLAP_POI_SETTING, OVERLAP_POI_DEFAULT).toBool())
_pathView->setPOIOverlap(false);
_mapView->setPOIOverlap(false);
else
_overlapPOIAction->setChecked(true);
if (!settings.value(LABELS_POI_SETTING, LABELS_POI_DEFAULT).toBool())
_pathView->showPOILabels(false);
_mapView->showPOILabels(false);
else
_showPOILabelsAction->setChecked(true);
if (settings.value(SHOW_POI_SETTING, SHOW_POI_DEFAULT).toBool())
_showPOIAction->setChecked(true);
else
_pathView->showPOI(false);
_mapView->showPOI(false);
for (int i = 0; i < _poiFilesActions.count(); i++)
_poiFilesActions.at(i)->setChecked(true);
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
@ -1721,30 +1724,30 @@ void GUI::readSettings()
settings.beginGroup(DATA_SETTINGS_GROUP);
if (!settings.value(SHOW_TRACKS_SETTING, SHOW_TRACKS_DEFAULT).toBool()) {
_pathView->showTracks(false);
_mapView->showTracks(false);
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->showTracks(false);
} else
_showTracksAction->setChecked(true);
if (!settings.value(SHOW_ROUTES_SETTING, SHOW_ROUTES_DEFAULT).toBool()) {
_pathView->showRoutes(false);
_mapView->showRoutes(false);
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->showRoutes(false);
} else
_showRoutesAction->setChecked(true);
if (!settings.value(SHOW_WAYPOINTS_SETTING, SHOW_WAYPOINTS_DEFAULT)
.toBool())
_pathView->showWaypoints(false);
_mapView->showWaypoints(false);
else
_showWaypointsAction->setChecked(true);
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
_pathView->showWaypointLabels(false);
_mapView->showWaypointLabels(false);
else
_showWaypointLabelsAction->setChecked(true);
if (!settings.value(SHOW_ROUTE_WAYPOINTS_SETTING,
SHOW_ROUTE_WAYPOINTS_SETTING).toBool())
_pathView->showRouteWaypoints(false);
_mapView->showRouteWaypoints(false);
else
_showRouteWaypointsAction->setChecked(true);
settings.endGroup();
@ -1839,20 +1842,20 @@ void GUI::readSettings()
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
_pathView->setPalette(_options.palette);
_pathView->setMapOpacity(_options.mapOpacity);
_pathView->setBackgroundColor(_options.backgroundColor);
_pathView->setTrackWidth(_options.trackWidth);
_pathView->setRouteWidth(_options.routeWidth);
_pathView->setTrackStyle(_options.trackStyle);
_pathView->setRouteStyle(_options.routeStyle);
_pathView->setWaypointSize(_options.waypointSize);
_pathView->setWaypointColor(_options.waypointColor);
_pathView->setPOISize(_options.poiSize);
_pathView->setPOIColor(_options.poiColor);
_pathView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
_mapView->setPalette(_options.palette);
_mapView->setMapOpacity(_options.mapOpacity);
_mapView->setBackgroundColor(_options.backgroundColor);
_mapView->setTrackWidth(_options.trackWidth);
_mapView->setRouteWidth(_options.routeWidth);
_mapView->setTrackStyle(_options.trackStyle);
_mapView->setRouteStyle(_options.routeStyle);
_mapView->setWaypointSize(_options.waypointSize);
_mapView->setWaypointColor(_options.waypointColor);
_mapView->setPOISize(_options.poiSize);
_mapView->setPOIColor(_options.poiColor);
_mapView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
if (_options.useOpenGL)
_pathView->useOpenGL(true);
_mapView->useOpenGL(true);
for (int i = 0; i < _tabs.count(); i++) {
_tabs.at(i)->setPalette(_options.palette);

View File

@ -23,7 +23,7 @@ class QSignalMapper;
class QPrinter;
class FileBrowser;
class GraphTab;
class PathView;
class MapView;
class Map;
class MapList;
@ -93,7 +93,7 @@ private:
void createMenus();
void createToolBars();
void createStatusBar();
void createPathView();
void createMapView();
void createGraphTabs();
void createBrowser();
@ -104,7 +104,7 @@ private:
void updateWindowTitle();
void updateNavigationActions();
void updateGraphTabs();
void updatePathView();
void updateMapView();
TimeType timeType() const;
Units units() const;
@ -185,17 +185,17 @@ private:
QLabel *_distanceLabel;
QLabel *_timeLabel;
PathView *_pathView;
MapView *_mapView;
QTabWidget *_graphTabWidget;
QList<GraphTab*> _tabs;
POI *_poi;
MapList *_ml;
Map *_map;
FileBrowser *_browser;
QList<QString> _files;
Map *_map;
int _trackCount;
int _routeCount;
int _waypointCount;

View File

@ -13,7 +13,7 @@
#include "waypointitem.h"
#include "scaleitem.h"
#include "keys.h"
#include "pathview.h"
#include "mapview.h"
#define MAX_DIGITAL_ZOOM 2
@ -21,7 +21,7 @@
#define MARGIN 10.0
#define SCALE_OFFSET 7
PathView::PathView(Map *map, POI *poi, QWidget *parent)
MapView::MapView(Map *map, POI *poi, QWidget *parent)
: QGraphicsView(parent)
{
Q_ASSERT(map != 0);
@ -79,7 +79,7 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
centerOn(_scene->sceneRect().center());
}
void PathView::centerOn(const QPointF &pos)
void MapView::centerOn(const QPointF &pos)
{
QGraphicsView::centerOn(pos);
@ -97,7 +97,7 @@ void PathView::centerOn(const QPointF &pos)
_mapScale->setResolution(_res);
}
PathItem *PathView::addTrack(const Track &track)
PathItem *MapView::addTrack(const Track &track)
{
if (track.isNull()) {
_palette.nextColor();
@ -121,7 +121,7 @@ PathItem *PathView::addTrack(const Track &track)
return ti;
}
PathItem *PathView::addRoute(const Route &route)
PathItem *MapView::addRoute(const Route &route)
{
if (route.isNull()) {
_palette.nextColor();
@ -147,7 +147,7 @@ PathItem *PathView::addRoute(const Route &route)
return ri;
}
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
void MapView::addWaypoints(const QList<Waypoint> &waypoints)
{
for (int i = 0; i < waypoints.count(); i++) {
const Waypoint &w = waypoints.at(i);
@ -169,7 +169,7 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
}
}
QList<PathItem *> PathView::loadData(const Data &data)
QList<PathItem *> MapView::loadData(const Data &data)
{
QList<PathItem *> paths;
qreal zoom = _map->zoom();
@ -193,7 +193,7 @@ QList<PathItem *> PathView::loadData(const Data &data)
return paths;
}
void PathView::updateWaypointsBoundingRect(const Coordinates &wp)
void MapView::updateWaypointsBoundingRect(const Coordinates &wp)
{
if (_wr.isNull())
_wr = RectC(wp, wp);
@ -201,21 +201,23 @@ void PathView::updateWaypointsBoundingRect(const Coordinates &wp)
_wr.unite(wp);
}
qreal PathView::mapZoom() const
qreal MapView::mapZoom() const
{
RectC br = _tr | _rr | _wr;
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br);
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN),
br.isValid() ? br : RectC(_map->xy2ll(sceneRect().topLeft()),
_map->xy2ll(sceneRect().bottomRight())));
}
QPointF PathView::contentCenter() const
QPointF MapView::contentCenter() const
{
RectC br = _tr | _rr | _wr;
return _map->ll2xy(br.center());
return br.isValid() ? _map->ll2xy(br.center()) : sceneRect().center();
}
void PathView::updatePOIVisibility()
void MapView::updatePOIVisibility()
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it, jt;
@ -236,7 +238,7 @@ void PathView::updatePOIVisibility()
}
}
void PathView::rescale()
void MapView::rescale()
{
_scene->setSceneRect(_map->bounds());
resetCachedContent();
@ -255,7 +257,7 @@ void PathView::rescale()
updatePOIVisibility();
}
void PathView::setPalette(const Palette &palette)
void MapView::setPalette(const Palette &palette)
{
_palette = palette;
_palette.reset();
@ -266,7 +268,7 @@ void PathView::setPalette(const Palette &palette)
_routes.at(i)->setColor(_palette.nextColor());
}
void PathView::setMap(Map *map)
void MapView::setMap(Map *map)
{
QPointF pos = mapToScene(viewport()->rect().center());
Coordinates center = _map->xy2ll(pos);
@ -302,7 +304,7 @@ void PathView::setMap(Map *map)
QPixmapCache::clear();
}
void PathView::setPOI(POI *poi)
void MapView::setPOI(POI *poi)
{
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
connect(poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
@ -312,7 +314,7 @@ void PathView::setPOI(POI *poi)
updatePOI();
}
void PathView::updatePOI()
void MapView::updatePOI()
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -335,7 +337,7 @@ void PathView::updatePOI()
updatePOIVisibility();
}
void PathView::addPOI(const QList<Waypoint> &waypoints)
void MapView::addPOI(const QList<Waypoint> &waypoints)
{
for (int i = 0; i < waypoints.size(); i++) {
const Waypoint &w = waypoints.at(i);
@ -356,7 +358,7 @@ void PathView::addPOI(const QList<Waypoint> &waypoints)
}
}
void PathView::setUnits(enum Units units)
void MapView::setUnits(enum Units units)
{
_units = units;
@ -374,13 +376,13 @@ void PathView::setUnits(enum Units units)
it.value()->setUnits(units);
}
void PathView::clearMapCache()
void MapView::clearMapCache()
{
_map->clearCache();
resetCachedContent();
}
void PathView::resetDigitalZoom()
void MapView::resetDigitalZoom()
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -399,7 +401,7 @@ void PathView::resetDigitalZoom()
_mapScale->setDigitalZoom(0);
}
void PathView::digitalZoom(int zoom)
void MapView::digitalZoom(int zoom)
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -418,7 +420,7 @@ void PathView::digitalZoom(int zoom)
_mapScale->setDigitalZoom(_digitalZoom);
}
void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
void MapView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
{
bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
@ -444,7 +446,7 @@ void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
}
}
void PathView::wheelEvent(QWheelEvent *event)
void MapView::wheelEvent(QWheelEvent *event)
{
static int deg = 0;
@ -457,7 +459,7 @@ void PathView::wheelEvent(QWheelEvent *event)
zoom((event->delta() > 0) ? 1 : -1, event->pos(), c);
}
void PathView::mouseDoubleClickEvent(QMouseEvent *event)
void MapView::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
return;
@ -466,7 +468,7 @@ void PathView::mouseDoubleClickEvent(QMouseEvent *event)
zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos(), c);
}
void PathView::keyPressEvent(QKeyEvent *event)
void MapView::keyPressEvent(QKeyEvent *event)
{
int z;
@ -488,7 +490,7 @@ void PathView::keyPressEvent(QKeyEvent *event)
zoom(z, pos, c);
}
void PathView::plot(QPainter *painter, const QRectF &target, qreal scale,
void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
bool hires)
{
QRect orig, adj;
@ -564,7 +566,7 @@ void PathView::plot(QPainter *painter, const QRectF &target, qreal scale,
setUpdatesEnabled(true);
}
void PathView::clear()
void MapView::clear()
{
_pois.clear();
_tracks.clear();
@ -586,7 +588,7 @@ void PathView::clear()
QPixmapCache::clear();
}
void PathView::showTracks(bool show)
void MapView::showTracks(bool show)
{
_showTracks = show;
@ -596,7 +598,7 @@ void PathView::showTracks(bool show)
updatePOI();
}
void PathView::showRoutes(bool show)
void MapView::showRoutes(bool show)
{
_showRoutes = show;
@ -606,7 +608,7 @@ void PathView::showRoutes(bool show)
updatePOI();
}
void PathView::showWaypoints(bool show)
void MapView::showWaypoints(bool show)
{
_showWaypoints = show;
@ -616,7 +618,7 @@ void PathView::showWaypoints(bool show)
updatePOI();
}
void PathView::showWaypointLabels(bool show)
void MapView::showWaypointLabels(bool show)
{
_showWaypointLabels = show;
@ -627,7 +629,7 @@ void PathView::showWaypointLabels(bool show)
_routes.at(i)->showWaypointLabels(show);
}
void PathView::showRouteWaypoints(bool show)
void MapView::showRouteWaypoints(bool show)
{
_showRouteWaypoints = show;
@ -635,13 +637,13 @@ void PathView::showRouteWaypoints(bool show)
_routes.at(i)->showWaypoints(show);
}
void PathView::showMap(bool show)
void MapView::showMap(bool show)
{
_showMap = show;
resetCachedContent();
}
void PathView::showPOI(bool show)
void MapView::showPOI(bool show)
{
_showPOI = show;
@ -652,7 +654,7 @@ void PathView::showPOI(bool show)
updatePOIVisibility();
}
void PathView::showPOILabels(bool show)
void MapView::showPOILabels(bool show)
{
_showPOILabels = show;
@ -663,14 +665,14 @@ void PathView::showPOILabels(bool show)
updatePOIVisibility();
}
void PathView::setPOIOverlap(bool overlap)
void MapView::setPOIOverlap(bool overlap)
{
_overlapPOIs = overlap;
updatePOIVisibility();
}
void PathView::setTrackWidth(int width)
void MapView::setTrackWidth(int width)
{
_trackWidth = width;
@ -678,7 +680,7 @@ void PathView::setTrackWidth(int width)
_tracks.at(i)->setWidth(width);
}
void PathView::setRouteWidth(int width)
void MapView::setRouteWidth(int width)
{
_routeWidth = width;
@ -686,7 +688,7 @@ void PathView::setRouteWidth(int width)
_routes.at(i)->setWidth(width);
}
void PathView::setTrackStyle(Qt::PenStyle style)
void MapView::setTrackStyle(Qt::PenStyle style)
{
_trackStyle = style;
@ -694,7 +696,7 @@ void PathView::setTrackStyle(Qt::PenStyle style)
_tracks.at(i)->setStyle(style);
}
void PathView::setRouteStyle(Qt::PenStyle style)
void MapView::setRouteStyle(Qt::PenStyle style)
{
_routeStyle = style;
@ -702,7 +704,7 @@ void PathView::setRouteStyle(Qt::PenStyle style)
_routes.at(i)->setStyle(style);
}
void PathView::setWaypointSize(int size)
void MapView::setWaypointSize(int size)
{
_waypointSize = size;
@ -710,7 +712,7 @@ void PathView::setWaypointSize(int size)
_waypoints.at(i)->setSize(size);
}
void PathView::setWaypointColor(const QColor &color)
void MapView::setWaypointColor(const QColor &color)
{
_waypointColor = color;
@ -718,7 +720,7 @@ void PathView::setWaypointColor(const QColor &color)
_waypoints.at(i)->setColor(color);
}
void PathView::setPOISize(int size)
void MapView::setPOISize(int size)
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -728,7 +730,7 @@ void PathView::setPOISize(int size)
it.value()->setSize(size);
}
void PathView::setPOIColor(const QColor &color)
void MapView::setPOIColor(const QColor &color)
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -738,20 +740,20 @@ void PathView::setPOIColor(const QColor &color)
it.value()->setColor(color);
}
void PathView::setMapOpacity(int opacity)
void MapView::setMapOpacity(int opacity)
{
_opacity = opacity / 100.0;
resetCachedContent();
}
void PathView::setBackgroundColor(const QColor &color)
void MapView::setBackgroundColor(const QColor &color)
{
_backgroundColor = color;
_map->setBackgroundColor(color);
resetCachedContent();
}
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
void MapView::drawBackground(QPainter *painter, const QRectF &rect)
{
if (_showMap) {
if (_opacity < 1.0) {
@ -763,7 +765,7 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
painter->fillRect(rect, _backgroundColor);
}
void PathView::resizeEvent(QResizeEvent *event)
void MapView::resizeEvent(QResizeEvent *event)
{
qreal zoom = _map->zoom();
if (mapZoom() != zoom)
@ -774,7 +776,7 @@ void PathView::resizeEvent(QResizeEvent *event)
QGraphicsView::resizeEvent(event);
}
void PathView::paintEvent(QPaintEvent *event)
void MapView::paintEvent(QPaintEvent *event)
{
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
@ -785,7 +787,7 @@ void PathView::paintEvent(QPaintEvent *event)
QGraphicsView::paintEvent(event);
}
void PathView::scrollContentsBy(int dx, int dy)
void MapView::scrollContentsBy(int dx, int dy)
{
QGraphicsView::scrollContentsBy(dx, dy);
@ -798,7 +800,7 @@ void PathView::scrollContentsBy(int dx, int dy)
}
}
void PathView::useOpenGL(bool use)
void MapView::useOpenGL(bool use)
{
if (use)
setViewport(new OPENGL_WIDGET);
@ -806,12 +808,12 @@ void PathView::useOpenGL(bool use)
setViewport(new QWidget);
}
void PathView::useAntiAliasing(bool use)
void MapView::useAntiAliasing(bool use)
{
setRenderHint(QPainter::Antialiasing, use);
}
void PathView::reloadMap()
void MapView::reloadMap()
{
resetCachedContent();
}

View File

@ -1,5 +1,5 @@
#ifndef TRACKVIEW_H
#define TRACKVIEW_H
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include <QGraphicsView>
#include <QVector>
@ -22,12 +22,12 @@ class WaypointItem;
class ScaleItem;
class PathItem;
class PathView : public QGraphicsView
class MapView : public QGraphicsView
{
Q_OBJECT
public:
PathView(Map *map, POI *poi, QWidget *parent = 0);
MapView(Map *map, POI *poi, QWidget *parent = 0);
QList<PathItem*> loadData(const Data &data);
@ -38,10 +38,6 @@ public:
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
int trackCount() const {return _tracks.count();}
int routeCount() const {return _routes.count();}
int waypointCount() const {return _waypoints.count();}
void clear();
void setTrackWidth(int width);
@ -138,4 +134,4 @@ private:
bool _plot;
};
#endif // TRACKVIEW_H
#endif // MAPVIEW_H