mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Auto-size log view columns by hand
* Using the auto-resizing mode of RDHeaderView resizes based on the whole column every time, which is wasteful when only a few lines are added to a large log.
This commit is contained in:
@@ -310,12 +310,10 @@ LogView::LogView(ICaptureContext &ctx, QWidget *parent)
|
||||
|
||||
ui->pidFilter->setModel(m_PIDModel);
|
||||
|
||||
{
|
||||
RDHeaderView *header = new RDHeaderView(Qt::Horizontal, this);
|
||||
ui->messages->setHeader(header);
|
||||
ui->messages->header()->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setColumnStretchHints({-1, -1, -1, -1, -1, 1});
|
||||
}
|
||||
for(int c = 0; c < m_ItemModel->columnCount(); c++)
|
||||
ui->messages->resizeColumnToContents(c);
|
||||
|
||||
messages_refresh();
|
||||
|
||||
@@ -504,6 +502,8 @@ void LogView::messages_refresh()
|
||||
|
||||
QRegularExpression logRegex(r);
|
||||
|
||||
int prevCount = m_Messages.count();
|
||||
|
||||
for(const QString &line : lines)
|
||||
{
|
||||
QRegularExpressionMatch match = logRegex.match(line);
|
||||
@@ -546,6 +546,20 @@ void LogView::messages_refresh()
|
||||
m_FilterModel->addRows(m_Messages.count() - prevCount);
|
||||
}
|
||||
|
||||
// go through each new message and size up columns to fit
|
||||
for(int i = prevCount; i < m_Messages.count(); i++)
|
||||
{
|
||||
for(int c = 0; c < ui->messages->model()->columnCount(); c++)
|
||||
{
|
||||
QSize s = ui->messages->sizeHintForIndex(ui->messages->model()->index(i, c));
|
||||
|
||||
int w = ui->messages->header()->sectionSize(c);
|
||||
|
||||
if(s.width() > w)
|
||||
ui->messages->header()->resizeSection(c, s.width());
|
||||
}
|
||||
}
|
||||
|
||||
if(ui->followNew->isChecked())
|
||||
ui->messages->scrollToBottom();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user