|
ORE Studio 0.0.4
|
Abstract base class for entity controllers. More...
#include <EntityController.hpp>


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. | |
| void | detachableWindowCreated (DetachableMdiSubWindow *window) |
| Emitted when a detachable window is created by this controller. | |
| void | detachableWindowDestroyed (DetachableMdiSubWindow *window) |
| Emitted when a detachable window managed by this controller is destroyed. | |
Public Member Functions | |
| EntityController (QMainWindow *mainWindow, QMdiArea *mdiArea, ClientManager *clientManager, const QString &username, std::string_view eventName={}, 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. | |
| void | setAutoReloadOnSave (bool enabled) |
| Sets whether the list window should auto-reload after save/delete. | |
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. | |
| void | show_managed_window (DetachableMdiSubWindow *window, DetachableMdiSubWindow *referenceWindow=nullptr, QPoint offset=QPoint(30, 30)) |
| Shows a window in the MDI area, handling detach state. | |
| void | connect_dialog_close (DetailDialogBase *dialog, DetachableMdiSubWindow *window) |
| Connects a dialog's closeRequested signal to the window's close slot. | |
| void | register_detachable_window (DetachableMdiSubWindow *window) |
| Registers a detachable window and emits detachableWindowCreated signal. | |
| virtual EntityListMdiWindow * | listWindow () const |
| Returns the list window for marking as stale on notifications. | |
| virtual void | reloadListWindow ()=0 |
| Reloads the list window. Must be implemented by derived classes. | |
| void | handleEntitySaved () |
| Called when an entity is saved. | |
| void | handleEntityDeleted () |
| Called when an entity is deleted. | |
Protected Attributes | |
| QMainWindow * | mainWindow_ |
| QMdiArea * | mdiArea_ |
| ClientManager * | clientManager_ |
| QString | username_ |
| QMap< QString, DetachableMdiSubWindow * > | managed_windows_ |
| Map of active windows indexed by unique key. | |
| bool | autoReloadOnSave_ = false |
| Whether to auto-reload the list window after save/delete. Default: false. | |
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.
| EntityController | ( | QMainWindow * | mainWindow, |
| QMdiArea * | mdiArea, | ||
| ClientManager * | clientManager, | ||
| const QString & | username, | ||
| std::string_view | eventName = {}, |
||
| QObject * | parent = nullptr |
||
| ) |
Constructs an entity controller.
| mainWindow | Parent main window. |
| mdiArea | MDI area for displaying windows. |
| clientManager | Client manager for network operations. |
| username | Currently logged in user. |
| eventName | Event name to subscribe to for change notifications. Pass empty string_view to disable event subscription. |
| parent | QObject parent. |
|
pure virtual |
Shows the main list window for this entity. Must be implemented by derived classes.
Implemented in AccountController, CatalogController, ChangeReasonCategoryController, ChangeReasonController, CountryController, CurrencyController, DatasetBundleController, FeatureFlagController, NatureDimensionController, OriginDimensionController, RoleController, and TreatmentDimensionController.
|
pure virtual |
Closes all windows managed by this controller. Must be implemented by derived classes.
Implemented in AccountController, CatalogController, ChangeReasonCategoryController, ChangeReasonController, CountryController, CurrencyController, DatasetBundleController, FeatureFlagController, NatureDimensionController, OriginDimensionController, RoleController, and TreatmentDimensionController.
| void setAutoReloadOnSave | ( | bool | enabled | ) |
Sets whether the list window should auto-reload after save/delete.
Default is false (no auto-reload). This can be used to implement a user-configurable auto-reload preference in the future.
|
signal |
Emitted when a detachable window is created by this controller.
MainWindow connects to this signal to track all detachable windows for the "Reattach All Windows" functionality.

|
protected |
Generates a unique key for tracking windows.
| windowType | Type of window (e.g., "details", "history"). |
| identifier | Unique ID of the entity (e.g., ISO code). |
|
protected |
Tries to reuse an existing window if one exists for the key.
| key | Unique window key. |
|
protected |
Shows a window in the MDI area, handling detach state.
This method adds the window to the MDI area, removes the maximize button, adjusts the size, and shows the window. If a reference window is provided and is detached, the new window will also be detached and positioned relative to the reference window.
| window | The window to show. |
| referenceWindow | Optional window to follow detach state from. |
| offset | Position offset when detaching (default 30,30). |
|
protected |
Connects a dialog's closeRequested signal to the window's close slot.
Use this after creating a detail dialog to wire up decoupled window closing. The dialog can then call requestClose() instead of parentWidget()->close().
| dialog | The detail dialog. |
| window | The container window to close when the dialog requests it. |
|
protected |
Registers a detachable window and emits detachableWindowCreated signal.
Call this when creating a new detachable window. Also sets up the destroyed signal connection to automatically emit detachableWindowDestroyed.
| window | The window to register. |

|
protectedvirtual |
Returns the list window for marking as stale on notifications.
Override in derived classes to return the list window pointer. This is used by the base class onNotificationReceived to call markAsStale().
Reimplemented in CatalogController, DatasetBundleController, NatureDimensionController, OriginDimensionController, and TreatmentDimensionController.
|
protectedpure virtual |
Reloads the list window. Must be implemented by derived classes.
Implemented in AccountController, CatalogController, ChangeReasonCategoryController, ChangeReasonController, CountryController, CurrencyController, DatasetBundleController, FeatureFlagController, NatureDimensionController, OriginDimensionController, RoleController, and TreatmentDimensionController.

|
protected |
Called when an entity is saved.
If autoReloadOnSave_ is true, this will reload the list window. Call this from derived class signal handlers connected to entity saved signals.
|
protected |
Called when an entity is deleted.
If autoReloadOnSave_ is true, this will reload the list window. Call this from derived class signal handlers connected to entity deleted signals.