diff options
author | Christian Stenger <christian.stenger@qt.io> | 2020-07-01 15:45:48 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2020-07-07 05:11:26 +0000 |
commit | c12294c1b26d4849586d8433d6ad38441846c9e2 (patch) | |
tree | 53b00caeda7e381bc3a2369aedd788e905bd12af | |
parent | c7bc8a98ac300aeff854bdbbae260cf9fc440a73 (diff) |
AutoTest: Align file and line information of sub-items
Avoid displaying the file and line information inverse-cascaded
and fix initialization of the internal layout positions.
Change-Id: Ic9493741c58ece6074f659de110c9cabadafe7d6
Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r-- | src/plugins/autotest/testresultdelegate.h | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/plugins/autotest/testresultdelegate.h b/src/plugins/autotest/testresultdelegate.h index a3b2cb7c5f2..73b2d8291be 100644 --- a/src/plugins/autotest/testresultdelegate.h +++ b/src/plugins/autotest/testresultdelegate.h @@ -57,25 +57,17 @@ private: { public: LayoutPositions(QStyleOptionViewItem &options, const TestResultFilterModel *filterModel) - : m_totalWidth(options.rect.width()), - m_top(options.rect.top()), - m_bottom(options.rect.bottom()) + : m_top(options.rect.top()), + m_bottom(options.rect.bottom()), + m_left(options.rect.left()), + m_right(options.rect.right()) { TestResultModel *srcModel = static_cast<TestResultModel *>(filterModel->sourceModel()); m_maxFileLength = srcModel->maxWidthOfFileName(options.font); m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font); m_realFileLength = m_maxFileLength; m_typeAreaWidth = QFontMetrics(options.font).horizontalAdvance("XXXXXXXX"); - m_indentation = options.widget ? options.widget->style()->pixelMetric( - QStyle::PM_TreeViewIndentation, &options) : 0; - - const QModelIndex &rootIndex = srcModel->rootItem()->index(); - QModelIndex parentIndex = filterModel->mapToSource(options.index).parent(); - m_level = 1; - while (rootIndex != parentIndex) { - ++m_level; - parentIndex = parentIndex.parent(); - } + int flexibleArea = lineAreaLeft() - textAreaLeft() - ITEM_SPACING; if (m_maxFileLength > flexibleArea / 2) m_realFileLength = flexibleArea / 2; @@ -83,8 +75,8 @@ private: } int top() const { return m_top + ITEM_MARGIN; } - int left() const { return ITEM_MARGIN + m_indentation * m_level; } - int right() const { return m_totalWidth - ITEM_MARGIN; } + int left() const { return m_left + ITEM_MARGIN; } + int right() const { return m_right - ITEM_MARGIN; } int bottom() const { return m_bottom; } int minimumHeight() const { return ICON_SIZE + 2 * ITEM_MARGIN; } @@ -108,16 +100,15 @@ private: m_maxLineLength, m_fontHeight); } private: - int m_totalWidth; int m_maxFileLength; int m_maxLineLength; int m_realFileLength; int m_top; int m_bottom; + int m_left; + int m_right; int m_fontHeight; int m_typeAreaWidth; - int m_level; - int m_indentation; static const int ICON_SIZE = 16; static const int ITEM_MARGIN = 2; |