mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Splited route and track info in status bar
This commit is contained in:
parent
392b829733
commit
7cfc05c101
73
src/gui.cpp
73
src/gui.cpp
@ -39,8 +39,6 @@
|
|||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
|
||||||
|
|
||||||
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
loadMaps();
|
loadMaps();
|
||||||
@ -72,11 +70,12 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
setWindowTitle(APP_NAME);
|
setWindowTitle(APP_NAME);
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
|
|
||||||
_distance = 0;
|
|
||||||
_time = 0;
|
|
||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
_routeCount = 0;
|
_routeCount = 0;
|
||||||
_waypointCount = 0;
|
_waypointCount = 0;
|
||||||
|
_trackDistance = 0;
|
||||||
|
_routeDistance = 0;
|
||||||
|
_time = 0;
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
@ -275,11 +274,11 @@ void GUI::createActions()
|
|||||||
// Data actions
|
// Data actions
|
||||||
_showTracksAction = new QAction(tr("Tracks"), this);
|
_showTracksAction = new QAction(tr("Tracks"), this);
|
||||||
_showTracksAction->setCheckable(true);
|
_showTracksAction->setCheckable(true);
|
||||||
connect(_showTracksAction, SIGNAL(triggered(bool)), _track,
|
connect(_showTracksAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showTracks(bool)));
|
SLOT(showTracks(bool)));
|
||||||
_showRoutesAction = new QAction(tr("Routes"), this);
|
_showRoutesAction = new QAction(tr("Routes"), this);
|
||||||
_showRoutesAction->setCheckable(true);
|
_showRoutesAction->setCheckable(true);
|
||||||
connect(_showRoutesAction, SIGNAL(triggered(bool)), _track,
|
connect(_showRoutesAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showRoutes(bool)));
|
SLOT(showRoutes(bool)));
|
||||||
_showWaypointsAction = new QAction(tr("Waypoints"), this);
|
_showWaypointsAction = new QAction(tr("Waypoints"), this);
|
||||||
_showWaypointsAction->setCheckable(true);
|
_showWaypointsAction->setCheckable(true);
|
||||||
@ -594,10 +593,9 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
_track->loadGPX(gpx);
|
_track->loadGPX(gpx);
|
||||||
if (_showPOIAction->isChecked())
|
if (_showPOIAction->isChecked())
|
||||||
_track->loadPOI(_poi);
|
_track->loadPOI(_poi);
|
||||||
_track->movePositionMarker(_sliderPos);
|
|
||||||
|
|
||||||
for (int i = 0; i < gpx.tracks().count(); i++) {
|
for (int i = 0; i < gpx.tracks().count(); i++) {
|
||||||
_distance += gpx.tracks().at(i)->distance();
|
_trackDistance += gpx.tracks().at(i)->distance();
|
||||||
_time += gpx.tracks().at(i)->time();
|
_time += gpx.tracks().at(i)->time();
|
||||||
const QDate &date = gpx.tracks().at(i)->date().date();
|
const QDate &date = gpx.tracks().at(i)->date().date();
|
||||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||||
@ -608,7 +606,7 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
_trackCount += gpx.tracks().count();
|
_trackCount += gpx.tracks().count();
|
||||||
|
|
||||||
for (int i = 0; i < gpx.routes().count(); i++)
|
for (int i = 0; i < gpx.routes().count(); i++)
|
||||||
_distance += gpx.routes().at(i)->distance();
|
_routeDistance += gpx.routes().at(i)->distance();
|
||||||
_routeCount += gpx.routes().count();
|
_routeCount += gpx.routes().count();
|
||||||
|
|
||||||
_waypointCount += gpx.waypoints().count();
|
_waypointCount += gpx.waypoints().count();
|
||||||
@ -710,7 +708,8 @@ void GUI::plot(QPrinter *printer)
|
|||||||
TrackInfo info;
|
TrackInfo info;
|
||||||
qreal ih, gh, mh, ratio;
|
qreal ih, gh, mh, ratio;
|
||||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||||
|
qreal d = distance();
|
||||||
|
qreal t = time();
|
||||||
|
|
||||||
if (_dateRange.first.isValid()) {
|
if (_dateRange.first.isValid()) {
|
||||||
if (_dateRange.first == _dateRange.second) {
|
if (_dateRange.first == _dateRange.second) {
|
||||||
@ -731,10 +730,10 @@ void GUI::plot(QPrinter *printer)
|
|||||||
if (_waypointCount > 2)
|
if (_waypointCount > 2)
|
||||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||||
|
|
||||||
if (_distance > 0)
|
if (d > 0)
|
||||||
info.insert(tr("Distance"), ::distance(_distance, units));
|
info.insert(tr("Distance"), ::distance(d, units));
|
||||||
if (_time > 0)
|
if (t > 0)
|
||||||
info.insert(tr("Time"), timeSpan(_time));
|
info.insert(tr("Time"), ::timeSpan(t));
|
||||||
|
|
||||||
|
|
||||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||||
@ -762,12 +761,13 @@ void GUI::plot(QPrinter *printer)
|
|||||||
|
|
||||||
void GUI::reloadFile()
|
void GUI::reloadFile()
|
||||||
{
|
{
|
||||||
_distance = 0;
|
|
||||||
_time = 0;
|
|
||||||
_dateRange = DateRange(QDate(), QDate());
|
|
||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
_routeCount = 0;
|
_routeCount = 0;
|
||||||
_waypointCount = 0;
|
_waypointCount = 0;
|
||||||
|
_trackDistance = 0;
|
||||||
|
_routeDistance = 0;
|
||||||
|
_time = 0;
|
||||||
|
_dateRange = DateRange(QDate(), QDate());
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
_tabs.at(i)->clear();
|
_tabs.at(i)->clear();
|
||||||
@ -794,12 +794,13 @@ void GUI::reloadFile()
|
|||||||
|
|
||||||
void GUI::closeFiles()
|
void GUI::closeFiles()
|
||||||
{
|
{
|
||||||
_distance = 0;
|
|
||||||
_time = 0;
|
|
||||||
_dateRange = DateRange(QDate(), QDate());
|
|
||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
_routeCount = 0;
|
_routeCount = 0;
|
||||||
_waypointCount = 0;
|
_waypointCount = 0;
|
||||||
|
_trackDistance = 0;
|
||||||
|
_routeDistance = 0;
|
||||||
|
_time = 0;
|
||||||
|
_dateRange = DateRange(QDate(), QDate());
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
@ -886,9 +887,16 @@ void GUI::showFullscreen(bool checked)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::showWaypointLabels(bool checked)
|
void GUI::showTracks(bool show)
|
||||||
{
|
{
|
||||||
_track->showWaypointLabels(checked);
|
_track->showTracks(show);
|
||||||
|
updateStatusBarInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::showRoutes(bool show)
|
||||||
|
{
|
||||||
|
_track->showRoutes(show);
|
||||||
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::clearMapCache()
|
void GUI::clearMapCache()
|
||||||
@ -910,8 +918,8 @@ void GUI::updateStatusBarInfo()
|
|||||||
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
||||||
|
|
||||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||||
_distanceLabel->setText(distance(_distance, units));
|
_distanceLabel->setText(::distance(distance(), units));
|
||||||
_timeLabel->setText(timeSpan(_time));
|
_timeLabel->setText(::timeSpan(time()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateWindowTitle()
|
void GUI::updateWindowTitle()
|
||||||
@ -1269,3 +1277,20 @@ int GUI::mapIndex(const QString &name)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal GUI::distance()
|
||||||
|
{
|
||||||
|
qreal dist = 0;
|
||||||
|
|
||||||
|
if (_showTracksAction->isChecked())
|
||||||
|
dist += _trackDistance;
|
||||||
|
if (_showRoutesAction->isChecked())
|
||||||
|
dist += _routeDistance;
|
||||||
|
|
||||||
|
return dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal GUI::time()
|
||||||
|
{
|
||||||
|
return (_showTracksAction->isChecked()) ? _time : 0;
|
||||||
|
}
|
||||||
|
10
src/gui.h
10
src/gui.h
@ -48,7 +48,8 @@ private slots:
|
|||||||
void showGraphs(bool checked);
|
void showGraphs(bool checked);
|
||||||
void showToolbars(bool checked);
|
void showToolbars(bool checked);
|
||||||
void showFullscreen(bool checked);
|
void showFullscreen(bool checked);
|
||||||
void showWaypointLabels(bool checked);
|
void showTracks(bool show);
|
||||||
|
void showRoutes(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void nextMap();
|
void nextMap();
|
||||||
void prevMap();
|
void prevMap();
|
||||||
@ -57,6 +58,8 @@ private slots:
|
|||||||
void graphChanged(int);
|
void graphChanged(int);
|
||||||
void poiFileChecked(int);
|
void poiFileChecked(int);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void next();
|
void next();
|
||||||
void prev();
|
void prev();
|
||||||
void last();
|
void last();
|
||||||
@ -97,6 +100,8 @@ private:
|
|||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
qreal distance();
|
||||||
|
qreal time();
|
||||||
int mapIndex(const QString &name);
|
int mapIndex(const QString &name);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
@ -164,7 +169,8 @@ private:
|
|||||||
int _trackCount;
|
int _trackCount;
|
||||||
int _routeCount;
|
int _routeCount;
|
||||||
int _waypointCount;
|
int _waypointCount;
|
||||||
qreal _distance;
|
qreal _trackDistance;
|
||||||
|
qreal _routeDistance;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
DateRange _dateRange;
|
DateRange _dateRange;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user