Fixed the hangup bug because of very long label words

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-12-02 00:44:28 +01:00
parent 166ef0b82e
commit 21445db240
2 changed files with 20 additions and 0 deletions

View File

@ -445,6 +445,21 @@ QStringList VTextManager::SplitString(const QString &qs, qreal fW, const QFontMe
}
}
qslLines << qsCurrent;
int i = 0;
int iHorSp = fm.width(" ");
while (i < qslLines.count()) {
if (fm.width(qslLines[i]) + iHorSp > fW) {
int iPos = qslLines[i].length() >> 1;
QString qs1 = qslLines[i].left(iPos);
QString qs2 = qslLines[i].mid(iPos);
qslLines[i] = qs1;
qslLines.insert(i + 1, qs2);
} else {
++i;
}
}
return qslLines;
}

View File

@ -232,6 +232,7 @@ void VTextGraphicsItem::Clear()
*/
void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
{
qDebug() << "Setting size to" << fW << parentItem()->boundingRect().width();
// don't allow resize under specific size
if (fW < MIN_W || fH < m_iMinH)
{
@ -255,6 +256,7 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
fH = m_iMinH;
}
qDebug() << "Actual size set to" << fW;
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
m_rectBoundingBox.setWidth(fW);
m_rectBoundingBox.setHeight(fH);
@ -599,6 +601,7 @@ void VTextGraphicsItem::CorrectLabel()
{
++iFS;
}
// decrease the font size until the bounding rect is big enough
while (m_tm.IsBigEnough(m_rectBoundingBox.width(), m_rectBoundingBox.height(), iFS, fMinW, fMinH) == false)
{
@ -610,6 +613,8 @@ void VTextGraphicsItem::CorrectLabel()
{
SetSize(fMinW, fMinH);
}
qDebug() << "DEC FONT" << iFS << m_rectBoundingBox.width() << fMinW;
}
qreal dX;
qreal dY;