LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
ui::qt::FilterProfilesPanel Class Reference

Panel for saving and restoring named filter profiles. More...

#include <FilterProfilesPanel.hpp>

Inheritance diagram for ui::qt::FilterProfilesPanel:
Inheritance graph
Collaboration diagram for ui::qt::FilterProfilesPanel:
Collaboration graph

Public Types

using ExportResult = util::Result< std::monostate, error::Error >
 Result of exporting a single profile to a file.
 
using ReadProfilesResult = util::Result< std::vector< FilterProfile >, error::Error >
 Result of reading a .filters.json file: the profiles it contains.
 

Signals

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).
 

Public Member Functions

 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.
 

Static Public Member Functions

static ExportResult ExportProfileToPath (const FilterProfile &profile, const QString &path)
 Writes profile to path as a single-entry .filters.json array.
 
static ReadProfilesResult ReadProfilesFile (const QString &path)
 Reads and parses a .filters.json file (one or more profiles).
 

Private Slots

void HandleSave ()
 
void HandleLoad ()
 
void HandleDelete ()
 
void HandleSelectionChanged ()
 
void HandleExport ()
 
void HandleImport ()
 

Private Member Functions

void BuildLayout ()
 
void RebuildList ()
 
void SaveToFile ()
 
void LoadFromFile ()
 

Static Private Member Functions

static std::string DefaultFilePath ()
 

Private Attributes

std::vector< FilterProfile > m_profiles
 
QListWidget * m_list {nullptr}
 
QLineEdit * m_nameEdit {nullptr}
 
QPushButton * m_saveBtn {nullptr}
 
QPushButton * m_loadBtn {nullptr}
 
QPushButton * m_deleteBtn {nullptr}
 
QPushButton * m_exportBtn {nullptr}
 
QPushButton * m_importBtn {nullptr}
 
QLabel * m_statusLabel {nullptr}
 

Detailed Description

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.

Member Typedef Documentation

◆ ExportResult

Result of exporting a single profile to a file.

◆ ReadProfilesResult

Result of reading a .filters.json file: the profiles it contains.

Constructor & Destructor Documentation

◆ FilterProfilesPanel()

ui::qt::FilterProfilesPanel::FilterProfilesPanel ( QWidget *  parent = nullptr)
explicit

Constructs the panel, builds its layout, and loads persisted profiles.

Parameters
parentOptional Qt parent widget.
Here is the call graph for this function:

Member Function Documentation

◆ BuildLayout()

void ui::qt::FilterProfilesPanel::BuildLayout ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultFilePath()

std::string ui::qt::FilterProfilesPanel::DefaultFilePath ( )
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExportProfileToPath()

FilterProfilesPanel::ExportResult ui::qt::FilterProfilesPanel::ExportProfileToPath ( const FilterProfile &  profile,
const QString &  path 
)
static

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleDelete

void ui::qt::FilterProfilesPanel::HandleDelete ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleExport

void ui::qt::FilterProfilesPanel::HandleExport ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleImport

void ui::qt::FilterProfilesPanel::HandleImport ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleLoad

void ui::qt::FilterProfilesPanel::HandleLoad ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleSave

void ui::qt::FilterProfilesPanel::HandleSave ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleSelectionChanged

void ui::qt::FilterProfilesPanel::HandleSelectionChanged ( )
privateslot
Here is the caller graph for this function:

◆ HasProfile()

bool ui::qt::FilterProfilesPanel::HasProfile ( const std::string &  name) const

Whether a profile with the given name currently exists.

Here is the caller graph for this function:

◆ LoadFromFile()

void ui::qt::FilterProfilesPanel::LoadFromFile ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
profileThe selected profile to restore.
Here is the caller graph for this function:

◆ ReadProfilesFile()

FilterProfilesPanel::ReadProfilesResult ui::qt::FilterProfilesPanel::ReadProfilesFile ( const QString &  path)
static

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).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RebuildList()

void ui::qt::FilterProfilesPanel::RebuildList ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
nameThe profile name entered by the user (already trimmed).
Here is the caller graph for this function:

◆ SaveToFile()

void ui::qt::FilterProfilesPanel::SaveToFile ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
profileThe complete filter state to persist.
Here is the call graph for this function:

Member Data Documentation

◆ 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: