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

Pure C++ presenter that orchestrates main-window interactions independently of the underlying widget toolkit. More...

#include <MainWindowPresenter.hpp>

Inheritance diagram for ui::MainWindowPresenter:
Inheritance graph
Collaboration diagram for ui::MainWindowPresenter:
Collaboration graph

Public Member Functions

 MainWindowPresenter (IMainWindowView &view, mvc::IController &controller, db::EventsContainer &events, ui::ISearchResultsView &searchResults, ui::IEventsListView *eventsListView, ui::ITypeFilterView *typeFilterView, ui::IItemDetailsView *itemDetailsView)
 
void PerformSearch ()
 Runs the search pipeline using the current UI state.
 
void LoadLogFile (const std::filesystem::path &path)
 Parses and loads a log file, updating shared UI state.
 
void LoadLogFile (std::unique_ptr< parser::IDataParser > parser, const std::filesystem::path &path)
 Loads a log file using a pre-configured parser instance.
 
void MergeLogFile (std::unique_ptr< parser::IDataParser > parser, const std::filesystem::path &path, const std::string &existingAlias, const std::string &newFileAlias, const std::string &timestampField="timestamp")
 Parses and merges a log file with existing data, sorted by timestamp.
 
bool IsParsing () const
 Allows views to query whether parsing is active.
 
void UpdateTypeFilters ()
 Rebuilds the available type filters from current events.
 
void ApplySelectedTypeFilters ()
 Applies the selected type filters to the event list.
 
void SetItemDetailsVisible (bool visible)
 Shows or hides the item details view.
 
void ProgressUpdated () override
 Called when parsing progress is updated.
 
void NewEventFound (db::LogEvent &&event) override
 Called when a new event is discovered during parsing.
 
void NewEventBatchFound (std::vector< std::pair< int, db::LogEvent::EventItems > > &&eventBatch) override
 Called when a batch of new events is discovered during parsing.
 

Private Member Functions

void clearAllData ()
 
void RunParserAsync (std::unique_ptr< parser::IDataParser > parser, const std::filesystem::path &path, const std::string &previousStatus)
 

Static Private Member Functions

static int ClampToInt (std::size_t value)
 

Private Attributes

IMainWindowView & m_view
 
mvc::IController & m_controller
 
db::EventsContainer & m_events
 
ui::ISearchResultsView & m_searchResultsView
 
ui::IEventsListView * m_eventsListView {nullptr}
 
ui::ITypeFilterView * m_typeFilterView {nullptr}
 
ui::IItemDetailsView * m_itemDetailsView {nullptr}
 
bool m_isParsing {false}
 
bool m_progressConfigured {false}
 

Detailed Description

Pure C++ presenter that orchestrates main-window interactions independently of the underlying widget toolkit.

Constructor & Destructor Documentation

◆ MainWindowPresenter()

ui::MainWindowPresenter::MainWindowPresenter ( IMainWindowView &  view,
mvc::IController &  controller,
db::EventsContainer &  events,
ui::ISearchResultsView &  searchResults,
ui::IEventsListView *  eventsListView,
ui::ITypeFilterView *  typeFilterView,
ui::IItemDetailsView *  itemDetailsView 
)

Member Function Documentation

◆ ApplySelectedTypeFilters()

void ui::MainWindowPresenter::ApplySelectedTypeFilters ( )

Applies the selected type filters to the event list.

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

◆ ClampToInt()

int ui::MainWindowPresenter::ClampToInt ( std::size_t  value)
staticprivate
Here is the caller graph for this function:

◆ clearAllData()

void ui::MainWindowPresenter::clearAllData ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsParsing()

bool ui::MainWindowPresenter::IsParsing ( ) const
inline

Allows views to query whether parsing is active.

◆ LoadLogFile() [1/2]

void ui::MainWindowPresenter::LoadLogFile ( const std::filesystem::path &  path)

Parses and loads a log file, updating shared UI state.

Here is the call graph for this function:

◆ LoadLogFile() [2/2]

void ui::MainWindowPresenter::LoadLogFile ( std::unique_ptr< parser::IDataParser >  parser,
const std::filesystem::path &  path 
)

Loads a log file using a pre-configured parser instance.

Use this overload when the caller needs to pass a parser with custom construction-time parameters (e.g. AscParser with a DBC path). The parser must not yet have any observers registered.

Here is the call graph for this function:

◆ MergeLogFile()

void ui::MainWindowPresenter::MergeLogFile ( std::unique_ptr< parser::IDataParser >  parser,
const std::filesystem::path &  path,
const std::string &  existingAlias,
const std::string &  newFileAlias,
const std::string &  timestampField = "timestamp" 
)

Parses and merges a log file with existing data, sorted by timestamp.

Parameters
parserParser for the file (built by the caller, like LoadLogFile, so .txt/.log/.asc/.evl and user-chosen types are honoured)
pathPath to the log file to merge
existingAliasUser-friendly name for existing log data
newFileAliasUser-friendly name for new log file
timestampFieldName of the field containing timestamps
Here is the call graph for this function:

◆ NewEventBatchFound()

void ui::MainWindowPresenter::NewEventBatchFound ( std::vector< std::pair< int, db::LogEvent::EventItems > > &&  eventBatch)
overridevirtual

Called when a batch of new events is discovered during parsing.

For performance reasons, parsers may collect multiple events before notifying observers. This method delivers a batch of events at once.

Parameters
eventBatchVector of (id, items) pairs representing the events
Note
This method is preferred over NewEventFound for high-throughput scenarios

Implements parser::IDataParserObserver.

Here is the call graph for this function:

◆ NewEventFound()

void ui::MainWindowPresenter::NewEventFound ( db::LogEvent &&  event)
overridevirtual

Called when a new event is discovered during parsing.

Parameters
eventThe newly parsed LogEvent (moved to avoid copying)
Note
Implementations should be efficient as this may be called very frequently during parsing of large files

Implements parser::IDataParserObserver.

◆ PerformSearch()

void ui::MainWindowPresenter::PerformSearch ( )

Runs the search pipeline using the current UI state.

Here is the call graph for this function:

◆ ProgressUpdated()

void ui::MainWindowPresenter::ProgressUpdated ( )
overridevirtual

Called when parsing progress is updated.

This method is invoked periodically during parsing operations to allow observers to update progress indicators in the user interface.

Note
Implementations should be efficient as this may be called frequently

Implements parser::IDataParserObserver.

Here is the call graph for this function:

◆ RunParserAsync()

void ui::MainWindowPresenter::RunParserAsync ( std::unique_ptr< parser::IDataParser >  parser,
const std::filesystem::path &  path,
const std::string &  previousStatus 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetItemDetailsVisible()

void ui::MainWindowPresenter::SetItemDetailsVisible ( bool  visible)

Shows or hides the item details view.

Here is the call graph for this function:

◆ UpdateTypeFilters()

void ui::MainWindowPresenter::UpdateTypeFilters ( )

Rebuilds the available type filters from current events.

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

Member Data Documentation

◆ m_controller

mvc::IController& ui::MainWindowPresenter::m_controller
private

◆ m_events

db::EventsContainer& ui::MainWindowPresenter::m_events
private

◆ m_eventsListView

ui::IEventsListView* ui::MainWindowPresenter::m_eventsListView {nullptr}
private

◆ m_isParsing

bool ui::MainWindowPresenter::m_isParsing {false}
private

◆ m_itemDetailsView

ui::IItemDetailsView* ui::MainWindowPresenter::m_itemDetailsView {nullptr}
private

◆ m_progressConfigured

bool ui::MainWindowPresenter::m_progressConfigured {false}
private

◆ m_searchResultsView

ui::ISearchResultsView& ui::MainWindowPresenter::m_searchResultsView
private

◆ m_typeFilterView

ui::ITypeFilterView* ui::MainWindowPresenter::m_typeFilterView {nullptr}
private

◆ m_view

IMainWindowView& ui::MainWindowPresenter::m_view
private

The documentation for this class was generated from the following files: