mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-12-01 07:01:16 +01:00
Added coordinates format settings
+ Fixed units settings issues
This commit is contained in:
parent
089d796194
commit
7e42b57d73
@ -2,6 +2,32 @@
|
|||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
|
||||||
|
|
||||||
|
static QString deg2DMS(double val)
|
||||||
|
{
|
||||||
|
int deg = val;
|
||||||
|
double r1 = val - deg;
|
||||||
|
|
||||||
|
int min = r1 * 60.0;
|
||||||
|
double r2 = r1 - (min / 60.0);
|
||||||
|
|
||||||
|
double sec = r2 * 3600.0;
|
||||||
|
|
||||||
|
return QString("%1°%2'%3\"").arg(deg).arg(min, 2, 10, QChar('0'))
|
||||||
|
.arg(sec, 4, 'f', 1, QChar('0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString deg2DM(double val)
|
||||||
|
{
|
||||||
|
int deg = val;
|
||||||
|
double r1 = val - deg;
|
||||||
|
|
||||||
|
double min = r1 * 60.0;
|
||||||
|
|
||||||
|
return QString("%1°%2'").arg(deg).arg(min, 6, 'f', 3, QChar('0'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Format::timeSpan(qreal time, bool full)
|
QString Format::timeSpan(qreal time, bool full)
|
||||||
{
|
{
|
||||||
unsigned h, m, s;
|
unsigned h, m, s;
|
||||||
@ -47,11 +73,22 @@ QString Format::elevation(qreal value, Units units)
|
|||||||
+ qApp->translate("Format", "ft");
|
+ qApp->translate("Format", "ft");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Format::coordinates(const Coordinates &value)
|
QString Format::coordinates(const Coordinates &value, CoordinatesFormat type)
|
||||||
{
|
{
|
||||||
QChar yH = (value.lat() < 0) ? 'S' : 'N';
|
QChar yH = (value.lat() < 0) ? 'S' : 'N';
|
||||||
QChar xH = (value.lon() < 0) ? 'W' : 'E';
|
QChar xH = (value.lon() < 0) ? 'W' : 'E';
|
||||||
|
|
||||||
return QString::number(qAbs(value.lat()), 'f', 5) + yH + "," + QChar(0x00A0)
|
switch (type) {
|
||||||
+ QString::number(qAbs(value.lon()), 'f', 5) + xH;
|
case DegreesMinutes:
|
||||||
|
return deg2DM(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
||||||
|
+ deg2DM(qAbs(value.lon())) + xH;
|
||||||
|
break;
|
||||||
|
case DMS:
|
||||||
|
return deg2DMS(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
||||||
|
+ deg2DMS(qAbs(value.lon())) + xH;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return QString::number(qAbs(value.lat()), 'f', 5) + yH + ","
|
||||||
|
+ QChar(0x00A0) + QString::number(qAbs(value.lon()), 'f', 5) + xH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,18 @@
|
|||||||
|
|
||||||
class Coordinates;
|
class Coordinates;
|
||||||
|
|
||||||
|
enum CoordinatesFormat {
|
||||||
|
DecimalDegrees,
|
||||||
|
DegreesMinutes,
|
||||||
|
DMS
|
||||||
|
};
|
||||||
|
|
||||||
namespace Format
|
namespace Format
|
||||||
{
|
{
|
||||||
QString timeSpan(qreal time, bool full = true);
|
QString timeSpan(qreal time, bool full = true);
|
||||||
QString distance(qreal value, Units units);
|
QString distance(qreal value, Units units);
|
||||||
QString elevation(qreal value, Units units);
|
QString elevation(qreal value, Units units);
|
||||||
QString coordinates(const Coordinates &value);
|
QString coordinates(const Coordinates &value, CoordinatesFormat type);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FORMAT_H
|
#endif // FORMAT_H
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "cpuarch.h"
|
#include "cpuarch.h"
|
||||||
#include "graphtab.h"
|
#include "graphtab.h"
|
||||||
#include "format.h"
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
|
|
||||||
@ -373,6 +372,23 @@ void GUI::createActions()
|
|||||||
_imperialUnitsAction->setActionGroup(ag);
|
_imperialUnitsAction->setActionGroup(ag);
|
||||||
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
||||||
SLOT(setImperialUnits()));
|
SLOT(setImperialUnits()));
|
||||||
|
ag = new QActionGroup(this);
|
||||||
|
ag->setExclusive(true);
|
||||||
|
_decimalDegreesAction = new QAction(tr("Decimal degrees (DD)"), this);
|
||||||
|
_decimalDegreesAction->setCheckable(true);
|
||||||
|
_decimalDegreesAction->setActionGroup(ag);
|
||||||
|
connect(_decimalDegreesAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setDecimalDegrees()));
|
||||||
|
_degreesMinutesAction = new QAction(tr("Degrees and decimal minutes (DMM)"),
|
||||||
|
this);
|
||||||
|
_degreesMinutesAction->setCheckable(true);
|
||||||
|
_degreesMinutesAction->setActionGroup(ag);
|
||||||
|
connect(_degreesMinutesAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setDegreesMinutes()));
|
||||||
|
_DMSAction = new QAction(tr("Degrees, minutes, seconds (DMS)"), this);
|
||||||
|
_DMSAction->setCheckable(true);
|
||||||
|
_DMSAction->setActionGroup(ag);
|
||||||
|
connect(_DMSAction, SIGNAL(triggered()), this, SLOT(setDMS()));
|
||||||
_fullscreenAction = new QAction(QIcon(QPixmap(FULLSCREEN_ICON)),
|
_fullscreenAction = new QAction(QIcon(QPixmap(FULLSCREEN_ICON)),
|
||||||
tr("Fullscreen mode"), this);
|
tr("Fullscreen mode"), this);
|
||||||
_fullscreenAction->setCheckable(true);
|
_fullscreenAction->setCheckable(true);
|
||||||
@ -463,6 +479,10 @@ void GUI::createMenus()
|
|||||||
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||||
unitsMenu->addAction(_metricUnitsAction);
|
unitsMenu->addAction(_metricUnitsAction);
|
||||||
unitsMenu->addAction(_imperialUnitsAction);
|
unitsMenu->addAction(_imperialUnitsAction);
|
||||||
|
QMenu *coordinatesMenu = settingsMenu->addMenu(tr("Coordinates format"));
|
||||||
|
coordinatesMenu->addAction(_decimalDegreesAction);
|
||||||
|
coordinatesMenu->addAction(_degreesMinutesAction);
|
||||||
|
coordinatesMenu->addAction(_DMSAction);
|
||||||
settingsMenu->addSeparator();
|
settingsMenu->addSeparator();
|
||||||
settingsMenu->addAction(_showToolbarsAction);
|
settingsMenu->addAction(_showToolbarsAction);
|
||||||
settingsMenu->addAction(_fullscreenAction);
|
settingsMenu->addAction(_fullscreenAction);
|
||||||
@ -1293,6 +1313,11 @@ void GUI::setUnits(Units units)
|
|||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::setCoordinatesFormat(CoordinatesFormat format)
|
||||||
|
{
|
||||||
|
_mapView->setCoordinatesFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::setGraphType(GraphType type)
|
void GUI::setGraphType(GraphType type)
|
||||||
{
|
{
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
@ -1442,6 +1467,10 @@ void GUI::writeSettings()
|
|||||||
UNITS_DEFAULT)
|
UNITS_DEFAULT)
|
||||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||||
? Imperial : Metric);
|
? Imperial : Metric);
|
||||||
|
CoordinatesFormat ct = _DMSAction->isChecked() ? DMS
|
||||||
|
: _degreesMinutesAction->isChecked() ? DegreesMinutes : DecimalDegrees;
|
||||||
|
if (ct != COORDINATES_DEFAULT)
|
||||||
|
settings.setValue(COORDINATES_SETTING, ct);
|
||||||
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
||||||
settings.setValue(SHOW_TOOLBARS_SETTING,
|
settings.setValue(SHOW_TOOLBARS_SETTING,
|
||||||
_showToolbarsAction->isChecked());
|
_showToolbarsAction->isChecked());
|
||||||
@ -1610,20 +1639,24 @@ void GUI::readSettings()
|
|||||||
|
|
||||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||||
if (settings.value(TIME_TYPE_SETTING, TIME_TYPE_DEFAULT).toInt()
|
if (settings.value(TIME_TYPE_SETTING, TIME_TYPE_DEFAULT).toInt()
|
||||||
== Moving) {
|
== Moving)
|
||||||
setTimeType(Moving);
|
_movingTimeAction->activate(QAction::Trigger);
|
||||||
_movingTimeAction->setChecked(true);
|
else
|
||||||
} else {
|
_totalTimeAction->activate(QAction::Trigger);
|
||||||
setTimeType(Total);
|
|
||||||
_totalTimeAction->setChecked(true);
|
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial)
|
||||||
}
|
_imperialUnitsAction->activate(QAction::Trigger);
|
||||||
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
|
else
|
||||||
setUnits(Imperial);
|
_metricUnitsAction->activate(QAction::Trigger);
|
||||||
_imperialUnitsAction->setChecked(true);
|
|
||||||
} else {
|
if (settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt() == DMS)
|
||||||
setUnits(Metric);
|
_DMSAction->activate(QAction::Trigger);
|
||||||
_metricUnitsAction->setChecked(true);
|
else if (settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt()
|
||||||
}
|
== DegreesMinutes)
|
||||||
|
_degreesMinutesAction->activate(QAction::Trigger);
|
||||||
|
else
|
||||||
|
_decimalDegreesAction->activate(QAction::Trigger);
|
||||||
|
|
||||||
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
|
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
|
||||||
showToolbars(false);
|
showToolbars(false);
|
||||||
else
|
else
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "data/poi.h"
|
#include "data/poi.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "timetype.h"
|
#include "timetype.h"
|
||||||
|
#include "format.h"
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
#include "optionsdialog.h"
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
@ -75,6 +76,9 @@ private slots:
|
|||||||
void setImperialUnits() {setUnits(Imperial);}
|
void setImperialUnits() {setUnits(Imperial);}
|
||||||
void setDistanceGraph() {setGraphType(Distance);}
|
void setDistanceGraph() {setGraphType(Distance);}
|
||||||
void setTimeGraph() {setGraphType(Time);}
|
void setTimeGraph() {setGraphType(Time);}
|
||||||
|
void setDecimalDegrees() {setCoordinatesFormat(DecimalDegrees);}
|
||||||
|
void setDegreesMinutes() {setCoordinatesFormat(DegreesMinutes);}
|
||||||
|
void setDMS() {setCoordinatesFormat(DMS);}
|
||||||
|
|
||||||
void sliderPositionChanged(qreal pos);
|
void sliderPositionChanged(qreal pos);
|
||||||
|
|
||||||
@ -111,6 +115,7 @@ private:
|
|||||||
Units units() const;
|
Units units() const;
|
||||||
void setTimeType(TimeType type);
|
void setTimeType(TimeType type);
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
@ -165,6 +170,9 @@ private:
|
|||||||
QAction *_firstAction;
|
QAction *_firstAction;
|
||||||
QAction *_metricUnitsAction;
|
QAction *_metricUnitsAction;
|
||||||
QAction *_imperialUnitsAction;
|
QAction *_imperialUnitsAction;
|
||||||
|
QAction *_decimalDegreesAction;
|
||||||
|
QAction *_degreesMinutesAction;
|
||||||
|
QAction *_DMSAction;
|
||||||
QAction *_totalTimeAction;
|
QAction *_totalTimeAction;
|
||||||
QAction *_movingTimeAction;
|
QAction *_movingTimeAction;
|
||||||
QAction *_nextMapAction;
|
QAction *_nextMapAction;
|
||||||
|
@ -49,6 +49,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
_coordinatesFormat = DecimalDegrees;
|
||||||
_opacity = 1.0;
|
_opacity = 1.0;
|
||||||
_backgroundColor = Qt::white;
|
_backgroundColor = Qt::white;
|
||||||
_markerColor = Qt::red;
|
_markerColor = Qt::red;
|
||||||
@ -137,6 +138,7 @@ PathItem *MapView::addRoute(const Route &route)
|
|||||||
ri->setWidth(_routeWidth);
|
ri->setWidth(_routeWidth);
|
||||||
ri->setStyle(_routeStyle);
|
ri->setStyle(_routeStyle);
|
||||||
ri->setUnits(_units);
|
ri->setUnits(_units);
|
||||||
|
ri->setCoordinatesFormat(_coordinatesFormat);
|
||||||
ri->setVisible(_showRoutes);
|
ri->setVisible(_showRoutes);
|
||||||
ri->showWaypoints(_showRouteWaypoints);
|
ri->showWaypoints(_showRouteWaypoints);
|
||||||
ri->showWaypointLabels(_showWaypointLabels);
|
ri->showWaypointLabels(_showWaypointLabels);
|
||||||
@ -162,7 +164,7 @@ void MapView::addWaypoints(const QList<Waypoint> &waypoints)
|
|||||||
wi->setSize(_waypointSize);
|
wi->setSize(_waypointSize);
|
||||||
wi->setColor(_waypointColor);
|
wi->setColor(_waypointColor);
|
||||||
wi->showLabel(_showWaypointLabels);
|
wi->showLabel(_showWaypointLabels);
|
||||||
wi->setUnits(_units);
|
wi->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
wi->setVisible(_showWaypoints);
|
wi->setVisible(_showWaypoints);
|
||||||
wi->setDigitalZoom(_digitalZoom);
|
wi->setDigitalZoom(_digitalZoom);
|
||||||
_scene->addItem(wi);
|
_scene->addItem(wi);
|
||||||
@ -348,28 +350,49 @@ void MapView::addPOI(const QList<Waypoint> &waypoints)
|
|||||||
pi->showLabel(_showPOILabels);
|
pi->showLabel(_showPOILabels);
|
||||||
pi->setVisible(_showPOI);
|
pi->setVisible(_showPOI);
|
||||||
pi->setDigitalZoom(_digitalZoom);
|
pi->setDigitalZoom(_digitalZoom);
|
||||||
|
pi->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
_scene->addItem(pi);
|
_scene->addItem(pi);
|
||||||
|
|
||||||
_pois.insert(SearchPointer<Waypoint>(&(pi->waypoint())), pi);
|
_pois.insert(SearchPointer<Waypoint>(&(pi->waypoint())), pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::setUnits(enum Units units)
|
void MapView::setUnits(Units units)
|
||||||
{
|
{
|
||||||
|
if (_units == units)
|
||||||
|
return;
|
||||||
|
|
||||||
_units = units;
|
_units = units;
|
||||||
|
|
||||||
_mapScale->setUnits(units);
|
_mapScale->setUnits(_units);
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.count(); i++)
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
_tracks[i]->setUnits(units);
|
_tracks[i]->setUnits(_units);
|
||||||
for (int i = 0; i < _routes.count(); i++)
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
_routes[i]->setUnits(units);
|
_routes[i]->setUnits(_units);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setUnits(units);
|
_waypoints.at(i)->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
|
|
||||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
it.value()->setUnits(units);
|
it.value()->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapView::setCoordinatesFormat(CoordinatesFormat format)
|
||||||
|
{
|
||||||
|
if (_coordinatesFormat == format)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_coordinatesFormat = format;
|
||||||
|
|
||||||
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
|
_waypoints.at(i)->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes[i]->setCoordinatesFormat(_coordinatesFormat);
|
||||||
|
|
||||||
|
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||||
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
|
it.value()->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::clearMapCache()
|
void MapView::clearMapCache()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "data/waypoint.h"
|
#include "data/waypoint.h"
|
||||||
#include "searchpointer.h"
|
#include "searchpointer.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "format.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
@ -34,12 +35,13 @@ public:
|
|||||||
void setPalette(const Palette &palette);
|
void setPalette(const Palette &palette);
|
||||||
void setPOI(POI *poi);
|
void setPOI(POI *poi);
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
void setUnits(enum Units units);
|
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
|
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void setUnits(Units units);
|
||||||
|
void setMarkerColor(const QColor &color);
|
||||||
void setTrackWidth(int width);
|
void setTrackWidth(int width);
|
||||||
void setRouteWidth(int width);
|
void setRouteWidth(int width);
|
||||||
void setTrackStyle(Qt::PenStyle style);
|
void setTrackStyle(Qt::PenStyle style);
|
||||||
@ -52,7 +54,6 @@ public:
|
|||||||
void setBackgroundColor(const QColor &color);
|
void setBackgroundColor(const QColor &color);
|
||||||
void useOpenGL(bool use);
|
void useOpenGL(bool use);
|
||||||
void useAntiAliasing(bool use);
|
void useAntiAliasing(bool use);
|
||||||
void setMarkerColor(const QColor &color);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showMap(bool show);
|
void showMap(bool show);
|
||||||
@ -65,6 +66,7 @@ public slots:
|
|||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePOI();
|
void updatePOI();
|
||||||
@ -108,6 +110,7 @@ private:
|
|||||||
POI *_poi;
|
POI *_poi;
|
||||||
Palette _palette;
|
Palette _palette;
|
||||||
Units _units;
|
Units _units;
|
||||||
|
CoordinatesFormat _coordinatesFormat;
|
||||||
|
|
||||||
qreal _opacity;
|
qreal _opacity;
|
||||||
QColor _backgroundColor;
|
QColor _backgroundColor;
|
||||||
|
@ -30,6 +30,8 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
|||||||
|
|
||||||
_name = route.name();
|
_name = route.name();
|
||||||
_desc = route.description();
|
_desc = route.description();
|
||||||
|
_units = Metric;
|
||||||
|
_coordinatesFormat = DecimalDegrees;
|
||||||
|
|
||||||
setToolTip(toolTip(Metric));
|
setToolTip(toolTip(Metric));
|
||||||
}
|
}
|
||||||
@ -47,9 +49,38 @@ void RouteItem::setMap(Map *map)
|
|||||||
PathItem::setMap(map);
|
PathItem::setMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setUnits(enum Units units)
|
void RouteItem::setUnits(Units units)
|
||||||
{
|
{
|
||||||
setToolTip(toolTip(units));
|
if (_units == units)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_units = units;
|
||||||
|
|
||||||
|
setToolTip(toolTip(_units));
|
||||||
|
|
||||||
|
QList<QGraphicsItem *> childs = childItems();
|
||||||
|
for (int i = 0; i < childs.count(); i++) {
|
||||||
|
if (childs.at(i) != _marker) {
|
||||||
|
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||||
|
wi->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
||||||
|
{
|
||||||
|
if (_coordinatesFormat == format)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_coordinatesFormat = format;
|
||||||
|
|
||||||
|
QList<QGraphicsItem *> childs = childItems();
|
||||||
|
for (int i = 0; i < childs.count(); i++) {
|
||||||
|
if (childs.at(i) != _marker) {
|
||||||
|
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||||
|
wi->setToolTipFormat(_units, _coordinatesFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::showWaypoints(bool show)
|
void RouteItem::showWaypoints(bool show)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "data/route.h"
|
#include "data/route.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "format.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ public:
|
|||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
|
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
|
|
||||||
@ -25,6 +27,8 @@ private:
|
|||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _desc;
|
QString _desc;
|
||||||
|
Units _units;
|
||||||
|
CoordinatesFormat _coordinatesFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROUTEITEM_H
|
#endif // ROUTEITEM_H
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#define TIME_TYPE_DEFAULT Total
|
#define TIME_TYPE_DEFAULT Total
|
||||||
#define UNITS_SETTING "units"
|
#define UNITS_SETTING "units"
|
||||||
#define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric)
|
#define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric)
|
||||||
|
#define COORDINATES_SETTING "coordinates"
|
||||||
|
#define COORDINATES_DEFAULT DecimalDegrees
|
||||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||||
#define SHOW_TOOLBARS_DEFAULT true
|
#define SHOW_TOOLBARS_DEFAULT true
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "format.h"
|
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
|
||||||
@ -11,14 +10,14 @@
|
|||||||
#define FS(size) \
|
#define FS(size) \
|
||||||
((int)((qreal)size * 1.41))
|
((int)((qreal)size * 1.41))
|
||||||
|
|
||||||
QString WaypointItem::toolTip(Units units)
|
QString WaypointItem::toolTip(Units units, CoordinatesFormat ct)
|
||||||
{
|
{
|
||||||
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::coordinates(_waypoint.coordinates(), ct));
|
||||||
if (!std::isnan(_waypoint.elevation()))
|
if (!std::isnan(_waypoint.elevation()))
|
||||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||||
Format::elevation(_waypoint.elevation(), units));
|
Format::elevation(_waypoint.elevation(), units));
|
||||||
@ -44,7 +43,7 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
|||||||
updateShape();
|
updateShape();
|
||||||
|
|
||||||
setPos(map->ll2xy(waypoint.coordinates()));
|
setPos(map->ll2xy(waypoint.coordinates()));
|
||||||
setToolTip(toolTip(Metric));
|
setToolTip(toolTip(Metric, DecimalDegrees));
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
@ -108,6 +107,9 @@ void WaypointItem::paint(QPainter *painter,
|
|||||||
|
|
||||||
void WaypointItem::setSize(int size)
|
void WaypointItem::setSize(int size)
|
||||||
{
|
{
|
||||||
|
if (_size == size)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_size = size;
|
_size = size;
|
||||||
updateShape();
|
updateShape();
|
||||||
@ -115,17 +117,23 @@ void WaypointItem::setSize(int size)
|
|||||||
|
|
||||||
void WaypointItem::setColor(const QColor &color)
|
void WaypointItem::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
|
if (_color == color)
|
||||||
|
return;
|
||||||
|
|
||||||
_color = color;
|
_color = color;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::setUnits(enum Units units)
|
void WaypointItem::setToolTipFormat(Units units, CoordinatesFormat ct)
|
||||||
{
|
{
|
||||||
setToolTip(toolTip(units));
|
setToolTip(toolTip(units, ct));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::showLabel(bool show)
|
void WaypointItem::showLabel(bool show)
|
||||||
{
|
{
|
||||||
|
if (_showLabel == show)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_showLabel = show;
|
_showLabel = show;
|
||||||
updateShape();
|
updateShape();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "data/waypoint.h"
|
#include "data/waypoint.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "format.h"
|
||||||
|
|
||||||
class WaypointItem : public QGraphicsItem
|
class WaypointItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
@ -15,7 +16,7 @@ public:
|
|||||||
const Waypoint &waypoint() const {return _waypoint;}
|
const Waypoint &waypoint() const {return _waypoint;}
|
||||||
|
|
||||||
void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
|
void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
|
||||||
void setUnits(Units units);
|
void setToolTipFormat(Units units, CoordinatesFormat ct);
|
||||||
void setSize(int size);
|
void setSize(int size);
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
void showLabel(bool show);
|
void showLabel(bool show);
|
||||||
@ -31,7 +32,7 @@ private:
|
|||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
void updateShape();
|
void updateShape();
|
||||||
QString toolTip(Units units);
|
QString toolTip(Units units, CoordinatesFormat ct);
|
||||||
|
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
Waypoint _waypoint;
|
Waypoint _waypoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user