27#include <QApplication>
44 this->setVerticalScrollMode(ScrollMode::ScrollPerPixel);
46 setObjectName(QString::fromUtf8(
"tableLog"));
47 QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Expanding);
48 sizePolicy2.setHorizontalStretch(10);
49 sizePolicy2.setVerticalStretch(10);
50 sizePolicy2.setHeightForWidth(sizePolicy().hasHeightForWidth());
51 setSizePolicy(sizePolicy2);
52 setSizeIncrement(QSize(1, 0));
53 setEditTriggers(QAbstractItemView::DoubleClicked);
54 setAlternatingRowColors(
true);
56 setGridStyle(Qt::SolidLine);
57 setSortingEnabled(
false);
59 setCornerButtonEnabled(
true);
61 setSelectionMode(QAbstractItemView::SingleSelection);
62 setSelectionBehavior(QAbstractItemView::SelectRows);
64 horizontalHeader()->setVisible(
true);
65 horizontalHeader()->setCascadingSectionResizes(
true);
66 horizontalHeader()->setDefaultSectionSize(100);
67 horizontalHeader()->setMinimumSectionSize(20);
68 horizontalHeader()->setStretchLastSection(
true);
69 verticalHeader()->setVisible(
false);
70 verticalHeader()->setDefaultSectionSize(20);
76 setColumnWidth(0, 90);
77 setColumnWidth(1, 90);
78 setColumnWidth(2, 90);
79 setColumnWidth(3, 60);
80 setColumnWidth(4, 700);
81 setColumnWidth(5, 150);
82 setColumnWidth(6, 200);
93 QAbstractItemModel* absmodel = qobject_cast<QAbstractItemModel*>(model());
95 SIGNAL(rowsAboutToBeInserted(QModelIndex,
int,
int)),
99 this, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(
doubleClickOnCell(QModelIndex)));
101 setContextMenuPolicy(Qt::CustomContextMenu);
103 SIGNAL(customContextMenuRequested(QPoint)),
107 SIGNAL(dataChanged(QModelIndex, QModelIndex)),
110 connect(verticalScrollBar(), SIGNAL(valueChanged(
int)),
this, SLOT(
checkAutoScroll()));
122 const QModelIndex
index = indexAt(pos);
123 if (!
index.isValid())
128 const int row =
index.row();
136 QAction* removeAction = menu.addAction(tr(
"Remove label"));
137 connect(removeAction,
144 QAction* addAction = menu.addAction(tr(
"Add label"));
146 addAction, &QAction::triggered,
this, [
this, seq] { emit
addLabelRequested(seq); });
148 menu.exec(viewport()->mapToGlobal(pos));
172 if (!isRowHidden(row) && !contains)
174 setRowHidden(row,
true);
176 else if (isRowHidden(row) && contains)
178 setRowHidden(row,
false);
190 int rowCount = model()->rowCount();
192 for (
int i = startRow; i < rowCount; i++)
196 setRowHidden(i,
true);
200 qApp->processEvents();
219 int rowCount = model()->rowCount();
221 for (
int i = startRow; i < rowCount; i++)
227 setRowHidden(i,
false);
232 setRowHidden(i,
true);
236 qApp->processEvents();
295 if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
316 QTableView::showEvent(event);
338 if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
355 const int fontHeight = QFontMetrics(font()).height();
356 const int rowCount = logModel->
rowCount();
357 for (
int i = std::max(0, start); i <= end && i < rowCount; ++i)
364 setRowHeight(i, fontHeight * stringRows + 1);
374 QTableView::rowsInserted(parent, start, end);
391 QTableView::rowsAboutToBeRemoved(parent, start, end);
393 if (end - start >= model()->rowCount() - 1)
403 int checkCounter = 0;
404 int tempSelectedSearchIndex = indexAt(QPoint(10, 10)).row();
406 if (selectedIndexes().size() > 0)
408 tempSelectedSearchIndex = selectedIndexes()[0].row();
411 int oldSelectedSearchIndex = tempSelectedSearchIndex;
416 if ((tempSelectedSearchIndex != oldSelectedSearchIndex || keepSelectionIfPossible) &&
417 getModel()->rowContainsString(tempSelectedSearchIndex,
420 selectRow(tempSelectedSearchIndex);
426 tempSelectedSearchIndex--;
430 tempSelectedSearchIndex++;
433 if (tempSelectedSearchIndex >= model()->rowCount())
435 tempSelectedSearchIndex = 0;
438 if (tempSelectedSearchIndex < 0)
440 tempSelectedSearchIndex = model()->rowCount() - 1;
446 if (checkCounter > model()->rowCount())
450 }
while (tempSelectedSearchIndex != oldSelectedSearchIndex);
463 std::string fileWithLineNumber = model()->data(
index).toString().toStdString();
464 const auto colonPos = fileWithLineNumber.rfind(
':');
465 if (colonPos == std::string::npos)
470 std::string file = fileWithLineNumber.substr(0, colonPos);
471 std::string line = fileWithLineNumber.substr(colonPos + 1);
473 if (!std::filesystem::exists(file))
475 ARMARX_INFO <<
"File '" << file <<
"' does not exists - cannot open it.";
479 fileOpener.openFileWithDefaultEditor(file, atoi(line.c_str()));
#define ARMARX_LOG_FILESTR
#define ARMARX_LOG_MESSAGESTR
A filtered view onto the shared LogStore.
void setMaterialised(bool materialised)
Build rows (materialised) or drop them and only keep counting (not).
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int lineCountAt(int row) const
Number of display lines of the message column for the given row.
LogSeq seqAt(int row) const
Store sequence number of the given display row, or 0 if the row is invalid.
bool rowContainsString(int row, const QString &searchStr) const
void search(const QString &searchStr)
void liveFilter(const QString &search, int startRow=0)
void doubleClickOnCell(const QModelIndex &index)
void showContextMenu(const QPoint &pos)
Build the right-click menu ("Add label" / "Remove label") for the row under pos.
bool selectNextSearchResult(bool backwards=true, bool keepSelectionIfPossible=false)
void showEvent(QShowEvent *event) override
QString currentLiveFilter
void liveFilterRow(const QString &filterStr, int row)
bool liveSearch(const QString &search)
LogTableModel * getModel()
void removeLabelRequested(LogSeq seq)
Emitted from the context menu to remove the pin on the given line.
MessageType maxNewLogLevelType
void hideEvent(QHideEvent *) override
QString getCurrentLiveFilter() const
LogTable(QWidget *parent=0)
bool checkAutoScroll(const QModelIndex &parent, int start, int end)
void applyRowHeights(int start, int end)
Give rows [start, end] the height their message needs.
void itemsAdded(QModelIndex leftTop, QModelIndex bottomRight)
void resetNewMessageCount()
Clear the new-message badge (count and highest severity seen).
void notifyNewMessages(int count, MessageType maxLevel)
Account for messages this filter accepted while it was hidden.
void addLabelRequested(LogSeq seq)
Emitted from the context menu to pin the given line (assign a label).
EditorFileOpener fileOpener
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
void rowsInserted(const QModelIndex &parent, int start, int end) override
#define ARMARX_INFO
The normal logging level.
This file offers overloads of toIce() and fromIce() functions for STL container types.
quint64 LogSeq
Identifies a stored log entry for as long as it is retained.