mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-07 12:05:14 +01:00
Show the arrows even when no label is set
This commit is contained in:
parent
6ce2a63a1c
commit
dcf45475ba
@ -320,9 +320,6 @@ void RasterTile::processStreetNames(const QList<MapData::Poly> &lines,
|
|||||||
|
|
||||||
if (style.img().isNull() && style.foreground() == Qt::NoPen)
|
if (style.img().isNull() && style.foreground() == Qt::NoPen)
|
||||||
continue;
|
continue;
|
||||||
if (poly.label.text().isEmpty()
|
|
||||||
|| style.textFontSize() == Style::None)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QFont *fnt = font(style.textFontSize(), Style::Small);
|
const QFont *fnt = font(style.textFontSize(), Style::Small);
|
||||||
const QColor *color = style.textColor().isValid()
|
const QColor *color = style.textColor().isValid()
|
||||||
@ -331,9 +328,14 @@ void RasterTile::processStreetNames(const QList<MapData::Poly> &lines,
|
|||||||
const QImage *img = poly.oneway
|
const QImage *img = poly.oneway
|
||||||
? Style::isWaterLine(poly.type)
|
? Style::isWaterLine(poly.type)
|
||||||
? &waterArrow : &arrow : 0;
|
? &waterArrow : &arrow : 0;
|
||||||
|
const QString *label = poly.label.text().isEmpty()
|
||||||
|
? 0 : &poly.label.text();
|
||||||
|
|
||||||
TextPathItem *item = new TextPathItem(poly.points,
|
if (!img && (!label || !fnt))
|
||||||
&poly.label.text(), _rect, fnt, color, hColor, img);
|
continue;
|
||||||
|
|
||||||
|
TextPathItem *item = new TextPathItem(poly.points, label, _rect, fnt,
|
||||||
|
color, hColor, img);
|
||||||
if (item->isValid() && !item->collides(textItems))
|
if (item->isValid() && !item->collides(textItems))
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
else {
|
else {
|
||||||
|
@ -263,12 +263,15 @@ template<class T>
|
|||||||
void TextPathItem::init(const T &line, const QRect &tileRect)
|
void TextPathItem::init(const T &line, const QRect &tileRect)
|
||||||
{
|
{
|
||||||
qreal cw, mw, textWidth;
|
qreal cw, mw, textWidth;
|
||||||
|
bool label = _text && _font;
|
||||||
|
|
||||||
if (_text && _img) {
|
Q_ASSERT(label || _img);
|
||||||
|
|
||||||
|
if (label && _img) {
|
||||||
cw = _font->pixelSize() * CHAR_RATIO;
|
cw = _font->pixelSize() * CHAR_RATIO;
|
||||||
mw = _font->pixelSize() / 2.0;
|
mw = _font->pixelSize() / 2.0;
|
||||||
textWidth = _text->size() * cw + _img->width() + PADDING;
|
textWidth = _text->size() * cw + _img->width() + PADDING;
|
||||||
} else if (_text) {
|
} else if (label) {
|
||||||
cw = _font->pixelSize() * CHAR_RATIO;
|
cw = _font->pixelSize() * CHAR_RATIO;
|
||||||
mw = _font->pixelSize() / 2.0;
|
mw = _font->pixelSize() / 2.0;
|
||||||
textWidth = _text->size() * cw;
|
textWidth = _text->size() * cw;
|
||||||
@ -328,7 +331,7 @@ void TextPathItem::paint(QPainter *painter) const
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_text) {
|
if (_text && _font) {
|
||||||
QFontMetrics fm(*_font);
|
QFontMetrics fm(*_font);
|
||||||
int textWidth = fm.boundingRect(*_text).width();
|
int textWidth = fm.boundingRect(*_text).width();
|
||||||
int imgWidth = _img ? _img->width() + PADDING : 0;
|
int imgWidth = _img ? _img->width() + PADDING : 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user