|
LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
|
#include <EventsTableModel.hpp>


Classes | |
| struct | ColumnFilter |
| struct | PrunedColumnState |
| struct | SortKey |
| Sort key of one row, computed once (see SortIndices / SortBefore). More... | |
Signals | |
| void | ColumnFiltersChanged () |
| void | SearchMatchesChanged () |
| Search matches were recomputed after the row set changed. | |
Public Member Functions | |
| EventsTableModel (db::EventsContainer &events, QObject *parent=nullptr) | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| QVariant | data (const QModelIndex &index, int role) const override |
| QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
| void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override |
| void | SyncWithContainer () |
| void | RefreshAll () |
| void | RefreshColumns () |
| void | UpdateColors () |
| void | SetFilteredIndices (const std::vector< unsigned long > &indices) |
| void | ClearFilter () |
| const std::vector< unsigned long > & | GetFilteredIndices () const |
| const std::vector< unsigned long > * | GetBaseFilteredIndices () const |
| bool | IsFilteringActive () const |
| True if a filter is active — distinguishes "no filter" from "filter active, zero matches". | |
| void | SetSearchTerm (const QString &term, bool caseSensitive) |
| void | SetSearchMode (utils::SearchMode mode) |
| int | MatchCount () const |
| const std::vector< int > & | MatchedRows () const |
| const utils::SearchEngine & | GetSearchEngine () const |
| void | RebuildSearchMatchesAsync () |
| Asynchronous search rebuild (doesn't block UI) | |
| ColumnDistinctValues | DistinctColumnValues (int column, std::size_t maxValues) const |
| QSet< QString > | AllColumnValues (int column) const |
Distinct cell texts of column among all events, ignoring every filter. | |
| bool | HasColumnFilter (int column) const |
| bool | HasAnyColumnFilter () const |
| bool | HasActiveColumnFilter () const |
| QSet< QString > | ColumnFilterValues (int column) const |
| bool | IsColumnFilterExclusion (int column) const |
True if column's filter hides the listed values instead of showing them. | |
| void | SetColumnFilter (int column, const QSet< QString > &allowed) |
Restricts column to allowed (an empty set matches nothing). | |
| void | SetColumnFilterExcluding (int column, const QSet< QString > &excluded) |
| void | ClearColumnFilter (int column) |
| void | ClearColumnFilters () |
| int | ResolveToActualIndex (int row) const |
| int | RowFromActualIndex (int actualIndex) const |
| std::vector< int > | ColumnWidths () const |
| int | ConfigIndexForColumn (int column) const |
| int | ActiveSortColumn () const |
| Model column of the active sort, or -1 if there is none or its column is hidden. | |
| Qt::SortOrder | ActiveSortOrder () const |
Private Member Functions | |
| bool | ResolveColumn (int column, std::string &name, bool &mergeSource) const |
| Resolves a model column to its data-column name / merge-source flag. | |
| bool | PassesColumnFilters (const db::LogEvent &event, const std::string *skipKey) const |
| void | ApplyEffectiveFilter () |
| void | SortIndices (std::vector< unsigned long > &indices, const std::string &columnName, bool isMergeSource, Qt::SortOrder order) const |
| SortKey | MakeSortKey (unsigned long idx, const std::string &columnName, bool isMergeSource) const |
| bool | SortBefore (unsigned long a, unsigned long b) const |
True if row a sorts before row b in the active sort. | |
| void | AppendSortedRows (std::size_t total) |
| PrunedColumnState | PruneStaleColumnState () |
| bool | BaseFilterIsStale () const |
| bool | HasStaleIndices () const |
| True if the upstream filter or the effective row list is stale. | |
| void | EndReset () |
| void | StoreColumnFilter (int column, const QSet< QString > &values, bool exclude) |
| void | RebuildVisibleColumns () |
| bool | ShouldShowSourceColumn () const |
| bool | ShouldShowOriginalIdColumn () const |
| QString | ComposeCellText (const db::LogEvent &event, const std::string &columnName, bool mergeSource) const |
| QVariant | GetSortValue (const db::LogEvent &event, const std::string &columnName, bool mergeSource) const |
| void | RebuildSearchMatches () |
Static Private Member Functions | |
| static std::string | ColumnFilterKey (const std::string &name, bool mergeSource) |
| static int | CompareSortKeys (const SortKey &a, const SortKey &b) |
| Three-way ascending comparison of two keys (ties broken by event id). | |
Private Attributes | |
| db::EventsContainer & | m_events |
| std::vector< unsigned long > | m_filteredIndices |
| Effective rows (upstream ∩ column filters, sorted if m_hasSort) | |
| std::vector< unsigned long > | m_baseFilteredIndices |
| Rows chosen by the rest of the app. | |
| bool | m_baseFilterActive {false} |
| std::uint64_t | m_baseGeneration {0} |
| container generation the upstream filter was set for | |
| std::uint64_t | m_indicesGeneration {0} |
| container generation m_filteredIndices was built for | |
| std::map< std::string, ColumnFilter > | m_columnFilters |
| std::set< std::string > | m_visibleFilterKeys |
| Keys of the visible columns; only their filters apply. | |
| bool | m_hasSort {false} |
| std::size_t | m_fullSortedCount {0} |
| std::string | m_sortName |
| sort column by data name, so it survives column changes | |
| bool | m_sortMergeSource {false} |
| Qt::SortOrder | m_sortOrder {Qt::AscendingOrder} |
| std::unordered_map< unsigned long, int > | m_reverseFilteredIndices |
| std::vector< int > | m_visibleColumnIndices |
| const config::Config & | m_config |
| bool | m_hasSourceColumn {false} |
| bool | m_filteringActive {false} |
| std::unique_ptr< utils::SearchEngine > | m_searchEngine |
| QString | m_searchTerm |
| bool | m_searchCaseSensitive {false} |
| std::vector< int > | m_matchedRows |
| model row indices with at least one matching cell | |
| std::unordered_set< int > | m_matchedRowSet |
| O(1) lookup used in data() | |
|
explicit |

| int ui::qt::EventsTableModel::ActiveSortColumn | ( | ) | const |
Model column of the active sort, or -1 if there is none or its column is hidden.

|
inline |

| QSet< QString > ui::qt::EventsTableModel::AllColumnValues | ( | int | column | ) | const |
Distinct cell texts of column among all events, ignoring every filter.

|
private |
Slots rows appended since the last full sort into the sorted list (O(k log k + n) instead of a full re-sort). Falls back to a full re-filter when the sorted list does not cover the previous events.


|
private |
Rebuilds m_filteredIndices from the upstream filter + column filters (+ the active sort). Does not reset the model — callers do.


|
private |
True if the upstream filter belongs to an older container generation or points past the container's end.


| void ui::qt::EventsTableModel::ClearColumnFilter | ( | int | column | ) |

| void ui::qt::EventsTableModel::ClearColumnFilters | ( | ) |

| void ui::qt::EventsTableModel::ClearFilter | ( | ) |


|
override |

|
staticprivate |

|
signal |

| QSet< QString > ui::qt::EventsTableModel::ColumnFilterValues | ( | int | column | ) | const |
Values of column's filter (empty set if none): the allowed values, or the excluded ones when IsColumnFilterExclusion().

| std::vector< int > ui::qt::EventsTableModel::ColumnWidths | ( | ) | const |

|
staticprivate |
Three-way ascending comparison of two keys (ties broken by event id).
|
private |
mergeSource: the column is the dynamic multi-file "source" column (shows LogEvent::GetSource()). A configured data column that merely happens to be named "source" reads the event's own "source" field.


| int ui::qt::EventsTableModel::ConfigIndexForColumn | ( | int | column | ) | const |
Index into Config::GetColumns() shown by model column; -1 for the dynamic source / original_id columns or an invalid column.

|
override |


| ColumnDistinctValues ui::qt::EventsTableModel::DistinctColumnValues | ( | int | column, |
| std::size_t | maxValues | ||
| ) | const |
Distinct cell texts of column among the rows that pass every filter except this column's own (so the list narrows as other columns are filtered, like Excel). At most maxValues values are returned.


|
private |
Ends a model reset begun with beginResetModel(): repairs stale row state, then re-applies search highlighting. Row-set changes must be made after beginResetModel() so views can still map their selection to events.


|
inline |
The rows chosen by the rest of the application (SetFilteredIndices), before column filters and sorting; nullptr when no such filter is set.

|
inline |

|
inline |
|
private |

| bool ui::qt::EventsTableModel::HasActiveColumnFilter | ( | ) | const |
True if a column filter of a visible column restricts the rows (filters of hidden columns are kept but not applied).

|
inline |
| bool ui::qt::EventsTableModel::HasColumnFilter | ( | int | column | ) | const |

|
private |
True if the upstream filter or the effective row list is stale.


|
override |


| bool ui::qt::EventsTableModel::IsColumnFilterExclusion | ( | int | column | ) | const |
True if column's filter hides the listed values instead of showing them.

|
inline |
True if a filter is active — distinguishes "no filter" from "filter active, zero matches".

|
private |
|
inline |

|
inline |

|
private |


|
private |

|
private |

| void ui::qt::EventsTableModel::RebuildSearchMatchesAsync | ( | ) |
Asynchronous search rebuild (doesn't block UI)
|
private |

| void ui::qt::EventsTableModel::RefreshAll | ( | ) |

| void ui::qt::EventsTableModel::RefreshColumns | ( | ) |


|
private |
Resolves a model column to its data-column name / merge-source flag.


| int ui::qt::EventsTableModel::ResolveToActualIndex | ( | int | row | ) | const |

|
override |


| int ui::qt::EventsTableModel::RowFromActualIndex | ( | int | actualIndex | ) | const |

|
signal |
Search matches were recomputed after the row set changed.

| void ui::qt::EventsTableModel::SetColumnFilter | ( | int | column, |
| const QSet< QString > & | allowed | ||
| ) |
Restricts column to allowed (an empty set matches nothing).

| void ui::qt::EventsTableModel::SetColumnFilterExcluding | ( | int | column, |
| const QSet< QString > & | excluded | ||
| ) |
Hides the excluded values of column and keeps every other value (used when the value list was too long to show completely).

| void ui::qt::EventsTableModel::SetFilteredIndices | ( | const std::vector< unsigned long > & | indices | ) |


| void ui::qt::EventsTableModel::SetSearchMode | ( | utils::SearchMode | mode | ) |
| void ui::qt::EventsTableModel::SetSearchTerm | ( | const QString & | term, |
| bool | caseSensitive | ||
| ) |

|
private |
|
private |
|
override |

|
private |
True if row a sorts before row b in the active sort.
|
private |

|
private |
| void ui::qt::EventsTableModel::SyncWithContainer | ( | ) |


| void ui::qt::EventsTableModel::UpdateColors | ( | ) |


|
private |
|
private |
Rows chosen by the rest of the app.
|
private |
container generation the upstream filter was set for
|
private |
|
private |
|
private |
|
private |
Effective rows (upstream ∩ column filters, sorted if m_hasSort)
|
private |
|
private |
Events covered by m_filteredIndices when it is the complete sorted list (no upstream or column filter); 0 when it is not such a list.
|
private |
|
private |
|
private |
container generation m_filteredIndices was built for
|
private |
model row indices with at least one matching cell
|
private |
O(1) lookup used in data()
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
sort column by data name, so it survives column changes
|
private |
|
private |
|
private |
Keys of the visible columns; only their filters apply.