Panel for saving and restoring named filter profiles.
More...
#include <FilterProfilesPanel.hpp>
|
| void | SaveRequested (const QString &name) |
| | Emitted when the user clicks Save current state.
|
| |
| void | ProfileLoadRequested (const FilterProfile &profile) |
| | Emitted when the user selects a profile and clicks Load (or double-clicks the list item).
|
| |
|
| | FilterProfilesPanel (QWidget *parent=nullptr) |
| | Constructs the panel, builds its layout, and loads persisted profiles.
|
| |
| void | StoreProfile (const FilterProfile &profile) |
| | Stores (or replaces) a profile in the panel and persists it to disk.
|
| |
| size_t | MergeProfiles (std::vector< FilterProfile > incoming, bool overwriteCollisions) |
| | Merges incoming into this panel's profile list and persists the result to internal storage.
|
| |
| size_t | ProfileCount () const |
| | Number of profiles currently held by the panel.
|
| |
| bool | HasProfile (const std::string &name) const |
| | Whether a profile with the given name currently exists.
|
| |
Panel for saving and restoring named filter profiles.
Profiles capture the complete filter state (time range, actor checks, type filter) and persist them to a JSON file in the app config directory.
- Responsibility split
- The panel is deliberately kept thin. It knows nothing about the other filter panels. All cross-panel coordination is delegated to MainWindow via the two signals below.
- Persistence
- Profiles are stored in
<appdata>/filter_profiles.json (one JSON array). The file is loaded in the constructor and saved after every mutating operation (save / delete).
- Double-click shortcut
- Double-clicking a list item is equivalent to clicking Load.
- Export / Import
- Export writes the selected profile to a user-chosen
*.filters.json file (same JSON array format as internal storage, just one entry) for sharing with teammates. Import reads a *.filters.json file (one or more profiles) and merges it into the current list, prompting once if any imported name collides with an existing profile.
- Testability
- The QFileDialog calls that pick the export/import path live only in the
HandleExport() / HandleImport() slots. The actual file I/O (ExportProfileToPath(), ReadProfilesFile()) and the merge logic (MergeProfiles()) are separate public methods that take a path or a profile list directly, so they can be exercised in tests without going through a native file picker.
◆ ExportResult
Result of exporting a single profile to a file.
◆ ReadProfilesResult
Result of reading a .filters.json file: the profiles it contains.
◆ FilterProfilesPanel()
| ui::qt::FilterProfilesPanel::FilterProfilesPanel |
( |
QWidget * |
parent = nullptr | ) |
|
|
explicit |
Constructs the panel, builds its layout, and loads persisted profiles.
- Parameters
-
| parent | Optional Qt parent widget. |
◆ BuildLayout()
| void ui::qt::FilterProfilesPanel::BuildLayout |
( |
| ) |
|
|
private |
◆ DefaultFilePath()
| std::string ui::qt::FilterProfilesPanel::DefaultFilePath |
( |
| ) |
|
|
staticprivate |
◆ ExportProfileToPath()
Writes profile to path as a single-entry .filters.json array.
Pure I/O — does not touch this panel's own profile list or persisted storage, so it can be tested directly with a temp path.
◆ HandleDelete
| void ui::qt::FilterProfilesPanel::HandleDelete |
( |
| ) |
|
|
privateslot |
◆ HandleExport
| void ui::qt::FilterProfilesPanel::HandleExport |
( |
| ) |
|
|
privateslot |
◆ HandleImport
| void ui::qt::FilterProfilesPanel::HandleImport |
( |
| ) |
|
|
privateslot |
◆ HandleLoad
| void ui::qt::FilterProfilesPanel::HandleLoad |
( |
| ) |
|
|
privateslot |
◆ HandleSave
| void ui::qt::FilterProfilesPanel::HandleSave |
( |
| ) |
|
|
privateslot |
◆ HandleSelectionChanged
| void ui::qt::FilterProfilesPanel::HandleSelectionChanged |
( |
| ) |
|
|
privateslot |
◆ HasProfile()
| bool ui::qt::FilterProfilesPanel::HasProfile |
( |
const std::string & |
name | ) |
const |
Whether a profile with the given name currently exists.
◆ LoadFromFile()
| void ui::qt::FilterProfilesPanel::LoadFromFile |
( |
| ) |
|
|
private |
◆ MergeProfiles()
| size_t ui::qt::FilterProfilesPanel::MergeProfiles |
( |
std::vector< FilterProfile > |
incoming, |
|
|
bool |
overwriteCollisions |
|
) |
| |
Merges incoming into this panel's profile list and persists the result to internal storage.
Profiles whose name matches one already in the list are skipped unless overwriteCollisions is true, in which case the existing profile is replaced in place.
- Returns
- The number of profiles actually added or overwritten.
◆ ProfileCount()
| size_t ui::qt::FilterProfilesPanel::ProfileCount |
( |
| ) |
const |
|
inline |
Number of profiles currently held by the panel.
◆ ProfileLoadRequested
| void ui::qt::FilterProfilesPanel::ProfileLoadRequested |
( |
const FilterProfile & |
profile | ) |
|
|
signal |
Emitted when the user selects a profile and clicks Load (or double-clicks the list item).
The receiver (MainWindow) should apply profile to all filter panels.
- Parameters
-
| profile | The selected profile to restore. |
◆ ReadProfilesFile()
Reads and parses a .filters.json file (one or more profiles).
Pure I/O — does not touch this panel's own state. Entries with an empty name or a name duplicated within the file are silently skipped (matches the same rule LoadFromFile() applies to internal storage).
◆ RebuildList()
| void ui::qt::FilterProfilesPanel::RebuildList |
( |
| ) |
|
|
private |
◆ SaveRequested
| void ui::qt::FilterProfilesPanel::SaveRequested |
( |
const QString & |
name | ) |
|
|
signal |
Emitted when the user clicks Save current state.
The receiver (MainWindow) should gather filter state from all panels, build a FilterProfile, set its name to name, and call StoreProfile().
- Parameters
-
| name | The profile name entered by the user (already trimmed). |
◆ SaveToFile()
| void ui::qt::FilterProfilesPanel::SaveToFile |
( |
| ) |
|
|
private |
◆ StoreProfile()
| void ui::qt::FilterProfilesPanel::StoreProfile |
( |
const FilterProfile & |
profile | ) |
|
Stores (or replaces) a profile in the panel and persists it to disk.
Called by MainWindow after it has gathered state from all filter panels in response to the SaveRequested signal. If a profile with the same name already exists it is replaced in-place; otherwise the profile is appended.
- Parameters
-
| profile | The complete filter state to persist. |
◆ m_deleteBtn
| QPushButton* ui::qt::FilterProfilesPanel::m_deleteBtn {nullptr} |
|
private |
◆ m_exportBtn
| QPushButton* ui::qt::FilterProfilesPanel::m_exportBtn {nullptr} |
|
private |
◆ m_importBtn
| QPushButton* ui::qt::FilterProfilesPanel::m_importBtn {nullptr} |
|
private |
◆ m_list
| QListWidget* ui::qt::FilterProfilesPanel::m_list {nullptr} |
|
private |
◆ m_loadBtn
| QPushButton* ui::qt::FilterProfilesPanel::m_loadBtn {nullptr} |
|
private |
◆ m_nameEdit
| QLineEdit* ui::qt::FilterProfilesPanel::m_nameEdit {nullptr} |
|
private |
◆ m_profiles
| std::vector<FilterProfile> ui::qt::FilterProfilesPanel::m_profiles |
|
private |
◆ m_saveBtn
| QPushButton* ui::qt::FilterProfilesPanel::m_saveBtn {nullptr} |
|
private |
◆ m_statusLabel
| QLabel* ui::qt::FilterProfilesPanel::m_statusLabel {nullptr} |
|
private |
The documentation for this class was generated from the following files: