From 99e32b1a15605085a1f322d55159266de024407d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 12 Feb 2017 19:57:55 +0100 Subject: [PATCH] Made the moving time switch affect all related values More standardized time type switching (menu) --- gpxsee.pro | 5 +- lang/gpxsee_cs.ts | 203 +++++++++++++++++++++-------------------- lang/gpxsee_sv.ts | 203 +++++++++++++++++++++-------------------- src/fliplabel.cpp | 28 ------ src/fliplabel.h | 22 ----- src/graphtab.h | 10 +- src/gui.cpp | 47 ++++++++-- src/gui.h | 10 +- src/heartrategraph.h | 2 - src/optionsdialog.cpp | 2 +- src/powergraph.h | 2 - src/settings.h | 2 + src/speedgraph.cpp | 14 ++- src/speedgraph.h | 4 +- src/temperaturegraph.h | 1 - src/timetype.h | 9 ++ src/trackitem.cpp | 4 +- 17 files changed, 291 insertions(+), 277 deletions(-) delete mode 100644 src/fliplabel.cpp delete mode 100644 src/fliplabel.h create mode 100644 src/timetype.h diff --git a/gpxsee.pro b/gpxsee.pro index 39df89b9..c173e01a 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -77,7 +77,7 @@ HEADERS += src/config.h \ src/colorbox.h \ src/stylecombobox.h \ src/opengl.h \ - src/fliplabel.h + src/timetype.h SOURCES += src/main.cpp \ src/gui.cpp \ src/poi.cpp \ @@ -131,8 +131,7 @@ SOURCES += src/main.cpp \ src/nmeaparser.cpp \ src/optionsdialog.cpp \ src/colorbox.cpp \ - src/stylecombobox.cpp \ - src/fliplabel.cpp + src/stylecombobox.cpp RESOURCES += gpxsee.qrc TRANSLATIONS = lang/gpxsee_cs.ts \ lang/gpxsee_sv.ts diff --git a/lang/gpxsee_cs.ts b/lang/gpxsee_cs.ts index 57c0162d..1a68eaf3 100644 --- a/lang/gpxsee_cs.ts +++ b/lang/gpxsee_cs.ts @@ -190,55 +190,55 @@ GUI - + GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese - + Open file Otevřít soubor - + Open POI file Otevřít POI soubor - + Open Otevřít - + Quit Ukončit - - - + + + Keyboard controls Ovládací klávesy - + Close Zavřít - + Reload Znovu načíst - + Show Zobrazit - - + + File Soubor @@ -258,195 +258,195 @@ Soubory NMEA (*.nmea) - - - + + + Data sources Zdroje dat - + Load POI file Nahrát POI soubor - + Close POI files Zavřit POI soubory - + Overlap POIs Překrývat POI - + Show POI labels Zobrazit názvy POI - + Show POIs Zobrazit POI - + Show map Zobrazit mapu - + Clear tile cache Vymazat mezipaměť dlaždic - - - + + + Next map Následující mapa - + Show tracks Zobrazit cesty - + Show routes Zobrazit trasy - + Show waypoints Zobrazit navigační body - + Waypoint labels Názvy navigačních bodů - + Show graphs Zobrazit grafy - + Show grid Zobrazit mřížku - + Show toolbars Zobrazovat nástrojové lišty - + + Total time + Celkový čas + + + + + Moving time + Čistý čas + + + Metric Metrické - + Imperial Imperiální - + Fullscreen mode Celoobrazovkový režim - + Options... Nastavení... - + Next Následující - + Previous Předchozí - + Last Poslední - + First První - + Map Mapa - + Graph Graf - + POI POI - + POI files POI soubory - + Data Data - + Display Zobrazit - + Settings Nastavení - + Units Jednotky - + Help Nápověda - + Previous map Předchozí mapa - - - Moving Time - Čistý čas - - - + No files loaded Nejsou načteny žádné soubory - - - Total Time - Celkový čas - GPX files (*.gpx) @@ -473,18 +473,18 @@ Všechny soubory (*) - - + + Date Datum - + Routes Trasy - + %n files %n soubor @@ -493,32 +493,32 @@ - + Next file Následující soubor - + Version Verze - + Print... Tisknout... - + Export to PDF... Exportovat do PDF... - + Waypoints Navigační body - + Previous file Předchozí soubor @@ -528,96 +528,97 @@ Podporované soubory (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx) - + Route waypoints Body tras - + First file První soubor - + Last file Poslední soubor - + Append modifier Modifikátor nahradit/přidat - + Map (tiles) source URLs are read on program startup from the following file: URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru: - + 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: Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad: - + To make GPXSee load a POI file automatically on startup, add the file to the following directory: POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře: - + Error loading data file: Datový soubor nelze načíst: - - + + Line: %1 Řádka: %1 - + Error loading POI file: Soubor POI nelze načíst: - + Name Název - + Tracks Cesty - - + + About GPXSee O aplikaci GPXSee - + Navigation Navigace - + Map sources Mapové zdroje - + POIs POI body - - + + Distance Vzdálenost - - + + + Time Čas @@ -807,7 +808,7 @@ - Moving Time + Moving time Čistý čas @@ -926,7 +927,7 @@ Rychlost - + km/h km/h @@ -941,7 +942,7 @@ Maximum - + mi/h mi/h @@ -999,12 +1000,12 @@ - Time - Čas + Total time + Celkový čas - Moving Time + Moving time Čistý čas diff --git a/lang/gpxsee_sv.ts b/lang/gpxsee_sv.ts index 61e44787..d2834181 100644 --- a/lang/gpxsee_sv.ts +++ b/lang/gpxsee_sv.ts @@ -190,55 +190,55 @@ GUI - + GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at GPXSee distribueras under vilkoren för GNU General Public License version 3. För mer info om GPXSee, besök hemsidan på - + Open file Öppna fil - + Open POI file Öppna POI-fil - + Open Öppna - + Quit Avsluta - - - + + + Keyboard controls Snabbtangenter - + Close Stäng - + Reload Uppdatera - + Show Visa - - + + File Arkiv @@ -258,203 +258,203 @@ NMEA-filer (*.nmea) - - - + + + Data sources Datakällor - + Load POI file Läs in POI-fil - + Close POI files Stäng POI-filer - + Overlap POIs Överlappa POI:er - + Show POI labels Visa POI-namn - + Show POIs Visa POI:er - + Show map Visa karta - + Clear tile cache Rensa kart-cache - - - + + + Next map Nästa karta - + Show tracks Visa spår - + Show routes Visa rutter - + Show waypoints Visa vägpunkter - + Waypoint labels Vägpunktsnamn - + Show graphs Visa diagram - + Show grid Visa stödlinjer - + Show toolbars Visa verktygsfält - + + Total time + + + + + + Moving time + + + + Metric Meter - + Imperial Imperial - + Fullscreen mode Helskärmsläge - + Options... Alternativ... - + Next Nästa - + Previous Föregående - + Last Sista - + First Första - + Map Karta - + Graph Diagram - + POI POI - + POI files POI-filer - + Data Data - + Display Visa - + Settings Inställningar - + Units Enhet - + Help Hjälp - + Previous map Föregående karta - - - Moving Time - - - - + No files loaded Inga filer inlästa - + %n files %n filer %n filer - - - Total Time - - GPX files (*.gpx) @@ -481,43 +481,43 @@ Alla filer (*) - - + + Date Datum - + Routes Rutter - + Next file Nästa fil - + Version Version - + Print... Skriv ut... - + Export to PDF... Exportera till PDF... - + Waypoints Vägpunkter - + Previous file Föregående fil @@ -527,96 +527,97 @@ Filer som stöds (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx) - + Route waypoints Ruttvägpunkter - + First file Första filen - + Last file Sista filen - + Append modifier Tillämpa modifierare - + Map (tiles) source URLs are read on program startup from the following file: Kartadresser (URL:er) läses in vid programstart, från följande fil: - + 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: Filformatet är en kartpost per rad, bestående av kartnamn och kartrutans URL, avgränsade med ett TAB-tecken. Kartrutans X- och Y-koordinater ersätts med $x och $y i URL:en och zoomnivån ersätts med $z. Exempel på en kartfil kan se ut så här: - + To make GPXSee load a POI file automatically on startup, add the file to the following directory: För att GPXSee skall läsa in en POI-fil automatiskt vid programstart, läggs filen i följande mapp: - + Error loading data file: Fel vid inläsning av datafil: - - + + Line: %1 Rad: %1 - + Error loading POI file: Fel vid inläsning av POI-fil: - + Name Namn - + Tracks Spår - - + + About GPXSee Om GPXSee - + Navigation Navigation - + Map sources Kartkällor - + POIs POI:er - - + + Distance Avstånd - - + + + Time Tid @@ -806,7 +807,7 @@ - Moving Time + Moving time @@ -925,7 +926,7 @@ Hastighet - + km/h km/h @@ -940,7 +941,7 @@ Max - + mi/h mi/h @@ -998,12 +999,12 @@ - Time - Tid + Total time + - Moving Time + Moving time diff --git a/src/fliplabel.cpp b/src/fliplabel.cpp deleted file mode 100644 index 0e7471d9..00000000 --- a/src/fliplabel.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "fliplabel.h" - - -void FlipLabel::addItem(const QString &key, const QString &value) -{ - _labels.insert(key, value); - - if (_labels.size() == 1) - _it = _labels.constBegin(); - - QLabel::setText(_it.value()); - QLabel::setToolTip(_it.key()); -} - -void FlipLabel::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - - if (!_labels.count()) - return; - - _it++; - if (_it == _labels.constEnd()) - _it = _labels.constBegin(); - - QLabel::setText(_it.value()); - QLabel::setToolTip(_it.key()); -} diff --git a/src/fliplabel.h b/src/fliplabel.h deleted file mode 100644 index 35ba2a47..00000000 --- a/src/fliplabel.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FLIPLABEL_H -#define FLIPLABEL_H - -#include -#include - -class FlipLabel : public QLabel -{ -public: - FlipLabel(QWidget *parent = 0) : QLabel(parent) {} - - void addItem(const QString &key, const QString &value); - -protected: - void mousePressEvent(QMouseEvent *event); - -private: - QMap _labels; - QMap::const_iterator _it; -}; - -#endif // FLIPLABEL_H diff --git a/src/graphtab.h b/src/graphtab.h index 96dc0151..f01d265c 100644 --- a/src/graphtab.h +++ b/src/graphtab.h @@ -4,6 +4,7 @@ #include #include "graphview.h" #include "units.h" +#include "timetype.h" class Data; class PathItem; @@ -18,10 +19,11 @@ public: virtual QString label() const = 0; virtual void loadData(const Data &data, const QList &paths) = 0; - virtual void clear() = 0; - virtual void setUnits(enum Units units) = 0; - virtual void showTracks(bool show) = 0; - virtual void showRoutes(bool show) = 0; + virtual void clear() {} + virtual void setUnits(enum Units units) {Q_UNUSED(units)} + virtual void setTimeType(enum TimeType type) {Q_UNUSED(type)} + virtual void showTracks(bool show) {Q_UNUSED(show)} + virtual void showRoutes(bool show) {Q_UNUSED(show)} }; #endif // GRAPHTAB_H diff --git a/src/gui.cpp b/src/gui.cpp index a152bcdb..e535d74a 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -41,7 +41,6 @@ #include "cpuarch.h" #include "graphtab.h" #include "format.h" -#include "fliplabel.h" #include "gui.h" @@ -361,6 +360,18 @@ void GUI::createActions() SLOT(showToolbars(bool))); ag = new QActionGroup(this); ag->setExclusive(true); + _totalTimeAction = new QAction(tr("Total time"), this); + _totalTimeAction->setCheckable(true); + _totalTimeAction->setActionGroup(ag); + connect(_totalTimeAction, SIGNAL(triggered()), this, + SLOT(setTotalTime())); + _movingTimeAction = new QAction(tr("Moving time"), this); + _movingTimeAction->setCheckable(true); + _movingTimeAction->setActionGroup(ag); + connect(_movingTimeAction, SIGNAL(triggered()), this, + SLOT(setMovingTime())); + ag = new QActionGroup(this); + ag->setExclusive(true); _metricUnitsAction = new QAction(tr("Metric"), this); _metricUnitsAction->setCheckable(true); _metricUnitsAction->setActionGroup(ag); @@ -452,6 +463,9 @@ void GUI::createMenus() dataMenu->addAction(_showWaypointsAction); QMenu *settingsMenu = menuBar()->addMenu(tr("Settings")); + QMenu *timeMenu = settingsMenu->addMenu(tr("Time")); + timeMenu->addAction(_totalTimeAction); + timeMenu->addAction(_movingTimeAction); QMenu *unitsMenu = settingsMenu->addMenu(tr("Units")); unitsMenu->addAction(_metricUnitsAction); unitsMenu->addAction(_imperialUnitsAction); @@ -534,7 +548,7 @@ void GUI::createStatusBar() { _fileNameLabel = new QLabel(); _distanceLabel = new QLabel(); - _timeLabel = new FlipLabel(); + _timeLabel = new QLabel(); _distanceLabel->setAlignment(Qt::AlignHCenter); _timeLabel->setAlignment(Qt::AlignHCenter); @@ -859,7 +873,7 @@ void GUI::plot(QPrinter *printer) if (t > 0 && _options.printTime) info.insert(tr("Time"), Format::timeSpan(t)); if (tm > 0 && _options.printMovingTime) - info.insert(tr("Moving Time"), Format::timeSpan(tm)); + info.insert(tr("Moving time"), Format::timeSpan(tm)); ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI; @@ -1077,9 +1091,10 @@ void GUI::updateStatusBarInfo() _distanceLabel->clear(); if (time() > 0) { - _timeLabel->addItem(tr("Total Time"), Format::timeSpan(time())); - _timeLabel->addItem(tr("Moving Time"), Format::timeSpan(movingTime()) - + "M"); + if (_movingTimeAction->isChecked()) + _timeLabel->setText(Format::timeSpan(movingTime())); + else + _timeLabel->setText(Format::timeSpan(time())); } else _timeLabel->clear(); } @@ -1190,6 +1205,14 @@ void GUI::updatePathView() + _pathView->waypointCount())); } +void GUI::setTimeType(TimeType type) +{ + for (int i = 0; i <_tabs.count(); i++) + _tabs.at(i)->setTimeType(type); + + updateStatusBarInfo(); +} + void GUI::setUnits(Units units) { _export.units = units; @@ -1325,6 +1348,10 @@ void GUI::writeSettings() settings.endGroup(); settings.beginGroup(SETTINGS_SETTINGS_GROUP); + if ((_movingTimeAction->isChecked() ? Moving : Total) != + TIME_TYPE_DEFAULT) + settings.setValue(TIME_TYPE_SETTING, _movingTimeAction->isChecked() + ? Moving : Total); if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) != UNITS_DEFAULT) settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked() @@ -1455,6 +1482,14 @@ void GUI::readSettings() settings.endGroup(); settings.beginGroup(SETTINGS_SETTINGS_GROUP); + if (settings.value(TIME_TYPE_SETTING, TIME_TYPE_DEFAULT).toInt() + == Moving) { + setTimeType(Moving); + _movingTimeAction->setChecked(true); + } else { + setTimeType(Total); + _totalTimeAction->setChecked(true); + } if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) { setUnits(Imperial); _imperialUnitsAction->setChecked(true); diff --git a/src/gui.h b/src/gui.h index 81fa1a78..8e43eac8 100644 --- a/src/gui.h +++ b/src/gui.h @@ -7,6 +7,7 @@ #include #include #include "units.h" +#include "timetype.h" #include "graph.h" #include "poi.h" #include "exportdialog.h" @@ -18,7 +19,6 @@ class QTabWidget; class QActionGroup; class QAction; class QLabel; -class FlipLabel; class QSignalMapper; class QPrinter; class FileBrowser; @@ -68,6 +68,8 @@ private slots: void last(); void first(); + void setTotalTime() {setTimeType(Total);} + void setMovingTime() {setTimeType(Moving);} void setMetricUnits() {setUnits(Metric);} void setImperialUnits() {setUnits(Imperial);} void setDistanceGraph() {setGraphType(Distance);} @@ -103,7 +105,9 @@ private: void updateGraphTabs(); void updatePathView(); + TimeType timeType() const; Units units() const; + void setTimeType(TimeType type); void setUnits(Units units); void setGraphType(GraphType type); @@ -157,6 +161,8 @@ private: QAction *_firstAction; QAction *_metricUnitsAction; QAction *_imperialUnitsAction; + QAction *_totalTimeAction; + QAction *_movingTimeAction; QAction *_nextMapAction; QAction *_prevMapAction; QAction *_showTracksAction; @@ -172,7 +178,7 @@ private: QLabel *_fileNameLabel; QLabel *_distanceLabel; - FlipLabel *_timeLabel; + QLabel *_timeLabel; PathView *_pathView; QTabWidget *_graphTabWidget; diff --git a/src/heartrategraph.h b/src/heartrategraph.h index 0fcd46a2..a0b0b062 100644 --- a/src/heartrategraph.h +++ b/src/heartrategraph.h @@ -13,9 +13,7 @@ public: QString label() const {return tr("Heart rate");} void loadData(const Data &data, const QList &paths); void clear(); - void setUnits(enum Units) {} void showTracks(bool show); - void showRoutes(bool show) {Q_UNUSED(show);} private: qreal avg() const; diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index ef3027c4..88ca0b5f 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -152,7 +152,7 @@ QWidget *OptionsDialog::createExportPage() _distance->setChecked(_options->printDistance); _time = new QCheckBox(tr("Time")); _time->setChecked(_options->printTime); - _movingTime = new QCheckBox(tr("Moving Time")); + _movingTime = new QCheckBox(tr("Moving time")); _movingTime->setChecked(_options->printMovingTime); _itemCount = new QCheckBox(tr("Item count (>1)")); _itemCount->setChecked(_options->printItemCount); diff --git a/src/powergraph.h b/src/powergraph.h index eba67126..d369756d 100644 --- a/src/powergraph.h +++ b/src/powergraph.h @@ -13,9 +13,7 @@ public: QString label() const {return tr("Power");} void loadData(const Data &data, const QList &paths); void clear(); - void setUnits(enum Units) {} void showTracks(bool show); - void showRoutes(bool show) {Q_UNUSED(show);} private: qreal avg() const; diff --git a/src/settings.h b/src/settings.h index 0e3a883d..a23fdc94 100644 --- a/src/settings.h +++ b/src/settings.h @@ -11,6 +11,8 @@ #define WINDOW_POS_DEFAULT QPoint(10, 10) #define SETTINGS_SETTINGS_GROUP "Settings" +#define TIME_TYPE_SETTING "timeType" +#define TIME_TYPE_DEFAULT Total #define UNITS_SETTING "units" #define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric) #define SHOW_TOOLBARS_SETTING "toolbar" diff --git a/src/speedgraph.cpp b/src/speedgraph.cpp index 70aaef2a..f3d42d49 100644 --- a/src/speedgraph.cpp +++ b/src/speedgraph.cpp @@ -36,6 +36,8 @@ void SpeedGraph::loadData(const Data &data, const QList &paths) _avg.append(QPointF(data.tracks().at(i)->distance(), data.tracks().at(i)->distance() / data.tracks().at(i)->time())); + _avgM.append(QPointF(data.tracks().at(i)->distance(), + data.tracks().at(i)->distance() / data.tracks().at(i)->movingTime())); GraphView::loadGraph(graph, paths.at(i)); } @@ -52,8 +54,9 @@ qreal SpeedGraph::avg() const { qreal sum = 0, w = 0; QList::const_iterator it; + const QList &list = (_timeType == Moving) ? _avgM : _avg; - for (it = _avg.begin(); it != _avg.end(); it++) { + for (it = list.begin(); it != list.end(); it++) { sum += it->y() * it->x(); w += it->x(); } @@ -64,6 +67,7 @@ qreal SpeedGraph::avg() const void SpeedGraph::clear() { _avg.clear(); + _avgM.clear(); GraphView::clear(); } @@ -90,6 +94,14 @@ void SpeedGraph::setUnits(enum Units units) redraw(); } +void SpeedGraph::setTimeType(enum TimeType type) +{ + _timeType = type; + + setInfo(); + redraw(); +} + void SpeedGraph::showTracks(bool show) { _showTracks = show; diff --git a/src/speedgraph.h b/src/speedgraph.h index 3e763b4c..6fd12eef 100644 --- a/src/speedgraph.h +++ b/src/speedgraph.h @@ -15,8 +15,8 @@ public: void loadData(const Data &data, const QList &paths); void clear(); void setUnits(enum Units units); + void setTimeType(enum TimeType type); void showTracks(bool show); - void showRoutes(bool show) {Q_UNUSED(show);} private: qreal avg() const; @@ -25,8 +25,10 @@ private: void setInfo(); QList _avg; + QList _avgM; enum Units _units; + enum TimeType _timeType; bool _showTracks; }; diff --git a/src/temperaturegraph.h b/src/temperaturegraph.h index 5636b03d..54e6fefd 100644 --- a/src/temperaturegraph.h +++ b/src/temperaturegraph.h @@ -15,7 +15,6 @@ public: void clear(); void setUnits(enum Units units); void showTracks(bool show); - void showRoutes(bool show) {Q_UNUSED(show);} private: qreal avg() const; diff --git a/src/timetype.h b/src/timetype.h new file mode 100644 index 00000000..ecb42e64 --- /dev/null +++ b/src/timetype.h @@ -0,0 +1,9 @@ +#ifndef TIMETYPE_H +#define TIMETYPE_H + +enum TimeType { + Total, + Moving +}; + +#endif // TIMETYPE_H diff --git a/src/trackitem.cpp b/src/trackitem.cpp index 953a5356..a84cf8b5 100644 --- a/src/trackitem.cpp +++ b/src/trackitem.cpp @@ -14,9 +14,9 @@ QString TrackItem::toolTip() tt.insert(tr("Description"), _desc); tt.insert(tr("Distance"), Format::distance(_distance.last(), _units)); if (_time > 0) - tt.insert(tr("Time"), Format::timeSpan(_time)); + tt.insert(tr("Total time"), Format::timeSpan(_time)); if (_movingTime > 0) - tt.insert(tr("Moving Time"), Format::timeSpan(_movingTime)); + tt.insert(tr("Moving time"), Format::timeSpan(_movingTime)); if (!_date.isNull()) tt.insert(tr("Date"), _date.toString(Qt::SystemLocaleShortDate));