mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-25 16:02:14 +08:00
Cabana: Reimplement HistoryLog::sizeHintForColumn to improve performance (#26393)
Reimplement sizeHintForColumn to improve performance
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "tools/cabana/historylog.h"
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
// HistoryLogModel
|
||||
|
||||
@@ -89,3 +88,8 @@ HistoryLog::HistoryLog(QWidget *parent) : QTableView(parent) {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
||||
setStyleSheet("QTableView::item { border:0px; padding-left:5px; padding-right:5px; }");
|
||||
}
|
||||
|
||||
int HistoryLog::sizeHintForColumn(int column) const {
|
||||
// sizeHintForColumn is only called for column 0 (ResizeToContents)
|
||||
return itemDelegate()->sizeHint(viewOptions(), model->index(0, 0)).width() + 1; // +1 for grid
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
class HeaderView : public QHeaderView {
|
||||
public:
|
||||
HeaderView(Qt::Orientation orientation, QWidget *parent = nullptr) : QHeaderView(orientation, parent) {}
|
||||
QSize sectionSizeFromContents(int logicalIndex) const;
|
||||
QSize sectionSizeFromContents(int logicalIndex) const override;
|
||||
};
|
||||
|
||||
class HistoryLogModel : public QAbstractTableModel {
|
||||
@@ -40,5 +40,6 @@ public:
|
||||
void setMessage(const QString &message_id) { model->setMessage(message_id); }
|
||||
void updateState() { model->updateState(); }
|
||||
private:
|
||||
int sizeHintForColumn(int column) const override;
|
||||
HistoryLogModel *model;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user