Code cleanup

This commit is contained in:
Martin Tůma 2018-12-07 00:50:11 +01:00
parent a83d4909ed
commit a3d555bb6a
8 changed files with 27 additions and 19 deletions

View File

@ -1,4 +1,5 @@
#include <QByteArray> #include <QByteArray>
#include <QImage>
#include <QPainter> #include <QPainter>
#include <QDebug> #include <QDebug>
#include <QVariantHash> #include <QVariantHash>
@ -70,7 +71,7 @@ private:
const vector_tile::Tile_Feature *_data; const vector_tile::Tile_Feature *_data;
}; };
bool cmp(const Feature &f1, const Feature &f2) static bool cmp(const Feature &f1, const Feature &f2)
{ {
return f1.data()->id() < f2.data()->id(); return f1.data()->id() < f2.data()->id();
} }
@ -113,8 +114,8 @@ static inline QPoint parameters(quint32 v1, quint32 v2)
return QPoint(zigzag32decode(v1), zigzag32decode(v2)); return QPoint(zigzag32decode(v1), zigzag32decode(v2));
} }
static void drawFeature(const Feature &feature, Style *style, int styleLayer, static void drawFeature(const Feature &feature, const Style *style,
const QSizeF &factor, Tile &tile) int styleLayer, const QSizeF &factor, Tile &tile)
{ {
if (!style->match(tile.zoom(), styleLayer, feature.tags())) if (!style->match(tile.zoom(), styleLayer, feature.tags()))
return; return;
@ -155,7 +156,7 @@ static void drawFeature(const Feature &feature, Style *style, int styleLayer,
style->drawFeature(tile, styleLayer, path, feature.tags()); style->drawFeature(tile, styleLayer, path, feature.tags());
} }
static void drawLayer(const Layer &layer, Style *style, int styleLayer, static void drawLayer(const Layer &layer, const Style *style, int styleLayer,
Tile &tile) Tile &tile)
{ {
if (layer.data()->version() > 2) if (layer.data()->version() > 2)
@ -172,7 +173,7 @@ static void drawLayer(const Layer &layer, Style *style, int styleLayer,
tile.painter().restore(); tile.painter().restore();
} }
bool PBF::render(const QByteArray &data, int zoom, Style *style, bool PBF::render(const QByteArray &data, int zoom, const Style *style,
const QPointF &scale, QImage *image) const QPointF &scale, QImage *image)
{ {
vector_tile::Tile tile; vector_tile::Tile tile;

View File

@ -1,14 +1,14 @@
#ifndef PBF_H #ifndef PBF_H
#define PBF_H #define PBF_H
#include <QImage>
class QByteArray; class QByteArray;
class QImage;
class Style; class Style;
class QPointF;
namespace PBF namespace PBF
{ {
bool render(const QByteArray &data, int zoom, Style *style, bool render(const QByteArray &data, int zoom, const Style *style,
const QPointF &scale, QImage *render); const QPointF &scale, QImage *render);
} }

View File

@ -2,16 +2,16 @@
#define PBFHANDLER_H #define PBFHANDLER_H
#include <QImageIOHandler> #include <QImageIOHandler>
#include <QImage>
#include <QVariant> #include <QVariant>
#include <QSize> #include <QSize>
class QImage;
class Style; class Style;
class PBFHandler : public QImageIOHandler class PBFHandler : public QImageIOHandler
{ {
public: public:
PBFHandler(Style *style) : _style(style) {} PBFHandler(const Style *style) : _style(style) {}
~PBFHandler() {} ~PBFHandler() {}
bool canRead() const; bool canRead() const;
@ -19,12 +19,12 @@ public:
QVariant option(ImageOption option) const; QVariant option(ImageOption option) const;
bool supportsOption(ImageOption option) const; bool supportsOption(ImageOption option) const;
void setOption(QImageIOHandler::ImageOption option, const QVariant &value); void setOption(ImageOption option, const QVariant &value);
static bool canRead(QIODevice *device); static bool canRead(QIODevice *device);
private: private:
Style *_style; const Style *_style;
QSize _scaledSize; QSize _scaledSize;
}; };

View File

@ -4,6 +4,9 @@
#include <QRect> #include <QRect>
#include <QMap> #include <QMap>
#include <QImage> #include <QImage>
#include <QString>
class QJsonObject;
class Sprites class Sprites
{ {

View File

@ -3,6 +3,8 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QVector>
#include <QPair>
#include <QVariantHash> #include <QVariantHash>
#include <QStringList> #include <QStringList>
#include <QSet> #include <QSet>
@ -16,6 +18,8 @@
class QPainter; class QPainter;
class QPainterPath; class QPainterPath;
class QJsonArray;
class QJsonObject;
class Tile; class Tile;
class Style : public QObject class Style : public QObject

View File

@ -1,8 +1,13 @@
#ifndef TEXTITEM_H #ifndef TEXTITEM_H
#define TEXTITEM_H #define TEXTITEM_H
#include <QString>
#include <QPainterPath> #include <QPainterPath>
#include <QPen>
#include <QFont> #include <QFont>
#include <QRectF>
class QPainter;
class TextItem class TextItem
{ {

View File

@ -1,10 +1,7 @@
#ifndef TEXTPATHITEM_H #ifndef TEXTPATHITEM_H
#define TEXTPATHITEM_H #define TEXTPATHITEM_H
#include <QFont>
#include <QString>
#include "textitem.h" #include "textitem.h"
#include "text.h"
class TextPathItem : public TextItem class TextPathItem : public TextItem
{ {

View File

@ -1,11 +1,9 @@
#ifndef TEXTPOINTITEM_H #ifndef TEXTPOINTITEM_H
#define TEXTPOINTITEM_H #define TEXTPOINTITEM_H
#include <QPen> #include <QImage>
#include <QFont>
#include <QString>
#include "textitem.h"
#include "text.h" #include "text.h"
#include "textitem.h"
class TextPointItem : public TextItem class TextPointItem : public TextItem
{ {