Code cleanup

This commit is contained in:
Martin Tůma 2018-11-24 18:57:24 +01:00
parent 0dd83979cf
commit c1a00d902e
4 changed files with 7 additions and 13 deletions

View File

@ -151,7 +151,8 @@ static void drawFeature(const Feature &feature, Style *style, int styleLayer,
} }
} }
style->drawFeature(tile, styleLayer, path, feature.tags()); if (path.elementCount())
style->drawFeature(tile, styleLayer, path, feature.tags());
} }
static void drawLayer(const Layer &layer, Style *style, int styleLayer, static void drawLayer(const Layer &layer, Style *style, int styleLayer,

View File

@ -152,9 +152,6 @@ void Text::render(QPainter *painter) const
void Text::addLabel(const QString &text, const QPointF &pos, void Text::addLabel(const QString &text, const QPointF &pos,
const QPainter &painter, bool overlap, const QImage &icon) const QPainter &painter, bool overlap, const QImage &icon)
{ {
if (text.isEmpty())
return;
TextPointItem *ti = new TextPointItem(text, pos, painter.font(), TextPointItem *ti = new TextPointItem(text, pos, painter.font(),
_properties, icon); _properties, icon);
if (!overlap && !_sceneRect.contains(ti->boundingRect())) { if (!overlap && !_sceneRect.contains(ti->boundingRect())) {
@ -172,11 +169,6 @@ void Text::addLabel(const QString &text, const QPointF &pos,
void Text::addLabel(const QString &text, const QPainterPath &path, void Text::addLabel(const QString &text, const QPainterPath &path,
const QPainter &painter) const QPainter &painter)
{ {
if (path.isEmpty())
return;
if (text.isEmpty())
return;
int textWidth = text.size() * painter.font().pixelSize() * 0.6; int textWidth = text.size() * painter.font().pixelSize() * 0.6;
if (textWidth > path.length()) if (textWidth > path.length())
return; return;

View File

@ -30,7 +30,8 @@ public:
}; };
Text(const QSize &size) : _sceneRect(QRectF(QPointF(0, 0), size)) {} Text(const QSize &size)
: _sceneRect(QRectF(QPointF(0, 0), size)), _textPathPresent(false) {}
~Text(); ~Text();
void setProperties(const Properties &prop) void setProperties(const Properties &prop)

View File

@ -17,6 +17,9 @@ TextPathItem::TextPathItem(const QString &text, const QPainterPath &path,
void TextPathItem::paint(QPainter *painter) const void TextPathItem::paint(QPainter *painter) const
{ {
//painter->setPen(Qt::red);
//painter->drawPath(_shape);
QFontMetrics fm(_font); QFontMetrics fm(_font);
int textWidth = fm.width(text()); int textWidth = fm.width(text());
@ -40,7 +43,4 @@ void TextPathItem::paint(QPainter *painter) const
int width = fm.charWidth(text(), i); int width = fm.charWidth(text(), i);
percent += ((qreal)width / (qreal)textWidth) * factor; percent += ((qreal)width / (qreal)textWidth) * factor;
} }
//painter->setPen(Qt::red);
//painter->drawPath(_shape);
} }