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,6 +151,7 @@ static void drawFeature(const Feature &feature, Style *style, int styleLayer,
}
}
if (path.elementCount())
style->drawFeature(tile, styleLayer, path, feature.tags());
}

View File

@ -152,9 +152,6 @@ void Text::render(QPainter *painter) const
void Text::addLabel(const QString &text, const QPointF &pos,
const QPainter &painter, bool overlap, const QImage &icon)
{
if (text.isEmpty())
return;
TextPointItem *ti = new TextPointItem(text, pos, painter.font(),
_properties, icon);
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,
const QPainter &painter)
{
if (path.isEmpty())
return;
if (text.isEmpty())
return;
int textWidth = text.size() * painter.font().pixelSize() * 0.6;
if (textWidth > path.length())
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();
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
{
//painter->setPen(Qt::red);
//painter->drawPath(_shape);
QFontMetrics fm(_font);
int textWidth = fm.width(text());
@ -40,7 +43,4 @@ void TextPathItem::paint(QPainter *painter) const
int width = fm.charWidth(text(), i);
percent += ((qreal)width / (qreal)textWidth) * factor;
}
//painter->setPen(Qt::red);
//painter->drawPath(_shape);
}