ORE Studio 0.0.4
Loading...
Searching...
No Matches
EntityListMdiWindow.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 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_ENTITY_LIST_MDI_WINDOW_HPP
21#define ORES_QT_ENTITY_LIST_MDI_WINDOW_HPP
22
23#include <string_view>
24#include <QWidget>
25#include <QAction>
26#include <QTimer>
27#include <QIcon>
28#include <QCloseEvent>
29#include <QProgressBar>
30#include <QSplitter>
31#include <QTableView>
32#include "ores.logging/make_logger.hpp"
33#include "ores.qt/AbstractClientModel.hpp"
34#include "ores.qt/export.hpp"
35
36namespace ores::qt {
37
63class ORES_QT_API EntityListMdiWindow : public QWidget {
64 Q_OBJECT
65
66private:
67 inline static std::string_view logger_name = "ores.qt.entity_list_mdi_window";
68
69 [[nodiscard]] static auto& lg() {
70 using namespace ores::logging;
71 static auto instance = make_logger(logger_name);
72 return instance;
73 }
74
75public:
76 explicit EntityListMdiWindow(QWidget* parent = nullptr);
77 ~EntityListMdiWindow() override;
78
79 QSize sizeHint() const override;
80
81public slots:
88 void markAsStale();
89
96 void clearStaleIndicator();
97
104 void reload();
105
106protected:
114 virtual void doReload() = 0;
115
123 virtual void saveSettings();
124
125protected:
126 void closeEvent(QCloseEvent* event) override;
127
142 void initializeTableSettings(QTableView* tableView,
143 QAbstractItemModel* sourceModel,
144 std::string_view settingsGroup,
145 const QVector<int>& defaultHiddenColumns = {},
146 const QSize& defaultSize = {900, 400},
147 int settingsVersion = 1,
148 QSplitter* splitter = nullptr);
149
158 void initializeStaleIndicator(QAction* refreshAction, const QString& iconPath);
159
169 QProgressBar* loadingBar();
170
176 void beginLoading();
177
183 void endLoading();
184
192 void connectModel(AbstractClientModel* model);
193
199 virtual QString normalRefreshTooltip() const { return tr("Refresh"); }
200
206 virtual QString staleRefreshTooltip() const {
207 return tr("Data changed on server - click to reload");
208 }
209
210private slots:
211 void onPulseTimeout();
212
213private:
214 void startPulseAnimation();
215 void setupColumnVisibility();
216 void showHeaderContextMenu(const QPoint& pos);
217 void restoreTableSettings();
218
219 // Stale indicator members
220 QAction* refreshAction_{nullptr};
221 QTimer* pulseTimer_{nullptr};
222 QIcon normalReloadIcon_;
223 QIcon pulseReloadIcon_;
224 bool pulseState_{false};
225 int pulseCount_{0};
226
227 // Loading indicator
228 QProgressBar* loadingBar_{nullptr};
229
230 // Table settings members
231 QTableView* settingsTableView_{nullptr};
232 QAbstractItemModel* settingsModel_{nullptr};
233 QString settingsGroup_;
234 QVector<int> defaultHiddenColumns_;
235 QSize defaultSize_{900, 400};
236 int settingsVersion_{1};
237 QSplitter* settingsSplitter_{nullptr};
238
239protected:
247};
248
249}
250
251#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:63
virtual QString staleRefreshTooltip() const
Get the stale tooltip text for the refresh action.
Definition EntityListMdiWindow.hpp:206
virtual void doReload()=0
Subclass implementation of the reload operation.
virtual QString normalRefreshTooltip() const
Get the normal (non-stale) tooltip text for the refresh action.
Definition EntityListMdiWindow.hpp:199
QSize savedWindowSize_
Saved window size from QSettings.
Definition EntityListMdiWindow.hpp:246