ORE Studio 0.0.4
Loading...
Searching...
No Matches
BookStatusMdiWindow.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_BOOK_STATUS_MDI_WINDOW_HPP
21#define ORES_QT_BOOK_STATUS_MDI_WINDOW_HPP
22
23#include <QToolBar>
24#include <QTableView>
25#include <QSortFilterProxyModel>
26#include "ores.qt/EntityListMdiWindow.hpp"
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/ClientBookStatusModel.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.refdata.api/domain/book_status.hpp"
31
32namespace ores::qt {
33
41 Q_OBJECT
42
43private:
44 inline static std::string_view logger_name =
45 "ores.qt.book_status_mdi_window";
46
47 [[nodiscard]] static auto& lg() {
48 using namespace ores::logging;
49 static auto instance = make_logger(logger_name);
50 return instance;
51 }
52
53public:
54 explicit BookStatusMdiWindow(
55 ClientManager* clientManager,
56 const QString& username,
57 QWidget* parent = nullptr);
58 ~BookStatusMdiWindow() override = default;
59
60public slots:
61 void doReload() override;
62
63signals:
64 void statusChanged(const QString& message);
65 void errorOccurred(const QString& error_message);
66 void showStatusDetails(const refdata::domain::book_status& status);
67 void addNewRequested();
68 void statusDeleted(const QString& code);
69 void showStatusHistory(const refdata::domain::book_status& status);
70
71public slots:
72 void addNew();
73 void editSelected();
74 void deleteSelected();
75 void viewHistorySelected();
76
77private slots:
78 void onDataLoaded();
79 void onLoadError(const QString& error_message, const QString& details = {});
80 void onSelectionChanged();
81 void onDoubleClicked(const QModelIndex& index);
82
83protected:
84 QString normalRefreshTooltip() const override {
85 return tr("Refresh book statuses");
86 }
87
88private:
89 void setupUi();
90 void setupToolbar();
91 void setupTable();
92 void setupConnections();
93 void updateActionStates();
94
95 ClientManager* clientManager_;
96 QString username_;
97
98 QToolBar* toolbar_;
99 QTableView* tableView_;
100 ClientBookStatusModel* model_;
101 QSortFilterProxyModel* proxyModel_;
102
103 // Toolbar actions
104 QAction* reloadAction_;
105 QAction* addAction_;
106 QAction* editAction_;
107 QAction* deleteAction_;
108 QAction* historyAction_;
109};
110
111}
112
113#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
MDI window for displaying and managing book statuses.
Definition BookStatusMdiWindow.hpp:40
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition BookStatusMdiWindow.hpp:84
Model for displaying book statuses fetched from the server.
Definition ClientBookStatusModel.hpp:43
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:62
Lifecycle states for book records.
Definition book_status.hpp:38