ORE Studio 0.0.4
Loading...
Searching...
No Matches
CountryMdiWindow.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_COUNTRY_MDI_WINDOW_HPP
21#define ORES_QT_COUNTRY_MDI_WINDOW_HPP
22
23#include <QTableView>
24#include <QVBoxLayout>
25#include <QToolBar>
26#include <QSortFilterProxyModel>
27#include <memory>
28#include "ores.qt/EntityListMdiWindow.hpp"
29#include "ores.qt/ClientManager.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.qt/ClientCountryModel.hpp"
32#include "ores.qt/PaginationWidget.hpp"
33
34namespace ores::qt {
35
36class ImageCache;
37
42 Q_OBJECT
43
44private:
45 inline static std::string_view logger_name =
46 "ores.qt.country_mdi_window";
47
48 [[nodiscard]] static auto& lg() {
49 using namespace ores::logging;
50 static auto instance = make_logger(logger_name);
51 return instance;
52 }
53
54public:
55 explicit CountryMdiWindow(ClientManager* clientManager,
56 ImageCache* imageCache,
57 const QString& username,
58 QWidget* parent = nullptr);
59 ~CountryMdiWindow() override;
60
61 ClientCountryModel* countryModel() const { return countryModel_.get(); }
62
63signals:
64 void statusChanged(const QString& message);
65 void errorOccurred(const QString& error_message);
66 void selectionChanged(int selection_count);
67 void addNewRequested();
68 void showCountryDetails(const refdata::domain::country& country);
69 void countryDeleted(const QString& alpha2_code);
70 void showCountryHistory(const QString& alpha2_code);
71
72public slots:
73 void doReload() override;
74 void addNew();
75 void editSelected();
76 void deleteSelected();
77 void viewHistorySelected();
78 void exportToCSV();
79
80private slots:
81 void onDataLoaded();
82 void onLoadError(const QString& error_message, const QString& details = {});
83 void onRowDoubleClicked(const QModelIndex& index);
84 void onSelectionChanged();
85 void onConnectionStateChanged();
86
87protected:
88 QString normalRefreshTooltip() const override { return tr("Refresh countries"); }
89
90private:
91 void updateActionStates();
92 void setupReloadAction();
93
94private:
95 QVBoxLayout* verticalLayout_;
96 QTableView* countryTableView_;
97 QToolBar* toolBar_;
98 PaginationWidget* pagination_widget_;
99
100 // Reload action with stale indicator
101 QAction* reloadAction_;
102
103 QAction* addAction_;
104 QAction* editAction_;
105 QAction* deleteAction_;
106 QAction* historyAction_;
107
108 std::unique_ptr<ClientCountryModel> countryModel_;
109 QSortFilterProxyModel* proxyModel_;
110 ClientManager* clientManager_;
111 ImageCache* imageCache_;
112 QString username_;
113};
114
115}
116
117#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Model for displaying countries fetched from the server.
Definition ClientCountryModel.hpp:45
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
MDI window for displaying countries.
Definition CountryMdiWindow.hpp:41
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition CountryMdiWindow.hpp:88
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:62
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:53
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:39
Represents a country using ISO 3166-1 standard codes.
Definition country.hpp:34