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