20#ifndef ORES_QT_ENTITY_CONTROLLER_HPP
21#define ORES_QT_ENTITY_CONTROLLER_HPP
33#include "ores.qt/ClientManager.hpp"
34#include "ores.qt/DetailDialogBase.hpp"
35#include "ores.logging/make_logger.hpp"
39class DetachableMdiSubWindow;
40class EntityListMdiWindow;
54 inline static std::string_view logger_name =
"ores.qt.entity_controller";
56 [[nodiscard]]
static auto& lg() {
58 static auto instance = make_logger(logger_name);
74 QMainWindow* mainWindow,
77 const QString& username,
78 std::string_view eventName = {},
79 QObject* parent =
nullptr);
91 void setUsername(
const QString& username) { username_ = username; }
140 QString
build_window_key(
const QString& windowType,
const QString& identifier)
const;
178 QPoint offset = QPoint(30, 30));
239 void onNotificationReceived(
const QString& eventType,
240 const QDateTime& timestamp,
241 const QStringList& entityIds);
244 void setupEventSubscription();
245 void teardownEventSubscription();
248 QMainWindow* mainWindow_;
261 std::string eventName_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
QMdiSubWindow that can be detached to become a floating window.
Definition DetachableMdiSubWindow.hpp:39
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:54
Abstract base class for entity controllers.
Definition EntityController.hpp:50
void register_detachable_window(DetachableMdiSubWindow *window)
Registers a detachable window and emits detachableWindowCreated signal.
Definition EntityController.cpp:180
virtual EntityListMdiWindow * listWindow() const
Returns the list window for marking as stale on notifications.
Definition EntityController.hpp:209
QMap< QString, DetachableMdiSubWindow * > managed_windows_
Map of active windows indexed by unique key.
Definition EntityController.hpp:254
void setAutoReloadOnSave(bool enabled)
Sets whether the list window should auto-reload after save/delete.
Definition EntityController.hpp:111
void bring_window_to_front(DetachableMdiSubWindow *window)
Activates the specified window, handling detached state.
Definition EntityController.cpp:136
bool autoReloadOnSave_
Whether to auto-reload the list window after save/delete. Default: false.
Definition EntityController.hpp:257
void detachableWindowDestroyed(DetachableMdiSubWindow *window)
Emitted when a detachable window managed by this controller is destroyed.
void untrack_window(const QString &key)
Unregisters a window from tracking.
Definition EntityController.cpp:155
void show_managed_window(DetachableMdiSubWindow *window, DetachableMdiSubWindow *referenceWindow=nullptr, QPoint offset=QPoint(30, 30))
Shows a window in the MDI area, handling detach state.
Definition EntityController.cpp:159
QString build_window_key(const QString &windowType, const QString &identifier) const
Generates a unique key for tracking windows.
Definition EntityController.cpp:120
void statusMessage(const QString &message)
Emitted when a status message should be shown to the user.
void connect_dialog_close(DetailDialogBase *dialog, DetachableMdiSubWindow *window)
Connects a dialog's closeRequested signal to the window's close slot.
Definition EntityController.cpp:175
bool try_reuse_window(const QString &key)
Tries to reuse an existing window if one exists for the key.
Definition EntityController.cpp:125
void handleEntitySaved()
Called when an entity is saved.
Definition EntityController.cpp:192
virtual void closeAllWindows()=0
Closes all windows managed by this controller. Must be implemented by derived classes.
void track_window(const QString &key, DetachableMdiSubWindow *window)
Registers a window for tracking.
Definition EntityController.cpp:150
void detachableWindowCreated(DetachableMdiSubWindow *window)
Emitted when a detachable window is created by this controller.
void setClientManager(ClientManager *clientManager, const QString &username)
Updates the client manager and username (e.g. after re-login).
Definition EntityController.cpp:114
virtual void showListWindow()=0
Shows the main list window for this entity. Must be implemented by derived classes.
virtual void reloadListWindow()=0
Reloads the list window. Must be implemented by derived classes.
void setUsername(const QString &username)
Updates just the username.
Definition EntityController.hpp:91
void errorMessage(const QString &message)
Emitted when an error message should be shown to the user.
void handleEntityDeleted()
Called when an entity is deleted.
Definition EntityController.cpp:198
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:56