mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Show track/route source file info when multiple files are opened
Closes #559
This commit is contained in:
@ -9,8 +9,9 @@
|
||||
#include "areaitem.h"
|
||||
|
||||
|
||||
ToolTip AreaItem::info() const
|
||||
ToolTip AreaItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
ToolTip tt;
|
||||
|
||||
if (!_area.name().isEmpty())
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
void setDigitalZoom(int zoom);
|
||||
void updateStyle();
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
protected:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
@ -9,8 +9,9 @@ CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
|
||||
{
|
||||
}
|
||||
|
||||
ToolTip CadenceGraphItem::info() const
|
||||
ToolTip CadenceGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
ToolTip tt;
|
||||
QLocale l(QLocale::system());
|
||||
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
CadenceGraphItem(const Graph &graph, GraphType type, int width,
|
||||
const QColor &color, QGraphicsItem *parent = 0);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
};
|
||||
|
||||
#endif // CADENCEGRAPHITEM_H
|
||||
|
@ -26,8 +26,10 @@ ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
||||
}
|
||||
}
|
||||
|
||||
ToolTip ElevationGraphItem::info() const
|
||||
ToolTip ElevationGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
|
||||
ToolTip tt;
|
||||
qreal scale = (_units == Metric) ? 1.0 : M2FT;
|
||||
QString su = (_units == Metric) ? tr("m") : tr("ft");
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
qreal max() const {return _max;}
|
||||
qreal min() const {return _min;}
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
private:
|
||||
qreal _ascent, _descent, _min, _max;
|
||||
|
@ -27,8 +27,10 @@ GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
|
||||
_top = key;
|
||||
}
|
||||
|
||||
ToolTip GearRatioGraphItem::info() const
|
||||
ToolTip GearRatioGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
|
||||
ToolTip tt;
|
||||
QLocale l(QLocale::system());
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
qreal top() const {return _top;}
|
||||
const QMap<qreal, qreal> &map() const {return _map;}
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
private:
|
||||
QMap<qreal, qreal> _map;
|
||||
|
@ -41,7 +41,8 @@ void GraphicsScene::helpEvent(QGraphicsSceneHelpEvent *event)
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.at(i)->type() == QGraphicsItem::UserType + 1) {
|
||||
GraphicsItem *mi = static_cast<GraphicsItem*>(list.at(i));
|
||||
Popup::show(event->screenPos(), mi->info(), event->widget());
|
||||
Popup::show(event->screenPos(), mi->info(_showExtendedInfo),
|
||||
event->widget());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class GraphicsItem : public QGraphicsItem
|
||||
public:
|
||||
GraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) {}
|
||||
|
||||
virtual ToolTip info() const = 0;
|
||||
virtual ToolTip info(bool extended) const = 0;
|
||||
int type() const {return QGraphicsItem::UserType + 1;}
|
||||
|
||||
static void useStyle(bool use) {_useStyle = use;}
|
||||
@ -22,7 +22,11 @@ protected:
|
||||
class GraphicsScene : public QGraphicsScene
|
||||
{
|
||||
public:
|
||||
GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
||||
GraphicsScene(QObject *parent = 0)
|
||||
: QGraphicsScene(parent), _showExtendedInfo(false) {}
|
||||
|
||||
bool showExtendedInfo() const {return _showExtendedInfo;}
|
||||
void showExtendedInfo(bool show) {_showExtendedInfo = show;}
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
@ -31,6 +35,8 @@ protected:
|
||||
void helpEvent(QGraphicsSceneHelpEvent *event);
|
||||
|
||||
private:
|
||||
bool _showExtendedInfo;
|
||||
|
||||
QList<QGraphicsItem *> itemsAtPosition(const QPoint &screenPos,
|
||||
const QPointF &scenePos, QWidget *widget) const;
|
||||
};
|
||||
|
@ -379,6 +379,9 @@ void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Popup::show(event->screenPos(), info(), event->widget());
|
||||
GraphicsScene *gs = dynamic_cast<GraphicsScene *>(scene());
|
||||
if (gs)
|
||||
Popup::show(event->screenPos(), info(gs->showExtendedInfo()),
|
||||
event->widget());
|
||||
GraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
const QColor &color, Qt::PenStyle style, QGraphicsItem *parent = 0);
|
||||
virtual ~GraphItem() {}
|
||||
|
||||
virtual ToolTip info() const = 0;
|
||||
virtual ToolTip info(bool extended) const = 0;
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
|
@ -1069,6 +1069,8 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
updateNavigationActions();
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
if (_files.count() > 1)
|
||||
_mapView->showExtendedInfo(true);
|
||||
#ifndef Q_OS_ANDROID
|
||||
updateRecentFiles(canonicalFileName);
|
||||
#endif // Q_OS_ANDROID
|
||||
@ -1555,6 +1557,7 @@ void GUI::reloadFiles()
|
||||
_browser->setCurrent(_files.last());
|
||||
#endif // Q_OS_ANDROID
|
||||
updateDataDEMDownloadAction();
|
||||
_mapView->showExtendedInfo(_files.size() > 1);
|
||||
}
|
||||
|
||||
void GUI::closeFiles()
|
||||
@ -1575,6 +1578,7 @@ void GUI::closeFiles()
|
||||
_lastTab = 0;
|
||||
|
||||
_mapView->clear();
|
||||
_mapView->showExtendedInfo(false);
|
||||
|
||||
_files.clear();
|
||||
}
|
||||
|
@ -9,8 +9,10 @@ HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||
{
|
||||
}
|
||||
|
||||
ToolTip HeartRateGraphItem::info() const
|
||||
ToolTip HeartRateGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
|
||||
ToolTip tt;
|
||||
QLocale l(QLocale::system());
|
||||
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
HeartRateGraphItem(const Graph &graph, GraphType type, int width,
|
||||
const QColor &color, QGraphicsItem *parent = 0);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
};
|
||||
|
||||
#endif // HEARTRATEGRAPHITEM_H
|
||||
|
@ -71,8 +71,9 @@ static QRectF bbox(const RectC &rect, Map *map, int samples = 100)
|
||||
return prect;
|
||||
}
|
||||
|
||||
ToolTip MapItem::info() const
|
||||
ToolTip MapItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
ToolTip tt;
|
||||
|
||||
if (!_name.isEmpty())
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
void setPenStyle(Qt::PenStyle style);
|
||||
void setDigitalZoom(int zoom);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
signals:
|
||||
void triggered();
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "coordinatesitem.h"
|
||||
#include "mapitem.h"
|
||||
#include "keys.h"
|
||||
#include "graphicsscene.h"
|
||||
#include "mapaction.h"
|
||||
#include "markerinfoitem.h"
|
||||
#include "crosshairitem.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "format.h"
|
||||
#include "markerinfoitem.h"
|
||||
#include "palette.h"
|
||||
#include "graphicsscene.h"
|
||||
|
||||
|
||||
class QGeoPositionInfoSource;
|
||||
@ -35,7 +36,6 @@ class GraphItem;
|
||||
class PlaneItem;
|
||||
class MapItem;
|
||||
class Area;
|
||||
class GraphicsScene;
|
||||
class QTimeZone;
|
||||
class MapAction;
|
||||
class CrosshairItem;
|
||||
@ -64,6 +64,7 @@ public:
|
||||
void setMap(Map *map);
|
||||
void setPositionSource(QGeoPositionInfoSource *source);
|
||||
void setGraph(int index);
|
||||
void showExtendedInfo(bool show) {_scene->showExtendedInfo(show);}
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target, qreal scale,
|
||||
PlotFlags flags);
|
||||
|
@ -510,6 +510,9 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void PathItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Popup::show(event->screenPos(), info(), event->widget());
|
||||
GraphicsScene *gs = dynamic_cast<GraphicsScene *>(scene());
|
||||
if (gs)
|
||||
Popup::show(event->screenPos(), info(gs->showExtendedInfo()),
|
||||
event->widget());
|
||||
GraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
@ -76,6 +76,9 @@ QRect PathTickItem::tickRect(int value)
|
||||
void PathTickItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
const PathItem *pi = static_cast<PathItem*>(parentItem());
|
||||
Popup::show(event->screenPos(), pi->info(), event->widget());
|
||||
GraphicsScene *gs = dynamic_cast<GraphicsScene *>(scene());
|
||||
if (gs)
|
||||
Popup::show(event->screenPos(), pi->info(gs->showExtendedInfo()),
|
||||
event->widget());
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ public:
|
||||
void setDigitalZoom(int zoom) {setScale(qPow(2, -zoom));}
|
||||
|
||||
int type() const {return parentItem()->type();}
|
||||
ToolTip info() const
|
||||
ToolTip info(bool extended) const
|
||||
{
|
||||
return static_cast<GraphicsItem*>(parentItem())->info();
|
||||
return static_cast<GraphicsItem*>(parentItem())->info(extended);
|
||||
}
|
||||
|
||||
static QRect tickRect(int value);
|
||||
|
@ -9,8 +9,9 @@ PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type, int width,
|
||||
{
|
||||
}
|
||||
|
||||
ToolTip PowerGraphItem::info() const
|
||||
ToolTip PowerGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
ToolTip tt;
|
||||
QLocale l(QLocale::system());
|
||||
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
PowerGraphItem(const Graph &graph, GraphType type, int width,
|
||||
const QColor &color, QGraphicsItem *parent = 0);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
};
|
||||
|
||||
#endif // POWERGRAPHITEM_H
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include <QPainter>
|
||||
#include <QLocale>
|
||||
#include <QFileInfo>
|
||||
#include "data/waypoint.h"
|
||||
#include "data/route.h"
|
||||
#include "map/map.h"
|
||||
#include "format.h"
|
||||
#include "waypointitem.h"
|
||||
#include "tooltip.h"
|
||||
#include "routeitem.h"
|
||||
|
||||
|
||||
ToolTip RouteItem::info() const
|
||||
ToolTip RouteItem::info(bool extended) const
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
@ -31,6 +31,13 @@ ToolTip RouteItem::info() const
|
||||
}
|
||||
tt.insert(tr("Links"), links);
|
||||
}
|
||||
#ifdef Q_OS_ANDROID
|
||||
Q_UNUSED(extended);
|
||||
#else // Q_OS_ANDROID
|
||||
if (extended && !_file.isEmpty())
|
||||
tt.insert(tr("File"), QString("<a href=\"file:%1\">%2</a>")
|
||||
.arg(_file, QFileInfo(_file).fileName()));
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
return tt;
|
||||
}
|
||||
@ -48,6 +55,7 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
||||
_desc = route.description();
|
||||
_comment = route.comment();
|
||||
_links = route.links();
|
||||
_file = route.file();
|
||||
}
|
||||
|
||||
void RouteItem::setMap(Map *map)
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
void showWaypointLabels(bool show);
|
||||
void showWaypointIcons(bool show);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
QDateTime date() const {return QDateTime();}
|
||||
|
||||
private:
|
||||
@ -31,6 +31,7 @@ private:
|
||||
QString _comment;
|
||||
QVector<Link> _links;
|
||||
QVector<WaypointItem*> _waypoints;
|
||||
QString _file;
|
||||
};
|
||||
|
||||
#endif // ROUTEITEM_H
|
||||
|
@ -15,8 +15,10 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type, int width,
|
||||
_mavg = graph.last().last().s() / movingTime;
|
||||
}
|
||||
|
||||
ToolTip SpeedGraphItem::info() const
|
||||
ToolTip SpeedGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
|
||||
ToolTip tt;
|
||||
qreal scale = (_units == Imperial) ? MS2MIH : (_units == Nautical)
|
||||
? MS2KN : MS2KMH;
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
qreal mavg() const {return _mavg;}
|
||||
qreal max() const {return _max;}
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
void setTimeType(TimeType type);
|
||||
|
||||
|
@ -12,8 +12,10 @@ TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
|
||||
_avg = GraphItem::avg();
|
||||
}
|
||||
|
||||
ToolTip TemperatureGraphItem::info() const
|
||||
ToolTip TemperatureGraphItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
|
||||
ToolTip tt;
|
||||
qreal scale = (_units == Metric) ? 1.0 : C2FS;
|
||||
qreal offset = (_units == Metric) ? 0 : C2FO;
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
qreal min() const {return _min;}
|
||||
qreal avg() const {return _avg;}
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
private:
|
||||
qreal _min, _max, _avg;
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include <QPainter>
|
||||
#include "map/map.h"
|
||||
#include <QLocale>
|
||||
#include "common/util.h"
|
||||
#include "data/track.h"
|
||||
#include "format.h"
|
||||
#include "tooltip.h"
|
||||
#include "trackitem.h"
|
||||
|
||||
|
||||
ToolTip TrackItem::info() const
|
||||
ToolTip TrackItem::info(bool extended) const
|
||||
{
|
||||
ToolTip tt;
|
||||
QLocale l;
|
||||
@ -39,6 +39,13 @@ ToolTip TrackItem::info() const
|
||||
}
|
||||
tt.insert(tr("Links"), links);
|
||||
}
|
||||
#ifdef Q_OS_ANDROID
|
||||
Q_UNUSED(extended);
|
||||
#else // Q_OS_ANDROID
|
||||
if (extended && !_file.isEmpty())
|
||||
tt.insert(tr("File"), QString("<a href=\"file:%1\">%2</a>")
|
||||
.arg(_file, QFileInfo(_file).fileName()));
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
return tt;
|
||||
}
|
||||
@ -53,4 +60,5 @@ TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
|
||||
_date = track.date();
|
||||
_time = track.time();
|
||||
_movingTime = track.movingTime();
|
||||
_file = track.file();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class TrackItem : public PathItem
|
||||
public:
|
||||
TrackItem(const Track &track, Map *map, QGraphicsItem *parent = 0);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
QDateTime date() const {return _date;}
|
||||
|
||||
private:
|
||||
@ -26,6 +26,7 @@ private:
|
||||
QDateTime _date;
|
||||
qreal _time;
|
||||
qreal _movingTime;
|
||||
QString _file;
|
||||
};
|
||||
|
||||
#endif // TRACKITEM_H
|
||||
|
@ -16,8 +16,9 @@ Units WaypointItem::_units = Metric;
|
||||
CoordinatesFormat WaypointItem::_format = DecimalDegrees;
|
||||
QTimeZone WaypointItem::_timeZone = QTimeZone::utc();
|
||||
|
||||
ToolTip WaypointItem::info() const
|
||||
ToolTip WaypointItem::info(bool extended) const
|
||||
{
|
||||
Q_UNUSED(extended);
|
||||
ToolTip tt;
|
||||
QLocale l;
|
||||
|
||||
@ -274,7 +275,10 @@ void WaypointItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void WaypointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Popup::show(event->screenPos(), info(), event->widget());
|
||||
GraphicsScene *gs = dynamic_cast<GraphicsScene *>(scene());
|
||||
if (gs)
|
||||
Popup::show(event->screenPos(), info(gs->showExtendedInfo()),
|
||||
event->widget());
|
||||
/* Do not propagate the event any further as lower stacked items (path
|
||||
items) would replace the popup with their own popup */
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
ToolTip info() const;
|
||||
ToolTip info(bool extended) const;
|
||||
|
||||
static void setUnits(Units units) {_units = units;}
|
||||
static void setCoordinatesFormat(CoordinatesFormat format)
|
||||
|
Reference in New Issue
Block a user