mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Added statistics window
This commit is contained in:
parent
79388aa753
commit
531eb256f1
@ -132,7 +132,8 @@ HEADERS += src/config.h \
|
|||||||
src/map/geocentric.h \
|
src/map/geocentric.h \
|
||||||
src/map/mercator.h \
|
src/map/mercator.h \
|
||||||
src/map/jnxmap.h \
|
src/map/jnxmap.h \
|
||||||
src/map/krovak.h
|
src/map/krovak.h \
|
||||||
|
src/GUI/kv.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
#include "data/graph.h"
|
#include "data/graph.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "infoitem.h"
|
||||||
|
|
||||||
|
|
||||||
class AxisItem;
|
class AxisItem;
|
||||||
class SliderItem;
|
class SliderItem;
|
||||||
class SliderInfoItem;
|
class SliderInfoItem;
|
||||||
class InfoItem;
|
|
||||||
class GraphItem;
|
class GraphItem;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
class GridItem;
|
class GridItem;
|
||||||
@ -27,6 +27,7 @@ public:
|
|||||||
~GraphView();
|
~GraphView();
|
||||||
|
|
||||||
bool isEmpty() const {return _graphs.isEmpty();}
|
bool isEmpty() const {return _graphs.isEmpty();}
|
||||||
|
const QList<KV> &info() const {return _info->info();}
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
||||||
|
@ -238,6 +238,10 @@ void GUI::createActions()
|
|||||||
_reloadFileAction->setActionGroup(_fileActionGroup);
|
_reloadFileAction->setActionGroup(_fileActionGroup);
|
||||||
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
|
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
|
||||||
addAction(_reloadFileAction);
|
addAction(_reloadFileAction);
|
||||||
|
_statisticsAction = new QAction(tr("Statistics..."), this);
|
||||||
|
_statisticsAction->setShortcut(STATISTICS_SHORTCUT);
|
||||||
|
_statisticsAction->setActionGroup(_fileActionGroup);
|
||||||
|
connect(_statisticsAction, SIGNAL(triggered()), this, SLOT(statistics()));
|
||||||
|
|
||||||
// POI actions
|
// POI actions
|
||||||
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
||||||
@ -432,8 +436,9 @@ void GUI::createMenus()
|
|||||||
fileMenu->addAction(_printFileAction);
|
fileMenu->addAction(_printFileAction);
|
||||||
fileMenu->addAction(_exportFileAction);
|
fileMenu->addAction(_exportFileAction);
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction(_reloadFileAction);
|
fileMenu->addAction(_statisticsAction);
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
|
fileMenu->addAction(_reloadFileAction);
|
||||||
fileMenu->addAction(_closeFileAction);
|
fileMenu->addAction(_closeFileAction);
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
@ -908,6 +913,67 @@ void GUI::exportFile()
|
|||||||
plot(&printer);
|
plot(&printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::statistics()
|
||||||
|
{
|
||||||
|
QString text = "<style>td {white-space: pre; padding-right: 1em;}"
|
||||||
|
"th {text-align: left; padding-top: 0.5em;}</style><table>";
|
||||||
|
|
||||||
|
if (_showTracksAction->isChecked() && _trackCount > 1)
|
||||||
|
text.append("<tr><td>" + tr("Tracks") + ":</td><td>"
|
||||||
|
+ QString::number(_trackCount) + "</td></tr>");
|
||||||
|
if (_showRoutesAction->isChecked() && _routeCount > 1)
|
||||||
|
text.append("<tr><td>" + tr("Routes") + ":</td><td>"
|
||||||
|
+ QString::number(_routeCount) + "</td></tr>");
|
||||||
|
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
||||||
|
text.append("<tr><td>" + tr("Waypoints") + ":</td><td>"
|
||||||
|
+ QString::number(_waypointCount) + "</td></tr>");
|
||||||
|
|
||||||
|
if (_dateRange.first.isValid()) {
|
||||||
|
if (_dateRange.first == _dateRange.second) {
|
||||||
|
QString format = QLocale::system().dateFormat(QLocale::LongFormat);
|
||||||
|
text.append("<tr><td>" + tr("Date") + ":</td><td>"
|
||||||
|
+ _dateRange.first.toString(format) + "</td></tr>");
|
||||||
|
} else {
|
||||||
|
QString format = QLocale::system().dateFormat(QLocale::ShortFormat);
|
||||||
|
text.append("<tr><td>" + tr("Date") + ":</td><td>"
|
||||||
|
+ QString("%1 - %2").arg(_dateRange.first.toString(format),
|
||||||
|
_dateRange.second.toString(format)) + "</td></tr>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance() > 0)
|
||||||
|
text.append("<tr><td>" + tr("Distance") + ":</td><td>"
|
||||||
|
+ Format::distance(distance(), units()) + "</td></tr>");
|
||||||
|
if (time() > 0) {
|
||||||
|
text.append("<tr><td>" + tr("Time") + ":</td><td>"
|
||||||
|
+ Format::timeSpan(time()) + "</td></tr>");
|
||||||
|
text.append("<tr><td>" + tr("Moving time") + ":</td><td>"
|
||||||
|
+ Format::timeSpan(movingTime()) + "</td></tr>");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _tabs.count(); i++) {
|
||||||
|
const GraphTab *tab = _tabs.at(i);
|
||||||
|
if (tab->isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
text.append("<tr><th colspan=\"2\">" + tab->label() + "</th></tr>");
|
||||||
|
for (int j = 0; j < tab->info().size(); j++) {
|
||||||
|
const KV &kv = tab->info().at(j);
|
||||||
|
text.append("<tr><td>" + kv.key() + ":</td><td>" + kv.value()
|
||||||
|
+ "</td></tr>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text.append("</table>");
|
||||||
|
|
||||||
|
|
||||||
|
QMessageBox msgBox(this);
|
||||||
|
msgBox.setWindowTitle(tr("Statistics"));
|
||||||
|
msgBox.setText("<h3>" + tr("Statistics") + "</h3>");
|
||||||
|
msgBox.setInformativeText(text);
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::plot(QPrinter *printer)
|
void GUI::plot(QPrinter *printer)
|
||||||
{
|
{
|
||||||
QPainter p(printer);
|
QPainter p(printer);
|
||||||
@ -925,7 +991,7 @@ void GUI::plot(QPrinter *printer)
|
|||||||
info.insert(tr("Tracks"), QString::number(_trackCount));
|
info.insert(tr("Tracks"), QString::number(_trackCount));
|
||||||
if (_showRoutesAction->isChecked() && _routeCount > 1)
|
if (_showRoutesAction->isChecked() && _routeCount > 1)
|
||||||
info.insert(tr("Routes"), QString::number(_routeCount));
|
info.insert(tr("Routes"), QString::number(_routeCount));
|
||||||
if (_showWaypointsAction->isChecked() && _waypointCount > 2)
|
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
||||||
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ private slots:
|
|||||||
void openFile();
|
void openFile();
|
||||||
void closeAll();
|
void closeAll();
|
||||||
void reloadFile();
|
void reloadFile();
|
||||||
|
void statistics();
|
||||||
void openPOIFile();
|
void openPOIFile();
|
||||||
void closePOIFiles();
|
void closePOIFiles();
|
||||||
void showGraphs(bool show);
|
void showGraphs(bool show);
|
||||||
@ -150,6 +151,7 @@ private:
|
|||||||
QAction *_openFileAction;
|
QAction *_openFileAction;
|
||||||
QAction *_closeFileAction;
|
QAction *_closeFileAction;
|
||||||
QAction *_reloadFileAction;
|
QAction *_reloadFileAction;
|
||||||
|
QAction *_statisticsAction;
|
||||||
QAction *_openPOIAction;
|
QAction *_openPOIAction;
|
||||||
QAction *_closePOIAction;
|
QAction *_closePOIAction;
|
||||||
QAction *_showPOIAction;
|
QAction *_showPOIAction;
|
||||||
|
@ -22,8 +22,8 @@ void InfoItem::updateBoundingRect()
|
|||||||
|
|
||||||
for (QList<KV>::const_iterator i = _list.constBegin();
|
for (QList<KV>::const_iterator i = _list.constBegin();
|
||||||
i != _list.constEnd(); i++) {
|
i != _list.constEnd(); i++) {
|
||||||
width += fm.width(i->key + ": ");
|
width += fm.width(i->key() + ": ");
|
||||||
width += fm.width(i->value) + ((i == _list.constEnd() - 1)
|
width += fm.width(i->value()) + ((i == _list.constEnd() - 1)
|
||||||
? 0 : PADDING);
|
? 0 : PADDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,10 +43,10 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
for (QList<KV>::const_iterator i = _list.constBegin();
|
for (QList<KV>::const_iterator i = _list.constBegin();
|
||||||
i != _list.constEnd(); i++) {
|
i != _list.constEnd(); i++) {
|
||||||
painter->drawText(width, fm.height() - fm.descent(), i->key + ": ");
|
painter->drawText(width, fm.height() - fm.descent(), i->key() + ": ");
|
||||||
width += fm.width(i->key + ": ");
|
width += fm.width(i->key() + ": ");
|
||||||
painter->drawText(width, fm.height() - fm.descent(), i->value);
|
painter->drawText(width, fm.height() - fm.descent(), i->value());
|
||||||
width += fm.width(i->value) + ((i == _list.constEnd() - 1)
|
width += fm.width(i->value()) + ((i == _list.constEnd() - 1)
|
||||||
? 0 : PADDING);
|
? 0 : PADDING);
|
||||||
if (i != _list.constEnd() - 1) {
|
if (i != _list.constEnd() - 1) {
|
||||||
painter->save();
|
painter->save();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include "kv.h"
|
||||||
|
|
||||||
class InfoItem : public QGraphicsItem
|
class InfoItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
@ -13,6 +14,8 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
|
const QList<KV> &info() const {return _list;}
|
||||||
|
|
||||||
void insert(const QString &key, const QString &value);
|
void insert(const QString &key, const QString &value);
|
||||||
void clear();
|
void clear();
|
||||||
bool isEmpty() {return _list.isEmpty();}
|
bool isEmpty() {return _list.isEmpty();}
|
||||||
@ -20,17 +23,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
|
||||||
class KV {
|
|
||||||
public:
|
|
||||||
QString key;
|
|
||||||
QString value;
|
|
||||||
|
|
||||||
KV(const QString &k, const QString &v)
|
|
||||||
{key = k; value = v;}
|
|
||||||
bool operator==(const KV &other) const
|
|
||||||
{return this->key == other.key;}
|
|
||||||
};
|
|
||||||
|
|
||||||
QList<KV> _list;
|
QList<KV> _list;
|
||||||
QRectF _boundingRect;
|
QRectF _boundingRect;
|
||||||
QFont _font;
|
QFont _font;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
|
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
|
||||||
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
|
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
|
||||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||||
|
#define STATISTICS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_S)
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
||||||
|
21
src/GUI/kv.h
Normal file
21
src/GUI/kv.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef KV_H
|
||||||
|
#define KV_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class KV {
|
||||||
|
public:
|
||||||
|
KV(const QString &key, const QString &value) : _key(key), _value(value) {}
|
||||||
|
|
||||||
|
const QString &key() const {return _key;}
|
||||||
|
const QString &value() const {return _value;}
|
||||||
|
|
||||||
|
bool operator==(const KV &other) const
|
||||||
|
{return this->key() == other.key();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _key;
|
||||||
|
QString _value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KV_H
|
Loading…
Reference in New Issue
Block a user