ORE Studio 0.0.4
Loading...
Searching...
No Matches
ComputeConsoleWindow.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_COMPUTE_CONSOLE_WINDOW_HPP
21#define ORES_QT_COMPUTE_CONSOLE_WINDOW_HPP
22
23#include <memory>
24#include <string>
25#include <QTimer>
26#include <QWidget>
27#include <QAction>
28#include <QSplitter>
29#include <QTabWidget>
30#include <QTableView>
31#include <QToolBar>
32#include <QSortFilterProxyModel>
33#include <QFutureWatcher>
34#include "ores.qt/ChangeReasonCache.hpp"
35#include "ores.qt/ClientManager.hpp"
36#include "ores.qt/HostDisplayNameCache.hpp"
37#include "ores.qt/ComputeTaskViewModel.hpp"
38#include "ores.qt/ComputeTransferModel.hpp"
39#include "ores.qt/ClientAppModel.hpp"
40#include "ores.qt/ClientAppVersionModel.hpp"
41#include "ores.qt/ClientHostModel.hpp"
42#include "ores.compute.api/domain/host.hpp"
43#include "ores.logging/make_logger.hpp"
44
45namespace ores::qt {
46
47class BadgeCache;
48
65class ComputeConsoleWindow : public QWidget {
66 Q_OBJECT
67
68private:
69 inline static std::string_view logger_name =
70 "ores.qt.compute_console_window";
71
72 [[nodiscard]] static auto& lg() {
73 using namespace ores::logging;
74 static auto instance = make_logger(logger_name);
75 return instance;
76 }
77
78public:
79 explicit ComputeConsoleWindow(ClientManager* clientManager,
80 ChangeReasonCache* changeReasonCache,
81 BadgeCache* badgeCache,
82 QWidget* parent = nullptr);
83
88 ComputeTransferModel* transfer_model() const { return transfer_model_.get(); }
89
90 void setHttpBaseUrl(const std::string& url) { http_base_url_ = url; }
91
92 QSize sizeHint() const override { return {1200, 720}; }
93
94public slots:
95 void refresh();
96
97signals:
98 void statusChanged(const QString& message);
99 void errorOccurred(const QString& error);
100
101private slots:
102 void on_hosts_loaded();
103 void on_tasks_loaded();
104 void on_tasks_error(const QString& message, const QString& details);
105 void on_apps_loaded();
106 void on_app_versions_loaded();
107 void on_task_selection_changed();
108 void on_app_selection_changed();
109 void on_tab_changed(int index);
110 void on_auto_refresh_toggled(bool checked);
111 void on_new_application();
112 void on_new_app_version();
113 void on_new_batch();
114 void on_new_work_unit();
115 void on_show_logs();
116 void on_download_input();
117 void on_download_output();
118 void on_task_double_clicked(const QModelIndex& index);
119 void on_app_double_clicked(const QModelIndex& index);
120 void on_app_version_double_clicked(const QModelIndex& index);
121
122private:
123 void setup_ui();
124 QWidget* make_tasks_tab();
125 QWidget* make_apps_tab();
126 QWidget* make_hosts_tab();
127 QWidget* make_transfers_tab();
128
129 QToolBar* make_tab_toolbar(Qt::ToolButtonStyle style = Qt::ToolButtonTextBesideIcon);
130
131 // Tab indices (App Versions is now embedded in the Apps tab, not a top tab)
132 static constexpr int kTasksTab = 0;
133 static constexpr int kAppsTab = 1;
134 static constexpr int kHostsTab = 2;
135 static constexpr int kTransfersTab = 3;
136
137 ClientManager* client_manager_;
138 ChangeReasonCache* change_reason_cache_;
139 BadgeCache* badge_cache_;
140 std::string http_base_url_;
141
142 // Models
143 HostDisplayNameCache* host_cache_{nullptr}; // owned by this
144 std::unique_ptr<ComputeTaskViewModel> task_model_;
145 std::unique_ptr<ClientAppModel> app_model_;
146 std::unique_ptr<ClientAppVersionModel> app_version_model_;
147 std::unique_ptr<ClientHostModel> host_model_;
148 std::unique_ptr<ComputeTransferModel> transfer_model_;
149
150 // Host fetch watcher (also populates host_cache_)
151 using HostList = std::vector<compute::domain::host>;
152 QFutureWatcher<HostList>* host_watcher_{nullptr};
153
154 // Top-level tab bar
155 QTabWidget* main_tabs_{nullptr};
156
157 // Tasks tab
158 QTableView* task_view_{nullptr};
159 QSortFilterProxyModel* task_proxy_{nullptr};
160 QAction* logs_action_{nullptr};
161 QAction* download_input_action_{nullptr};
162 QAction* download_output_action_{nullptr};
163 QString selected_result_id_;
164 const compute_task* selected_task_{nullptr};
165
166 // Apps tab — master-detail split
167 QTableView* app_view_{nullptr};
168 QSortFilterProxyModel* app_proxy_{nullptr};
169 QTableView* app_version_view_{nullptr};
170 QSortFilterProxyModel* app_version_proxy_{nullptr};
171 QAction* new_app_version_action_{nullptr}; // enabled when app selected
172
173 // Hosts tab
174 QTableView* host_view_{nullptr};
175 QSortFilterProxyModel* host_proxy_{nullptr};
176
177 // Transfers tab
178 QTableView* transfer_view_{nullptr};
179
180 QTimer* auto_refresh_timer_{nullptr};
181};
182
183} // namespace ores::qt
184
185#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Client-side cache of badge definitions and mappings.
Definition BadgeCache.hpp:46
Shared cache for change reasons used across all entity dialogs.
Definition ChangeReasonCache.hpp:47
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Unified compute console modelled on the BOINC manager UI.
Definition ComputeConsoleWindow.hpp:65
ComputeTransferModel * transfer_model() const
Exposes the transfer model so external upload/download helpers can call add_transfer / update_progres...
Definition ComputeConsoleWindow.hpp:88
Pure Qt model tracking upload/download progress.
Definition ComputeTransferModel.hpp:47