ORE Studio 0.0.4
Loading...
Searching...
No Matches
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EntityController Class Referenceabstract

Abstract base class for entity controllers. More...

#include <EntityController.hpp>

Inheritance diagram for EntityController:
Inheritance graph
Collaboration diagram for EntityController:
Collaboration graph

Signals

void statusMessage (const QString &message)
 Emitted when a status message should be shown to the user.
 
void errorMessage (const QString &message)
 Emitted when an error message should be shown to the user.
 

Public Member Functions

 EntityController (QMainWindow *mainWindow, QMdiArea *mdiArea, ClientManager *clientManager, const QString &username, QObject *parent=nullptr)
 Constructs an entity controller.
 
void setClientManager (ClientManager *clientManager, const QString &username)
 Updates the client manager and username (e.g. after re-login).
 
void setUsername (const QString &username)
 Updates just the username.
 
virtual void showListWindow ()=0
 Shows the main list window for this entity. Must be implemented by derived classes.
 
virtual void closeAllWindows ()=0
 Closes all windows managed by this controller. Must be implemented by derived classes.
 

Protected Member Functions

QString build_window_key (const QString &windowType, const QString &identifier) const
 Generates a unique key for tracking windows.
 
bool try_reuse_window (const QString &key)
 Tries to reuse an existing window if one exists for the key.
 
void bring_window_to_front (DetachableMdiSubWindow *window)
 Activates the specified window, handling detached state.
 
void track_window (const QString &key, DetachableMdiSubWindow *window)
 Registers a window for tracking.
 
void untrack_window (const QString &key)
 Unregisters a window from tracking.
 

Protected Attributes

QMainWindow * mainWindow_
 
QMdiArea * mdiArea_
 
ClientManagerclientManager_
 
QString username_
 
QMap< QString, DetachableMdiSubWindow * > managed_windows_
 Map of active windows indexed by unique key.
 

Detailed Description

Abstract base class for entity controllers.

Entity controllers manage the lifecycle of windows related to specific data entities (like currencies, accounts, etc.). This base class provides common functionality for managing windows, tracking them for reuse, and handling the client connection.

Constructor & Destructor Documentation

◆ EntityController()

EntityController ( QMainWindow *  mainWindow,
QMdiArea *  mdiArea,
ClientManager clientManager,
const QString &  username,
QObject *  parent = nullptr 
)

Constructs an entity controller.

Parameters
mainWindowParent main window.
mdiAreaMDI area for displaying windows.
clientManagerClient manager for network operations.
usernameCurrently logged in user.
parentQObject parent.

Member Function Documentation

◆ showListWindow()

virtual void showListWindow ( )
pure virtual

Shows the main list window for this entity. Must be implemented by derived classes.

Implemented in CurrencyController.

◆ closeAllWindows()

virtual void closeAllWindows ( )
pure virtual

Closes all windows managed by this controller. Must be implemented by derived classes.

Implemented in CurrencyController.

◆ build_window_key()

QString build_window_key ( const QString &  windowType,
const QString &  identifier 
) const
protected

Generates a unique key for tracking windows.

Parameters
windowTypeType of window (e.g., "details", "history").
identifierUnique ID of the entity (e.g., ISO code).
Returns
A string key for the window map.

◆ try_reuse_window()

bool try_reuse_window ( const QString &  key)
protected

Tries to reuse an existing window if one exists for the key.

Parameters
keyUnique window key.
Returns
true if window was found and activated, false otherwise.