LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
FilterProfilesPanel.hpp
Go to the documentation of this file.
1
30#pragma once
31
33#include "Error.hpp"
34#include "Result.hpp"
35
36#include <nlohmann/json.hpp>
37
38#include <QWidget>
39#include <set>
40#include <string>
41#include <vector>
42
43class QLabel;
44class QLineEdit;
45class QListWidget;
46class QPushButton;
47
48namespace ui::qt {
49
50// ---------------------------------------------------------------------------
51// FilterProfile data structure
52// ---------------------------------------------------------------------------
53
82{
83 std::string name;
84
85 // Time range ──────────────────────────────────────────────────────────
88
89 // Actor filter ────────────────────────────────────────────────────────
93 std::vector<std::string> uncheckedActors;
94
95 // Type filter ─────────────────────────────────────────────────────────
98 bool hasTypeFilter {false};
99
102 std::vector<std::string> checkedTypes;
103
104 // ── JSON round-trip ─────────────────────────────────────────────────
106 [[nodiscard]] nlohmann::json ToJson() const;
107
110 [[nodiscard]] static FilterProfile FromJson(const nlohmann::json& j);
111};
112
113// ---------------------------------------------------------------------------
114// FilterProfilesPanel widget
115// ---------------------------------------------------------------------------
116
152{
153 Q_OBJECT
154
155public:
160 explicit FilterProfilesPanel(QWidget* parent = nullptr);
161
172 void StoreProfile(const FilterProfile& profile);
173
178
185 [[nodiscard]] static ExportResult ExportProfileToPath(
186 const FilterProfile& profile, const QString& path);
187
195 [[nodiscard]] static ReadProfilesResult ReadProfilesFile(const QString& path);
196
207 size_t MergeProfiles(std::vector<FilterProfile> incoming, bool overwriteCollisions);
208
210 [[nodiscard]] size_t ProfileCount() const { return m_profiles.size(); }
211
213 [[nodiscard]] bool HasProfile(const std::string& name) const;
214
215signals:
225 void SaveRequested(const QString& name);
226
236
237private slots:
238 void HandleSave();
239 void HandleLoad();
240 void HandleDelete();
242 void HandleExport();
243 void HandleImport();
244
245private:
246 void BuildLayout();
247 void RebuildList();
248 void SaveToFile();
249 void LoadFromFile();
250 static std::string DefaultFilePath();
251
252 std::vector<FilterProfile> m_profiles;
253 QListWidget* m_list {nullptr};
254 QLineEdit* m_nameEdit {nullptr};
255 QPushButton* m_saveBtn {nullptr};
256 QPushButton* m_loadBtn {nullptr};
257 QPushButton* m_deleteBtn {nullptr};
258 QPushButton* m_exportBtn {nullptr};
259 QPushButton* m_importBtn {nullptr};
260 QLabel* m_statusLabel{nullptr};
261};
262
263} // namespace ui::qt
Error handling utilities.
Panel for filtering events by a user-defined timestamp range.
Definition Error.hpp:62
Panel for saving and restoring named filter profiles.
Definition FilterProfilesPanel.hpp:152
void StoreProfile(const FilterProfile &profile)
Stores (or replaces) a profile in the panel and persists it to disk.
Definition FilterProfilesPanel.cpp:245
void LoadFromFile()
Definition FilterProfilesPanel.cpp:563
QPushButton * m_exportBtn
Definition FilterProfilesPanel.hpp:258
QPushButton * m_loadBtn
Definition FilterProfilesPanel.hpp:256
void RebuildList()
Definition FilterProfilesPanel.cpp:517
QListWidget * m_list
Definition FilterProfilesPanel.hpp:253
size_t MergeProfiles(std::vector< FilterProfile > incoming, bool overwriteCollisions)
Merges incoming into this panel's profile list and persists the result to internal storage.
Definition FilterProfilesPanel.cpp:477
void HandleImport()
Definition FilterProfilesPanel.cpp:369
void HandleLoad()
Definition FilterProfilesPanel.cpp:304
QPushButton * m_deleteBtn
Definition FilterProfilesPanel.hpp:257
void SaveToFile()
Definition FilterProfilesPanel.cpp:537
void HandleSelectionChanged()
Definition FilterProfilesPanel.cpp:336
void SaveRequested(const QString &name)
Emitted when the user clicks Save current state.
bool HasProfile(const std::string &name) const
Whether a profile with the given name currently exists.
Definition FilterProfilesPanel.cpp:507
size_t ProfileCount() const
Number of profiles currently held by the panel.
Definition FilterProfilesPanel.hpp:210
void ProfileLoadRequested(const FilterProfile &profile)
Emitted when the user selects a profile and clicks Load (or double-clicks the list item).
void HandleSave()
Definition FilterProfilesPanel.cpp:277
void BuildLayout()
Definition FilterProfilesPanel.cpp:149
QLineEdit * m_nameEdit
Definition FilterProfilesPanel.hpp:254
void HandleExport()
Definition FilterProfilesPanel.cpp:344
void HandleDelete()
Definition FilterProfilesPanel.cpp:317
std::vector< FilterProfile > m_profiles
Definition FilterProfilesPanel.hpp:252
static ReadProfilesResult ReadProfilesFile(const QString &path)
Reads and parses a .filters.json file (one or more profiles).
Definition FilterProfilesPanel.cpp:442
QLabel * m_statusLabel
Definition FilterProfilesPanel.hpp:260
QPushButton * m_saveBtn
Definition FilterProfilesPanel.hpp:255
static ExportResult ExportProfileToPath(const FilterProfile &profile, const QString &path)
Writes profile to path as a single-entry .filters.json array.
Definition FilterProfilesPanel.cpp:417
QPushButton * m_importBtn
Definition FilterProfilesPanel.hpp:259
static std::string DefaultFilePath()
Definition FilterProfilesPanel.cpp:612
Definition Result.hpp:15
Definition ConfigEditorDialog.cpp:19
Snapshot of all active filter state that can be named and persisted.
Definition FilterProfilesPanel.hpp:82
static FilterProfile FromJson(const nlohmann::json &j)
Definition FilterProfilesPanel.cpp:112
bool hasTypeFilter
Definition FilterProfilesPanel.hpp:98
TimeRangeFilterPanel::State timeRange
Time range filter state; active=false means "no time filter".
Definition FilterProfilesPanel.hpp:87
std::vector< std::string > checkedTypes
Definition FilterProfilesPanel.hpp:102
std::string name
Human-readable profile name (used as the unique identifier)
Definition FilterProfilesPanel.hpp:83
nlohmann::json ToJson() const
Serialises the profile to a JSON object.
Definition FilterProfilesPanel.cpp:88
std::vector< std::string > uncheckedActors
Definition FilterProfilesPanel.hpp:93
Plain-data snapshot of the panel state — used by filter profiles.
Definition TimeRangeFilterPanel.hpp:68