2015-10-05 01:43:48 +02:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QPrinter>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QKeyEvent>
|
2015-11-23 02:37:08 +01:00
|
|
|
#include <QSignalMapper>
|
2016-03-05 18:01:13 +01:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QActionGroup>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QLabel>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "icons.h"
|
|
|
|
#include "keys.h"
|
|
|
|
#include "gpx.h"
|
2015-11-23 02:37:08 +01:00
|
|
|
#include "map.h"
|
2015-11-23 23:19:57 +01:00
|
|
|
#include "maplist.h"
|
2015-10-12 01:12:12 +02:00
|
|
|
#include "elevationgraph.h"
|
|
|
|
#include "speedgraph.h"
|
2016-03-21 22:37:55 +01:00
|
|
|
#include "heartrategraph.h"
|
2016-02-11 20:58:52 +01:00
|
|
|
#include "trackview.h"
|
2015-10-19 00:35:08 +02:00
|
|
|
#include "infoitem.h"
|
2015-10-20 22:18:41 +02:00
|
|
|
#include "filebrowser.h"
|
2015-10-19 00:35:08 +02:00
|
|
|
#include "gui.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
|
2015-10-14 02:54:36 +02:00
|
|
|
static QString timeSpan(qreal time)
|
|
|
|
{
|
|
|
|
unsigned h, m, s;
|
|
|
|
|
|
|
|
h = time / 3600;
|
|
|
|
m = (time - (h * 3600)) / 60;
|
|
|
|
s = time - (h * 3600) - (m * 60);
|
|
|
|
|
|
|
|
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
2015-12-19 20:23:07 +01:00
|
|
|
.arg(s, 2, 10, QChar('0'));
|
2015-10-14 02:54:36 +02:00
|
|
|
}
|
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
|
2016-02-12 20:12:37 +01:00
|
|
|
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2015-11-26 19:13:59 +01:00
|
|
|
loadFiles();
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
createActions();
|
|
|
|
createMenus();
|
|
|
|
createToolBars();
|
|
|
|
createTrackView();
|
|
|
|
createTrackGraphs();
|
|
|
|
createStatusBar();
|
|
|
|
|
|
|
|
connect(_elevationGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
|
|
|
|
SLOT(movePositionMarker(qreal)));
|
|
|
|
connect(_speedGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
|
|
|
|
SLOT(movePositionMarker(qreal)));
|
2016-03-21 22:37:55 +01:00
|
|
|
connect(_heartRateGraph, SIGNAL(sliderPositionChanged(qreal)), _track,
|
|
|
|
SLOT(movePositionMarker(qreal)));
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
_browser = new FileBrowser(this);
|
|
|
|
_browser->setFilter(QStringList("*.gpx"));
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
layout->addWidget(_track);
|
|
|
|
layout->addWidget(_trackGraphs);
|
|
|
|
|
|
|
|
QWidget *widget = new QWidget;
|
|
|
|
widget->setLayout(layout);
|
|
|
|
setCentralWidget(widget);
|
|
|
|
|
|
|
|
setWindowTitle(APP_NAME);
|
|
|
|
setUnifiedTitleAndToolBarOnMac(true);
|
|
|
|
|
2015-10-14 02:54:36 +02:00
|
|
|
_distance = 0;
|
|
|
|
_time = 0;
|
2016-02-08 17:53:09 +01:00
|
|
|
_trackCount = 0;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-03-21 22:37:55 +01:00
|
|
|
_lastGraph = static_cast<GraphView*>(_trackGraphs->currentWidget());
|
|
|
|
_lastSliderPos = _lastGraph->sliderPosition();
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
resize(600, 800);
|
|
|
|
}
|
|
|
|
|
2015-11-26 19:13:59 +01:00
|
|
|
void GUI::loadFiles()
|
2015-11-23 02:37:08 +01:00
|
|
|
{
|
2015-11-26 19:13:59 +01:00
|
|
|
// Maps
|
2016-02-12 20:12:37 +01:00
|
|
|
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE)
|
|
|
|
.arg(QDir::homePath()));
|
|
|
|
_maps += MapList::load(this, ":/maps.txt");
|
2015-11-26 19:13:59 +01:00
|
|
|
|
|
|
|
// POI files
|
2016-02-07 18:27:50 +01:00
|
|
|
QDir dir(QString("%1/" POI_DIR).arg(QDir::homePath()));
|
2015-11-26 19:13:59 +01:00
|
|
|
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
|
2016-02-12 20:12:37 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i)
|
|
|
|
_poi.loadFile(list.at(i).absoluteFilePath());
|
2015-11-23 02:37:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createMapActions()
|
|
|
|
{
|
|
|
|
QActionGroup *ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
|
|
|
|
|
|
|
QSignalMapper *sm = new QSignalMapper(this);
|
|
|
|
|
|
|
|
for (int i = 0; i < _maps.count(); i++) {
|
|
|
|
QAction *a = new QAction(_maps.at(i)->name(), this);
|
|
|
|
a->setCheckable(true);
|
|
|
|
a->setActionGroup(ag);
|
|
|
|
|
|
|
|
sm->setMapping(a, i);
|
|
|
|
connect(a, SIGNAL(triggered()), sm, SLOT(map()));
|
|
|
|
|
|
|
|
_mapActions.append(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
|
|
|
|
|
|
|
|
_mapActions.at(0)->setChecked(true);
|
|
|
|
_currentMap = _maps.at(0);
|
|
|
|
}
|
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
void GUI::createPOIFilesActions()
|
|
|
|
{
|
|
|
|
_poiFilesSM = new QSignalMapper(this);
|
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
for (int i = 0; i < _poi.files().count(); i++)
|
|
|
|
createPOIFileAction(i);
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
|
|
|
}
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
QAction *GUI::createPOIFileAction(int index)
|
|
|
|
{
|
|
|
|
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
|
|
|
|
this);
|
|
|
|
a->setCheckable(true);
|
|
|
|
a->setChecked(true);
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
_poiFilesSM->setMapping(a, index);
|
|
|
|
connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map()));
|
|
|
|
|
|
|
|
_poiFilesActions.append(a);
|
|
|
|
|
|
|
|
return a;
|
2016-03-05 18:01:13 +01:00
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::createActions()
|
|
|
|
{
|
|
|
|
// Action Groups
|
|
|
|
_fileActionGroup = new QActionGroup(this);
|
|
|
|
_fileActionGroup->setExclusive(false);
|
|
|
|
_fileActionGroup->setEnabled(false);
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationActionGroup = new QActionGroup(this);
|
|
|
|
_navigationActionGroup->setEnabled(false);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
// General actions
|
2015-10-06 00:48:43 +02:00
|
|
|
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
|
|
|
|
_exitAction->setShortcut(QKeySequence::Quit);
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
// Help & About
|
2015-11-30 22:42:51 +01:00
|
|
|
_dataSourcesAction = new QAction(tr("Data sources"), this);
|
|
|
|
connect(_dataSourcesAction, SIGNAL(triggered()), this, SLOT(dataSources()));
|
2015-10-21 01:09:17 +02:00
|
|
|
_keysAction = new QAction(tr("Keyboard controls"), this);
|
|
|
|
connect(_keysAction, SIGNAL(triggered()), this, SLOT(keys()));
|
2015-10-05 01:43:48 +02:00
|
|
|
_aboutAction = new QAction(QIcon(QPixmap(APP_ICON)),
|
|
|
|
tr("About GPXSee"), this);
|
|
|
|
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
2015-10-22 00:05:45 +02:00
|
|
|
_aboutQtAction = new QAction(QIcon(QPixmap(QT_ICON)), tr("About Qt"), this);
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
|
|
|
|
|
|
|
// File related actions
|
|
|
|
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
|
|
|
tr("Open"), this);
|
2015-10-06 00:48:43 +02:00
|
|
|
_openFileAction->setShortcut(QKeySequence::Open);
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
|
|
|
|
_saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)),
|
|
|
|
tr("Save"), this);
|
2015-10-06 00:48:43 +02:00
|
|
|
_saveFileAction->setShortcut(QKeySequence::Save);
|
2015-10-05 01:43:48 +02:00
|
|
|
_saveFileAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile()));
|
|
|
|
_saveAsAction = new QAction(QIcon(QPixmap(SAVE_AS_ICON)),
|
|
|
|
tr("Save as"), this);
|
2015-10-06 00:48:43 +02:00
|
|
|
_saveAsAction->setShortcut(QKeySequence::SaveAs);
|
2015-10-05 01:43:48 +02:00
|
|
|
_saveAsAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
|
|
|
|
_closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
|
|
|
tr("Close"), this);
|
2015-10-06 00:48:43 +02:00
|
|
|
_closeFileAction->setShortcut(QKeySequence::Close);
|
2015-10-05 01:43:48 +02:00
|
|
|
_closeFileAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeFile()));
|
2015-10-20 22:18:41 +02:00
|
|
|
_reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
|
|
|
|
tr("Reload"), this);
|
|
|
|
_reloadFileAction->setShortcut(QKeySequence::Refresh);
|
|
|
|
_reloadFileAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
// POI actions
|
|
|
|
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
2015-11-23 02:37:08 +01:00
|
|
|
tr("Load POI file"), this);
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
|
2016-03-05 18:01:13 +01:00
|
|
|
_closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
|
|
|
tr("Close POI files"), this);
|
|
|
|
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
2015-10-05 01:43:48 +02:00
|
|
|
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
2015-11-23 02:37:08 +01:00
|
|
|
tr("Show POIs"), this);
|
2015-10-05 01:43:48 +02:00
|
|
|
_showPOIAction->setCheckable(true);
|
2016-02-02 23:13:08 +01:00
|
|
|
_showPOIAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
|
2015-11-24 00:24:26 +01:00
|
|
|
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
2016-03-05 18:01:13 +01:00
|
|
|
createPOIFilesActions();
|
2015-11-23 02:37:08 +01:00
|
|
|
|
|
|
|
// Map actions
|
|
|
|
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
|
|
|
|
this);
|
|
|
|
_showMapAction->setCheckable(true);
|
2016-02-02 23:13:08 +01:00
|
|
|
_showMapAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
2015-11-24 00:24:26 +01:00
|
|
|
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
|
2015-11-23 02:37:08 +01:00
|
|
|
if (_maps.empty())
|
|
|
|
_showMapAction->setEnabled(false);
|
2016-02-07 18:12:03 +01:00
|
|
|
else {
|
2015-11-23 02:37:08 +01:00
|
|
|
createMapActions();
|
2016-02-07 18:12:03 +01:00
|
|
|
_showMapAction->setChecked(true);
|
|
|
|
}
|
2015-11-24 00:24:26 +01:00
|
|
|
|
|
|
|
// Settings actions
|
|
|
|
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
|
|
|
_showGraphsAction->setCheckable(true);
|
|
|
|
_showGraphsAction->setChecked(true);
|
2016-02-02 23:13:08 +01:00
|
|
|
_showGraphsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
|
2015-11-24 00:24:26 +01:00
|
|
|
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(showGraphs(bool)));
|
|
|
|
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
|
|
|
_showToolbarsAction->setCheckable(true);
|
|
|
|
_showToolbarsAction->setChecked(true);
|
|
|
|
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(showToolbars(bool)));
|
2015-12-19 20:23:07 +01:00
|
|
|
QActionGroup *ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
|
|
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
|
|
|
_metricUnitsAction->setCheckable(true);
|
|
|
|
_metricUnitsAction->setActionGroup(ag);
|
|
|
|
_metricUnitsAction->setChecked(true);
|
|
|
|
connect(_metricUnitsAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(setMetricUnits()));
|
|
|
|
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
|
|
|
_imperialUnitsAction->setCheckable(true);
|
|
|
|
_imperialUnitsAction->setActionGroup(ag);
|
|
|
|
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(setImperialUnits()));
|
2015-12-18 22:21:11 +01:00
|
|
|
|
|
|
|
// Navigation actions
|
|
|
|
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
|
|
|
|
_nextAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_nextAction, SIGNAL(triggered()), this, SLOT(next()));
|
|
|
|
_prevAction = new QAction(QIcon(QPixmap(PREV_FILE_ICON)), tr("Previous"),
|
|
|
|
this);
|
|
|
|
_prevAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_prevAction, SIGNAL(triggered()), this, SLOT(prev()));
|
|
|
|
_lastAction = new QAction(QIcon(QPixmap(LAST_FILE_ICON)), tr("Last"), this);
|
|
|
|
_lastAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_lastAction, SIGNAL(triggered()), this, SLOT(last()));
|
|
|
|
_firstAction = new QAction(QIcon(QPixmap(FIRST_FILE_ICON)), tr("First"),
|
|
|
|
this);
|
|
|
|
_firstAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_firstAction, SIGNAL(triggered()), this, SLOT(first()));
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createMenus()
|
|
|
|
{
|
|
|
|
_fileMenu = menuBar()->addMenu(tr("File"));
|
|
|
|
_fileMenu->addAction(_openFileAction);
|
2015-10-06 00:48:43 +02:00
|
|
|
_fileMenu->addSeparator();
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileMenu->addAction(_saveFileAction);
|
|
|
|
_fileMenu->addAction(_saveAsAction);
|
2015-10-06 00:48:43 +02:00
|
|
|
_fileMenu->addSeparator();
|
2015-10-20 22:18:41 +02:00
|
|
|
_fileMenu->addAction(_reloadFileAction);
|
|
|
|
_fileMenu->addSeparator();
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileMenu->addAction(_closeFileAction);
|
2015-12-01 23:13:20 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2015-10-06 00:48:43 +02:00
|
|
|
_fileMenu->addSeparator();
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileMenu->addAction(_exitAction);
|
2015-12-01 23:13:20 +01:00
|
|
|
#endif // Q_OS_MAC
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-11-23 02:37:08 +01:00
|
|
|
_mapMenu = menuBar()->addMenu(tr("Map"));
|
|
|
|
_mapMenu->addActions(_mapActions);
|
|
|
|
_mapMenu->addSeparator();
|
|
|
|
_mapMenu->addAction(_showMapAction);
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_poiMenu = menuBar()->addMenu(tr("POI"));
|
2016-03-05 18:01:13 +01:00
|
|
|
_poiFilesMenu = _poiMenu->addMenu(tr("POI files"));
|
|
|
|
_poiFilesMenu->addActions(_poiFilesActions);
|
|
|
|
_poiMenu->addSeparator();
|
2015-10-05 01:43:48 +02:00
|
|
|
_poiMenu->addAction(_openPOIAction);
|
2016-03-05 18:01:13 +01:00
|
|
|
_poiMenu->addAction(_closePOIAction);
|
|
|
|
_poiMenu->addSeparator();
|
2015-10-05 01:43:48 +02:00
|
|
|
_poiMenu->addAction(_showPOIAction);
|
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
_settingsMenu = menuBar()->addMenu(tr("Settings"));
|
2015-12-19 20:23:07 +01:00
|
|
|
_unitsMenu = _settingsMenu->addMenu(tr("Units"));
|
|
|
|
_unitsMenu->addAction(_metricUnitsAction);
|
|
|
|
_unitsMenu->addAction(_imperialUnitsAction);
|
|
|
|
_settingsMenu->addSeparator();
|
2015-11-24 00:24:26 +01:00
|
|
|
_settingsMenu->addAction(_showToolbarsAction);
|
|
|
|
_settingsMenu->addAction(_showGraphsAction);
|
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
_helpMenu = menuBar()->addMenu(tr("Help"));
|
2015-11-30 22:42:51 +01:00
|
|
|
_helpMenu->addAction(_dataSourcesAction);
|
2015-10-21 01:09:17 +02:00
|
|
|
_helpMenu->addAction(_keysAction);
|
|
|
|
_helpMenu->addSeparator();
|
|
|
|
_helpMenu->addAction(_aboutAction);
|
|
|
|
_helpMenu->addAction(_aboutQtAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createToolBars()
|
|
|
|
{
|
|
|
|
_fileToolBar = addToolBar(tr("File"));
|
|
|
|
_fileToolBar->addAction(_openFileAction);
|
|
|
|
_fileToolBar->addAction(_saveFileAction);
|
2015-10-20 22:18:41 +02:00
|
|
|
_fileToolBar->addAction(_reloadFileAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileToolBar->addAction(_closeFileAction);
|
2015-12-01 23:13:20 +01:00
|
|
|
#ifdef Q_OS_MAC
|
2015-10-06 00:48:43 +02:00
|
|
|
_fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
2015-12-01 23:13:20 +01:00
|
|
|
#endif // Q_OS_MAC
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-11-23 02:37:08 +01:00
|
|
|
_showToolBar = addToolBar(tr("Show"));
|
|
|
|
_showToolBar->addAction(_showPOIAction);
|
|
|
|
_showToolBar->addAction(_showMapAction);
|
2015-12-01 23:13:20 +01:00
|
|
|
#ifdef Q_OS_MAC
|
2015-11-23 02:37:08 +01:00
|
|
|
_showToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
2015-12-01 23:13:20 +01:00
|
|
|
#endif // Q_OS_MAC
|
2015-12-18 22:21:11 +01:00
|
|
|
|
|
|
|
_navigationToolBar = addToolBar(tr("Navigation"));
|
|
|
|
_navigationToolBar->addAction(_firstAction);
|
|
|
|
_navigationToolBar->addAction(_prevAction);
|
|
|
|
_navigationToolBar->addAction(_nextAction);
|
|
|
|
_navigationToolBar->addAction(_lastAction);
|
2015-12-19 08:26:23 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
_navigationToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
#endif // Q_OS_MAC
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createTrackView()
|
|
|
|
{
|
2016-02-11 20:58:52 +01:00
|
|
|
_track = new TrackView(this);
|
2016-02-07 18:12:03 +01:00
|
|
|
|
|
|
|
if (_showMapAction->isChecked())
|
|
|
|
_track->setMap(_currentMap);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createTrackGraphs()
|
|
|
|
{
|
2015-10-12 01:12:12 +02:00
|
|
|
_elevationGraph = new ElevationGraph;
|
|
|
|
_speedGraph = new SpeedGraph;
|
2016-03-21 22:37:55 +01:00
|
|
|
_heartRateGraph = new HeartRateGraph;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
_trackGraphs = new QTabWidget;
|
|
|
|
_trackGraphs->addTab(_elevationGraph, tr("Elevation"));
|
|
|
|
_trackGraphs->addTab(_speedGraph, tr("Speed"));
|
2016-03-21 22:37:55 +01:00
|
|
|
_trackGraphs->addTab(_heartRateGraph, tr("Heart rate"));
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
|
|
|
|
SLOT(graphChanged(int)));
|
|
|
|
|
|
|
|
_trackGraphs->setFixedHeight(200);
|
|
|
|
_trackGraphs->setSizePolicy(
|
|
|
|
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createStatusBar()
|
|
|
|
{
|
2015-10-14 02:54:36 +02:00
|
|
|
_fileNameLabel = new QLabel();
|
|
|
|
_distanceLabel = new QLabel();
|
|
|
|
_timeLabel = new QLabel();
|
|
|
|
_distanceLabel->setAlignment(Qt::AlignHCenter);
|
|
|
|
_timeLabel->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
|
|
|
statusBar()->addPermanentWidget(_fileNameLabel, 8);
|
|
|
|
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
|
|
|
statusBar()->addPermanentWidget(_timeLabel, 1);
|
2015-10-05 01:43:48 +02:00
|
|
|
statusBar()->setSizeGripEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::about()
|
|
|
|
{
|
2015-10-22 00:05:45 +02:00
|
|
|
QMessageBox msgBox(this);
|
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("About GPXSee"));
|
2016-02-07 18:27:50 +01:00
|
|
|
msgBox.setText(QString("<h3>") + QString(APP_NAME " " APP_VERSION)
|
2015-10-22 00:05:45 +02:00
|
|
|
+ QString("</h3><p>") + tr("GPX viewer and analyzer") + QString("<p/>"));
|
|
|
|
msgBox.setInformativeText(QString("<table width=\"300\"><tr><td>")
|
|
|
|
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
|
|
|
"License version 3. For more info about GPXSee visit the project "
|
2016-02-07 18:27:50 +01:00
|
|
|
"homepage at ") + QString("<a href=\"" APP_HOMEPAGE "\">" APP_HOMEPAGE
|
2015-10-22 00:05:45 +02:00
|
|
|
"</a>.</td></tr></table>"));
|
|
|
|
|
|
|
|
QIcon icon = msgBox.windowIcon();
|
|
|
|
QSize size = icon.actualSize(QSize(64, 64));
|
|
|
|
msgBox.setIconPixmap(icon.pixmap(size));
|
|
|
|
|
|
|
|
msgBox.exec();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
void GUI::keys()
|
|
|
|
{
|
|
|
|
QMessageBox msgBox(this);
|
2015-10-22 00:05:45 +02:00
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("Keyboard controls"));
|
|
|
|
msgBox.setText(QString("<h3>") + tr("Keyboard controls") + QString("</h3>"));
|
|
|
|
msgBox.setInformativeText(
|
|
|
|
QString("<div><table width=\"300\"><tr><td>") + tr("Next file")
|
2015-10-21 01:09:17 +02:00
|
|
|
+ QString("</td><td><i>SPACE</i></td></tr><tr><td>") + tr("Previous file")
|
|
|
|
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
|
2015-12-18 22:21:11 +01:00
|
|
|
+ tr("First file") + QString("</td><td><i>HOME</i></td></tr><tr><td>")
|
|
|
|
+ tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td></td>"
|
|
|
|
"<td></td></tr><tr><td>") + tr("Append modifier")
|
|
|
|
+ QString("</td><td><i>SHIFT</i></td></tr></table></div>"));
|
2015-10-22 00:05:45 +02:00
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2015-11-30 22:42:51 +01:00
|
|
|
void GUI::dataSources()
|
|
|
|
{
|
|
|
|
QMessageBox msgBox(this);
|
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("Data sources"));
|
|
|
|
msgBox.setText(QString("<h3>") + tr("Data sources") + QString("</h3>"));
|
|
|
|
msgBox.setInformativeText(
|
|
|
|
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
|
|
|
+ tr("Map (tiles) source URLs are read on program startup from the "
|
|
|
|
"following file:")
|
|
|
|
+ QString("</p><p><code>") + QDir::homePath()
|
2016-02-07 18:27:50 +01:00
|
|
|
+ QString("/" MAP_LIST_FILE "</code></p><p>")
|
2015-12-01 23:38:02 +01:00
|
|
|
+ tr("The file format is one map entry per line, consisting of the map "
|
|
|
|
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
|
|
|
"coordinates are replaced with $x and $y in the URL and the zoom "
|
|
|
|
"level is replaced with $z. An example map file could look like:")
|
|
|
|
+ QString("</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
|
|
|
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>")
|
2015-11-30 22:42:51 +01:00
|
|
|
|
|
|
|
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
|
|
|
|
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
|
|
|
"the file to the following directory:")
|
|
|
|
+ QString("</p><p><code>") + QDir::homePath()
|
2016-02-07 18:27:50 +01:00
|
|
|
+ QString("/" POI_DIR "</code></p>")
|
2015-11-30 22:42:51 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::openFile()
|
|
|
|
{
|
2016-02-12 20:12:37 +01:00
|
|
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"),
|
|
|
|
QString(), tr("GPX files (*.gpx);;All files (*)"));
|
2015-10-05 01:43:48 +02:00
|
|
|
QStringList list = files;
|
|
|
|
|
2015-10-07 01:30:03 +02:00
|
|
|
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
2015-10-20 22:18:41 +02:00
|
|
|
openFile(*it);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GUI::openFile(const QString &fileName)
|
|
|
|
{
|
2015-10-20 22:18:41 +02:00
|
|
|
if (fileName.isEmpty() || _files.contains(fileName))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (loadFile(fileName)) {
|
|
|
|
_files.append(fileName);
|
|
|
|
_browser->setCurrent(fileName);
|
|
|
|
updateStatusBarInfo();
|
|
|
|
_fileActionGroup->setEnabled(true);
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationActionGroup->setEnabled(true);
|
|
|
|
updateNavigationActions();
|
2015-10-20 22:18:41 +02:00
|
|
|
return true;
|
2015-12-19 13:15:13 +01:00
|
|
|
} else {
|
|
|
|
updateNavigationActions();
|
2015-10-20 22:18:41 +02:00
|
|
|
return false;
|
2015-12-19 13:15:13 +01:00
|
|
|
}
|
2015-10-20 22:18:41 +02:00
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
bool GUI::loadFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
GPX gpx;
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
if (gpx.loadFile(fileName)) {
|
|
|
|
_elevationGraph->loadGPX(gpx);
|
|
|
|
_speedGraph->loadGPX(gpx);
|
2016-03-21 22:37:55 +01:00
|
|
|
_heartRateGraph->loadGPX(gpx);
|
2015-10-20 22:18:41 +02:00
|
|
|
_track->loadGPX(gpx);
|
|
|
|
if (_showPOIAction->isChecked())
|
|
|
|
_track->loadPOI(_poi);
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
for (int i = 0; i < gpx.trackCount(); i++) {
|
|
|
|
_distance += gpx.track(i).distance();
|
|
|
|
_time += gpx.track(i).time();
|
2016-02-08 17:53:09 +01:00
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
_trackCount += gpx.trackCount();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2015-11-26 19:13:59 +01:00
|
|
|
QString error = fileName + QString("\n\n")
|
|
|
|
+ tr("Error loading GPX file:\n%1").arg(gpx.errorString())
|
|
|
|
+ QString("\n");
|
|
|
|
if (gpx.errorLine())
|
|
|
|
error.append(tr("Line: %1").arg(gpx.errorLine()));
|
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Error"), error);
|
2015-10-20 22:18:41 +02:00
|
|
|
return false;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::openPOIFile()
|
|
|
|
{
|
2016-03-22 19:47:11 +01:00
|
|
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
2016-02-12 20:12:37 +01:00
|
|
|
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
|
2016-03-22 19:47:11 +01:00
|
|
|
QStringList list = files;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-03-22 19:47:11 +01:00
|
|
|
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
|
|
|
openPOIFile(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GUI::openPOIFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!_poi.loadFile(fileName)) {
|
|
|
|
QString error = tr("Error loading POI file:\n%1")
|
|
|
|
.arg(_poi.errorString()) + QString("\n");
|
|
|
|
if (_poi.errorLine())
|
|
|
|
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
|
|
|
QMessageBox::critical(this, tr("Error"), error);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
_showPOIAction->setChecked(true);
|
|
|
|
_track->loadPOI(_poi);
|
|
|
|
_poiFilesMenu->addAction(createPOIFileAction(
|
|
|
|
_poi.files().indexOf(fileName)));
|
|
|
|
|
|
|
|
return true;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
void GUI::closePOIFiles()
|
|
|
|
{
|
|
|
|
_poiFilesMenu->clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < _poiFilesActions.count(); i++)
|
|
|
|
delete _poiFilesActions[i];
|
|
|
|
_poiFilesActions.clear();
|
|
|
|
|
|
|
|
_track->clearPOI();
|
|
|
|
|
|
|
|
_poi.clear();
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::saveAs()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, "Export to PDF",
|
|
|
|
QString(), "*.pdf");
|
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
|
|
|
saveFile(fileName);
|
|
|
|
_saveFileName = fileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::saveFile()
|
|
|
|
{
|
|
|
|
if (_saveFileName.isEmpty())
|
|
|
|
emit saveAs();
|
|
|
|
else
|
|
|
|
saveFile(_saveFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::saveFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
QPrinter printer(QPrinter::HighResolution);
|
|
|
|
printer.setPageSize(QPrinter::A4);
|
|
|
|
printer.setOrientation(_track->orientation());
|
|
|
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
|
|
|
printer.setOutputFileName(fileName);
|
|
|
|
|
|
|
|
QPainter p(&printer);
|
2015-10-19 00:35:08 +02:00
|
|
|
|
|
|
|
_track->plot(&p, QRectF(0, 300, printer.width(), (0.80 * printer.height())
|
|
|
|
- 400));
|
2015-10-05 01:43:48 +02:00
|
|
|
_elevationGraph->plot(&p, QRectF(0, 0.80 * printer.height(),
|
|
|
|
printer.width(), printer.height() * 0.20));
|
2015-10-19 00:35:08 +02:00
|
|
|
|
|
|
|
QGraphicsScene scene;
|
|
|
|
InfoItem info;
|
2015-12-19 20:23:07 +01:00
|
|
|
if (_imperialUnitsAction->isChecked()) {
|
|
|
|
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f', 1)
|
2016-02-13 12:13:56 +01:00
|
|
|
+ UNIT_SPACE + tr("mi"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Time"), timeSpan(_time));
|
|
|
|
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent()
|
2016-02-13 12:13:56 +01:00
|
|
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Descent"), QString::number(_elevationGraph->descent()
|
2016-02-13 12:13:56 +01:00
|
|
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Maximum"), QString::number(_elevationGraph->max()
|
2016-02-13 12:13:56 +01:00
|
|
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Minimum"), QString::number(_elevationGraph->min()
|
2016-02-13 12:13:56 +01:00
|
|
|
* M2FT, 'f', 0) + UNIT_SPACE + tr("ft"));
|
2015-12-19 20:23:07 +01:00
|
|
|
} else {
|
|
|
|
info.insert(tr("Distance"), QString::number(_distance * M2KM, 'f', 1)
|
2016-02-13 12:13:56 +01:00
|
|
|
+ UNIT_SPACE + tr("km"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Time"), timeSpan(_time));
|
|
|
|
info.insert(tr("Ascent"), QString::number(_elevationGraph->ascent(),
|
2016-02-13 12:13:56 +01:00
|
|
|
'f', 0) + UNIT_SPACE + tr("m"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Descent"), QString::number(_elevationGraph->descent(),
|
2016-02-13 12:13:56 +01:00
|
|
|
'f', 0) + UNIT_SPACE + tr("m"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Maximum"), QString::number(_elevationGraph->max(), 'f',
|
2016-02-13 12:13:56 +01:00
|
|
|
0) + UNIT_SPACE + tr("m"));
|
2015-12-19 20:23:07 +01:00
|
|
|
info.insert(tr("Minimum"), QString::number(_elevationGraph->min(), 'f',
|
2016-02-13 12:13:56 +01:00
|
|
|
0) + UNIT_SPACE + tr("m"));
|
2015-12-19 20:23:07 +01:00
|
|
|
}
|
2015-10-19 00:35:08 +02:00
|
|
|
scene.addItem(&info);
|
|
|
|
scene.render(&p, QRectF(0, 0, printer.width(), 200));
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
void GUI::reloadFile()
|
|
|
|
{
|
|
|
|
_distance = 0;
|
|
|
|
_time = 0;
|
2016-02-29 09:04:36 +01:00
|
|
|
_trackCount = 0;
|
2015-10-20 22:18:41 +02:00
|
|
|
|
|
|
|
_elevationGraph->clear();
|
|
|
|
_speedGraph->clear();
|
2016-03-21 22:37:55 +01:00
|
|
|
_heartRateGraph->clear();
|
2015-10-20 22:18:41 +02:00
|
|
|
_track->clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < _files.size(); i++) {
|
|
|
|
if (!loadFile(_files.at(i))) {
|
|
|
|
_files.removeAt(i);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateStatusBarInfo();
|
|
|
|
if (_files.isEmpty())
|
|
|
|
_fileActionGroup->setEnabled(false);
|
|
|
|
else
|
|
|
|
_browser->setCurrent(_files.last());
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::closeFile()
|
|
|
|
{
|
2015-10-14 02:54:36 +02:00
|
|
|
_distance = 0;
|
|
|
|
_time = 0;
|
2016-02-08 17:53:09 +01:00
|
|
|
_trackCount = 0;
|
2015-10-12 01:12:12 +02:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_elevationGraph->clear();
|
|
|
|
_speedGraph->clear();
|
2016-03-21 22:37:55 +01:00
|
|
|
_heartRateGraph->clear();
|
2015-10-05 01:43:48 +02:00
|
|
|
_track->clear();
|
2015-10-20 22:18:41 +02:00
|
|
|
|
|
|
|
_files.clear();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
_fileActionGroup->setEnabled(false);
|
2015-10-20 22:18:41 +02:00
|
|
|
updateStatusBarInfo();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
void GUI::showPOI(bool checked)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2015-11-24 00:24:26 +01:00
|
|
|
if (checked)
|
2015-10-05 01:43:48 +02:00
|
|
|
_track->loadPOI(_poi);
|
|
|
|
else
|
|
|
|
_track->clearPOI();
|
|
|
|
}
|
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
void GUI::showMap(bool checked)
|
2015-11-23 02:37:08 +01:00
|
|
|
{
|
2015-11-24 00:24:26 +01:00
|
|
|
if (checked)
|
2015-11-23 02:37:08 +01:00
|
|
|
_track->setMap(_currentMap);
|
|
|
|
else
|
|
|
|
_track->setMap(0);
|
|
|
|
}
|
2015-10-20 22:18:41 +02:00
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
void GUI::showGraphs(bool checked)
|
|
|
|
{
|
|
|
|
_trackGraphs->setHidden(!checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::showToolbars(bool checked)
|
|
|
|
{
|
|
|
|
if (checked) {
|
|
|
|
addToolBar(_fileToolBar);
|
|
|
|
addToolBar(_showToolBar);
|
2015-12-19 08:29:31 +01:00
|
|
|
addToolBar(_navigationToolBar);
|
2015-11-24 00:24:26 +01:00
|
|
|
_fileToolBar->show();
|
|
|
|
_showToolBar->show();
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationToolBar->show();
|
2015-11-24 00:24:26 +01:00
|
|
|
} else {
|
|
|
|
removeToolBar(_fileToolBar);
|
|
|
|
removeToolBar(_showToolBar);
|
2015-12-18 22:21:11 +01:00
|
|
|
removeToolBar(_navigationToolBar);
|
2015-11-24 00:24:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
void GUI::updateStatusBarInfo()
|
2015-10-17 12:08:30 +02:00
|
|
|
{
|
2016-02-08 17:53:09 +01:00
|
|
|
if (_files.count() == 0) {
|
2015-10-20 22:18:41 +02:00
|
|
|
_fileNameLabel->clear();
|
|
|
|
_distanceLabel->clear();
|
|
|
|
_timeLabel->clear();
|
|
|
|
return;
|
2016-02-08 17:53:09 +01:00
|
|
|
} else if (_files.count() == 1)
|
2015-10-20 22:18:41 +02:00
|
|
|
_fileNameLabel->setText(_files.at(0));
|
2015-10-17 12:08:30 +02:00
|
|
|
else
|
2016-02-08 17:53:09 +01:00
|
|
|
_fileNameLabel->setText(tr("%1 tracks").arg(_trackCount));
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2015-12-19 20:23:07 +01:00
|
|
|
if (_imperialUnitsAction->isChecked())
|
|
|
|
_distanceLabel->setText(QString::number(_distance * M2MI, 'f', 1)
|
2016-03-05 22:09:53 +01:00
|
|
|
+ UNIT_SPACE + tr("mi"));
|
2015-12-19 20:23:07 +01:00
|
|
|
else
|
|
|
|
_distanceLabel->setText(QString::number(_distance * M2KM, 'f', 1)
|
2016-03-05 22:09:53 +01:00
|
|
|
+ UNIT_SPACE + tr("km"));
|
2015-10-17 12:08:30 +02:00
|
|
|
_timeLabel->setText(timeSpan(_time));
|
|
|
|
}
|
|
|
|
|
2015-11-23 02:37:08 +01:00
|
|
|
void GUI::mapChanged(int index)
|
|
|
|
{
|
|
|
|
_currentMap = _maps.at(index);
|
|
|
|
|
|
|
|
if (_showMapAction->isChecked())
|
|
|
|
_track->setMap(_currentMap);
|
|
|
|
}
|
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
void GUI::poiFileChecked(int index)
|
|
|
|
{
|
|
|
|
_poi.enableFile(_poi.files().at(index),
|
|
|
|
_poiFilesActions.at(index)->isChecked());
|
2016-03-19 09:05:40 +01:00
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
_track->clearPOI();
|
2016-03-19 09:05:40 +01:00
|
|
|
if (_showPOIAction->isChecked())
|
|
|
|
_track->loadPOI(_poi);
|
2016-03-05 18:01:13 +01:00
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::graphChanged(int index)
|
|
|
|
{
|
2016-03-21 22:37:55 +01:00
|
|
|
GraphView *tv = static_cast<GraphView*>(_trackGraphs->widget(index));
|
|
|
|
if (_lastGraph->sliderPosition() >= 0)
|
|
|
|
_lastSliderPos = _lastGraph->sliderPosition();
|
|
|
|
tv->setSliderPosition(_lastSliderPos);
|
|
|
|
_lastGraph = tv;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
void GUI::updateNavigationActions()
|
|
|
|
{
|
|
|
|
if (_browser->isLast()) {
|
|
|
|
_nextAction->setEnabled(false);
|
|
|
|
_lastAction->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
_nextAction->setEnabled(true);
|
|
|
|
_lastAction->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_browser->isFirst()) {
|
|
|
|
_prevAction->setEnabled(false);
|
|
|
|
_firstAction->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
_prevAction->setEnabled(true);
|
|
|
|
_firstAction->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-19 20:23:07 +01:00
|
|
|
void GUI::setMetricUnits()
|
|
|
|
{
|
2016-01-14 00:37:51 +01:00
|
|
|
_track->setUnits(Metric);
|
2015-12-19 20:23:07 +01:00
|
|
|
_elevationGraph->setUnits(Metric);
|
|
|
|
_speedGraph->setUnits(Metric);
|
2016-03-21 22:37:55 +01:00
|
|
|
_heartRateGraph->setUnits(Metric);
|
2015-12-19 20:23:07 +01:00
|
|
|
updateStatusBarInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::setImperialUnits()
|
|
|
|
{
|
2016-01-14 00:37:51 +01:00
|
|
|
_track->setUnits(Imperial);
|
2015-12-19 20:23:07 +01:00
|
|
|
_elevationGraph->setUnits(Imperial);
|
|
|
|
_speedGraph->setUnits(Imperial);
|
2016-03-21 22:37:55 +01:00
|
|
|
_heartRateGraph->setUnits(Imperial);
|
2015-12-19 20:23:07 +01:00
|
|
|
updateStatusBarInfo();
|
|
|
|
}
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
void GUI::next()
|
|
|
|
{
|
|
|
|
QString file = _browser->next();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
closeFile();
|
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::prev()
|
|
|
|
{
|
|
|
|
QString file = _browser->prev();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
closeFile();
|
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::last()
|
|
|
|
{
|
|
|
|
QString file = _browser->last();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
closeFile();
|
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::first()
|
|
|
|
{
|
|
|
|
QString file = _browser->first();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
closeFile();
|
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
2015-10-20 22:18:41 +02:00
|
|
|
QString file;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
switch (event->key()) {
|
|
|
|
case PREV_KEY:
|
|
|
|
file = _browser->prev();
|
|
|
|
break;
|
|
|
|
case NEXT_KEY:
|
|
|
|
file = _browser->next();
|
|
|
|
break;
|
|
|
|
case FIRST_KEY:
|
|
|
|
file = _browser->first();
|
|
|
|
break;
|
|
|
|
case LAST_KEY:
|
|
|
|
file = _browser->last();
|
|
|
|
break;
|
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
if (!file.isNull()) {
|
|
|
|
if (!(event->modifiers() & MODIFIER))
|
|
|
|
closeFile();
|
|
|
|
openFile(file);
|
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|