mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-07 12:05:14 +01:00
Add Coordinates display option to position info
+ Data menu redesign Closes #343
This commit is contained in:
parent
60fb421f28
commit
e5de4dd5be
@ -84,23 +84,38 @@ QString Format::elevation(qreal value, Units units)
|
|||||||
+ qApp->translate("Format", "ft");
|
+ qApp->translate("Format", "ft");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Format::coordinates(const Coordinates &value, CoordinatesFormat type)
|
|
||||||
|
QString Format::lon(const Coordinates &c, CoordinatesFormat type)
|
||||||
{
|
{
|
||||||
QChar yH = (value.lat() < 0) ? 'S' : 'N';
|
QChar xH = (c.lon() < 0) ? 'W' : 'E';
|
||||||
QChar xH = (value.lon() < 0) ? 'W' : 'E';
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DegreesMinutes:
|
case DegreesMinutes:
|
||||||
return deg2DMM(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
return deg2DMM(qAbs(c.lon())) + xH;
|
||||||
+ deg2DMM(qAbs(value.lon())) + xH;
|
|
||||||
break;
|
|
||||||
case DMS:
|
case DMS:
|
||||||
return deg2DMS(qAbs(value.lat())) + yH + "," + QChar(0x00A0)
|
return deg2DMS(qAbs(c.lon())) + xH;
|
||||||
+ deg2DMS(qAbs(value.lon())) + xH;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
QLocale l(QLocale::system());
|
QLocale l(QLocale::system());
|
||||||
return l.toString(qAbs(value.lat()), 'f', 5) + yH + ","
|
return l.toString(qAbs(c.lon()), 'f', 5) + xH;
|
||||||
+ QChar(0x00A0) + l.toString(qAbs(value.lon()), 'f', 5) + xH;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Format::lat(const Coordinates &c, CoordinatesFormat type)
|
||||||
|
{
|
||||||
|
QChar yH = (c.lat() < 0) ? 'S' : 'N';
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case DegreesMinutes:
|
||||||
|
return deg2DMM(qAbs(c.lat())) + yH;
|
||||||
|
case DMS:
|
||||||
|
return deg2DMS(qAbs(c.lat())) + yH;
|
||||||
|
default:
|
||||||
|
QLocale l(QLocale::system());
|
||||||
|
return l.toString(qAbs(c.lat()), 'f', 5) + yH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Format::coordinates(const Coordinates &c, CoordinatesFormat type)
|
||||||
|
{
|
||||||
|
return lat(c, type) + "," + QChar(0x00A0) + lon(c, type);
|
||||||
|
}
|
||||||
|
@ -17,7 +17,9 @@ 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, CoordinatesFormat type);
|
QString coordinates(const Coordinates &c, CoordinatesFormat type);
|
||||||
|
QString lon(const Coordinates &c, CoordinatesFormat type);
|
||||||
|
QString lat(const Coordinates &c, CoordinatesFormat type);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FORMAT_H
|
#endif // FORMAT_H
|
||||||
|
105
src/GUI/gui.cpp
105
src/GUI/gui.cpp
@ -374,16 +374,25 @@ void GUI::createActions()
|
|||||||
_showTicksAction->setCheckable(true);
|
_showTicksAction->setCheckable(true);
|
||||||
connect(_showTicksAction, SIGNAL(triggered(bool)), _mapView,
|
connect(_showTicksAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
SLOT(showTicks(bool)));
|
SLOT(showTicks(bool)));
|
||||||
_showMarkersAction = new QAction(tr("Position markers"), this);
|
QActionGroup *markerInfoGroup = new QActionGroup(this);
|
||||||
|
connect(markerInfoGroup, SIGNAL(triggered(QAction*)), this,
|
||||||
|
SLOT(showPathMarkerInfo(QAction*)));
|
||||||
|
_hideMarkersAction = new QAction(tr("Do not show"), this);
|
||||||
|
_hideMarkersAction->setMenuRole(QAction::NoRole);
|
||||||
|
_hideMarkersAction->setCheckable(true);
|
||||||
|
_hideMarkersAction->setActionGroup(markerInfoGroup);
|
||||||
|
_showMarkersAction = new QAction(tr("Marker only"), this);
|
||||||
_showMarkersAction->setMenuRole(QAction::NoRole);
|
_showMarkersAction->setMenuRole(QAction::NoRole);
|
||||||
_showMarkersAction->setCheckable(true);
|
_showMarkersAction->setCheckable(true);
|
||||||
connect(_showMarkersAction, SIGNAL(triggered(bool)), _mapView,
|
_showMarkersAction->setActionGroup(markerInfoGroup);
|
||||||
SLOT(showMarkers(bool)));
|
_showMarkerDateAction = new QAction(tr("Date/time"), this);
|
||||||
_showMarkerInfoAction = new QAction(tr("Position date/time"), this);
|
_showMarkerDateAction->setMenuRole(QAction::NoRole);
|
||||||
_showMarkerInfoAction->setMenuRole(QAction::NoRole);
|
_showMarkerDateAction->setCheckable(true);
|
||||||
_showMarkerInfoAction->setCheckable(true);
|
_showMarkerDateAction->setActionGroup(markerInfoGroup);
|
||||||
connect(_showMarkerInfoAction, SIGNAL(triggered(bool)), _mapView,
|
_showMarkerCoordinatesAction = new QAction(tr("Coordinates"), this);
|
||||||
SLOT(showMarkerInfo(bool)));
|
_showMarkerCoordinatesAction->setMenuRole(QAction::NoRole);
|
||||||
|
_showMarkerCoordinatesAction->setCheckable(true);
|
||||||
|
_showMarkerCoordinatesAction->setActionGroup(markerInfoGroup);
|
||||||
|
|
||||||
// Graph actions
|
// Graph actions
|
||||||
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
||||||
@ -564,12 +573,14 @@ void GUI::createMenus()
|
|||||||
poiMenu->addAction(_showPOIAction);
|
poiMenu->addAction(_showPOIAction);
|
||||||
|
|
||||||
QMenu *dataMenu = menuBar()->addMenu(tr("&Data"));
|
QMenu *dataMenu = menuBar()->addMenu(tr("&Data"));
|
||||||
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
dataMenu->addAction(_showWaypointLabelsAction);
|
||||||
displayMenu->addAction(_showWaypointLabelsAction);
|
dataMenu->addAction(_showRouteWaypointsAction);
|
||||||
displayMenu->addAction(_showRouteWaypointsAction);
|
dataMenu->addAction(_showTicksAction);
|
||||||
displayMenu->addAction(_showTicksAction);
|
QMenu *markerMenu = dataMenu->addMenu(tr("Position info"));
|
||||||
displayMenu->addAction(_showMarkersAction);
|
markerMenu->addAction(_hideMarkersAction);
|
||||||
displayMenu->addAction(_showMarkerInfoAction);
|
markerMenu->addAction(_showMarkersAction);
|
||||||
|
markerMenu->addAction(_showMarkerDateAction);
|
||||||
|
markerMenu->addAction(_showMarkerCoordinatesAction);
|
||||||
dataMenu->addSeparator();
|
dataMenu->addSeparator();
|
||||||
dataMenu->addAction(_showTracksAction);
|
dataMenu->addAction(_showTracksAction);
|
||||||
dataMenu->addAction(_showRoutesAction);
|
dataMenu->addAction(_showRoutesAction);
|
||||||
@ -728,7 +739,9 @@ void GUI::keys()
|
|||||||
+ tr("Toggle graph type") + "</td><td><i>"
|
+ tr("Toggle graph type") + "</td><td><i>"
|
||||||
+ QKeySequence(TOGGLE_GRAPH_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
+ QKeySequence(TOGGLE_GRAPH_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
||||||
+ tr("Toggle time type") + "</td><td><i>"
|
+ tr("Toggle time type") + "</td><td><i>"
|
||||||
+ QKeySequence(TOGGLE_TIME_TYPE_KEY).toString()
|
+ QKeySequence(TOGGLE_TIME_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
||||||
|
+ tr("Toggle position info") + "</td><td><i>"
|
||||||
|
+ QKeySequence(TOGGLE_MARKER_INFO_KEY).toString() + "</i></td></tr>"
|
||||||
+ "<tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
+ "<tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
||||||
+ "</td><td><i>" + NEXT_MAP_SHORTCUT.toString() + "</i></td></tr><tr><td>"
|
+ "</td><td><i>" + NEXT_MAP_SHORTCUT.toString() + "</i></td></tr><tr><td>"
|
||||||
+ tr("Previous map") + "</td><td><i>" + PREV_MAP_SHORTCUT.toString()
|
+ tr("Previous map") + "</td><td><i>" + PREV_MAP_SHORTCUT.toString()
|
||||||
@ -1026,7 +1039,6 @@ void GUI::openOptions()
|
|||||||
_mapView->setTimeZone(options.timeZone.zone());
|
_mapView->setTimeZone(options.timeZone.zone());
|
||||||
_dateRange.first = _dateRange.first.toTimeZone(options.timeZone.zone());
|
_dateRange.first = _dateRange.first.toTimeZone(options.timeZone.zone());
|
||||||
_dateRange.second = _dateRange.second.toTimeZone(options.timeZone.zone());
|
_dateRange.second = _dateRange.second.toTimeZone(options.timeZone.zone());
|
||||||
reload = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reload)
|
if (reload)
|
||||||
@ -1429,6 +1441,23 @@ void GUI::showGraphSliderInfo(bool show)
|
|||||||
_tabs.at(i)->showSliderInfo(show);
|
_tabs.at(i)->showSliderInfo(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::showPathMarkerInfo(QAction *action)
|
||||||
|
{
|
||||||
|
if (action == _showMarkersAction) {
|
||||||
|
_mapView->showMarkers(true);
|
||||||
|
_mapView->showMarkerInfo(MarkerInfoItem::None);
|
||||||
|
} else if (action == _showMarkerDateAction) {
|
||||||
|
_mapView->showMarkers(true);
|
||||||
|
_mapView->showMarkerInfo(MarkerInfoItem::Date);
|
||||||
|
} else if (action == _showMarkerCoordinatesAction) {
|
||||||
|
_mapView->showMarkers(true);
|
||||||
|
_mapView->showMarkerInfo(MarkerInfoItem::Position);
|
||||||
|
} else {
|
||||||
|
_mapView->showMarkers(false);
|
||||||
|
_mapView->showMarkerInfo(MarkerInfoItem::None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::loadMap()
|
void GUI::loadMap()
|
||||||
{
|
{
|
||||||
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open map file"),
|
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open map file"),
|
||||||
@ -1851,6 +1880,12 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
|||||||
else
|
else
|
||||||
_movingTimeAction->trigger();
|
_movingTimeAction->trigger();
|
||||||
break;
|
break;
|
||||||
|
case TOGGLE_MARKER_INFO_KEY:
|
||||||
|
if (_showMarkerDateAction->isChecked())
|
||||||
|
_showMarkerCoordinatesAction->trigger();
|
||||||
|
else if (_showMarkerCoordinatesAction->isChecked())
|
||||||
|
_showMarkerDateAction->trigger();
|
||||||
|
break;
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
if (_fullscreenAction->isChecked()) {
|
if (_fullscreenAction->isChecked()) {
|
||||||
_fullscreenAction->setChecked(false);
|
_fullscreenAction->setChecked(false);
|
||||||
@ -2012,12 +2047,17 @@ void GUI::writeSettings()
|
|||||||
if (_showTicksAction->isChecked() != SHOW_TICKS_DEFAULT)
|
if (_showTicksAction->isChecked() != SHOW_TICKS_DEFAULT)
|
||||||
settings.setValue(SHOW_TICKS_SETTING,
|
settings.setValue(SHOW_TICKS_SETTING,
|
||||||
_showTicksAction->isChecked());
|
_showTicksAction->isChecked());
|
||||||
if (_showMarkersAction->isChecked() != SHOW_MARKERS_DEFAULT)
|
bool sm = _showMarkersAction->isChecked()
|
||||||
settings.setValue(SHOW_MARKERS_SETTING,
|
| _showMarkerDateAction->isChecked()
|
||||||
_showMarkersAction->isChecked());
|
| _showMarkerCoordinatesAction->isChecked();
|
||||||
if (_showMarkerInfoAction->isChecked() != SHOW_MARKER_INFO_DEFAULT)
|
if (sm != SHOW_MARKERS_DEFAULT)
|
||||||
settings.setValue(SHOW_MARKER_INFO_SETTING,
|
settings.setValue(SHOW_MARKERS_SETTING, sm);
|
||||||
_showMarkerInfoAction->isChecked());
|
if (_showMarkerDateAction->isChecked()
|
||||||
|
&& SHOW_MARKER_INFO_DEFAULT != MarkerInfoItem::Date)
|
||||||
|
settings.setValue(SHOW_MARKER_INFO_SETTING, MarkerInfoItem::Date);
|
||||||
|
else if (_showMarkerCoordinatesAction->isChecked()
|
||||||
|
&& SHOW_MARKER_INFO_DEFAULT != MarkerInfoItem::Position)
|
||||||
|
settings.setValue(SHOW_MARKER_INFO_SETTING, MarkerInfoItem::Position);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
||||||
@ -2311,15 +2351,18 @@ void GUI::readSettings()
|
|||||||
_mapView->showTicks(true);
|
_mapView->showTicks(true);
|
||||||
_showTicksAction->setChecked(true);
|
_showTicksAction->setChecked(true);
|
||||||
}
|
}
|
||||||
if (!settings.value(SHOW_MARKERS_SETTING, SHOW_MARKERS_DEFAULT).toBool())
|
if (settings.value(SHOW_MARKERS_SETTING, SHOW_MARKERS_DEFAULT).toBool()) {
|
||||||
_mapView->showMarkers(false);
|
MarkerInfoItem::Type mt = static_cast<MarkerInfoItem::Type>
|
||||||
else
|
(settings.value(SHOW_MARKER_INFO_SETTING,
|
||||||
_showMarkersAction->setChecked(true);
|
SHOW_MARKER_INFO_DEFAULT).toInt());
|
||||||
if (settings.value(SHOW_MARKER_INFO_SETTING,
|
if (mt == MarkerInfoItem::Position)
|
||||||
SHOW_MARKER_INFO_DEFAULT).toBool()) {
|
_showMarkerCoordinatesAction->trigger();
|
||||||
_mapView->showMarkerInfo(true);
|
else if (mt == MarkerInfoItem::Date)
|
||||||
_showMarkerInfoAction->setChecked(true);
|
_showMarkerDateAction->trigger();
|
||||||
}
|
else
|
||||||
|
_showMarkersAction->trigger();
|
||||||
|
} else
|
||||||
|
_hideMarkersAction->trigger();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
||||||
|
@ -60,6 +60,7 @@ private slots:
|
|||||||
void showGraphs(bool show);
|
void showGraphs(bool show);
|
||||||
void showGraphGrids(bool show);
|
void showGraphGrids(bool show);
|
||||||
void showGraphSliderInfo(bool show);
|
void showGraphSliderInfo(bool show);
|
||||||
|
void showPathMarkerInfo(QAction *action);
|
||||||
void showToolbars(bool show);
|
void showToolbars(bool show);
|
||||||
void showFullscreen(bool show);
|
void showFullscreen(bool show);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
@ -205,8 +206,10 @@ private:
|
|||||||
QAction *_showWaypointLabelsAction;
|
QAction *_showWaypointLabelsAction;
|
||||||
QAction *_showAreasAction;
|
QAction *_showAreasAction;
|
||||||
QAction *_showRouteWaypointsAction;
|
QAction *_showRouteWaypointsAction;
|
||||||
|
QAction *_hideMarkersAction;
|
||||||
QAction *_showMarkersAction;
|
QAction *_showMarkersAction;
|
||||||
QAction *_showMarkerInfoAction;
|
QAction *_showMarkerDateAction;
|
||||||
|
QAction *_showMarkerCoordinatesAction;
|
||||||
QAction *_showTicksAction;
|
QAction *_showTicksAction;
|
||||||
QAction *_showCoordinatesAction;
|
QAction *_showCoordinatesAction;
|
||||||
QAction *_openOptionsAction;
|
QAction *_openOptionsAction;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#define ZOOM_OUT Qt::Key_Minus
|
#define ZOOM_OUT Qt::Key_Minus
|
||||||
#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X
|
#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X
|
||||||
#define TOGGLE_TIME_TYPE_KEY Qt::Key_T
|
#define TOGGLE_TIME_TYPE_KEY Qt::Key_T
|
||||||
|
#define TOGGLE_MARKER_INFO_KEY Qt::Key_I
|
||||||
|
|
||||||
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
||||||
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "graphicsscene.h"
|
#include "graphicsscene.h"
|
||||||
#include "mapaction.h"
|
#include "mapaction.h"
|
||||||
|
#include "markerinfoitem.h"
|
||||||
#include "mapview.h"
|
#include "mapview.h"
|
||||||
|
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_overlapPOIs = true;
|
_overlapPOIs = true;
|
||||||
_showRouteWaypoints = true;
|
_showRouteWaypoints = true;
|
||||||
_showMarkers = true;
|
_showMarkers = true;
|
||||||
_showMarkerInfo = false;
|
_markerInfoType = MarkerInfoItem::None;
|
||||||
_showPathTicks = false;
|
_showPathTicks = false;
|
||||||
_trackWidth = 3;
|
_trackWidth = 3;
|
||||||
_routeWidth = 3;
|
_routeWidth = 3;
|
||||||
@ -142,7 +143,7 @@ PathItem *MapView::addTrack(const Track &track)
|
|||||||
ti->setDigitalZoom(_digitalZoom);
|
ti->setDigitalZoom(_digitalZoom);
|
||||||
ti->setMarkerColor(_markerColor);
|
ti->setMarkerColor(_markerColor);
|
||||||
ti->showMarker(_showMarkers);
|
ti->showMarker(_showMarkers);
|
||||||
ti->showMarkerInfo(_showMarkerInfo);
|
ti->showMarkerInfo(_markerInfoType);
|
||||||
ti->showTicks(_showPathTicks);
|
ti->showTicks(_showPathTicks);
|
||||||
_scene->addItem(ti);
|
_scene->addItem(ti);
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ PathItem *MapView::addRoute(const Route &route)
|
|||||||
ri->setDigitalZoom(_digitalZoom);
|
ri->setDigitalZoom(_digitalZoom);
|
||||||
ri->setMarkerColor(_markerColor);
|
ri->setMarkerColor(_markerColor);
|
||||||
ri->showMarker(_showMarkers);
|
ri->showMarker(_showMarkers);
|
||||||
ri->showMarkerInfo(_showMarkerInfo);
|
ri->showMarkerInfo(_markerInfoType);
|
||||||
ri->showTicks(_showPathTicks);
|
ri->showTicks(_showPathTicks);
|
||||||
_scene->addItem(ri);
|
_scene->addItem(ri);
|
||||||
|
|
||||||
@ -484,6 +485,12 @@ void MapView::setUnits(Units units)
|
|||||||
void MapView::setCoordinatesFormat(CoordinatesFormat format)
|
void MapView::setCoordinatesFormat(CoordinatesFormat format)
|
||||||
{
|
{
|
||||||
WaypointItem::setCoordinatesFormat(format);
|
WaypointItem::setCoordinatesFormat(format);
|
||||||
|
PathItem::setCoordinatesFormat(format);
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
|
_tracks[i]->updateMarkerInfo();
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes[i]->updateMarkerInfo();
|
||||||
|
|
||||||
_coordinates->setFormat(format);
|
_coordinates->setFormat(format);
|
||||||
}
|
}
|
||||||
@ -492,6 +499,11 @@ void MapView::setTimeZone(const QTimeZone &zone)
|
|||||||
{
|
{
|
||||||
WaypointItem::setTimeZone(zone);
|
WaypointItem::setTimeZone(zone);
|
||||||
PathItem::setTimeZone(zone);
|
PathItem::setTimeZone(zone);
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
|
_tracks[i]->updateMarkerInfo();
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes[i]->updateMarkerInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::clearMapCache()
|
void MapView::clearMapCache()
|
||||||
@ -808,14 +820,14 @@ void MapView::showMarkers(bool show)
|
|||||||
_routes.at(i)->showMarker(show);
|
_routes.at(i)->showMarker(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::showMarkerInfo(bool show)
|
void MapView::showMarkerInfo(MarkerInfoItem::Type type)
|
||||||
{
|
{
|
||||||
_showMarkerInfo = show;
|
_markerInfoType = type;
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++)
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
_tracks.at(i)->showMarkerInfo(show);
|
_tracks.at(i)->showMarkerInfo(type);
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
_routes.at(i)->showMarkerInfo(show);
|
_routes.at(i)->showMarkerInfo(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::showTicks(bool show)
|
void MapView::showTicks(bool show)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "searchpointer.h"
|
#include "searchpointer.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
#include "markerinfoitem.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ public slots:
|
|||||||
void showCoordinates(bool show);
|
void showCoordinates(bool show);
|
||||||
void showTicks(bool show);
|
void showTicks(bool show);
|
||||||
void showMarkers(bool show);
|
void showMarkers(bool show);
|
||||||
void showMarkerInfo(bool show);
|
void showMarkerInfo(MarkerInfoItem::Type type);
|
||||||
void showOverlappedPOIs(bool show);
|
void showOverlappedPOIs(bool show);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
@ -162,7 +163,8 @@ private:
|
|||||||
|
|
||||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||||
_showMarkers, _showMarkerInfo, _showPathTicks;
|
_showMarkers, _showPathTicks;
|
||||||
|
MarkerInfoItem::Type _markerInfoType;
|
||||||
bool _overlapPOIs;
|
bool _overlapPOIs;
|
||||||
int _trackWidth, _routeWidth, _areaWidth;
|
int _trackWidth, _routeWidth, _areaWidth;
|
||||||
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
#include "common/coordinates.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "markerinfoitem.h"
|
#include "markerinfoitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define OFFSET 7
|
#define OFFSET 7
|
||||||
|
|
||||||
|
CoordinatesFormat MarkerInfoItem::_format = DecimalDegrees;
|
||||||
|
|
||||||
MarkerInfoItem::MarkerInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
MarkerInfoItem::MarkerInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
_color = Qt::red;
|
_color = Qt::red;
|
||||||
@ -20,8 +23,18 @@ void MarkerInfoItem::setDate(const QDateTime &date)
|
|||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
QLocale l;
|
QLocale l;
|
||||||
_date = l.toString(date.date(), QLocale::ShortFormat);
|
_s1 = l.toString(date.date(), QLocale::ShortFormat);
|
||||||
_time = l.toString(date.time(), QLocale::ShortFormat);
|
_s2 = l.toString(date.time(), QLocale::ShortFormat);
|
||||||
|
|
||||||
|
updateBoundingRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MarkerInfoItem::setCoordinates(const Coordinates &c)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_s1 = Format::lat(c, _format);
|
||||||
|
_s2 = Format::lon(c, _format);
|
||||||
|
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
}
|
}
|
||||||
@ -30,8 +43,8 @@ void MarkerInfoItem::updateBoundingRect()
|
|||||||
{
|
{
|
||||||
QFontMetrics fm(_font);
|
QFontMetrics fm(_font);
|
||||||
|
|
||||||
qreal width = qMax(fm.boundingRect(_date).width(),
|
qreal width = qMax(fm.boundingRect(_s1).width(),
|
||||||
fm.boundingRect(_time).width());
|
fm.boundingRect(_s2).width());
|
||||||
qreal height = 2 * fm.height() - 2*fm.descent();
|
qreal height = 2 * fm.height() - 2*fm.descent();
|
||||||
|
|
||||||
_boundingRect = QRectF(-OFFSET/2, -height/2, width + 1.5*OFFSET, height);
|
_boundingRect = QRectF(-OFFSET/2, -height/2, width + 1.5*OFFSET, height);
|
||||||
@ -44,24 +57,24 @@ void MarkerInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
QFontMetrics fm(_font);
|
QFontMetrics fm(_font);
|
||||||
QRectF rd(OFFSET, -fm.height() + fm.descent(),
|
QRectF r1(OFFSET, -fm.height() + fm.descent(),
|
||||||
fm.boundingRect(_date).width(), fm.height() - fm.descent());
|
fm.boundingRect(_s1).width(), fm.height() - fm.descent());
|
||||||
QRectF rt(OFFSET, 0, fm.boundingRect(_time).width(), fm.height()
|
QRectF r2(OFFSET, 0, fm.boundingRect(_s2).width(), fm.height()
|
||||||
- fm.descent());
|
- fm.descent());
|
||||||
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
QColor bc(painter->background().color());
|
QColor bc(painter->background().color());
|
||||||
bc.setAlpha(196);
|
bc.setAlpha(196);
|
||||||
painter->setBrush(QBrush(bc));
|
painter->setBrush(QBrush(bc));
|
||||||
painter->drawRect(rt);
|
painter->drawRect(r2);
|
||||||
painter->drawRect(rd);
|
painter->drawRect(r1);
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
painter->setFont(_font);
|
painter->setFont(_font);
|
||||||
painter->setPen(_color);
|
painter->setPen(_color);
|
||||||
|
|
||||||
painter->drawText(OFFSET, -fm.descent()/2, _date);
|
painter->drawText(OFFSET, -fm.descent()/2, _s1);
|
||||||
painter->drawText(OFFSET, fm.height() - fm.descent()*1.5, _time);
|
painter->drawText(OFFSET, fm.height() - fm.descent()*1.5, _s2);
|
||||||
|
|
||||||
//painter->drawRect(boundingRect());
|
//painter->drawRect(boundingRect());
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,19 @@
|
|||||||
#define MARKERINFOITEM_H
|
#define MARKERINFOITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include "format.h"
|
||||||
|
|
||||||
|
class Coordinates;
|
||||||
|
|
||||||
class MarkerInfoItem : public QGraphicsItem
|
class MarkerInfoItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum Type {
|
||||||
|
None,
|
||||||
|
Date,
|
||||||
|
Position
|
||||||
|
};
|
||||||
|
|
||||||
MarkerInfoItem(QGraphicsItem *parent = 0);
|
MarkerInfoItem(QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const {return _boundingRect;}
|
QRectF boundingRect() const {return _boundingRect;}
|
||||||
@ -13,15 +22,22 @@ public:
|
|||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
void setDate(const QDateTime &date);
|
void setDate(const QDateTime &date);
|
||||||
|
void setCoordinates(const Coordinates &c);
|
||||||
|
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
|
static void setCoordinatesFormat(const CoordinatesFormat &format)
|
||||||
|
{_format = format;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
|
||||||
QString _date, _time;
|
QString _s1, _s2;
|
||||||
QRectF _boundingRect;
|
QRectF _boundingRect;
|
||||||
QColor _color;
|
QColor _color;
|
||||||
QFont _font;
|
QFont _font;
|
||||||
|
|
||||||
|
static CoordinatesFormat _format;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MARKERINFOITEM_H
|
#endif // MARKERINFOITEM_H
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "popup.h"
|
#include "popup.h"
|
||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
#include "markerinfoitem.h"
|
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +43,7 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
|||||||
_pen = QPen(brush, _width);
|
_pen = QPen(brush, _width);
|
||||||
_showMarker = true;
|
_showMarker = true;
|
||||||
_showTicks = false;
|
_showTicks = false;
|
||||||
|
_markerInfoType = MarkerInfoItem::None;
|
||||||
|
|
||||||
updatePainterPath();
|
updatePainterPath();
|
||||||
updateShape();
|
updateShape();
|
||||||
@ -288,13 +288,22 @@ void PathItem::setMarkerPosition(qreal pos)
|
|||||||
|
|
||||||
void PathItem::setMarkerInfo(qreal pos)
|
void PathItem::setMarkerInfo(qreal pos)
|
||||||
{
|
{
|
||||||
qreal time = _graph
|
if (_markerInfoType == MarkerInfoItem::Date) {
|
||||||
? (_graph->graphType() == Time) ? pos : _graph->timeAtDistance(pos)
|
qreal time = _graph
|
||||||
: NAN;
|
? (_graph->graphType() == Time) ? pos : _graph->timeAtDistance(pos)
|
||||||
QDateTime d(date());
|
: NAN;
|
||||||
|
QDateTime d(date());
|
||||||
|
if (!std::isnan(time) && d.isValid())
|
||||||
|
_markerInfo->setDate(d.addSecs(time).toTimeZone(_timeZone));
|
||||||
|
} else if (_markerInfoType == MarkerInfoItem::Position)
|
||||||
|
_markerInfo->setCoordinates(_map->xy2ll(_marker->pos()));
|
||||||
|
}
|
||||||
|
|
||||||
if (!std::isnan(time) && d.isValid())
|
void PathItem::updateMarkerInfo()
|
||||||
_markerInfo->setDate(d.addSecs(time).toTimeZone(_timeZone));
|
{
|
||||||
|
qreal pos = _graph ? (_graph->graphType() == Time)
|
||||||
|
? _graph->distanceAtTime(_markerDistance) : _markerDistance : NAN;
|
||||||
|
setMarkerInfo(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setMarkerColor(const QColor &color)
|
void PathItem::setMarkerColor(const QColor &color)
|
||||||
@ -322,12 +331,18 @@ void PathItem::showMarker(bool show)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_showMarker = show;
|
_showMarker = show;
|
||||||
|
updateMarkerInfo();
|
||||||
_marker->setVisible(show && isValid(position(_markerDistance)));
|
_marker->setVisible(show && isValid(position(_markerDistance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::showMarkerInfo(bool show)
|
void PathItem::showMarkerInfo(MarkerInfoItem::Type type)
|
||||||
{
|
{
|
||||||
_markerInfo->setVisible(show);
|
if (_markerInfoType == type)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_markerInfoType = type;
|
||||||
|
updateMarkerInfo();
|
||||||
|
_markerInfo->setVisible(type > MarkerInfoItem::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PathItem::xInM() const
|
qreal PathItem::xInM() const
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
#include "data/path.h"
|
#include "data/path.h"
|
||||||
#include "graphicsscene.h"
|
#include "graphicsscene.h"
|
||||||
|
#include "markerinfoitem.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
class PathTickItem;
|
class PathTickItem;
|
||||||
class GraphItem;
|
class GraphItem;
|
||||||
class MarkerItem;
|
class MarkerItem;
|
||||||
class MarkerInfoItem;
|
|
||||||
|
|
||||||
class PathItem : public QObject, public GraphicsItem
|
class PathItem : public QObject, public GraphicsItem
|
||||||
{
|
{
|
||||||
@ -42,15 +42,18 @@ public:
|
|||||||
void setDigitalZoom(int zoom);
|
void setDigitalZoom(int zoom);
|
||||||
void setMarkerColor(const QColor &color);
|
void setMarkerColor(const QColor &color);
|
||||||
void showMarker(bool show);
|
void showMarker(bool show);
|
||||||
void showMarkerInfo(bool show);
|
void showMarkerInfo(MarkerInfoItem::Type type);
|
||||||
void showTicks(bool show);
|
void showTicks(bool show);
|
||||||
|
|
||||||
void setMarkerPosition(qreal pos);
|
void setMarkerPosition(qreal pos);
|
||||||
|
|
||||||
void updateTicks();
|
void updateTicks();
|
||||||
|
void updateMarkerInfo();
|
||||||
|
|
||||||
static void setUnits(Units units) {_units = units;}
|
static void setUnits(Units units) {_units = units;}
|
||||||
static void setTimeZone(const QTimeZone &zone) {_timeZone = zone;}
|
static void setTimeZone(const QTimeZone &zone) {_timeZone = zone;}
|
||||||
|
static void setCoordinatesFormat(const CoordinatesFormat &format)
|
||||||
|
{MarkerInfoItem::setCoordinatesFormat(format);}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void hover(bool hover);
|
void hover(bool hover);
|
||||||
@ -90,6 +93,7 @@ private:
|
|||||||
QPainterPath _painterPath;
|
QPainterPath _painterPath;
|
||||||
bool _showMarker;
|
bool _showMarker;
|
||||||
bool _showTicks;
|
bool _showTicks;
|
||||||
|
MarkerInfoItem::Type _markerInfoType;
|
||||||
|
|
||||||
MarkerItem *_marker;
|
MarkerItem *_marker;
|
||||||
MarkerInfoItem *_markerInfo;
|
MarkerInfoItem *_markerInfo;
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
#define SHOW_MARKERS_SETTING "positionMarkers"
|
#define SHOW_MARKERS_SETTING "positionMarkers"
|
||||||
#define SHOW_MARKERS_DEFAULT true
|
#define SHOW_MARKERS_DEFAULT true
|
||||||
#define SHOW_MARKER_INFO_SETTING "markerInfo"
|
#define SHOW_MARKER_INFO_SETTING "markerInfo"
|
||||||
#define SHOW_MARKER_INFO_DEFAULT false
|
#define SHOW_MARKER_INFO_DEFAULT MarkerInfoItem::None
|
||||||
|
|
||||||
#define PDF_EXPORT_SETTINGS_GROUP "Export"
|
#define PDF_EXPORT_SETTINGS_GROUP "Export"
|
||||||
#define PAPER_ORIENTATION_SETTING "orientation"
|
#define PAPER_ORIENTATION_SETTING "orientation"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user