ORE Studio 0.0.4
Loading...
Searching...
No Matches
QueueDetailDialog.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_QUEUE_DETAIL_DIALOG_HPP
21#define ORES_QT_QUEUE_DETAIL_DIALOG_HPP
22
23#include <cstdint>
24#include <vector>
25#include <QWidget>
26#include <QToolBar>
27#include <QTabWidget>
28#include <QSpinBox>
29#include <QComboBox>
30#include <QLineEdit>
31#include <QTableWidget>
32#include <QPlainTextEdit>
33#include <QLabel>
34#include <QFutureWatcher>
35#include "ores.qt/ClientManager.hpp"
36#include "ores.logging/make_logger.hpp"
37
38namespace ores::qt {
39
47class QueueDetailDialog final : public QWidget {
48 Q_OBJECT
49
50private:
51 inline static std::string_view logger_name =
52 "ores.qt.queue_detail_dialog";
53
54 [[nodiscard]] static auto& lg() {
55 using namespace ores::logging;
56 static auto instance = make_logger(logger_name);
57 return instance;
58 }
59
60public:
61 explicit QueueDetailDialog(const QString& streamName,
62 const QString& displayName,
63 ClientManager* clientManager,
64 QWidget* parent = nullptr);
65 ~QueueDetailDialog() override = default;
66
67 QSize sizeHint() const override { return {750, 520}; }
68
69signals:
70 void statusChanged(const QString& message);
71 void errorOccurred(const QString& error_message);
72
73private slots:
74 void onPublish();
75 void onGetMessages();
76 void onDeleteSelected();
77 void onPublishDone();
78 void onGetMessagesDone();
79
80private:
81 enum class GetMode { Peek, Pop };
82
83 struct PublishResult {
84 bool success{false};
85 QString error_message;
86 QString error_details;
87 };
88
89 struct MessageRow {
90 std::uint64_t sequence{0};
91 std::string subject;
92 std::string timestamp; // formatted string
93 std::string payload;
94 };
95
96 struct GetMessagesResult {
97 bool success{false};
98 std::vector<MessageRow> messages;
99 GetMode mode{GetMode::Peek};
100 QString error_message;
101 QString error_details;
102 };
103
104 void setupUi();
105 void setupToolbar();
106 void setupPublishTab();
107 void setupMessagesTab();
108 void populateMessagesTable(const std::vector<MessageRow>& messages);
109 void updateDeleteAction();
110
111 QString streamName_; // NATS stream name (used as identifier)
112 QString displayName_; // human-readable name shown in UI
113 ClientManager* clientManager_;
114
115 QToolBar* toolbar_;
116 QAction* publishAction_;
117 QAction* getMessagesAction_;
118 QAction* deleteAction_;
119 QTabWidget* tabWidget_;
120
121 // Publish tab
122 QWidget* publishTab_;
123 QLineEdit* subjectEdit_;
124 QPlainTextEdit* payloadEdit_;
125
126 // Messages tab
127 QWidget* messagesTab_;
128 QComboBox* modeCombo_;
129 QSpinBox* startSeqSpinBox_;
130 QSpinBox* countSpinBox_;
131 QTableWidget* messagesTable_;
132
133 QFutureWatcher<PublishResult>* publishWatcher_;
134 QFutureWatcher<GetMessagesResult>* getWatcher_;
135};
136
137}
138
139#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Detail widget for a single JetStream stream.
Definition QueueDetailDialog.hpp:47