1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2016-05-12 09:03:05 +02:00
parent dcdd250858
commit ee9a8df51f
7 changed files with 142 additions and 103 deletions

View File

@ -39,7 +39,8 @@ HEADERS += src/config.h \
src/range.h \
src/cpuarch.h \
src/settings.h \
src/app.h
src/app.h \
src/trackinfo.h
SOURCES += src/main.cpp \
src/gui.cpp \
src/gpx.cpp \
@ -66,7 +67,8 @@ SOURCES += src/main.cpp \
src/palette.cpp \
src/heartrategraph.cpp \
src/range.cpp \
src/app.cpp
src/app.cpp \
src/trackinfo.cpp
RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts
macx {

View File

@ -59,114 +59,114 @@
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="448"/>
<location filename="../src/gui.cpp" line="450"/>
<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="512"/>
<location filename="../src/gui.cpp" line="514"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="208"/>
<location filename="../src/gui.cpp" line="211"/>
<source>Save as</source>
<translation>Uložit jako</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="583"/>
<location filename="../src/gui.cpp" line="586"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="197"/>
<location filename="../src/gui.cpp" line="200"/>
<source>Open</source>
<translation>Otevřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="181"/>
<location filename="../src/gui.cpp" line="184"/>
<source>Quit</source>
<translation>Ukončit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="464"/>
<location filename="../src/gui.cpp" line="465"/>
<location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="466"/>
<location filename="../src/gui.cpp" line="467"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="202"/>
<location filename="../src/gui.cpp" line="205"/>
<source>Save</source>
<translation>Uložit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="214"/>
<location filename="../src/gui.cpp" line="217"/>
<source>Close</source>
<translation>Zavřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="220"/>
<location filename="../src/gui.cpp" line="223"/>
<source>Reload</source>
<translation>Znovu načíst</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="379"/>
<location filename="../src/gui.cpp" line="378"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="321"/>
<location filename="../src/gui.cpp" line="370"/>
<location filename="../src/gui.cpp" line="320"/>
<location filename="../src/gui.cpp" line="369"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="187"/>
<location filename="../src/gui.cpp" line="487"/>
<location filename="../src/gui.cpp" line="488"/>
<location filename="../src/gui.cpp" line="190"/>
<location filename="../src/gui.cpp" line="489"/>
<location filename="../src/gui.cpp" line="490"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="228"/>
<location filename="../src/gui.cpp" line="231"/>
<source>Load POI file</source>
<translation>Nahrát POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="231"/>
<location filename="../src/gui.cpp" line="234"/>
<source>Close POI files</source>
<translation>Zavřit POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="234"/>
<location filename="../src/gui.cpp" line="237"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="242"/>
<location filename="../src/gui.cpp" line="245"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="248"/>
<location filename="../src/gui.cpp" line="251"/>
<source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="258"/>
<location filename="../src/gui.cpp" line="262"/>
<location filename="../src/gui.cpp" line="474"/>
<location filename="../src/gui.cpp" line="260"/>
<location filename="../src/gui.cpp" line="264"/>
<location filename="../src/gui.cpp" line="476"/>
<source>Next map</source>
<translation>Následující mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="269"/>
<location filename="../src/gui.cpp" line="271"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="276"/>
<location filename="../src/gui.cpp" line="277"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
@ -176,67 +176,67 @@
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="289"/>
<location filename="../src/gui.cpp" line="288"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="295"/>
<location filename="../src/gui.cpp" line="294"/>
<source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="303"/>
<location filename="../src/gui.cpp" line="302"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="306"/>
<location filename="../src/gui.cpp" line="305"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="310"/>
<location filename="../src/gui.cpp" line="309"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="313"/>
<location filename="../src/gui.cpp" line="312"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="335"/>
<location filename="../src/gui.cpp" line="334"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="342"/>
<location filename="../src/gui.cpp" line="341"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="343"/>
<location filename="../src/gui.cpp" line="342"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="351"/>
<location filename="../src/gui.cpp" line="350"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="352"/>
<location filename="../src/gui.cpp" line="351"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="361"/>
<location filename="../src/gui.cpp" line="360"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="476"/>
<location filename="../src/gui.cpp" line="478"/>
<source>Previous map</source>
<translation>Předchozí mapa</translation>
</message>
@ -246,159 +246,159 @@
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="922"/>
<location filename="../src/gui.cpp" line="931"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="923"/>
<location filename="../src/gui.cpp" line="932"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="924"/>
<location filename="../src/gui.cpp" line="933"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="467"/>
<location filename="../src/gui.cpp" line="469"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="444"/>
<location filename="../src/gui.cpp" line="446"/>
<source>Version </source>
<translation>Verze </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="468"/>
<location filename="../src/gui.cpp" line="470"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="470"/>
<location filename="../src/gui.cpp" line="472"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="471"/>
<location filename="../src/gui.cpp" line="473"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="472"/>
<location filename="../src/gui.cpp" line="474"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="491"/>
<location filename="../src/gui.cpp" line="493"/>
<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="494"/>
<location filename="../src/gui.cpp" line="496"/>
<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="502"/>
<location filename="../src/gui.cpp" line="504"/>
<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="513"/>
<location filename="../src/gui.cpp" line="515"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>soubory GPX (*.gpx);;všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="574"/>
<location filename="../src/gui.cpp" line="600"/>
<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="584"/>
<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="665"/>
<location filename="../src/gui.cpp" line="662"/>
<location filename="../src/gui.cpp" line="837"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="668"/>
<location filename="../src/gui.cpp" line="670"/>
<location filename="../src/gui.cpp" line="672"/>
<location filename="../src/gui.cpp" line="674"/>
<location filename="../src/gui.cpp" line="665"/>
<location filename="../src/gui.cpp" line="667"/>
<location filename="../src/gui.cpp" line="669"/>
<location filename="../src/gui.cpp" line="671"/>
<location filename="../src/gui.cpp" line="834"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="671"/>
<location filename="../src/gui.cpp" line="683"/>
<location filename="../src/gui.cpp" line="668"/>
<location filename="../src/gui.cpp" line="680"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="673"/>
<location filename="../src/gui.cpp" line="685"/>
<location filename="../src/gui.cpp" line="670"/>
<location filename="../src/gui.cpp" line="682"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="442"/>
<location filename="../src/gui.cpp" line="195"/>
<location filename="../src/gui.cpp" line="444"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="386"/>
<location filename="../src/gui.cpp" line="385"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="490"/>
<location filename="../src/gui.cpp" line="492"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="501"/>
<location filename="../src/gui.cpp" line="503"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="664"/>
<location filename="../src/gui.cpp" line="676"/>
<location filename="../src/gui.cpp" line="661"/>
<location filename="../src/gui.cpp" line="673"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="666"/>
<location filename="../src/gui.cpp" line="678"/>
<location filename="../src/gui.cpp" line="663"/>
<location filename="../src/gui.cpp" line="675"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="667"/>
<location filename="../src/gui.cpp" line="679"/>
<location filename="../src/gui.cpp" line="664"/>
<location filename="../src/gui.cpp" line="676"/>
<source>Ascent</source>
<translation>Stoupání</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="680"/>
<location filename="../src/gui.cpp" line="682"/>
<location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="686"/>
<location filename="../src/gui.cpp" line="677"/>
<location filename="../src/gui.cpp" line="679"/>
<location filename="../src/gui.cpp" line="681"/>
<location filename="../src/gui.cpp" line="683"/>
<location filename="../src/gui.cpp" line="841"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="669"/>
<location filename="../src/gui.cpp" line="681"/>
<location filename="../src/gui.cpp" line="666"/>
<location filename="../src/gui.cpp" line="678"/>
<source>Descent</source>
<translation>Klesání</translation>
</message>
@ -408,26 +408,26 @@
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="677"/>
<location filename="../src/gui.cpp" line="674"/>
<location filename="../src/gui.cpp" line="844"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="576"/>
<location filename="../src/gui.cpp" line="601"/>
<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="571"/>
<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="597"/>
<location filename="../src/gui.cpp" line="600"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:

View File

@ -67,8 +67,6 @@ GraphView::~GraphView()
if (_info->scene() != _scene)
delete _info;
delete _scene;
}
void GraphView::updateBounds(const QPointF &point)

View File

@ -26,7 +26,7 @@
#include "speedgraph.h"
#include "heartrategraph.h"
#include "trackview.h"
#include "infoitem.h"
#include "trackinfo.h"
#include "filebrowser.h"
#include "cpuarch.h"
#include "gui.h"
@ -656,13 +656,7 @@ void GUI::saveFile(const QString &fileName)
QPainter p(&printer);
_track->plot(&p, QRectF(0, 300, printer.width(), (0.80 * printer.height())
- 400));
_elevationGraph->plot(&p, QRectF(0, 0.80 * printer.height(),
printer.width(), printer.height() * 0.20));
QGraphicsScene scene;
InfoItem info;
TrackInfo info;
if (_imperialUnitsAction->isChecked()) {
info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f', 1)
+ UNIT_SPACE + tr("mi"));
@ -688,8 +682,12 @@ void GUI::saveFile(const QString &fileName)
info.insert(tr("Minimum"), QString::number(_elevationGraph->min(), 'f',
0) + UNIT_SPACE + tr("m"));
}
scene.addItem(&info);
scene.render(&p, QRectF(0, 0, printer.width(), 200));
_track->plot(&p, QRectF(0, 300, printer.width(), (0.80 * printer.height())
- 400));
_elevationGraph->plot(&p, QRectF(0, 0.80 * printer.height(),
printer.width(), printer.height() * 0.20));
info.plot(&p, QRectF(0, 0, printer.width(), 200));
}
void GUI::reloadFile()

18
src/trackinfo.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "infoitem.h"
#include "trackinfo.h"
TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent)
{
_info = new InfoItem();
addItem(_info);
}
void TrackInfo::insert(const QString &key, const QString &value)
{
_info->insert(key, value);
}
void TrackInfo::plot(QPainter *painter, const QRectF &target)
{
render(painter, QRectF(0, 0, target.width(), target.height()));
}

22
src/trackinfo.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef TRACKINFO_H
#define TRACKINFO_H
#include <QGraphicsScene>
class InfoItem;
class TrackInfo : public QGraphicsScene
{
Q_OBJECT
public:
TrackInfo(QObject *parent = 0);
void insert(const QString &key, const QString &value);
void plot(QPainter *painter, const QRectF &target);
private:
InfoItem *_info;
};
#endif // TRACKINFO_H

View File

@ -40,7 +40,8 @@ TrackView::TrackView(QWidget *parent)
TrackView::~TrackView()
{
delete _scene;
if (_mapScale->scene() != _scene)
delete _mapScale;
}
void TrackView::addTrack(const QVector<QPointF> &track)