forked from qt-creator/qt-creator
Axivion: Make use of the column widths coming from the server
Change-Id: Idcce80ed987ed02cb0197cfca93d32deb715f95c Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -388,11 +388,13 @@ void IssuesWidget::updateTable()
|
||||
QStringList columnHeaders;
|
||||
QStringList hiddenColumns;
|
||||
QList<bool> sortableColumns;
|
||||
QList<int> columnWidths;
|
||||
for (const Dto::ColumnInfoDto &column : m_currentTableInfo->columns) {
|
||||
columnHeaders << column.header.value_or(column.key);
|
||||
if (!column.showByDefault)
|
||||
hiddenColumns << column.key;
|
||||
sortableColumns << column.canSort;
|
||||
columnWidths << column.width;
|
||||
}
|
||||
m_addedFilter->setText("0");
|
||||
m_removedFilter->setText("0");
|
||||
@@ -401,7 +403,6 @@ void IssuesWidget::updateTable()
|
||||
m_issuesModel->clear();
|
||||
m_issuesModel->setHeader(columnHeaders);
|
||||
m_headerView->setSortableColumns(sortableColumns);
|
||||
|
||||
int counter = 0;
|
||||
for (const QString &header : std::as_const(columnHeaders))
|
||||
m_issuesView->setColumnHidden(counter++, hiddenColumns.contains(header));
|
||||
|
||||
@@ -115,9 +115,11 @@ void IssueHeaderView::onToggleSort(int index, SortOrder order)
|
||||
|
||||
QSize IssueHeaderView::sectionSizeFromContents(int logicalIndex) const
|
||||
{
|
||||
QSize size = QHeaderView::sectionSizeFromContents(logicalIndex);
|
||||
const QSize oldSize = QHeaderView::sectionSizeFromContents(logicalIndex);
|
||||
const QSize newSize = logicalIndex < m_columnWidths.size()
|
||||
? QSize(qMax(m_columnWidths.at(logicalIndex), oldSize.width()), oldSize.height()) : oldSize;
|
||||
// add icon size and margin (2)
|
||||
return QSize{size.width() + ICON_SIZE + 2, qMax(size.height(), ICON_SIZE)};
|
||||
return QSize{newSize.width() + ICON_SIZE + 2, qMax(newSize.height(), ICON_SIZE)};
|
||||
}
|
||||
|
||||
void IssueHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
|
||||
|
||||
@@ -16,9 +16,11 @@ class IssueHeaderView : public QHeaderView
|
||||
public:
|
||||
explicit IssueHeaderView(QWidget *parent = nullptr) : QHeaderView(Qt::Horizontal, parent) {}
|
||||
void setSortableColumns(const QList<bool> &sortable);
|
||||
void setColumnWidths(const QList<int> &widths) { m_columnWidths = widths; }
|
||||
|
||||
SortOrder currentSortOrder() const { return m_currentSortOrder; }
|
||||
int currentSortColumn() const;
|
||||
|
||||
signals:
|
||||
void sortTriggered();
|
||||
|
||||
@@ -36,6 +38,7 @@ private:
|
||||
int m_currentSortIndex = -1;
|
||||
SortOrder m_currentSortOrder = SortOrder::None;
|
||||
QList<bool> m_sortableColumns;
|
||||
QList<int> m_columnWidths;
|
||||
};
|
||||
|
||||
} // namespace Axivion::Internal
|
||||
|
||||
Reference in New Issue
Block a user