ORE Studio 0.0.4
Loading...
Searching...
No Matches
PublicationHistoryDialog.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_PUBLICATION_HISTORY_DIALOG_HPP
21#define ORES_QT_PUBLICATION_HISTORY_DIALOG_HPP
22
23#include <QDialog>
24#include <QTableView>
25#include <QVBoxLayout>
26#include <QAbstractTableModel>
27#include <QFutureWatcher>
28#include <memory>
29#include <boost/uuid/uuid.hpp>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.dq/domain/publication.hpp"
33
34namespace ores::qt {
35
39class PublicationHistoryModel : public QAbstractTableModel {
40 Q_OBJECT
41
42public:
43 explicit PublicationHistoryModel(QObject* parent = nullptr);
44
45 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
46 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
47 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
48 QVariant headerData(int section, Qt::Orientation orientation,
49 int role = Qt::DisplayRole) const override;
50
51 void setPublications(const std::vector<dq::domain::publication>& publications);
52 void clear();
53
54private:
55 enum Column {
56 PublishedAt,
57 DatasetCode,
58 Mode,
59 TargetTable,
60 Inserted,
61 Skipped,
62 Deleted,
63 PublishedBy,
64 ColumnCount
65 };
66
67 std::vector<dq::domain::publication> publications_;
68};
69
76class PublicationHistoryDialog : public QDialog {
77 Q_OBJECT
78
79private:
80 inline static std::string_view logger_name =
81 "ores.qt.publication_history_dialog";
82
83 [[nodiscard]] static auto& lg() {
84 using namespace ores::logging;
85 static auto instance = make_logger(logger_name);
86 return instance;
87 }
88
89public:
90 explicit PublicationHistoryDialog(ClientManager* clientManager,
91 QWidget* parent = nullptr);
93
97 void refresh();
98
99signals:
100 void statusMessage(const QString& message);
101 void errorMessage(const QString& message);
102
103private slots:
104 void onPublicationsLoaded();
105
106private:
107 void setupUi();
108
109 QTableView* tableView_;
111 ClientManager* clientManager_;
112
113 struct FetchResult {
114 bool success;
115 std::vector<dq::domain::publication> publications;
116 };
117
118 QFutureWatcher<FetchResult>* watcher_;
119};
120
121}
122
123#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Table model for displaying publication history.
Definition PublicationHistoryDialog.hpp:39
Dialog for displaying publication history.
Definition PublicationHistoryDialog.hpp:76
void refresh()
Refresh the publication list from the server.
Definition PublicationHistoryDialog.cpp:174