1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 13:41:16 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2019-06-28 07:43:16 +02:00
parent 255f4ca63c
commit ebb690673c
2 changed files with 23 additions and 16 deletions

View File

@ -73,7 +73,6 @@ private:
QList<IMG::Point> _points; QList<IMG::Point> _points;
}; };
static void convertUnits(QString &str) static void convertUnits(QString &str)
{ {
bool ok; bool ok;
@ -103,6 +102,22 @@ static int minPOIZoom(Style::POIClass cl)
} }
} }
/* The fonts must be initialized on first usage (after the QGuiApplication
instance is created) */
#define FONT(name, size) \
static const QFont *name() \
{ \
static QFont f; \
f.setPixelSize(size); \
return &f; \
}
FONT(largeFont, LARGE_FONT_SIZE)
FONT(normalFont, NORMAL_FONT_SIZE)
FONT(smallFont, SMALL_FONT_SIZE)
FONT(poiFont, POI_FONT_SIZE)
IMGMap::IMGMap(const QString &fileName, QObject *parent) IMGMap::IMGMap(const QString &fileName, QObject *parent)
: Map(parent), _fileName(fileName), _img(fileName), : Map(parent), _fileName(fileName), _img(fileName),
_projection(PCS::pcs(3857)), _valid(false) _projection(PCS::pcs(3857)), _valid(false)
@ -117,11 +132,6 @@ IMGMap::IMGMap(const QString &fileName, QObject *parent)
updateTransform(); updateTransform();
_largeFont.setPixelSize(LARGE_FONT_SIZE);
_normalFont.setPixelSize(NORMAL_FONT_SIZE);
_smallFont.setPixelSize(SMALL_FONT_SIZE);
_poiFont.setPixelSize(POI_FONT_SIZE);
_valid = true; _valid = true;
} }
@ -290,13 +300,13 @@ void IMGMap::processLines(QList<IMG::Poly> &lines, const QPoint &tile,
const QFont *font; const QFont *font;
switch (style.textFontSize()) { switch (style.textFontSize()) {
case Style::Large: case Style::Large:
font = &_largeFont; font = largeFont();
break; break;
case Style::Small: case Style::Small:
font = &_smallFont; font = smallFont();
break; break;
default: default:
font = &_normalFont; font = normalFont();
} }
const QColor *color = style.textColor().isValid() const QColor *color = style.textColor().isValid()
? &style.textColor() : 0; ? &style.textColor() : 0;
@ -330,20 +340,20 @@ void IMGMap::processPoints(QList<IMG::Point> &points,
if (style.textFontSize() == Style::None) if (style.textFontSize() == Style::None)
label = 0; label = 0;
else else
font = &_poiFont; font = poiFont();
} else { } else {
switch (style.textFontSize()) { switch (style.textFontSize()) {
case Style::None: case Style::None:
label = 0; label = 0;
break; break;
case Style::Normal: case Style::Normal:
font = &_normalFont; font = normalFont();
break; break;
case Style::Small: case Style::Small:
font = &_smallFont; font = smallFont();
break; break;
default: default:
font = &_largeFont; font = largeFont();
} }
} }
const QColor *color = style.textColor().isValid() const QColor *color = style.textColor().isValid()

View File

@ -57,9 +57,6 @@ private:
Range _zooms; Range _zooms;
Projection _projection; Projection _projection;
Transform _transform; Transform _transform;
QFont _largeFont, _normalFont, _smallFont, _poiFont;
bool _valid; bool _valid;
QString _errorString; QString _errorString;
}; };