1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Remaining tool-tip related changes

Improved/fixed POI handling
This commit is contained in:
Martin Tůma 2016-08-02 20:46:22 +02:00
parent dafadbab60
commit ee2f471ca0
15 changed files with 263 additions and 164 deletions

View File

@ -163,17 +163,17 @@
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="440"/>
<location filename="../src/gui.cpp" line="446"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="504"/>
<location filename="../src/gui.cpp" line="510"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="580"/>
<location filename="../src/gui.cpp" line="586"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
@ -189,8 +189,8 @@
</message>
<message>
<location filename="../src/gui.cpp" line="186"/>
<location filename="../src/gui.cpp" line="456"/>
<location filename="../src/gui.cpp" line="457"/>
<location filename="../src/gui.cpp" line="462"/>
<location filename="../src/gui.cpp" line="463"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
</message>
@ -205,20 +205,20 @@
<translation>Znovu načíst</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="372"/>
<location filename="../src/gui.cpp" line="378"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="313"/>
<location filename="../src/gui.cpp" line="366"/>
<location filename="../src/gui.cpp" line="317"/>
<location filename="../src/gui.cpp" line="372"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="184"/>
<location filename="../src/gui.cpp" line="479"/>
<location filename="../src/gui.cpp" line="480"/>
<location filename="../src/gui.cpp" line="485"/>
<location filename="../src/gui.cpp" line="486"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
@ -233,125 +233,130 @@
<translation>Zavřit POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="230"/>
<location filename="../src/gui.cpp" line="229"/>
<source>Overlap POIs</source>
<translation>Překrývat POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="234"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="238"/>
<location filename="../src/gui.cpp" line="242"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="244"/>
<location filename="../src/gui.cpp" line="248"/>
<source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="253"/>
<location filename="../src/gui.cpp" line="257"/>
<location filename="../src/gui.cpp" line="466"/>
<location filename="../src/gui.cpp" line="261"/>
<location filename="../src/gui.cpp" line="472"/>
<source>Next map</source>
<translation>Následující mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="264"/>
<location filename="../src/gui.cpp" line="268"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="270"/>
<location filename="../src/gui.cpp" line="274"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="276"/>
<location filename="../src/gui.cpp" line="280"/>
<source>Metric</source>
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="281"/>
<location filename="../src/gui.cpp" line="285"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="287"/>
<location filename="../src/gui.cpp" line="291"/>
<source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="295"/>
<location filename="../src/gui.cpp" line="299"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="298"/>
<location filename="../src/gui.cpp" line="302"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="302"/>
<location filename="../src/gui.cpp" line="306"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="305"/>
<location filename="../src/gui.cpp" line="309"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="327"/>
<location filename="../src/gui.cpp" line="331"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="334"/>
<location filename="../src/gui.cpp" line="338"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="335"/>
<location filename="../src/gui.cpp" line="339"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="343"/>
<location filename="../src/gui.cpp" line="349"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="344"/>
<location filename="../src/gui.cpp" line="350"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="353"/>
<location filename="../src/gui.cpp" line="359"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="468"/>
<location filename="../src/gui.cpp" line="474"/>
<source>Previous map</source>
<translation>Předchozí mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="665"/>
<location filename="../src/gui.cpp" line="668"/>
<location filename="../src/gui.cpp" line="672"/>
<location filename="../src/gui.cpp" line="675"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="841"/>
<location filename="../src/gui.cpp" line="853"/>
<source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="459"/>
<location filename="../src/gui.cpp" line="465"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="436"/>
<location filename="../src/gui.cpp" line="442"/>
<source>Version </source>
<translation>Verze </translation>
</message>
@ -366,123 +371,123 @@
<translation>Exportovat do PDF...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="460"/>
<location filename="../src/gui.cpp" line="466"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="462"/>
<location filename="../src/gui.cpp" line="468"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="463"/>
<location filename="../src/gui.cpp" line="469"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="464"/>
<location filename="../src/gui.cpp" line="470"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="483"/>
<location filename="../src/gui.cpp" line="489"/>
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="486"/>
<location filename="../src/gui.cpp" line="492"/>
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="494"/>
<location filename="../src/gui.cpp" line="500"/>
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="505"/>
<location filename="../src/gui.cpp" line="511"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="571"/>
<location filename="../src/gui.cpp" line="597"/>
<location filename="../src/gui.cpp" line="577"/>
<location filename="../src/gui.cpp" line="603"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="581"/>
<location filename="../src/gui.cpp" line="587"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="671"/>
<location filename="../src/gui.cpp" line="678"/>
<source>Tracks</source>
<translation>Počet tras</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="677"/>
<location filename="../src/gui.cpp" line="684"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="434"/>
<location filename="../src/gui.cpp" line="440"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="376"/>
<location filename="../src/gui.cpp" line="382"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="482"/>
<location filename="../src/gui.cpp" line="488"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="493"/>
<location filename="../src/gui.cpp" line="499"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="676"/>
<location filename="../src/gui.cpp" line="679"/>
<location filename="../src/gui.cpp" line="683"/>
<location filename="../src/gui.cpp" line="686"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="691"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="848"/>
<location filename="../src/gui.cpp" line="860"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="680"/>
<location filename="../src/gui.cpp" line="687"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="573"/>
<location filename="../src/gui.cpp" line="598"/>
<location filename="../src/gui.cpp" line="579"/>
<location filename="../src/gui.cpp" line="604"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="568"/>
<location filename="../src/gui.cpp" line="574"/>
<source>Error loading GPX file:
%1</source>
<translation>Soubor GPX nelze otevřít:
%1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="594"/>
<location filename="../src/gui.cpp" line="600"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:
@ -538,30 +543,49 @@
<translation>mi</translation>
</message>
</context>
<context>
<name>Misc</name>
<message>
<location filename="../src/misc.cpp" line="55"/>
<location filename="../src/misc.cpp" line="76"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/misc.cpp" line="58"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/misc.cpp" line="62"/>
<location filename="../src/misc.cpp" line="73"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/misc.cpp" line="65"/>
<source>km</source>
<translation>km</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../src/misc.cpp" line="57"/>
<location filename="../src/scaleitem.cpp" line="81"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/misc.cpp" line="54"/>
<location filename="../src/misc.cpp" line="74"/>
<location filename="../src/scaleitem.cpp" line="81"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/misc.cpp" line="64"/>
<location filename="../src/scaleitem.cpp" line="83"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/misc.cpp" line="61"/>
<location filename="../src/misc.cpp" line="71"/>
<location filename="../src/scaleitem.cpp" line="83"/>
<source>m</source>
<translation>m</translation>
@ -680,4 +704,45 @@
<translation>F</translation>
</message>
</context>
<context>
<name>TrackItem</name>
<message>
<location filename="../src/trackitem.cpp" line="16"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/trackitem.cpp" line="19"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/trackitem.cpp" line="21"/>
<source>Date</source>
<translation>Datum</translation>
</message>
</context>
<context>
<name>WaypointItem</name>
<message>
<location filename="../src/waypointitem.cpp" line="16"/>
<source>Coordinates</source>
<translation>Souřadnice</translation>
</message>
<message>
<location filename="../src/waypointitem.cpp" line="19"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/waypointitem.cpp" line="22"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/waypointitem.cpp" line="25"/>
<source>Description</source>
<translation>Popis</translation>
</message>
</context>
</TS>

View File

@ -226,6 +226,10 @@ void GUI::createActions()
_closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
tr("Close POI files"), this);
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
_overlapPOIAction->setCheckable(true);
connect(_overlapPOIAction, SIGNAL(triggered(bool)), this,
SLOT(overlapPOIs(bool)));
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
tr("Show POIs"), this);
_showPOIAction->setCheckable(true);
@ -338,6 +342,8 @@ void GUI::createMenus()
_poiMenu->addAction(_openPOIAction);
_poiMenu->addAction(_closePOIAction);
_poiMenu->addSeparator();
_poiMenu->addAction(_overlapPOIAction);
_poiMenu->addSeparator();
_poiMenu->addAction(_showPOIAction);
_settingsMenu = menuBar()->addMenu(tr("Settings"));
@ -601,8 +607,9 @@ bool GUI::openPOIFile(const QString &fileName)
} else {
_showPOIAction->setChecked(true);
_track->loadPOI(_poi);
_poiFilesMenu->addAction(createPOIFileAction(
_poi.files().indexOf(fileName)));
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
action->setChecked(true);
_poiFilesMenu->addAction(action);
return true;
}
@ -764,6 +771,11 @@ void GUI::closeAll()
updateTrackView();
}
void GUI::overlapPOIs(bool checked)
{
_track->setPOIOverlap(checked);
}
void GUI::showPOI(bool checked)
{
if (checked)
@ -1082,6 +1094,7 @@ void GUI::writeSettings()
settings.beginGroup(POI_SETTINGS_GROUP);
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
@ -1138,6 +1151,11 @@ void GUI::readSettings()
settings.endGroup();
settings.beginGroup(POI_SETTINGS_GROUP);
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false) {
_track->setPOIOverlap(false);
_overlapPOIAction->setChecked(false);
} else
_overlapPOIAction->setChecked(true);
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
_showPOIAction->setChecked(true);
for (int i = 0; i < _poiFilesActions.count(); i++)

View File

@ -43,6 +43,7 @@ private slots:
void reloadFile();
void openPOIFile();
void closePOIFiles();
void overlapPOIs(bool checked);
void showPOI(bool checked);
void showMap(bool checked);
void showGraphs(bool checked);
@ -128,6 +129,7 @@ private:
QAction *_openPOIAction;
QAction *_closePOIAction;
QAction *_showPOIAction;
QAction *_overlapPOIAction;
QAction *_showMapAction;
QAction *_fullscreenAction;
QAction *_clearMapCacheAction;

View File

@ -35,6 +35,16 @@ QPointF ll2mercator(const QPointF &ll)
return m;
}
QPointF mercator2ll(const QPointF &m)
{
QPointF ll;
ll.setX(m.x());
ll.setY(rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2));
return ll;
}
QPoint mercator2tile(const QPointF &m, int z)
{
QPoint tile;

View File

@ -8,6 +8,7 @@
#define ZOOM_MIN 3
QPointF ll2mercator(const QPointF &ll);
QPointF mercator2ll(const QPointF &m);
qreal llDistance(const QPointF &p1, const QPointF &p2);
QPoint mercator2tile(const QPointF &m, int zoom);
QPointF tile2mercator(const QPoint &tile, int zoom);

View File

@ -1,7 +1,8 @@
#include <cmath>
#include <QObject>
#include <QApplication>
#include "misc.h"
double niceNum(double x, int round)
{
int expv;
@ -50,28 +51,29 @@ QString distance(qreal value, Units units)
{
if (units == Imperial) {
if (value < MIINM)
return QString::number(value * M2FT, 'f', 0)
+ UNIT_SPACE + QObject::tr("ft");
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
+ qApp->translate("Misc", "ft");
else
return QString::number(value * M2MI, 'f', 1)
+ UNIT_SPACE + QObject::tr("mi");
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
+ qApp->translate("Misc", "mi");
} else {
if (value < KMINM)
return QString::number(value, 'f', 0) + UNIT_SPACE
+ QObject::tr("m");
+ qApp->translate("Misc", "m");
else
return QString::number(value * M2KM, 'f', 1)
+ UNIT_SPACE + QObject::tr("km");
return QString::number(value * M2KM, 'f', 1) + UNIT_SPACE
+ qApp->translate("Misc", "km");
}
}
QString elevation(qreal value, Units units)
{
if (units == Metric)
return QString::number(value, 'f', 0) + UNIT_SPACE + QObject::tr("m");
return QString::number(value, 'f', 0) + UNIT_SPACE
+ qApp->translate("Misc", "m");
else
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
+ QObject::tr("ft");
+ qApp->translate("Misc", "ft");
}
QString coordinates(const QPointF &value)
@ -79,7 +81,6 @@ QString coordinates(const QPointF &value)
QChar yH = (value.y() < 0) ? 'S' : 'N';
QChar xH = (value.x() < 0) ? 'W' : 'E';
return QString::number(qAbs(value.y()), 'f', 5) + QChar(0x00B0) + " " + yH
+ ", " + QString::number(qAbs(value.x()), 'f', 5) + QChar(0x00B0) + " "
+ xH ;
return QString::number(qAbs(value.y()), 'f', 5) + yH + "," + QChar(0x00A0)
+ QString::number(qAbs(value.x()), 'f', 5) + xH;
}

View File

@ -52,10 +52,10 @@ bool POI::loadGPXFile(const QString &fileName)
index.end = _data.size() - 1;
for (int i = index.start; i <= index.end; i++) {
QPointF p = ll2mercator(_data.at(i).coordinates());
const QPointF &p = _data.at(i).coordinates();
qreal c[2];
c[0] = p.x();
c[1] = -p.y();
c[1] = p.y();
_tree.Insert(c, c, i);
}
@ -124,10 +124,10 @@ bool POI::loadCSVFile(const QString &fileName)
index.end = _data.size() - 1;
for (int i = index.start; i <= index.end; i++) {
QPointF p = ll2mercator(_data.at(i).coordinates());
const QPointF &p = _data.at(i).coordinates();
qreal c[2];
c[0] = p.x();
c[1] = -p.y();
c[1] = p.y();
_tree.Insert(c, c, i);
}
@ -152,11 +152,11 @@ QVector<Waypoint> POI::points(const QPainterPath &path, qreal radius) const
qreal min[2], max[2];
for (int i = 0; i < path.elementCount(); i++) {
const QPointF &p = path.elementAt(i);
QPointF p = mercator2ll(path.elementAt(i));
min[0] = p.x() - radius;
min[1] = p.y() - radius;
min[1] = -p.y() - radius;
max[0] = p.x() + radius;
max[1] = p.y() + radius;
max[1] = -p.y() + radius;
_tree.Search(min, max, cb, &set);
}
@ -177,7 +177,7 @@ QVector<Waypoint> POI::points(const QList<WaypointItem*> &list, qreal radius)
qreal min[2], max[2];
for (int i = 0; i < list.count(); i++) {
const QPointF &p = list.at(i)->coordinates();
const QPointF &p = list.at(i)->waypoint().coordinates();
min[0] = p.x() - radius;
min[1] = p.y() - radius;
max[0] = p.x() + radius;

View File

@ -15,6 +15,7 @@
#define SHOW_MAP_SETTING "show"
#define POI_SETTINGS_GROUP "POI"
#define OVERLAP_POI_SETTING "overlap"
#define SHOW_POI_SETTING "show"
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
#define DISABLED_POI_FILE_SETTING "file"

View File

@ -1,26 +1,20 @@
#include "tooltip.h"
ToolTip::ToolTip()
{
}
void ToolTip::insert(const QString &key, const QString &value)
{
KV kv(key, value);
int i;
if ((i = _list.indexOf(kv)) < 0)
_list.append(kv);
else
_list[i] = kv;
QPair<QString, QString> entry(key, value);
_list.append(entry);
}
QString ToolTip::toString()
{
QString ret;
QString ret = "<table>";
for (int i = 0; i < _list.count(); i++)
ret += "<b>" + _list.at(i).key + ":</b> " + _list.at(i).value + "<br/>";
ret += "<tr><td align=\"right\"><b>" + _list.at(i).first
+ ":&nbsp;</b></td><td>" + _list.at(i).second + "</td></tr>";
ret += "</table>";
return ret;
}

View File

@ -3,28 +3,16 @@
#include <QString>
#include <QList>
#include <QPair>
class ToolTip
{
public:
ToolTip();
void insert(const QString &key, const QString &value);
QString toString();
private:
class KV {
public:
QString key;
QString value;
KV(const QString &k, const QString &v)
{key = k; value = v;}
bool operator==(const KV &other) const
{return this->key == other.key;}
};
QList<KV> _list;
QList<QPair<QString, QString> > _list;
};
#endif // TOOLTIP_H

View File

@ -1,3 +1,4 @@
#include <QApplication>
#include <QCursor>
#include <QPen>
#include "ll.h"
@ -12,11 +13,13 @@ QString TrackItem::toolTip()
{
ToolTip tt;
tt.insert("Distance", ::distance(_distance, _units));
tt.insert(qApp->translate("TrackItem", "Distance"),
::distance(_distance, _units));
if (_time > 0)
tt.insert("Time", ::timeSpan(_time));
tt.insert(qApp->translate("TrackItem", "Time"), ::timeSpan(_time));
if (!_date.isNull())
tt.insert("Date", _date.toString(Qt::SystemLocaleShortDate));
tt.insert(qApp->translate("TrackItem", "Date"),
_date.toString(Qt::SystemLocaleShortDate));
return tt.toString();
}

View File

@ -39,6 +39,7 @@ TrackView::TrackView(QWidget *parent)
_plot = false;
_units = Metric;
_overlap = true;
}
TrackView::~TrackView()
@ -199,6 +200,19 @@ qreal TrackView::mapScale(int zoom) const
return ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
}
void TrackView::checkPOIOverlap()
{
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
&& it.value()->collidesWithItem(jt.value()))
jt.value()->hide();
}
}
}
void TrackView::rescale(qreal scale)
{
for (int i = 0; i < _paths.size(); i++) {
@ -209,19 +223,14 @@ void TrackView::rescale(qreal scale)
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setScale(1.0/scale);
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
QHash<Waypoint, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
it.value()->setScale(1.0/scale);
it.value()->show();
}
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
&& it.value()->collidesWithItem(jt.value()))
jt.value()->hide();
}
}
if (!_overlap)
checkPOIOverlap();
_scale = scale;
}
@ -245,8 +254,6 @@ void TrackView::addPOI(const QVector<Waypoint> &waypoints)
void TrackView::loadPOI(const POI &poi)
{
QHash<Waypoint, WaypointItem*>::const_iterator it,jt;
if (!_paths.size() && !_waypoints.size())
return;
@ -254,13 +261,8 @@ void TrackView::loadPOI(const POI &poi)
addPOI(poi.points(_paths.at(i)->path()));
addPOI(poi.points(_waypoints));
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
if (it != jt && it.value()->isVisible() && jt.value()->isVisible()
&& it.value()->collidesWithItem(jt.value()))
jt.value()->hide();
}
}
if (!_overlap)
checkPOIOverlap();
}
void TrackView::setMap(Map *map)
@ -434,6 +436,18 @@ void TrackView::movePositionMarker(qreal val)
}
}
void TrackView::setPOIOverlap(bool overlap)
{
_overlap = overlap;
if (_overlap) {
QHash<Waypoint, WaypointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->show();
} else
checkPOIOverlap();
}
void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
{
if ((_paths.isEmpty() && _waypoints.isEmpty()) || !_map) {

View File

@ -34,6 +34,7 @@ public:
void setMap(Map *map);
void setUnits(enum Units units);
void setPOIOverlap(bool overlap);
void plot(QPainter *painter, const QRectF &target);
@ -57,6 +58,7 @@ private:
void rescale(qreal scale);
void rescale();
void zoom(int z, const QPointF &pos);
void checkPOIOverlap();
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
@ -80,6 +82,7 @@ private:
int _zoom;
Units _units;
bool _overlap;
bool _plot;
};

View File

@ -1,3 +1,4 @@
#include <QApplication>
#include <QPainter>
#include "config.h"
#include "ll.h"
@ -12,13 +13,17 @@ QString WaypointItem::toolTip()
{
ToolTip tt;
tt.insert("Coordinates", ::coordinates(_coordinates));
if (!std::isnan(_elevation))
tt.insert("Elevation", ::elevation(_elevation, _units));
if (!_date.isNull())
tt.insert("Date", _date.toString(Qt::SystemLocaleShortDate));
if (!_description.isNull())
tt.insert("Description", _description);
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
::coordinates(_waypoint.coordinates()));
if (!std::isnan(_waypoint.elevation()))
tt.insert(qApp->translate("WaypointItem", "Elevation"),
::elevation(_waypoint.elevation() - _waypoint.geoidHeight(), _units));
if (!_waypoint.timestamp().isNull())
tt.insert(qApp->translate("WaypointItem", "Date"),
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
if (!_waypoint.description().isNull())
tt.insert(qApp->translate("WaypointItem", "Description"),
_waypoint.description());
return tt.toString();
}
@ -28,19 +33,15 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
{
_units = Metric;
_label = waypoint.name();
_waypoint = waypoint;
_coordinates = ll2mercator(QPointF(waypoint.coordinates().x(),
-waypoint.coordinates().y()));
_elevation = waypoint.elevation() - waypoint.geoidHeight();
_description = waypoint.description();
_date = waypoint.timestamp();
updateBoundingRect();
setPos(_coordinates);
setToolTip(toolTip());
setCursor(Qt::ArrowCursor);
setPos(_coordinates);
}
void WaypointItem::updateBoundingRect()
@ -49,7 +50,7 @@ void WaypointItem::updateBoundingRect()
font.setPixelSize(FONT_SIZE);
font.setFamily(FONT_FAMILY);
QFontMetrics fm(font);
QRect ts = fm.tightBoundingRect(_label);
QRect ts = fm.tightBoundingRect(_waypoint.name());
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
@ -64,11 +65,11 @@ void WaypointItem::paint(QPainter *painter,
font.setPixelSize(FONT_SIZE);
font.setFamily(FONT_FAMILY);
QFontMetrics fm(font);
QRect ts = fm.tightBoundingRect(_label);
QRect ts = fm.tightBoundingRect(_waypoint.name());
painter->setFont(font);
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
_label);
_waypoint.name());
painter->setBrush(Qt::SolidPattern);
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);

View File

@ -9,27 +9,25 @@ class WaypointItem : public QGraphicsItem
{
public:
WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent = 0);
const QPointF &coordinates() {return _coordinates;}
const Waypoint &waypoint() const {return _waypoint;}
const QPointF &coordinates() const {return _coordinates;}
void setUnits(enum Units units);
void setScale(qreal scale);
QRectF boundingRect() const {return _boundingRect;}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setUnits(enum Units units);
void setScale(qreal scale);
private:
void updateBoundingRect();
QString toolTip();
QString _label;
QPointF _coordinates;
QRectF _boundingRect;
QPointF _coordinates;
Waypoint _waypoint;
Units _units;
QDateTime _date;
QString _description;
qreal _elevation;
};
#endif // WAYPOINTITEM_H