LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
DrillDownFilter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "EventsContainer.hpp"
5
6#include <cstdint>
7#include <optional>
8#include <vector>
9
10namespace ui::qt
11{
12
20{
21 public:
23 void Apply(EventsTableView& view, const db::EventsContainer& events,
24 const std::vector<unsigned long>& indices,
25 const std::vector<unsigned long>& shown)
26 {
27 if (!IsActive(view, events)) // drilling again keeps the first "before"
28 {
29 const auto* base = view.GetBaseFilteredIndices();
30 m_previous = base ? std::optional(*base) : std::nullopt;
31 m_shown = shown;
32 }
33 m_applied = indices;
34 m_generation = events.Generation();
35 m_active = true;
36 view.SetFilteredEvents(indices);
37 }
38
41 [[nodiscard]] bool IsActive(const EventsTableView& view,
42 const db::EventsContainer& events) const
43 {
44 if (!m_active || events.Generation() != m_generation)
45 return false;
46 const auto* base = view.GetBaseFilteredIndices();
47 return base && *base == m_applied;
48 }
49
51 [[nodiscard]] const std::vector<unsigned long>& Shown() const { return m_shown; }
52
55 void Restore(EventsTableView& view, const db::EventsContainer& events)
56 {
57 const bool active = IsActive(view, events);
58 Reset();
59 if (!active)
60 return;
61 if (m_previous)
63 else
64 view.ClearFilter();
65 }
66
68 void Reset() { m_active = false; }
69
70 private:
71 bool m_active {false};
72 std::uint64_t m_generation {0};
73 std::vector<unsigned long> m_applied;
74 std::optional<std::vector<unsigned long>> m_previous;
75 std::vector<unsigned long> m_shown;
76};
77
78} // namespace ui::qt
Container class for managing collections of LogEvent objects.
High-performance, thread-safe container for managing large collections of LogEvent objects.
Definition EventsContainer.hpp:129
std::uint64_t Generation() const noexcept
Counter bumped whenever existing indices stop referring to the same events: Clear() of a non-empty co...
Definition EventsContainer.hpp:212
Definition DrillDownFilter.hpp:20
std::vector< unsigned long > m_applied
Definition DrillDownFilter.hpp:73
std::vector< unsigned long > m_shown
Definition DrillDownFilter.hpp:75
void Apply(EventsTableView &view, const db::EventsContainer &events, const std::vector< unsigned long > &indices, const std::vector< unsigned long > &shown)
Narrows view to indices. shown: the events the panel shows.
Definition DrillDownFilter.hpp:23
std::uint64_t m_generation
Definition DrillDownFilter.hpp:72
bool m_active
Definition DrillDownFilter.hpp:71
std::optional< std::vector< unsigned long > > m_previous
Definition DrillDownFilter.hpp:74
const std::vector< unsigned long > & Shown() const
The events the panel showed before the drill-down.
Definition DrillDownFilter.hpp:51
void Reset()
Forgets the drill-down (the filter was replaced by someone else).
Definition DrillDownFilter.hpp:68
void Restore(EventsTableView &view, const db::EventsContainer &events)
Definition DrillDownFilter.hpp:55
bool IsActive(const EventsTableView &view, const db::EventsContainer &events) const
Definition DrillDownFilter.hpp:41
Definition EventsTableView.hpp:29
void SetFilteredEvents(const std::vector< unsigned long > &filteredIndices) override
Applies filtered indices so only selected events are shown.
Definition EventsTableView.cpp:219
const std::vector< unsigned long > * GetBaseFilteredIndices() const
Definition EventsTableView.cpp:246
void ClearFilter() override
Clears any active filter; all events become visible via O(1) path.
Definition EventsTableView.cpp:229
Definition ConfigEditorDialog.cpp:19