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 <QWidget>
24#include <QAction>
25#include <QTimer>
26#include <QIcon>
27#include "ores.logging/make_logger.hpp"
28
29namespace ores::qt {
30
56class EntityListMdiWindow : public QWidget {
57 Q_OBJECT
58
59private:
60 inline static std::string_view logger_name = "ores.qt.entity_list_mdi_window";
61
62 [[nodiscard]] static auto& lg() {
63 using namespace ores::logging;
64 static auto instance = make_logger(logger_name);
65 return instance;
66 }
67
68public:
69 explicit EntityListMdiWindow(QWidget* parent = nullptr);
70 ~EntityListMdiWindow() override;
71
72public slots:
79 void markAsStale();
80
88
95 virtual void reload() = 0;
96
97protected:
106 void initializeStaleIndicator(QAction* refreshAction, const QString& iconPath);
107
113 virtual QString normalRefreshTooltip() const { return tr("Refresh"); }
114
120 virtual QString staleRefreshTooltip() const {
121 return tr("Data changed on server - click to reload");
122 }
123
124private slots:
125 void onPulseTimeout();
126
127private:
128 void startPulseAnimation();
129
130 QAction* refreshAction_{nullptr};
131 QTimer* pulseTimer_{nullptr};
132 QIcon normalReloadIcon_;
133 QIcon pulseReloadIcon_;
134 bool pulseState_{false};
135 int pulseCount_{0};
136};
137
138}
139
140#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:56
virtual void reload()=0
Reload data from the server.
virtual QString staleRefreshTooltip() const
Get the stale tooltip text for the refresh action.
Definition EntityListMdiWindow.hpp:120
void clearStaleIndicator()
Clear the stale indicator.
Definition EntityListMdiWindow.cpp:59
void markAsStale()
Mark the list as stale (data changed on server).
Definition EntityListMdiWindow.cpp:48
virtual QString normalRefreshTooltip() const
Get the normal (non-stale) tooltip text for the refresh action.
Definition EntityListMdiWindow.hpp:113
void initializeStaleIndicator(QAction *refreshAction, const QString &iconPath)
Initialize the stale indicator support.
Definition EntityListMdiWindow.cpp:36