Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
log_table_widget.h
1#pragma once
2
3#include <QLabel>
4#include <QPushButton>
5#include <QWidget>
6
7#include "dropdown_button.h"
8#include "log_filter_model.h"
9#include "log_table_highlight.h"
10#include "log_table_model.h"
11#include "logging.h"
12#include "settings_manager.h"
13
14class ClickableIcon;
15class ExpandingWidget;
16
20class LogTableWidget : public QWidget
21{
22 Q_OBJECT
23
24public:
30 LogTableWidget(QWidget* parent = nullptr);
31
41 void append(logging::LogLevel level, const QString& source, const QString& file, const uint32_t line, const QString& message);
42
52 void append(logging::LogLevel level, const std::string& source, const std::string& file, const uint32_t line, const std::string& message);
53
57 void clear();
58
62 void search();
63
67 void showAll();
68
69 void onSettingsChanged(const GeneralSettings& settings);
70
71private slots:
78 void onAreaExpanded(ClickableIcon* button, QLineEdit* lineEdit);
79
87 void onAreaCollapsed(ClickableIcon* button, QLineEdit* lineEdit, const QString& iconName);
88
94 void onClicked(const QModelIndex& index);
95
96private:
97 LogTableModel* mModel = nullptr;
99
100 QTableView* mTable = nullptr;
103 QLineEdit* mFileFilter = nullptr;
104 QLineEdit* mSearchField = nullptr;
105 QLabel* mSearchCounterLabel = nullptr;
106
109
111 QString mSearchText;
112 QVector<QModelIndex> mSearchMatches;
113 QSet<QString> mSources;
114
117 int mMaximumRows = 1000;
118 logging::LogLevel mCurrentLevel = logging::LogLevel::Error;
119
125 void setSearchText(const QString& text);
126
130 void nextSearchMatch();
131
135 void previousSearchMatch();
136
141
146
150 void updateSearchCounter();
151
157 QVector<int> selectedRows() const;
158
164 void showContextMenu(const QPoint& pos);
165
169 void copySelectedRows() const;
170
176 void copySelectedColumn(int column) const;
177
183 void copySelectedColumns(std::initializer_list<int> columns) const;
184
191 bool isMessageElided(int proxyRow) const;
192
200 bool eventFilter(QObject* watched, QEvent* event);
201
208 void updateFilterText(QToolButton* button, const QString& base);
209};
A clickable icon widget that can be checked or unchecked.
Definition clickable_icon.h:10
Definition dropdown_button.h:7
A widget that expands and collapses its content area.
Definition expanding_widget.h:17
A proxy model for filtering log entries based on various criteria.
Definition log_filter_model.h:11
A delegate for highlighting log entries based on search text and expanding specific rows.
Definition log_table_highlight.h:9
A custom table model for displaying log entries.
Definition log_table_model.h:19
void rebuildSearchMatches()
Rebuilds the list of search matches.
Definition log_table_widget.cpp:378
void nextSearchMatch()
Moves to the next search match.
Definition log_table_widget.cpp:356
DropDownButton * mSourceFilter
Pointer to the level filter button.
Definition log_table_widget.h:102
LogHighlightDelegate * mHighlightDelegate
Pointer to the filter box widget.
Definition log_table_widget.h:110
void append(logging::LogLevel level, const QString &source, const QString &file, const uint32_t line, const QString &message)
Appends a log message with a QString source and file.
Definition log_table_widget.cpp:284
void clear()
Clears all log messages from the table.
Definition log_table_widget.cpp:325
void focusCurrentSearchMatch()
Focuses on the current search match.
Definition log_table_widget.cpp:400
void copySelectedRows() const
Copies the selected rows to the clipboard.
Definition log_table_widget.cpp:452
int mCurrentSearchMatch
Set of sources for filtering.
Definition log_table_widget.h:115
int mMaximumRows
Default row height in pixels.
Definition log_table_widget.h:117
QTableView * mTable
Pointer to the log filter proxy model.
Definition log_table_widget.h:100
void copySelectedColumns(std::initializer_list< int > columns) const
Copies multiple columns of the selected rows to the clipboard.
Definition log_table_widget.cpp:463
DropDownButton * mLevelFilter
Pointer to the table view widget.
Definition log_table_widget.h:101
QString mSearchText
Pointer to the log highlight delegate.
Definition log_table_widget.h:111
QLabel * mSearchCounterLabel
Pointer to the search field line edit.
Definition log_table_widget.h:105
QVector< QModelIndex > mSearchMatches
The current search text.
Definition log_table_widget.h:112
LogFilterProxyModel * mProxy
Pointer to the log table model.
Definition log_table_widget.h:98
void onClicked(const QModelIndex &index)
Handles click events on table items.
Definition log_table_widget.cpp:250
ExpandingWidget * mSearchBox
Pointer to the search counter label.
Definition log_table_widget.h:107
void showAll()
Expand all the expandable widgets.
Definition log_table_widget.cpp:243
void updateFilterText(QToolButton *button, const QString &base)
Updates the text in a toolbutton filter.
Definition log_table_widget.cpp:200
bool eventFilter(QObject *watched, QEvent *event)
Filters events for child widgets.
Definition log_table_widget.cpp:508
ExpandingWidget * mFilterBox
Pointer to the search box widget.
Definition log_table_widget.h:108
void setSearchText(const QString &text)
Sets the search text and updates the search matches.
Definition log_table_widget.cpp:335
void showContextMenu(const QPoint &pos)
Shows the context menu at the specified position.
Definition log_table_widget.cpp:425
void updateSearchCounter()
Updates the search counter label.
Definition log_table_widget.cpp:414
QLineEdit * mFileFilter
Pointer to the source filter button.
Definition log_table_widget.h:103
QSet< QString > mSources
List of search matches.
Definition log_table_widget.h:113
bool isMessageElided(int proxyRow) const
Checks if a message is elided in the table.
Definition log_table_widget.cpp:485
int mDefaultRowHeight
Index of the current search match.
Definition log_table_widget.h:116
QLineEdit * mSearchField
Pointer to the file filter line edit.
Definition log_table_widget.h:104
void onAreaCollapsed(ClickableIcon *button, QLineEdit *lineEdit, const QString &iconName)
Handles area collapse events.
Definition log_table_widget.cpp:229
QVector< int > selectedRows() const
Returns a vector of selected row indices.
Definition log_table_widget.cpp:438
void copySelectedColumn(int column) const
Copies a specific column of the selected rows to the clipboard.
Definition log_table_widget.cpp:458
void search()
Initiates a search for the current search text.
Definition log_table_widget.cpp:330
void previousSearchMatch()
Moves to the previous search match.
Definition log_table_widget.cpp:367
void onAreaExpanded(ClickableIcon *button, QLineEdit *lineEdit)
Handles area expansion events.
Definition log_table_widget.cpp:217
LogTableWidget(QWidget *parent=nullptr)
Constructs a new LogTableWidget.
Definition log_table_widget.cpp:43
Holds general application settings.
Definition settings_manager.h:23