ui: scroll code horizontally to active sourcelocations

This commit is contained in:
Eberhard Graether
2018-07-22 19:40:01 +02:00
parent ad6f5c8727
commit 1db248a34e
7 changed files with 116 additions and 8 deletions
+4 -8
View File
@@ -101,20 +101,16 @@ QSize QtCodeField::sizeHint() const
int width = 0;
QFontMetrics fm = fontMetrics();
int maxTextSize = 0;
for (QTextBlock block = document()->firstBlock(); block.isValid(); block = block.next())
{
QRectF rect = blockBoundingGeometry(block);
height += rect.height();
{
int blockWidth = fm.boundingRect(
0, 0, 1000000, 1000000,
Qt::AlignLeft | Qt::AlignTop | Qt::TextExpandTabs, block.text(), tabStopWidth()).width();
int blockWidth = fm.boundingRect(
0, 0, 1000000, 1000000,
Qt::AlignLeft | Qt::AlignTop | Qt::TextExpandTabs, block.text(), tabStopWidth()).width();
width = std::max(blockWidth, width);
maxTextSize = block.text().size();
}
width = std::max(blockWidth, width);
}
return QSize(width + 1, height + 5);