20#ifndef ORES_QT_ENTITY_CONTROLLER_HPP
21#define ORES_QT_ENTITY_CONTROLLER_HPP
34#include "ores.qt/ClientManager.hpp"
35#include "ores.qt/DetailDialogBase.hpp"
36#include "ores.logging/make_logger.hpp"
37#include "ores.qt/export.hpp"
41class DetachableMdiSubWindow;
42class EntityListMdiWindow;
56 inline static std::string_view logger_name =
"ores.qt.entity_controller";
58 [[nodiscard]]
static auto& lg() {
60 static auto instance = make_logger(logger_name);
76 QMainWindow* mainWindow,
79 const QString& username,
80 std::string_view eventName = {},
81 QObject* parent =
nullptr);
88 void setClientManager(
ClientManager* clientManager,
const QString& username);
93 void setUsername(
const QString& username) { username_ = username; }
142 QString build_window_key(
const QString& windowType,
const QString& identifier)
const;
149 bool try_reuse_window(
const QString& key);
164 void untrack_window(
const QString& key);
180 QPoint offset = QPoint(30, 30));
225 void handleEntitySaved();
233 void handleEntityDeleted();
241 void onNotificationReceived(
const QString& eventType,
242 const QDateTime& timestamp,
243 const QStringList& entityIds,
244 const QString& tenantId);
247 void setupEventSubscription();
248 void teardownEventSubscription();
251 QMainWindow* mainWindow_;
253 QPointer<ClientManager> clientManager_;
260 bool autoReloadOnSave_ =
false;
264 std::string eventName_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
QMdiSubWindow that can be detached to become a floating window.
Definition DetachableMdiSubWindow.hpp:40
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:75
Abstract base class for entity controllers.
Definition EntityController.hpp:52
virtual EntityListMdiWindow * listWindow() const
Returns the list window for marking as stale on notifications.
Definition EntityController.hpp:211
QMap< QString, DetachableMdiSubWindow * > managed_windows_
Map of active windows indexed by unique key.
Definition EntityController.hpp:257
void setAutoReloadOnSave(bool enabled)
Sets whether the list window should auto-reload after save/delete.
Definition EntityController.hpp:113
void detachableWindowDestroyed(DetachableMdiSubWindow *window)
Emitted when a detachable window managed by this controller is destroyed.
void statusMessage(const QString &message)
Emitted when a status message should be shown to the user.
virtual void closeAllWindows()=0
Closes all windows managed by this controller. Must be implemented by derived classes.
void detachableWindowCreated(DetachableMdiSubWindow *window)
Emitted when a detachable window is created by this controller.
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:93
void errorMessage(const QString &message)
Emitted when an error message should be shown to the user.
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:63