mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Made the moving time switch affect all related values
More standardized time type switching (menu)
This commit is contained in:
@ -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());
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef FLIPLABEL_H
|
||||
#define FLIPLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
|
||||
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<QString, QString> _labels;
|
||||
QMap<QString, QString>::const_iterator _it;
|
||||
};
|
||||
|
||||
#endif // FLIPLABEL_H
|
@ -4,6 +4,7 @@
|
||||
#include <QList>
|
||||
#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<PathItem *> &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
|
||||
|
47
src/gui.cpp
47
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())
|
||||
+ "<sub>M</sub>");
|
||||
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);
|
||||
|
10
src/gui.h
10
src/gui.h
@ -7,6 +7,7 @@
|
||||
#include <QDate>
|
||||
#include <QPrinter>
|
||||
#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;
|
||||
|
@ -13,9 +13,7 @@ public:
|
||||
QString label() const {return tr("Heart rate");}
|
||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units) {}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
|
@ -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);
|
||||
|
@ -13,9 +13,7 @@ public:
|
||||
QString label() const {return tr("Power");}
|
||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units) {}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
|
@ -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"
|
||||
|
@ -36,6 +36,8 @@ void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &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<QPointF>::const_iterator it;
|
||||
const QList<QPointF> &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;
|
||||
|
@ -15,8 +15,8 @@ public:
|
||||
void loadData(const Data &data, const QList<PathItem *> &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<QPointF> _avg;
|
||||
QList<QPointF> _avgM;
|
||||
|
||||
enum Units _units;
|
||||
enum TimeType _timeType;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
9
src/timetype.h
Normal file
9
src/timetype.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef TIMETYPE_H
|
||||
#define TIMETYPE_H
|
||||
|
||||
enum TimeType {
|
||||
Total,
|
||||
Moving
|
||||
};
|
||||
|
||||
#endif // TIMETYPE_H
|
@ -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));
|
||||
|
||||
|
Reference in New Issue
Block a user