forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user