Utils: Simplify tree view columns width computation

... by using approximations of the value widths instead of precise
comuptation.

Change-Id: Ia7eefad8d79f09d1e0cfda32067d052f56b820a9
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2023-02-24 12:27:00 +01:00
parent 8eaf73700e
commit a1e9670541

View File

@@ -159,10 +159,11 @@ public:
a = a.sibling(a.row(), column);
QFontMetrics fm = q->fontMetrics();
const int ind = q->indentation();
const int avg = fm.averageCharWidth();
QAbstractItemModel *m = q->model();
for (int i = 0; i < 100 && a.isValid(); ++i) {
const QString s = m->data(a).toString();
int w = fm.horizontalAdvance(s) + 10;
int w = avg * s.size() + 20;
if (column == 0) {
for (QModelIndex b = a.parent(); b.isValid(); b = b.parent())
w += ind;