mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Code cleanup
This commit is contained in:
parent
014e260042
commit
70f4010f55
@ -28,7 +28,6 @@ HEADERS += src/config.h \
|
||||
src/units.h \
|
||||
src/scaleitem.h \
|
||||
src/waypoint.h \
|
||||
src/trackview.h \
|
||||
src/track.h \
|
||||
src/graphview.h \
|
||||
src/trackpoint.h \
|
||||
@ -52,7 +51,8 @@ HEADERS += src/config.h \
|
||||
src/routeitem.h \
|
||||
src/graphitem.h \
|
||||
src/graph.h \
|
||||
src/pathitem.h
|
||||
src/pathitem.h \
|
||||
src/pathview.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
@ -71,7 +71,6 @@ SOURCES += src/main.cpp \
|
||||
src/maplist.cpp \
|
||||
src/downloader.cpp \
|
||||
src/scaleitem.cpp \
|
||||
src/trackview.cpp \
|
||||
src/track.cpp \
|
||||
src/graphview.cpp \
|
||||
src/waypointitem.cpp \
|
||||
@ -90,7 +89,9 @@ SOURCES += src/main.cpp \
|
||||
src/tooltip.cpp \
|
||||
src/route.cpp \
|
||||
src/routeitem.cpp \
|
||||
src/graphitem.cpp
|
||||
src/graphitem.cpp \
|
||||
src/pathitem.cpp \
|
||||
src/pathview.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx {
|
||||
|
@ -10,7 +10,7 @@
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="139"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="141"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
@ -30,7 +30,7 @@
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="142"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="144"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
@ -156,7 +156,7 @@
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="657"/>
|
||||
<location filename="../src/gui.cpp" line="658"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
@ -363,23 +363,23 @@
|
||||
<translation>Předchozí mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="745"/>
|
||||
<location filename="../src/gui.cpp" line="748"/>
|
||||
<location filename="../src/gui.cpp" line="746"/>
|
||||
<location filename="../src/gui.cpp" line="749"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="757"/>
|
||||
<location filename="../src/gui.cpp" line="758"/>
|
||||
<source>Routes</source>
|
||||
<translation>Trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="947"/>
|
||||
<location filename="../src/gui.cpp" line="948"/>
|
||||
<source>No GPX files loaded</source>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="951"/>
|
||||
<location filename="../src/gui.cpp" line="952"/>
|
||||
<source>%1 files</source>
|
||||
<translation>%1 souborů</translation>
|
||||
</message>
|
||||
@ -404,7 +404,7 @@
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="759"/>
|
||||
<location filename="../src/gui.cpp" line="760"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Navigační body</translation>
|
||||
</message>
|
||||
@ -454,18 +454,18 @@
|
||||
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="648"/>
|
||||
<location filename="../src/gui.cpp" line="674"/>
|
||||
<location filename="../src/gui.cpp" line="649"/>
|
||||
<location filename="../src/gui.cpp" line="675"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="658"/>
|
||||
<location filename="../src/gui.cpp" line="659"/>
|
||||
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
|
||||
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="755"/>
|
||||
<location filename="../src/gui.cpp" line="756"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
@ -492,31 +492,31 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="313"/>
|
||||
<location filename="../src/gui.cpp" line="762"/>
|
||||
<location filename="../src/gui.cpp" line="763"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="319"/>
|
||||
<location filename="../src/gui.cpp" line="764"/>
|
||||
<location filename="../src/gui.cpp" line="765"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="650"/>
|
||||
<location filename="../src/gui.cpp" line="675"/>
|
||||
<location filename="../src/gui.cpp" line="651"/>
|
||||
<location filename="../src/gui.cpp" line="676"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<location filename="../src/gui.cpp" line="646"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="671"/>
|
||||
<location filename="../src/gui.cpp" line="672"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
@ -526,47 +526,47 @@
|
||||
<context>
|
||||
<name>GraphView</name>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="110"/>
|
||||
<location filename="../src/graphview.cpp" line="111"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="113"/>
|
||||
<location filename="../src/graphview.cpp" line="114"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="118"/>
|
||||
<location filename="../src/graphview.cpp" line="119"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="121"/>
|
||||
<location filename="../src/graphview.cpp" line="122"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="127"/>
|
||||
<location filename="../src/graphview.cpp" line="128"/>
|
||||
<source>s</source>
|
||||
<translation>s</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="130"/>
|
||||
<location filename="../src/graphview.cpp" line="131"/>
|
||||
<source>min</source>
|
||||
<translation>min</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="133"/>
|
||||
<location filename="../src/graphview.cpp" line="134"/>
|
||||
<source>h</source>
|
||||
<translation>h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="158"/>
|
||||
<location filename="../src/graphview.cpp" line="160"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/graphview.cpp" line="160"/>
|
||||
<location filename="../src/graphview.cpp" line="162"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
@ -623,7 +623,7 @@
|
||||
<context>
|
||||
<name>RouteItem</name>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="18"/>
|
||||
<location filename="../src/routeitem.cpp" line="15"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
@ -631,22 +631,22 @@
|
||||
<context>
|
||||
<name>ScaleItem</name>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="87"/>
|
||||
<location filename="../src/scaleitem.cpp" line="90"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="88"/>
|
||||
<location filename="../src/scaleitem.cpp" line="91"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="90"/>
|
||||
<location filename="../src/scaleitem.cpp" line="93"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/scaleitem.cpp" line="91"/>
|
||||
<location filename="../src/scaleitem.cpp" line="94"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
@ -717,17 +717,17 @@
|
||||
<context>
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<location filename="../src/trackitem.cpp" line="14"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="20"/>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="22"/>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
|
80
src/gui.cpp
80
src/gui.cpp
@ -30,7 +30,7 @@
|
||||
#include "speedgraph.h"
|
||||
#include "heartrategraph.h"
|
||||
#include "temperaturegraph.h"
|
||||
#include "trackview.h"
|
||||
#include "pathview.h"
|
||||
#include "trackinfo.h"
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
@ -56,7 +56,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
_browser->setFilter(QStringList("*.gpx"));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(_track);
|
||||
layout->addWidget(_pathView);
|
||||
layout->addWidget(_trackGraphs);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
#ifdef Q_OS_WIN32
|
||||
@ -238,11 +238,11 @@ 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)), _track,
|
||||
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _pathView,
|
||||
SLOT(setPOIOverlap(bool)));
|
||||
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
|
||||
_showPOILabelsAction->setCheckable(true);
|
||||
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _track,
|
||||
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _pathView,
|
||||
SLOT(showPOILabels(bool)));
|
||||
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
||||
tr("Show POIs"), this);
|
||||
@ -289,15 +289,15 @@ void GUI::createActions()
|
||||
SLOT(showRoutes(bool)));
|
||||
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
|
||||
_showWaypointsAction->setCheckable(true);
|
||||
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _track,
|
||||
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _pathView,
|
||||
SLOT(showWaypoints(bool)));
|
||||
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
||||
_showWaypointLabelsAction->setCheckable(true);
|
||||
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _track,
|
||||
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _pathView,
|
||||
SLOT(showWaypointLabels(bool)));
|
||||
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
|
||||
_showRouteWaypointsAction->setCheckable(true);
|
||||
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _track,
|
||||
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _pathView,
|
||||
SLOT(showRouteWaypoints(bool)));
|
||||
|
||||
// Graph actions
|
||||
@ -457,7 +457,7 @@ void GUI::createToolBars()
|
||||
|
||||
void GUI::createTrackView()
|
||||
{
|
||||
_track = new TrackView(this);
|
||||
_pathView = new PathView(this);
|
||||
#ifdef Q_OS_WIN32
|
||||
_track->setFrameShape(QFrame::NoFrame);
|
||||
#endif // Q_OS_WIN32
|
||||
@ -615,13 +615,13 @@ bool GUI::loadFile(const QString &fileName)
|
||||
QList<PathItem*> paths;
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
paths = _track->loadGPX(gpx);
|
||||
paths = _pathView->loadGPX(gpx);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->loadGPX(gpx, paths);
|
||||
updateGraphTabs();
|
||||
_track->setHidden(false);
|
||||
_pathView->setHidden(false);
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
_pathView->loadPOI(_poi);
|
||||
|
||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||
_trackDistance += gpx.tracks().at(i)->distance();
|
||||
@ -678,7 +678,7 @@ bool GUI::openPOIFile(const QString &fileName)
|
||||
return false;
|
||||
} else {
|
||||
_showPOIAction->setChecked(true);
|
||||
_track->loadPOI(_poi);
|
||||
_pathView->loadPOI(_poi);
|
||||
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
|
||||
action->setChecked(true);
|
||||
_poiFilesMenu->addAction(action);
|
||||
@ -695,7 +695,7 @@ void GUI::closePOIFiles()
|
||||
delete _poiFilesActions[i];
|
||||
_poiFilesActions.clear();
|
||||
|
||||
_track->clearPOI();
|
||||
_pathView->clearPOI();
|
||||
|
||||
_poi.clear();
|
||||
}
|
||||
@ -784,7 +784,7 @@ void GUI::plot(QPrinter *printer)
|
||||
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
||||
} else
|
||||
gh = 0;
|
||||
_track->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (ih + 2*mh + gh)));
|
||||
}
|
||||
|
||||
@ -800,7 +800,7 @@ void GUI::reloadFile()
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
_track->clear();
|
||||
_pathView->clear();
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
@ -835,7 +835,7 @@ void GUI::closeFiles()
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
_track->clear();
|
||||
_pathView->clear();
|
||||
|
||||
_files.clear();
|
||||
}
|
||||
@ -854,17 +854,17 @@ void GUI::closeAll()
|
||||
void GUI::showPOI(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
_track->loadPOI(_poi);
|
||||
_pathView->loadPOI(_poi);
|
||||
else
|
||||
_track->clearPOI();
|
||||
_pathView->clearPOI();
|
||||
}
|
||||
|
||||
void GUI::showMap(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
_track->setMap(_currentMap);
|
||||
_pathView->setMap(_currentMap);
|
||||
else
|
||||
_track->setMap(0);
|
||||
_pathView->setMap(0);
|
||||
}
|
||||
|
||||
void GUI::showGraphs(bool checked)
|
||||
@ -891,7 +891,7 @@ void GUI::showToolbars(bool checked)
|
||||
void GUI::showFullscreen(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
_frameStyle = _track->frameStyle();
|
||||
_frameStyle = _pathView->frameStyle();
|
||||
_showGraphs = _showGraphsAction->isChecked();
|
||||
|
||||
statusBar()->hide();
|
||||
@ -899,7 +899,7 @@ void GUI::showFullscreen(bool checked)
|
||||
showToolbars(false);
|
||||
showGraphs(false);
|
||||
_showGraphsAction->setChecked(false);
|
||||
_track->setFrameStyle(QFrame::NoFrame);
|
||||
_pathView->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
showFullScreen();
|
||||
} else {
|
||||
@ -910,7 +910,7 @@ void GUI::showFullscreen(bool checked)
|
||||
_showGraphsAction->setChecked(_showGraphs);
|
||||
if (_showGraphsAction->isEnabled())
|
||||
showGraphs(_showGraphs);
|
||||
_track->setFrameStyle(_frameStyle);
|
||||
_pathView->setFrameStyle(_frameStyle);
|
||||
|
||||
showNormal();
|
||||
}
|
||||
@ -918,7 +918,7 @@ void GUI::showFullscreen(bool checked)
|
||||
|
||||
void GUI::showTracks(bool show)
|
||||
{
|
||||
_track->showTracks(show);
|
||||
_pathView->showTracks(show);
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showTracks(show);
|
||||
@ -928,7 +928,7 @@ void GUI::showTracks(bool show)
|
||||
|
||||
void GUI::showRoutes(bool show)
|
||||
{
|
||||
_track->showRoutes(show);
|
||||
_pathView->showRoutes(show);
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showRoutes(show);
|
||||
@ -939,7 +939,7 @@ void GUI::showRoutes(bool show)
|
||||
void GUI::clearMapCache()
|
||||
{
|
||||
_currentMap->clearCache();
|
||||
_track->redraw();
|
||||
_pathView->redraw();
|
||||
}
|
||||
|
||||
void GUI::updateStatusBarInfo()
|
||||
@ -979,7 +979,7 @@ void GUI::mapChanged(int index)
|
||||
_currentMap = _maps.at(index);
|
||||
|
||||
if (_showMapAction->isChecked())
|
||||
_track->setMap(_currentMap);
|
||||
_pathView->setMap(_currentMap);
|
||||
}
|
||||
|
||||
void GUI::nextMap()
|
||||
@ -1005,9 +1005,9 @@ void GUI::poiFileChecked(int index)
|
||||
_poi.enableFile(_poi.files().at(index),
|
||||
_poiFilesActions.at(index)->isChecked());
|
||||
|
||||
_track->clearPOI();
|
||||
_pathView->clearPOI();
|
||||
if (_showPOIAction->isChecked())
|
||||
_track->loadPOI(_poi);
|
||||
_pathView->loadPOI(_poi);
|
||||
}
|
||||
|
||||
void GUI::sliderPositionChanged(qreal pos)
|
||||
@ -1072,13 +1072,13 @@ void GUI::updateGraphTabs()
|
||||
|
||||
void GUI::updateTrackView()
|
||||
{
|
||||
_track->setHidden(!(_track->trackCount() + _track->routeCount()
|
||||
+ _track->waypointCount()));
|
||||
_pathView->setHidden(!(_pathView->trackCount() + _pathView->routeCount()
|
||||
+ _pathView->waypointCount()));
|
||||
}
|
||||
|
||||
void GUI::setUnits(Units units)
|
||||
{
|
||||
_track->setUnits(units);
|
||||
_pathView->setUnits(units);
|
||||
for (int i = 0; i <_tabs.count(); i++)
|
||||
_tabs.at(i)->setUnits(units);
|
||||
updateStatusBarInfo();
|
||||
@ -1259,7 +1259,7 @@ void GUI::readSettings()
|
||||
_mapActions.at(index)->setChecked(true);
|
||||
_currentMap = _maps.at(index);
|
||||
if (_showMapAction->isChecked())
|
||||
_track->setMap(_currentMap);
|
||||
_pathView->setMap(_currentMap);
|
||||
} else
|
||||
_currentMap = 0;
|
||||
settings.endGroup();
|
||||
@ -1278,11 +1278,11 @@ void GUI::readSettings()
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
|
||||
_track->setPOIOverlap(false);
|
||||
_pathView->setPOIOverlap(false);
|
||||
else
|
||||
_overlapPOIAction->setChecked(true);
|
||||
if (settings.value(LABELS_POI_SETTING, true).toBool() == false)
|
||||
_track->showPOILabels(false);
|
||||
_pathView->showPOILabels(false);
|
||||
else
|
||||
_showPOILabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
||||
@ -1304,27 +1304,27 @@ void GUI::readSettings()
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
||||
_track->showTracks(false);
|
||||
_pathView->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, true).toBool() == false) {
|
||||
_track->showRoutes(false);
|
||||
_pathView->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, true).toBool() == false)
|
||||
_track->showWaypoints(false);
|
||||
_pathView->showWaypoints(false);
|
||||
else
|
||||
_showWaypointsAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINT_LABELS_SETTING, true).toBool() == false)
|
||||
_track->showWaypointLabels(false);
|
||||
_pathView->showWaypointLabels(false);
|
||||
else
|
||||
_showWaypointLabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
_track->showRouteWaypoints(false);
|
||||
_pathView->showRouteWaypoints(false);
|
||||
else
|
||||
_showRouteWaypointsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
@ -21,7 +21,7 @@ class QSignalMapper;
|
||||
class QPrinter;
|
||||
class FileBrowser;
|
||||
class GraphTab;
|
||||
class TrackView;
|
||||
class PathView;
|
||||
class Map;
|
||||
|
||||
class GUI : public QMainWindow
|
||||
@ -162,7 +162,7 @@ private:
|
||||
QLabel *_distanceLabel;
|
||||
QLabel *_timeLabel;
|
||||
|
||||
TrackView *_track;
|
||||
PathView *_pathView;
|
||||
QTabWidget *_trackGraphs;
|
||||
QList<GraphTab*> _tabs;
|
||||
|
||||
|
104
src/pathitem.cpp
Normal file
104
src/pathitem.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QPainter>
|
||||
#include "tooltip.h"
|
||||
#include "pathitem.h"
|
||||
|
||||
|
||||
#define PATH_WIDTH 3
|
||||
#define HOVER_WIDTH 4
|
||||
|
||||
void PathItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
||||
_shape = s.createStroke(_path);
|
||||
|
||||
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
|
||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
else
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
}
|
||||
|
||||
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||
{
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, PATH_WIDTH);
|
||||
|
||||
_units = Metric;
|
||||
|
||||
_marker = new MarkerItem(this);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath(_path);
|
||||
|
||||
/*
|
||||
QPen p = QPen(QBrush(Qt::red), 0);
|
||||
painter->setPen(p);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
}
|
||||
|
||||
void PathItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
_marker->setScale(1.0/scale);
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void PathItem::setColor(const QColor &color)
|
||||
{
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
}
|
||||
|
||||
void PathItem::moveMarker(qreal distance)
|
||||
{
|
||||
if (distance > _distance)
|
||||
_marker->setVisible(false);
|
||||
else {
|
||||
_marker->setVisible(true);
|
||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||
}
|
||||
}
|
||||
|
||||
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
||||
setZValue(zValue() + 1.0);
|
||||
update();
|
||||
|
||||
emit selected(true);
|
||||
}
|
||||
|
||||
void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale());
|
||||
setZValue(zValue() - 1.0);
|
||||
update();
|
||||
|
||||
emit selected(false);
|
||||
}
|
@ -2,21 +2,50 @@
|
||||
#define PATHITEM_H
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QPen>
|
||||
#include "markeritem.h"
|
||||
#include "units.h"
|
||||
|
||||
|
||||
class PathItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathItem(QGraphicsItem *parent = 0) : QGraphicsObject(parent) {}
|
||||
virtual void showMarker(bool show) = 0;
|
||||
PathItem(QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QPainterPath &path() const {return _path;}
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
void setScale(qreal scale);
|
||||
void setUnits(enum Units units);
|
||||
void setColor(const QColor &color);
|
||||
|
||||
public slots:
|
||||
virtual void moveMarker(qreal distance) = 0;
|
||||
void moveMarker(qreal distance);
|
||||
|
||||
signals:
|
||||
void selected(bool);
|
||||
|
||||
protected:
|
||||
void updateShape();
|
||||
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
qreal _distance;
|
||||
|
||||
private:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
};
|
||||
|
||||
#endif // PATHITEM_H
|
||||
|
@ -9,13 +9,13 @@
|
||||
#include "routeitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "scaleitem.h"
|
||||
#include "trackview.h"
|
||||
#include "pathview.h"
|
||||
|
||||
|
||||
#define MARGIN 10.0
|
||||
#define SCALE_OFFSET 7
|
||||
|
||||
TrackView::TrackView(QWidget *parent)
|
||||
PathView::PathView(QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
_scene = new QGraphicsScene(this);
|
||||
@ -47,13 +47,13 @@ TrackView::TrackView(QWidget *parent)
|
||||
_plot = false;
|
||||
}
|
||||
|
||||
TrackView::~TrackView()
|
||||
PathView::~PathView()
|
||||
{
|
||||
if (_mapScale->scene() != _scene)
|
||||
delete _mapScale;
|
||||
}
|
||||
|
||||
PathItem *TrackView::addTrack(const Track &track)
|
||||
PathItem *PathView::addTrack(const Track &track)
|
||||
{
|
||||
if (track.isNull()) {
|
||||
_palette.color();
|
||||
@ -72,7 +72,7 @@ PathItem *TrackView::addTrack(const Track &track)
|
||||
return ti;
|
||||
}
|
||||
|
||||
PathItem *TrackView::addRoute(const Route &route)
|
||||
PathItem *PathView::addRoute(const Route &route)
|
||||
{
|
||||
if (route.isNull()) {
|
||||
_palette.color();
|
||||
@ -93,7 +93,7 @@ PathItem *TrackView::addRoute(const Route &route)
|
||||
return ri;
|
||||
}
|
||||
|
||||
void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
{
|
||||
for (int i = 0; i < waypoints.count(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
@ -112,7 +112,7 @@ void TrackView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
_scale = mapScale(_zoom);
|
||||
}
|
||||
|
||||
QList<PathItem *> TrackView::loadGPX(const GPX &gpx)
|
||||
QList<PathItem *> PathView::loadGPX(const GPX &gpx)
|
||||
{
|
||||
QList<PathItem *> paths;
|
||||
PathItem *pi;
|
||||
@ -149,7 +149,7 @@ QList<PathItem *> TrackView::loadGPX(const GPX &gpx)
|
||||
return paths;
|
||||
}
|
||||
|
||||
QRectF TrackView::trackBoundingRect() const
|
||||
QRectF PathView::trackBoundingRect() const
|
||||
{
|
||||
if (_tracks.empty())
|
||||
return QRectF();
|
||||
@ -161,7 +161,7 @@ QRectF TrackView::trackBoundingRect() const
|
||||
return br;
|
||||
}
|
||||
|
||||
QRectF TrackView::routeBoundingRect() const
|
||||
QRectF PathView::routeBoundingRect() const
|
||||
{
|
||||
if (_routes.empty())
|
||||
return QRectF();
|
||||
@ -173,7 +173,7 @@ QRectF TrackView::routeBoundingRect() const
|
||||
return br;
|
||||
}
|
||||
|
||||
QRectF TrackView::waypointBoundingRect() const
|
||||
QRectF PathView::waypointBoundingRect() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
@ -197,7 +197,7 @@ QRectF TrackView::waypointBoundingRect() const
|
||||
return QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||
}
|
||||
|
||||
qreal TrackView::trackScale() const
|
||||
qreal PathView::trackScale() const
|
||||
{
|
||||
if (_tracks.empty())
|
||||
return mapScale(ZOOM_MAX);
|
||||
@ -213,7 +213,7 @@ qreal TrackView::trackScale() const
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal TrackView::routeScale() const
|
||||
qreal PathView::routeScale() const
|
||||
{
|
||||
if (_routes.empty())
|
||||
return mapScale(ZOOM_MAX);
|
||||
@ -229,7 +229,7 @@ qreal TrackView::routeScale() const
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal TrackView::waypointScale() const
|
||||
qreal PathView::waypointScale() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
@ -257,12 +257,12 @@ qreal TrackView::waypointScale() const
|
||||
return qMax(sc.x(), sc.y());
|
||||
}
|
||||
|
||||
qreal TrackView::mapScale(int zoom) const
|
||||
qreal PathView::mapScale(int zoom) const
|
||||
{
|
||||
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||
}
|
||||
|
||||
void TrackView::checkPOIOverlap()
|
||||
void PathView::checkPOIOverlap()
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||
|
||||
@ -275,7 +275,7 @@ void TrackView::checkPOIOverlap()
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::rescale(qreal scale)
|
||||
void PathView::rescale(qreal scale)
|
||||
{
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->setScale(1.0/scale);
|
||||
@ -298,7 +298,7 @@ void TrackView::rescale(qreal scale)
|
||||
_scale = scale;
|
||||
}
|
||||
|
||||
void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
{
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
@ -316,7 +316,7 @@ void TrackView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::loadPOI(const POI &poi)
|
||||
void PathView::loadPOI(const POI &poi)
|
||||
{
|
||||
if (!_tracks.size() && !_routes.size() && !_waypoints.size())
|
||||
return;
|
||||
@ -331,7 +331,7 @@ void TrackView::loadPOI(const POI &poi)
|
||||
checkPOIOverlap();
|
||||
}
|
||||
|
||||
void TrackView::setMap(Map *map)
|
||||
void PathView::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
if (_map)
|
||||
@ -340,7 +340,7 @@ void TrackView::setMap(Map *map)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::setUnits(enum Units units)
|
||||
void PathView::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
@ -358,12 +358,12 @@ void TrackView::setUnits(enum Units units)
|
||||
it.value()->setUnits(units);
|
||||
}
|
||||
|
||||
void TrackView::redraw()
|
||||
void PathView::redraw()
|
||||
{
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::rescale()
|
||||
void PathView::rescale()
|
||||
{
|
||||
_zoom = qMin(qMin(scale2zoom(trackScale()), scale2zoom(routeScale())),
|
||||
scale2zoom(waypointScale()));
|
||||
@ -372,7 +372,7 @@ void TrackView::rescale()
|
||||
_mapScale->setZoom(_zoom);
|
||||
}
|
||||
|
||||
void TrackView::zoom(int z, const QPointF &pos)
|
||||
void PathView::zoom(int z, const QPointF &pos)
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
@ -397,7 +397,7 @@ void TrackView::zoom(int z, const QPointF &pos)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::wheelEvent(QWheelEvent *event)
|
||||
void PathView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
@ -409,7 +409,7 @@ void TrackView::wheelEvent(QWheelEvent *event)
|
||||
zoom(z, pos);
|
||||
}
|
||||
|
||||
void TrackView::keyPressEvent(QKeyEvent *event)
|
||||
void PathView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int z = -1;
|
||||
|
||||
@ -424,7 +424,7 @@ void TrackView::keyPressEvent(QKeyEvent *event)
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void TrackView::plot(QPainter *painter, const QRectF &target)
|
||||
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
QRect orig, adj;
|
||||
qreal ratio, diff;
|
||||
@ -458,7 +458,7 @@ void TrackView::plot(QPainter *painter, const QRectF &target)
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void TrackView::clearPOI()
|
||||
void PathView::clearPOI()
|
||||
{
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
|
||||
@ -470,7 +470,7 @@ void TrackView::clearPOI()
|
||||
_pois.clear();
|
||||
}
|
||||
|
||||
void TrackView::clear()
|
||||
void PathView::clear()
|
||||
{
|
||||
if (_mapScale->scene() == _scene)
|
||||
_scene->removeItem(_mapScale);
|
||||
@ -488,7 +488,7 @@ void TrackView::clear()
|
||||
_scene->setSceneRect(QRectF());
|
||||
}
|
||||
|
||||
void TrackView::showTracks(bool show)
|
||||
void PathView::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
@ -496,7 +496,7 @@ void TrackView::showTracks(bool show)
|
||||
_tracks.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::showRoutes(bool show)
|
||||
void PathView::showRoutes(bool show)
|
||||
{
|
||||
_showRoutes = show;
|
||||
|
||||
@ -504,7 +504,7 @@ void TrackView::showRoutes(bool show)
|
||||
_routes.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::showWaypoints(bool show)
|
||||
void PathView::showWaypoints(bool show)
|
||||
{
|
||||
_showWaypoints = show;
|
||||
|
||||
@ -512,7 +512,7 @@ void TrackView::showWaypoints(bool show)
|
||||
_waypoints.at(i)->setVisible(show);
|
||||
}
|
||||
|
||||
void TrackView::showWaypointLabels(bool show)
|
||||
void PathView::showWaypointLabels(bool show)
|
||||
{
|
||||
_showWaypointLabels = show;
|
||||
|
||||
@ -523,7 +523,7 @@ void TrackView::showWaypointLabels(bool show)
|
||||
_routes.at(i)->showWaypointLabels(show);
|
||||
}
|
||||
|
||||
void TrackView::showRouteWaypoints(bool show)
|
||||
void PathView::showRouteWaypoints(bool show)
|
||||
{
|
||||
_showRouteWaypoints = show;
|
||||
|
||||
@ -531,7 +531,7 @@ void TrackView::showRouteWaypoints(bool show)
|
||||
_routes.at(i)->showWaypoints(show);
|
||||
}
|
||||
|
||||
void TrackView::showPOILabels(bool show)
|
||||
void PathView::showPOILabels(bool show)
|
||||
{
|
||||
_showPOILabels = show;
|
||||
|
||||
@ -542,7 +542,7 @@ void TrackView::showPOILabels(bool show)
|
||||
setPOIOverlap(_overlapPOIs);
|
||||
}
|
||||
|
||||
void TrackView::setPOIOverlap(bool overlap)
|
||||
void PathView::setPOIOverlap(bool overlap)
|
||||
{
|
||||
_overlapPOIs = overlap;
|
||||
|
||||
@ -554,7 +554,7 @@ void TrackView::setPOIOverlap(bool overlap)
|
||||
checkPOIOverlap();
|
||||
}
|
||||
|
||||
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
|| !_map) {
|
||||
@ -586,7 +586,7 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
}
|
||||
}
|
||||
|
||||
void TrackView::resizeEvent(QResizeEvent *e)
|
||||
void PathView::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
@ -612,7 +612,7 @@ void TrackView::resizeEvent(QResizeEvent *e)
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void TrackView::paintEvent(QPaintEvent *e)
|
||||
void PathView::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
@ -20,13 +20,13 @@ class WaypointItem;
|
||||
class ScaleItem;
|
||||
class PathItem;
|
||||
|
||||
class TrackView : public QGraphicsView
|
||||
class PathView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrackView(QWidget *parent = 0);
|
||||
~TrackView();
|
||||
PathView(QWidget *parent = 0);
|
||||
~PathView();
|
||||
|
||||
QList<PathItem*> loadGPX(const GPX &gpx);
|
||||
|
@ -8,9 +8,6 @@
|
||||
#include "routeitem.h"
|
||||
|
||||
|
||||
#define ROUTE_WIDTH 3
|
||||
#define HOVER_WIDTH 4
|
||||
|
||||
QString RouteItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
@ -21,18 +18,6 @@ QString RouteItem::toolTip()
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void RouteItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
||||
_shape = s.createStroke(_path);
|
||||
|
||||
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
|
||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
else
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
}
|
||||
|
||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||
: PathItem(parent)
|
||||
{
|
||||
@ -48,74 +33,32 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||
new WaypointItem(r.at(i), this);
|
||||
}
|
||||
|
||||
_units = Metric;
|
||||
_distance = route.distance();
|
||||
|
||||
setToolTip(toolTip());
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
updateShape();
|
||||
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, ROUTE_WIDTH, Qt::DotLine);
|
||||
_distance = route.distance();
|
||||
|
||||
_marker = new MarkerItem(this);
|
||||
_marker->setPos(_path.pointAtPercent(0));
|
||||
}
|
||||
|
||||
void RouteItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
_pen.setStyle(Qt::DotLine);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath(_path);
|
||||
|
||||
/*
|
||||
QPen p = QPen(QBrush(Qt::red), 0);
|
||||
painter->setPen(p);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void RouteItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(ROUTE_WIDTH * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++)
|
||||
childs.at(i)->setScale(1.0/scale);
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void RouteItem::setColor(const QColor &color)
|
||||
{
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
PathItem::setScale(scale);
|
||||
}
|
||||
|
||||
void RouteItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
PathItem::setUnits(units);
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void RouteItem::moveMarker(qreal distance)
|
||||
{
|
||||
if (distance > _distance)
|
||||
_marker->setVisible(false);
|
||||
else {
|
||||
_marker->setVisible(true);
|
||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||
}
|
||||
}
|
||||
|
||||
void RouteItem::showWaypoints(bool show)
|
||||
{
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
@ -134,25 +77,3 @@ void RouteItem::showWaypointLabels(bool show)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RouteItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
||||
setZValue(zValue() + 1.0);
|
||||
update();
|
||||
|
||||
emit selected(true);
|
||||
}
|
||||
|
||||
void RouteItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(ROUTE_WIDTH * 1.0/scale());
|
||||
setZValue(zValue() - 1.0);
|
||||
update();
|
||||
|
||||
emit selected(false);
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
#ifndef ROUTEITEM_H
|
||||
#define ROUTEITEM_H
|
||||
|
||||
#include <QPen>
|
||||
#include "pathitem.h"
|
||||
#include "markeritem.h"
|
||||
#include "route.h"
|
||||
#include "units.h"
|
||||
|
||||
|
||||
class RouteItem : public PathItem
|
||||
@ -15,38 +12,14 @@ class RouteItem : public PathItem
|
||||
public:
|
||||
RouteItem(const Route &route, QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QPainterPath &path() const {return _path;}
|
||||
|
||||
void setScale(qreal scale);
|
||||
void setColor(const QColor &color);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
void moveMarker(qreal distance);
|
||||
void setScale(qreal scale);
|
||||
|
||||
void showWaypoints(bool show);
|
||||
void showWaypointLabels(bool show);
|
||||
|
||||
private:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // ROUTEITEM_H
|
||||
|
@ -7,9 +7,6 @@
|
||||
#include "trackitem.h"
|
||||
|
||||
|
||||
#define TRACK_WIDTH 3
|
||||
#define HOVER_WIDTH 4
|
||||
|
||||
QString TrackItem::toolTip()
|
||||
{
|
||||
ToolTip tt;
|
||||
@ -25,18 +22,6 @@ QString TrackItem::toolTip()
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void TrackItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
||||
_shape = s.createStroke(_path);
|
||||
|
||||
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
|
||||
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
else
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
}
|
||||
|
||||
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
||||
: PathItem(parent)
|
||||
{
|
||||
@ -50,91 +35,19 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
||||
_path.lineTo(ll2mercator(QPointF(p.x(), -p.y())));
|
||||
}
|
||||
|
||||
_units = Metric;
|
||||
updateShape();
|
||||
|
||||
_date = track.date();
|
||||
_distance = track.distance();
|
||||
_time = track.time();
|
||||
|
||||
setToolTip(toolTip());
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
updateShape();
|
||||
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, TRACK_WIDTH);
|
||||
|
||||
_marker = new MarkerItem(this);
|
||||
_marker->setPos(_path.pointAtPercent(0));
|
||||
}
|
||||
|
||||
void TrackItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath(_path);
|
||||
|
||||
/*
|
||||
QPen p = QPen(QBrush(Qt::red), 0);
|
||||
painter->setPen(p);
|
||||
painter->drawRect(boundingRect());
|
||||
*/
|
||||
}
|
||||
|
||||
void TrackItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(TRACK_WIDTH * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
_marker->setScale(1.0/scale);
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void TrackItem::setColor(const QColor &color)
|
||||
{
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void TrackItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
PathItem::setUnits(units);
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void TrackItem::moveMarker(qreal distance)
|
||||
{
|
||||
if (distance > _distance)
|
||||
_marker->setVisible(false);
|
||||
else {
|
||||
_marker->setVisible(true);
|
||||
_marker->setPos(_path.pointAtPercent(distance / _distance));
|
||||
}
|
||||
}
|
||||
|
||||
void TrackItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
||||
setZValue(zValue() + 1.0);
|
||||
update();
|
||||
|
||||
emit selected(true);
|
||||
}
|
||||
|
||||
void TrackItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(TRACK_WIDTH * 1.0/scale());
|
||||
setZValue(zValue() - 1.0);
|
||||
update();
|
||||
|
||||
emit selected(false);
|
||||
}
|
||||
|
@ -3,10 +3,8 @@
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QPen>
|
||||
#include "pathitem.h"
|
||||
#include "units.h"
|
||||
#include "track.h"
|
||||
#include "markeritem.h"
|
||||
#include "pathitem.h"
|
||||
|
||||
|
||||
class TrackItem : public PathItem
|
||||
@ -16,37 +14,13 @@ class TrackItem : public PathItem
|
||||
public:
|
||||
TrackItem(const Track &track, QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QPainterPath &path() const {return _path;}
|
||||
|
||||
void setScale(qreal scale);
|
||||
void setUnits(enum Units units);
|
||||
void setColor(const QColor &color);
|
||||
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
void moveMarker(qreal distance);
|
||||
|
||||
private:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
QDateTime _date;
|
||||
qreal _time;
|
||||
qreal _distance;
|
||||
};
|
||||
|
||||
#endif // TRACKITEM_H
|
||||
|
Loading…
Reference in New Issue
Block a user