mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Added tooltip event triggers for info messages
This commit is contained in:
parent
694847a424
commit
9c96e7124a
@ -19,6 +19,7 @@ equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 4) {QT += opengl}
|
|||||||
|
|
||||||
INCLUDEPATH += ./src
|
INCLUDEPATH += ./src
|
||||||
HEADERS += src/common/config.h \
|
HEADERS += src/common/config.h \
|
||||||
|
src/GUI/graphicsscene.h \
|
||||||
src/GUI/popup.h \
|
src/GUI/popup.h \
|
||||||
src/common/staticassert.h \
|
src/common/staticassert.h \
|
||||||
src/common/coordinates.h \
|
src/common/coordinates.h \
|
||||||
|
@ -9,9 +9,8 @@ CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CadenceGraphItem::toolTip(Units units) const
|
QString CadenceGraphItem::info() const
|
||||||
{
|
{
|
||||||
Q_UNUSED(units);
|
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public:
|
|||||||
CadenceGraphItem(const Graph &graph, GraphType type, int width,
|
CadenceGraphItem(const Graph &graph, GraphType type, int width,
|
||||||
const QColor &color, QGraphicsItem *parent = 0);
|
const QColor &color, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CADENCEGRAPHITEM_H
|
#endif // CADENCEGRAPHITEM_H
|
||||||
|
@ -26,11 +26,11 @@ ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ElevationGraphItem::toolTip(Units units) const
|
QString ElevationGraphItem::info() const
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
qreal scale = (units == Metric) ? 1.0 : M2FT;
|
qreal scale = (_units == Metric) ? 1.0 : M2FT;
|
||||||
QString su = (units == Metric) ? tr("m") : tr("ft");
|
QString su = (_units == Metric) ? tr("m") : tr("ft");
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
tt.insert(tr("Ascent"), l.toString(ascent() * scale, 'f', 0)
|
tt.insert(tr("Ascent"), l.toString(ascent() * scale, 'f', 0)
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
qreal max() const {return _max;}
|
qreal max() const {return _max;}
|
||||||
qreal min() const {return _min;}
|
qreal min() const {return _min;}
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal _ascent, _descent, _min, _max;
|
qreal _ascent, _descent, _min, _max;
|
||||||
|
@ -27,9 +27,8 @@ GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
|
|||||||
_top = key;
|
_top = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GearRatioGraphItem::toolTip(Units units) const
|
QString GearRatioGraphItem::info() const
|
||||||
{
|
{
|
||||||
Q_UNUSED(units);
|
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
qreal top() const {return _top;}
|
qreal top() const {return _top;}
|
||||||
const QMap<qreal, qreal> &map() const {return _map;}
|
const QMap<qreal, qreal> &map() const {return _map;}
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<qreal, qreal> _map;
|
QMap<qreal, qreal> _map;
|
||||||
|
36
src/GUI/graphicsscene.h
Normal file
36
src/GUI/graphicsscene.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef GRAPHICSSCENE_H
|
||||||
|
#define GRAPHICSSCENE_H
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QGraphicsSceneHelpEvent>
|
||||||
|
#include <QWidget>
|
||||||
|
#include "popup.h"
|
||||||
|
|
||||||
|
class GraphicsItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) {}
|
||||||
|
|
||||||
|
virtual QString info() const = 0;
|
||||||
|
int type() const {return QGraphicsItem::UserType + 1;}
|
||||||
|
};
|
||||||
|
|
||||||
|
class GraphicsScene : public QGraphicsScene
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void helpEvent(QGraphicsSceneHelpEvent *event)
|
||||||
|
{
|
||||||
|
QGraphicsItem *item = itemAt(event->scenePos(), QTransform());
|
||||||
|
if (item && item->type() == QGraphicsItem::UserType + 1) {
|
||||||
|
GraphicsItem *mi = static_cast<GraphicsItem*>(item);
|
||||||
|
Popup::show(event->screenPos(), mi->info(),
|
||||||
|
static_cast<QWidget*>(parent()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHICSSCENE_H
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
GraphItem::GraphItem(const Graph &graph, GraphType type, int width,
|
GraphItem::GraphItem(const Graph &graph, GraphType type, int width,
|
||||||
const QColor &color, QGraphicsItem *parent)
|
const QColor &color, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent), _graph(graph), _type(type)
|
: GraphicsItem(parent), _graph(graph), _type(type)
|
||||||
{
|
{
|
||||||
Q_ASSERT(_graph.isValid());
|
Q_ASSERT(_graph.isValid());
|
||||||
|
|
||||||
@ -309,6 +309,6 @@ void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
|
|
||||||
void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Popup::show(event->screenPos(), toolTip(_units), event->widget());
|
Popup::show(event->screenPos(), info(), event->widget());
|
||||||
QGraphicsObject::mousePressEvent(event);
|
GraphicsItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include "data/graph.h"
|
#include "data/graph.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
class GraphItem : public QGraphicsObject
|
class GraphItem : public QObject, public GraphicsItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public:
|
|||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
virtual ~GraphItem() {}
|
virtual ~GraphItem() {}
|
||||||
|
|
||||||
virtual QString toolTip(Units units) const = 0;
|
virtual QString info() const = 0;
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
@ -52,6 +53,8 @@ protected:
|
|||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
Units _units;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const GraphSegment *segment(qreal x, GraphType type) const;
|
const GraphSegment *segment(qreal x, GraphType type) const;
|
||||||
void updatePath();
|
void updatePath();
|
||||||
@ -60,13 +63,11 @@ private:
|
|||||||
|
|
||||||
Graph _graph;
|
Graph _graph;
|
||||||
GraphType _type;
|
GraphType _type;
|
||||||
Units _units;
|
|
||||||
QPainterPath _path;
|
QPainterPath _path;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
QRectF _bounds;
|
QRectF _bounds;
|
||||||
qreal _sx, _sy;
|
qreal _sx, _sy;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
|
|
||||||
bool _time;
|
bool _time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +24,7 @@
|
|||||||
GraphView::GraphView(QWidget *parent)
|
GraphView::GraphView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
_scene = new QGraphicsScene(this);
|
_scene = new GraphicsScene(this);
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
|
|
||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
@ -37,9 +38,9 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
_yAxis = new AxisItem(AxisItem::Y);
|
_yAxis = new AxisItem(AxisItem::Y);
|
||||||
_yAxis->setZValue(1.0);
|
_yAxis->setZValue(1.0);
|
||||||
_slider = new SliderItem();
|
_slider = new SliderItem();
|
||||||
_slider->setZValue(3.0);
|
_slider->setZValue(4.0);
|
||||||
_sliderInfo = new SliderInfoItem(_slider);
|
_sliderInfo = new SliderInfoItem(_slider);
|
||||||
_sliderInfo->setZValue(3.0);
|
_sliderInfo->setZValue(4.0);
|
||||||
_info = new InfoItem();
|
_info = new InfoItem();
|
||||||
_grid = new GridItem();
|
_grid = new GridItem();
|
||||||
_message = new QGraphicsSimpleTextItem(tr("Data not available"));
|
_message = new QGraphicsSimpleTextItem(tr("Data not available"));
|
||||||
|
@ -17,6 +17,7 @@ class GraphItem;
|
|||||||
class PathItem;
|
class PathItem;
|
||||||
class GridItem;
|
class GridItem;
|
||||||
class QGraphicsSimpleTextItem;
|
class QGraphicsSimpleTextItem;
|
||||||
|
class GraphicsScene;
|
||||||
|
|
||||||
class GraphView : public QGraphicsView
|
class GraphView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -93,7 +94,7 @@ private:
|
|||||||
void removeItem(QGraphicsItem *item);
|
void removeItem(QGraphicsItem *item);
|
||||||
void addItem(QGraphicsItem *item);
|
void addItem(QGraphicsItem *item);
|
||||||
|
|
||||||
QGraphicsScene *_scene;
|
GraphicsScene *_scene;
|
||||||
|
|
||||||
AxisItem *_xAxis, *_yAxis;
|
AxisItem *_xAxis, *_yAxis;
|
||||||
SliderItem *_slider;
|
SliderItem *_slider;
|
||||||
|
@ -9,9 +9,8 @@ HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HeartRateGraphItem::toolTip(Units units) const
|
QString HeartRateGraphItem::info() const
|
||||||
{
|
{
|
||||||
Q_UNUSED(units);
|
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public:
|
|||||||
HeartRateGraphItem(const Graph &graph, GraphType type, int width,
|
HeartRateGraphItem(const Graph &graph, GraphType type, int width,
|
||||||
const QColor &color, QGraphicsItem *parent = 0);
|
const QColor &color, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HEARTRATEGRAPHITEM_H
|
#endif // HEARTRATEGRAPHITEM_H
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "scaleitem.h"
|
#include "scaleitem.h"
|
||||||
#include "coordinatesitem.h"
|
#include "coordinatesitem.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
#include "mapview.h"
|
#include "mapview.h"
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
Q_ASSERT(map != 0);
|
Q_ASSERT(map != 0);
|
||||||
Q_ASSERT(poi != 0);
|
Q_ASSERT(poi != 0);
|
||||||
|
|
||||||
_scene = new QGraphicsScene(this);
|
_scene = new GraphicsScene(this);
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
|
@ -30,6 +30,7 @@ class PathItem;
|
|||||||
class GraphItem;
|
class GraphItem;
|
||||||
class AreaItem;
|
class AreaItem;
|
||||||
class Area;
|
class Area;
|
||||||
|
class GraphicsScene;
|
||||||
|
|
||||||
class MapView : public QGraphicsView
|
class MapView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -120,7 +121,7 @@ private:
|
|||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void leaveEvent(QEvent *event);
|
void leaveEvent(QEvent *event);
|
||||||
|
|
||||||
QGraphicsScene *_scene;
|
GraphicsScene *_scene;
|
||||||
ScaleItem *_mapScale;
|
ScaleItem *_mapScale;
|
||||||
CoordinatesItem *_coordinates;
|
CoordinatesItem *_coordinates;
|
||||||
QList<TrackItem*> _tracks;
|
QList<TrackItem*> _tracks;
|
||||||
|
@ -22,7 +22,7 @@ static inline unsigned segments(qreal distance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent), _path(path), _map(map)
|
: GraphicsItem(parent), _path(path), _map(map)
|
||||||
{
|
{
|
||||||
Q_ASSERT(_path.isValid());
|
Q_ASSERT(_path.isValid());
|
||||||
|
|
||||||
@ -385,6 +385,6 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
|
|
||||||
void PathItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void PathItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Popup::show(event->screenPos(), toolTip(_units), event->widget());
|
Popup::show(event->screenPos(), info(), event->widget());
|
||||||
QGraphicsObject::mousePressEvent(event);
|
GraphicsItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
#include "data/path.h"
|
#include "data/path.h"
|
||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
class PathTickItem;
|
class PathTickItem;
|
||||||
|
|
||||||
class PathItem : public QGraphicsObject
|
class PathItem : public QObject, public GraphicsItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -18,8 +19,6 @@ public:
|
|||||||
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
||||||
virtual ~PathItem() {}
|
virtual ~PathItem() {}
|
||||||
|
|
||||||
virtual QString toolTip(Units units) const = 0;
|
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
@ -38,8 +37,6 @@ public:
|
|||||||
void showMarker(bool show);
|
void showMarker(bool show);
|
||||||
void showTicks(bool show);
|
void showTicks(bool show);
|
||||||
|
|
||||||
Units units() const {return _units;}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void moveMarker(qreal distance);
|
void moveMarker(qreal distance);
|
||||||
void hover(bool hover);
|
void hover(bool hover);
|
||||||
@ -52,6 +49,8 @@ protected:
|
|||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
Units _units;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const PathSegment *segment(qreal x) const;
|
const PathSegment *segment(qreal x) const;
|
||||||
QPointF position(qreal distance) const;
|
QPointF position(qreal distance) const;
|
||||||
@ -68,7 +67,6 @@ private:
|
|||||||
qreal _markerDistance;
|
qreal _markerDistance;
|
||||||
int _digitalZoom;
|
int _digitalZoom;
|
||||||
|
|
||||||
Units _units;
|
|
||||||
qreal _width;
|
qreal _width;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
|
@ -20,7 +20,7 @@ static QFont defaultFont()
|
|||||||
QFont PathTickItem::_font = defaultFont();
|
QFont PathTickItem::_font = defaultFont();
|
||||||
|
|
||||||
PathTickItem::PathTickItem(const QRectF &tickRect, int value,
|
PathTickItem::PathTickItem(const QRectF &tickRect, int value,
|
||||||
QGraphicsItem *parent) : QGraphicsItem(parent), _tickRect(tickRect),
|
QGraphicsItem *parent) : GraphicsItem(parent), _tickRect(tickRect),
|
||||||
_text(QString::number(value))
|
_text(QString::number(value))
|
||||||
{
|
{
|
||||||
_tickRect.moveCenter(QPointF(0, -_tickRect.height()/2.0 - 3));
|
_tickRect.moveCenter(QPointF(0, -_tickRect.height()/2.0 - 3));
|
||||||
@ -76,6 +76,6 @@ QRect PathTickItem::tickRect(int value)
|
|||||||
void PathTickItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void PathTickItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
const PathItem *pi = static_cast<PathItem*>(parentItem());
|
const PathItem *pi = static_cast<PathItem*>(parentItem());
|
||||||
Popup::show(event->screenPos(), pi->toolTip(pi->units()), event->widget());
|
Popup::show(event->screenPos(), pi->info(), event->widget());
|
||||||
QGraphicsItem::mousePressEvent(event);
|
QGraphicsItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
class PathTickItem : public QGraphicsItem
|
class PathTickItem : public GraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PathTickItem(const QRectF &tickRect, int value, QGraphicsItem *parent = 0);
|
PathTickItem(const QRectF &tickRect, int value, QGraphicsItem *parent = 0);
|
||||||
@ -16,6 +17,9 @@ public:
|
|||||||
void setPos(const QPointF &pos);
|
void setPos(const QPointF &pos);
|
||||||
void setColor(const QColor &color) {_brush = QBrush(color);}
|
void setColor(const QColor &color) {_brush = QBrush(color);}
|
||||||
|
|
||||||
|
int type() const {return parentItem()->type();}
|
||||||
|
QString info() const {return static_cast<GraphicsItem*>(parentItem())->info();}
|
||||||
|
|
||||||
static QRect tickRect(int value);
|
static QRect tickRect(int value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -9,9 +9,8 @@ PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type, int width,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PowerGraphItem::toolTip(Units units) const
|
QString PowerGraphItem::info() const
|
||||||
{
|
{
|
||||||
Q_UNUSED(units);
|
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public:
|
|||||||
PowerGraphItem(const Graph &graph, GraphType type, int width,
|
PowerGraphItem(const Graph &graph, GraphType type, int width,
|
||||||
const QColor &color, QGraphicsItem *parent = 0);
|
const QColor &color, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // POWERGRAPHITEM_H
|
#endif // POWERGRAPHITEM_H
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
|
|
||||||
|
|
||||||
QString RouteItem::toolTip(Units units) const
|
QString RouteItem::info() const
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ QString RouteItem::toolTip(Units units) const
|
|||||||
if (!_desc.isEmpty())
|
if (!_desc.isEmpty())
|
||||||
tt.insert(tr("Description"), _desc);
|
tt.insert(tr("Description"), _desc);
|
||||||
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
||||||
units));
|
_units));
|
||||||
for (int i = 0; i < _links.size(); i++) {
|
for (int i = 0; i < _links.size(); i++) {
|
||||||
const Link &link = _links.at(i);
|
const Link &link = _links.at(i);
|
||||||
if (!link.URL().isEmpty()) {
|
if (!link.URL().isEmpty()) {
|
||||||
@ -53,7 +53,7 @@ void RouteItem::setMap(Map *map)
|
|||||||
|
|
||||||
void RouteItem::setUnits(Units u)
|
void RouteItem::setUnits(Units u)
|
||||||
{
|
{
|
||||||
if (units() == u)
|
if (_units == u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < _waypoints.count(); i++)
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
@ -70,7 +70,7 @@ void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
|||||||
_coordinatesFormat = format;
|
_coordinatesFormat = format;
|
||||||
|
|
||||||
for (int i = 0; i < _waypoints.count(); i++)
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
_waypoints[i]->setToolTipFormat(units(), _coordinatesFormat);
|
_waypoints[i]->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::showWaypoints(bool show)
|
void RouteItem::showWaypoints(bool show)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
class WaypointItem;
|
class WaypointItem;
|
||||||
@ -23,7 +24,7 @@ public:
|
|||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _name;
|
QString _name;
|
||||||
|
@ -15,16 +15,16 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type, int width,
|
|||||||
_mavg = graph.last().last().s() / movingTime;
|
_mavg = graph.last().last().s() / movingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SpeedGraphItem::toolTip(Units units) const
|
QString SpeedGraphItem::info() const
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
qreal scale = (units == Imperial) ? MS2MIH : (units == Nautical)
|
qreal scale = (_units == Imperial) ? MS2MIH : (_units == Nautical)
|
||||||
? MS2KN : MS2KMH;
|
? MS2KN : MS2KMH;
|
||||||
QString su = (units == Imperial) ? tr("mi/h") : (units == Nautical)
|
QString su = (_units == Imperial) ? tr("mi/h") : (_units == Nautical)
|
||||||
? tr("kn") : tr("km/h");
|
? tr("kn") : tr("km/h");
|
||||||
QString pace = Format::timeSpan((3600.0 / ((_timeType == Total)
|
QString pace = Format::timeSpan((3600.0 / ((_timeType == Total)
|
||||||
? avg() * scale : mavg() * scale)), false);
|
? avg() * scale : mavg() * scale)), false);
|
||||||
QString pu = (units == Metric) ? tr("min/km") : (units == Imperial) ?
|
QString pu = (_units == Metric) ? tr("min/km") : (_units == Imperial) ?
|
||||||
tr("min/mi") : tr("min/nmi");
|
tr("min/mi") : tr("min/nmi");
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
qreal mavg() const {return _mavg;}
|
qreal mavg() const {return _mavg;}
|
||||||
qreal max() const {return _max;}
|
qreal max() const {return _max;}
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
|
|
||||||
void setTimeType(TimeType type);
|
void setTimeType(TimeType type);
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
|
|||||||
_avg = GraphItem::avg();
|
_avg = GraphItem::avg();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TemperatureGraphItem::toolTip(Units units) const
|
QString TemperatureGraphItem::info() const
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
qreal scale = (units == Metric) ? 1.0 : C2FS;
|
qreal scale = (_units == Metric) ? 1.0 : C2FS;
|
||||||
qreal offset = (units == Metric) ? 0 : C2FO;
|
qreal offset = (_units == Metric) ? 0 : C2FO;
|
||||||
QString su = (units == Metric) ?
|
QString su = (_units == Metric) ?
|
||||||
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
|
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
qreal min() const {return _min;}
|
qreal min() const {return _min;}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal _min, _max, _avg;
|
qreal _min, _max, _avg;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
|
|
||||||
|
|
||||||
QString TrackItem::toolTip(Units units) const
|
QString TrackItem::info() const
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ QString TrackItem::toolTip(Units units) const
|
|||||||
if (!_desc.isEmpty())
|
if (!_desc.isEmpty())
|
||||||
tt.insert(tr("Description"), _desc);
|
tt.insert(tr("Description"), _desc);
|
||||||
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
||||||
units));
|
_units));
|
||||||
if (_time > 0)
|
if (_time > 0)
|
||||||
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
||||||
if (_movingTime > 0)
|
if (_movingTime > 0)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "data/track.h"
|
#include "data/track.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ class TrackItem : public PathItem
|
|||||||
public:
|
public:
|
||||||
TrackItem(const Track &track, Map *map, QGraphicsItem *parent = 0);
|
TrackItem(const Track &track, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QString toolTip(Units units) const;
|
QString info() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _name;
|
QString _name;
|
||||||
|
@ -13,17 +13,17 @@
|
|||||||
#define FS(size) \
|
#define FS(size) \
|
||||||
((int)((qreal)size * 1.41))
|
((int)((qreal)size * 1.41))
|
||||||
|
|
||||||
ToolTip WaypointItem::toolTip(Units units, CoordinatesFormat format)
|
QString WaypointItem::info() const
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
if (!_waypoint.name().isEmpty())
|
if (!_waypoint.name().isEmpty())
|
||||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||||
Format::coordinates(_waypoint.coordinates(), format));
|
Format::coordinates(_waypoint.coordinates(), _format));
|
||||||
if (_waypoint.hasElevation())
|
if (_waypoint.hasElevation())
|
||||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||||
Format::elevation(_waypoint.elevation(), units));
|
Format::elevation(_waypoint.elevation(), _units));
|
||||||
if (_waypoint.timestamp().isValid())
|
if (_waypoint.timestamp().isValid())
|
||||||
tt.insert(qApp->translate("WaypointItem", "Date"),
|
tt.insert(qApp->translate("WaypointItem", "Date"),
|
||||||
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
||||||
@ -40,11 +40,11 @@ ToolTip WaypointItem::toolTip(Units units, CoordinatesFormat format)
|
|||||||
}
|
}
|
||||||
tt.setImage(_waypoint.image());
|
tt.setImage(_waypoint.image());
|
||||||
|
|
||||||
return tt;
|
return tt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
||||||
QGraphicsItem *parent) : QGraphicsItem(parent)
|
QGraphicsItem *parent) : GraphicsItem(parent)
|
||||||
{
|
{
|
||||||
_waypoint = waypoint;
|
_waypoint = waypoint;
|
||||||
_showLabel = true;
|
_showLabel = true;
|
||||||
@ -165,8 +165,7 @@ void WaypointItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
|
|
||||||
void WaypointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void WaypointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
ToolTip tt(toolTip(_units, _format));
|
Popup::show(event->screenPos(), info(), event->widget());
|
||||||
Popup::show(event->screenPos(), tt.toString(), event->widget());
|
|
||||||
/* Do not propagate the event any further as lower stacked items (path
|
/* Do not propagate the event any further as lower stacked items (path
|
||||||
items) would replace the popup with their own popup */
|
items) would replace the popup with their own popup */
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,15 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include <QFont>
|
||||||
#include "data/waypoint.h"
|
#include "data/waypoint.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "graphicsscene.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "tooltip.h"
|
|
||||||
|
|
||||||
|
|
||||||
class WaypointItem : public QGraphicsItem
|
class WaypointItem : public GraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
|
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
|
||||||
@ -29,6 +30,8 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
|
QString info() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
@ -36,7 +39,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateCache();
|
void updateCache();
|
||||||
ToolTip toolTip(Units units, CoordinatesFormat format);
|
|
||||||
|
|
||||||
Waypoint _waypoint;
|
Waypoint _waypoint;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
|
Loading…
Reference in New Issue
Block a user