ORE Studio 0.0.4
Loading...
Searching...
No Matches
DataLibrarianWindow.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_DATA_LIBRARIAN_WINDOW_HPP
21#define ORES_QT_DATA_LIBRARIAN_WINDOW_HPP
22
23#include <map>
24#include <QWidget>
25#include <QSplitter>
26#include <QTreeView>
27#include <QTableView>
28#include <QToolBar>
29#include <QStatusBar>
30#include <QLabel>
31#include <QProgressBar>
32#include <QSortFilterProxyModel>
33#include <QStandardItemModel>
34#include "ores.qt/ClientManager.hpp"
35#include "ores.qt/ClientDatasetModel.hpp"
36#include "ores.qt/ClientDataDomainModel.hpp"
37#include "ores.qt/ClientSubjectAreaModel.hpp"
38#include "ores.qt/ClientCatalogModel.hpp"
39#include "ores.qt/ClientDatasetDependencyModel.hpp"
40#include "ores.qt/ClientMethodologyModel.hpp"
41#include "ores.qt/ClientDatasetBundleModel.hpp"
42#include "ores.qt/ClientOriginDimensionModel.hpp"
43#include "ores.qt/ClientNatureDimensionModel.hpp"
44#include "ores.qt/ClientTreatmentDimensionModel.hpp"
45#include "ores.logging/make_logger.hpp"
46#include "ores.dq/domain/dataset.hpp"
47#include "ores.dq/domain/methodology.hpp"
48
49namespace ores::qt {
50
63class DataLibrarianWindow final : public QWidget {
64 Q_OBJECT
65
66private:
67 inline static std::string_view logger_name = "ores.qt.data_librarian_window";
68 static constexpr int total_model_loads = 10; // 6 original + 4 new (bundle, 3 dimensions)
69
70 [[nodiscard]] static auto& lg() {
71 using namespace ores::logging;
72 static auto instance = make_logger(logger_name);
73 return instance;
74 }
75
76public:
77 explicit DataLibrarianWindow(ClientManager* clientManager,
78 const QString& username,
79 QWidget* parent = nullptr);
80 ~DataLibrarianWindow() override = default;
81
82 QSize sizeHint() const override { return QSize(1600, 900); }
83
84signals:
85 void statusChanged(const QString& message);
86 void errorOccurred(const QString& error_message);
87
95 void datasetsPublished(const QStringList& datasetCodes);
96
97 // Signals to open related windows
98 void openOriginDimensionsRequested();
99 void openNatureDimensionsRequested();
100 void openTreatmentDimensionsRequested();
101 void openCodingSchemesRequested();
102 void openMethodologiesRequested();
103 void openBundlesRequested();
104 void openDataDomainsRequested();
105 void openSubjectAreasRequested();
106 void openCatalogsRequested();
107
108private slots:
109 void onNavigationSelectionChanged(const QModelIndex& current,
110 const QModelIndex& previous);
111 void onDatasetSelectionChanged();
112 void onDatasetDoubleClicked(const QModelIndex& index);
113 void onRefreshClicked();
114 void onViewDatasetClicked();
115 void onPublishClicked();
116 void onPublicationHistoryClicked();
117 void onDataLoaded();
118 void onLoadError(const QString& error_message, const QString& details = {});
119
120 // Navigation data loaded
121 void onDomainsLoaded();
122 void onSubjectAreasLoaded();
123 void onCatalogsLoaded();
124 void onDatasetDependenciesLoaded();
125 void onMethodologiesLoaded();
126 void onBundlesLoaded();
127 void onBundleMembersLoaded();
128 void onOriginDimensionsLoaded();
129 void onNatureDimensionsLoaded();
130 void onTreatmentDimensionsLoaded();
131
132 // Column visibility context menu
133 void showHeaderContextMenu(const QPoint& pos);
134
135 // Dataset context menu
136 void showDatasetContextMenu(const QPoint& pos);
137
138 // Navigation tree context menu
139 void showNavigationContextMenu(const QPoint& pos);
140
141private:
142 void setupUi();
143 void setupNavigationSidebar();
144 void setupCentralWorkspace();
145 void setupToolbar();
146 void setupConnections();
147 void buildNavigationTree();
148 void showDatasetDetailDialog(const dq::domain::dataset* dataset);
149 void filterDatasetsByCatalog(const QString& catalogName);
150 void filterDatasetsByDomain(const QString& domainName);
151 void filterDatasetsBySubjectArea(const QString& subjectAreaName);
152 void filterDatasetsByBundle(const QString& bundleCode);
153 void filterDatasetsByOrigin(const QString& originCode);
154 void filterDatasetsByNature(const QString& natureCode);
155 void filterDatasetsByTreatment(const QString& treatmentCode);
156 void clearDatasetFilter();
157 void selectFirstDataset();
158 void setupColumnVisibility();
159 void applyDefaultColumnVisibility();
160 void fetchBundleMembers();
161 std::vector<dq::domain::dataset> getDatasetsUnderNode(const QModelIndex& index);
162
163 ClientManager* clientManager_;
164 QString username_;
165
166 // Main layout
167 QSplitter* mainSplitter_;
168 QSplitter* centralSplitter_;
169
170 // Navigation sidebar ("The Stacks")
171 QTreeView* navigationTree_;
172 QStandardItemModel* navigationModel_;
173
174 // Toolbar
175 QToolBar* toolbar_;
176 QAction* refreshAction_;
177 QAction* viewDatasetAction_;
178 QAction* publishAction_;
179 QAction* publicationHistoryAction_;
180 QAction* originDimensionsAction_;
181 QAction* natureDimensionsAction_;
182 QAction* treatmentDimensionsAction_;
183 QAction* codingSchemesAction_;
184 QAction* methodologiesAction_;
185 QAction* bundlesAction_;
186
187 // Central workspace - Dataset table
188 QTableView* datasetTable_;
189 ClientDatasetModel* datasetModel_;
190 QSortFilterProxyModel* datasetProxyModel_;
191
192 // Data models for navigation
193 ClientDataDomainModel* dataDomainModel_;
194 ClientSubjectAreaModel* subjectAreaModel_;
195 ClientCatalogModel* catalogModel_;
196 ClientDatasetDependencyModel* datasetDependencyModel_;
197 ClientMethodologyModel* methodologyModel_;
198 ClientDatasetBundleModel* bundleModel_;
199 ClientOriginDimensionModel* originDimensionModel_;
200 ClientNatureDimensionModel* natureDimensionModel_;
201 ClientTreatmentDimensionModel* treatmentDimensionModel_;
202
203 // Bundle member cache for filtering (bundle_code -> list of dataset_codes)
204 std::map<QString, QStringList> bundleMemberCache_;
205
206 // Status bar with loading indicator
207 QStatusBar* statusBar_;
208 QProgressBar* loadingProgressBar_;
209 QLabel* statusLabel_;
210 int pendingLoads_{0};
211 int totalLoads_{0};
212
213 // Track selected filter
214 QString selectedCatalogName_;
215 QString selectedDomainName_;
216 QString selectedSubjectAreaName_;
217 QString selectedBundleCode_;
218 QString selectedOriginCode_;
219 QString selectedNatureCode_;
220 QString selectedTreatmentCode_;
221};
222
223}
224
225#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Represents a data quality dataset with lineage tracking.
Definition dataset.hpp:36
Table model for displaying catalogs in a QTableView.
Definition ClientCatalogModel.hpp:40
Model for displaying dataset bundles fetched from the server.
Definition ClientDatasetBundleModel.hpp:40
Table model for displaying dataset dependencies.
Definition ClientDatasetDependencyModel.hpp:37
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Model for displaying origin dimensions fetched from the server.
Definition ClientOriginDimensionModel.hpp:40
The Data Librarian window for browsing and managing datasets.
Definition DataLibrarianWindow.hpp:63
void datasetsPublished(const QStringList &datasetCodes)
Emitted when datasets are successfully published.