1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2018-09-30 12:16:41 +02:00
parent 076a091a5b
commit 254deae04a
11 changed files with 26 additions and 28 deletions

View File

@ -21,6 +21,7 @@ HEADERS += src/config.h \
src/common/wgs84.h \ src/common/wgs84.h \
src/common/str2int.h \ src/common/str2int.h \
src/common/rtree.h \ src/common/rtree.h \
src/common/kv.h \
src/GUI/app.h \ src/GUI/app.h \
src/GUI/icons.h \ src/GUI/icons.h \
src/GUI/gui.h \ src/GUI/gui.h \
@ -138,7 +139,6 @@ HEADERS += src/config.h \
src/map/mercator.h \ src/map/mercator.h \
src/map/jnxmap.h \ src/map/jnxmap.h \
src/map/krovak.h \ src/map/krovak.h \
src/GUI/kv.h \
src/data/locparser.h \ src/data/locparser.h \
src/data/slfparser.h \ src/data/slfparser.h \
src/map/geotiffmap.h \ src/map/geotiffmap.h \

View File

@ -3,7 +3,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QList> #include <QList>
#include "kv.h" #include "common/kv.h"
class InfoItem : public QGraphicsItem class InfoItem : public QGraphicsItem
{ {

View File

@ -2,8 +2,7 @@
void ToolTip::insert(const QString &key, const QString &value) void ToolTip::insert(const QString &key, const QString &value)
{ {
QPair<QString, QString> entry(key, value); _list.append(KV(key, value));
_list.append(entry);
} }
QString ToolTip::toString() QString ToolTip::toString()
@ -11,8 +10,8 @@ QString ToolTip::toString()
QString ret = "<table>"; QString ret = "<table>";
for (int i = 0; i < _list.count(); i++) for (int i = 0; i < _list.count(); i++)
ret += "<tr><td align=\"right\"><b>" + _list.at(i).first ret += "<tr><td align=\"right\"><b>" + _list.at(i).key()
+ ":&nbsp;</b></td><td>" + _list.at(i).second + "</td></tr>"; + ":&nbsp;</b></td><td>" + _list.at(i).value() + "</td></tr>";
ret += "</table>"; ret += "</table>";

View File

@ -3,7 +3,7 @@
#include <QString> #include <QString>
#include <QList> #include <QList>
#include <QPair> #include "common/kv.h"
class ToolTip class ToolTip
{ {
@ -12,7 +12,7 @@ public:
QString toString(); QString toString();
private: private:
QList<QPair<QString, QString> > _list; QList<KV> _list;
}; };
#endif // TOOLTIP_H #endif // TOOLTIP_H

View File

@ -156,8 +156,8 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
if (!attr.hasAttribute("id")) if (!attr.hasAttribute("id"))
reader.raiseError("Missing dimension id"); reader.raiseError("Missing dimension id");
else else
config.dimensions.append(QPair<QString, QString>( config.dimensions.append(KV(attr.value("id").toString(),
attr.value("id").toString(), reader.readElementText())); reader.readElementText()));
} else if (reader.name() == "crs") { } else if (reader.name() == "crs") {
config.coordinateSystem = coordinateSystem(reader); config.coordinateSystem = coordinateSystem(reader);
config.crs = reader.readElementText(); config.crs = reader.readElementText();

View File

@ -4,6 +4,7 @@
#include <QList> #include <QList>
#include "common/range.h" #include "common/range.h"
#include "common/rectc.h" #include "common/rectc.h"
#include "common/kv.h"
#include "downloader.h" #include "downloader.h"
#include "coordinatesystem.h" #include "coordinatesystem.h"
@ -36,7 +37,7 @@ private:
QString crs; QString crs;
CoordinateSystem coordinateSystem; CoordinateSystem coordinateSystem;
bool rest; bool rest;
QList<QPair<QString, QString> > dimensions; QList<KV> dimensions;
Authorization authorization; Authorization authorization;
qreal tileRatio; qreal tileRatio;

View File

@ -5,6 +5,7 @@
#include <QRectF> #include <QRectF>
#include "common/range.h" #include "common/range.h"
#include "common/rectc.h" #include "common/rectc.h"
#include "common/kv.h"
#include "projection.h" #include "projection.h"
#include "downloader.h" #include "downloader.h"
#include "coordinatesystem.h" #include "coordinatesystem.h"
@ -18,9 +19,8 @@ public:
{ {
public: public:
Setup(const QString &url, const QString &layer, const QString &style, Setup(const QString &url, const QString &layer, const QString &style,
const QString &format, const QString &crs, const QString &format, const QString &crs, const CoordinateSystem &cs,
const CoordinateSystem &cs, const QList<KV> &dimensions,
const QList<QPair<QString, QString> > &dimensions,
const Authorization &authorization = Authorization()) const Authorization &authorization = Authorization())
: _url(url), _layer(layer), _style(style), _format(format), : _url(url), _layer(layer), _style(style), _format(format),
_crs(crs), _cs(cs), _dimensions(dimensions), _crs(crs), _cs(cs), _dimensions(dimensions),
@ -33,8 +33,7 @@ public:
const QString &format() const {return _format;} const QString &format() const {return _format;}
const QString &crs() const {return _crs;} const QString &crs() const {return _crs;}
const CoordinateSystem &coordinateSystem() const {return _cs;} const CoordinateSystem &coordinateSystem() const {return _cs;}
const QList<QPair<QString, QString> > &dimensions() const const QList<KV> &dimensions() const {return _dimensions;}
{return _dimensions;}
private: private:
QString _url; QString _url;
@ -43,7 +42,7 @@ public:
QString _format; QString _format;
QString _crs; QString _crs;
CoordinateSystem _cs; CoordinateSystem _cs;
QList<QPair<QString, QString> > _dimensions; QList<KV> _dimensions;
Authorization _authorization; Authorization _authorization;
}; };

View File

@ -32,8 +32,8 @@ QString WMSMap::tileUrl(const QString &version) const
url.append(QString("&SRS=%1").arg(_setup.crs())); url.append(QString("&SRS=%1").arg(_setup.crs()));
for (int i = 0; i < _setup.dimensions().size(); i++) { for (int i = 0; i < _setup.dimensions().size(); i++) {
const QPair<QString, QString> &dim = _setup.dimensions().at(i); const KV &dim = _setup.dimensions().at(i);
url.append(QString("&%1=%2").arg(dim.first, dim.second)); url.append(QString("&%1=%2").arg(dim.key(), dim.value()));
} }
return url; return url;

View File

@ -318,8 +318,8 @@ WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false)
setup.url().contains('?') ? "&" : "?" , setup.format(), setup.url().contains('?') ? "&" : "?" , setup.format(),
setup.layer(), style, setup.set()); setup.layer(), style, setup.set());
for (int i = 0; i < setup.dimensions().size(); i++) { for (int i = 0; i < setup.dimensions().size(); i++) {
const QPair<QString, QString> &dim = setup.dimensions().at(i); const KV &dim = setup.dimensions().at(i);
_tileUrl.append(QString("&%1=%2").arg(dim.first, dim.second)); _tileUrl.append(QString("&%1=%2").arg(dim.key(), dim.value()));
} }
} else { } else {
_tileUrl.replace("{Style}", style, Qt::CaseInsensitive); _tileUrl.replace("{Style}", style, Qt::CaseInsensitive);
@ -328,8 +328,8 @@ WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false)
_tileUrl.replace("{TileRow}", "$y", Qt::CaseInsensitive); _tileUrl.replace("{TileRow}", "$y", Qt::CaseInsensitive);
_tileUrl.replace("{TileCol}", "$x", Qt::CaseInsensitive); _tileUrl.replace("{TileCol}", "$x", Qt::CaseInsensitive);
for (int i = 0; i < setup.dimensions().size(); i++) { for (int i = 0; i < setup.dimensions().size(); i++) {
const QPair<QString, QString> &dim = setup.dimensions().at(i); const KV &dim = setup.dimensions().at(i);
_tileUrl.replace(QString("{%1}").arg(dim.first), dim.second, _tileUrl.replace(QString("{%1}").arg(dim.key()), dim.value(),
Qt::CaseInsensitive); Qt::CaseInsensitive);
} }
} }

View File

@ -7,6 +7,7 @@
#include <QList> #include <QList>
#include <QHash> #include <QHash>
#include "common/rectc.h" #include "common/rectc.h"
#include "common/kv.h"
#include "projection.h" #include "projection.h"
#include "downloader.h" #include "downloader.h"
#include "coordinatesystem.h" #include "coordinatesystem.h"
@ -21,8 +22,7 @@ public:
public: public:
Setup(const QString &url, const QString &layer, const QString &set, Setup(const QString &url, const QString &layer, const QString &set,
const QString &style, const QString &format, bool rest, const QString &style, const QString &format, bool rest,
const CoordinateSystem &cs, const CoordinateSystem &cs, const QList<KV> &dimensions,
const QList<QPair<QString, QString> > &dimensions,
const Authorization &authorization = Authorization()) const Authorization &authorization = Authorization())
: _url(url), _layer(layer), _set(set), _style(style), : _url(url), _layer(layer), _set(set), _style(style),
_format(format), _rest(rest), _cs(cs), _dimensions(dimensions), _format(format), _rest(rest), _cs(cs), _dimensions(dimensions),
@ -36,8 +36,7 @@ public:
const QString &format() const {return _format;} const QString &format() const {return _format;}
bool rest() const {return _rest;} bool rest() const {return _rest;}
const CoordinateSystem &coordinateSystem() const {return _cs;} const CoordinateSystem &coordinateSystem() const {return _cs;}
const QList<QPair<QString, QString> > &dimensions() const const QList<KV> &dimensions() const {return _dimensions;}
{return _dimensions;}
private: private:
QString _url; QString _url;
@ -47,7 +46,7 @@ public:
QString _format; QString _format;
bool _rest; bool _rest;
CoordinateSystem _cs; CoordinateSystem _cs;
QList<QPair<QString, QString> > _dimensions; QList<KV> _dimensions;
Authorization _authorization; Authorization _authorization;
}; };