ORE Studio 0.0.4
Loading...
Searching...
No Matches
FeatureFlagHistoryDialog.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_FEATURE_FLAG_HISTORY_DIALOG_HPP
21#define ORES_QT_FEATURE_FLAG_HISTORY_DIALOG_HPP
22
23#include <memory>
24#include <QPair>
25#include <QWidget>
26#include <QString>
27#include <QVector>
28#include <QToolBar>
29#include <QAction>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.variability/domain/feature_flags.hpp"
32#include "ores.logging/make_logger.hpp"
33#include "ui_FeatureFlagHistoryDialog.h"
34
35namespace Ui {
36class FeatureFlagHistoryDialog;
37}
38
39namespace ores::qt {
40
44class FeatureFlagHistoryDialog : public QWidget {
45 Q_OBJECT
46
47private:
48 inline static std::string_view logger_name =
49 "ores.qt.feature_flag_history_dialog";
50
51 [[nodiscard]] static auto& lg() {
52 using namespace ores::logging;
53 static auto instance = make_logger(logger_name);
54 return instance;
55 }
56
57 const QIcon& getHistoryIcon() const;
58
59public:
60 explicit FeatureFlagHistoryDialog(QString name,
61 ClientManager* clientManager,
62 QWidget* parent = nullptr);
64
65 void loadHistory();
66
67 QSize sizeHint() const override;
68
75 void markAsStale();
76
80 [[nodiscard]] QString flagName() const { return flagName_; }
81
85 [[nodiscard]] const std::vector<variability::domain::feature_flags>& getHistory() const {
86 return history_;
87 }
88
89signals:
90 void statusChanged(const QString& message);
91 void errorOccurred(const QString& error_message);
92
98 void openVersionRequested(const variability::domain::feature_flags& flag, int versionNumber);
99
105
106private slots:
107 void onVersionSelected(int index);
108 void onHistoryLoaded();
109 void onHistoryLoadError(const QString& error);
110 void onOpenClicked();
111 void onRevertClicked();
112 void onReloadClicked();
113
114private:
115 void displayChangesTab(int version_index);
116 void displayFullDetailsTab(int version_index);
117
123 using DiffResult = QVector<QPair<QString, QPair<QString, QString>>>;
124 DiffResult calculateDiff(
126 const variability::domain::feature_flags& previous);
127
128 void setupToolbar();
129 void updateButtonStates();
130 int selectedVersionIndex() const;
131
132 std::unique_ptr<Ui::FeatureFlagHistoryDialog> ui_;
133 ClientManager* clientManager_;
134 QString flagName_;
135 std::vector<variability::domain::feature_flags> history_;
136
137 QToolBar* toolBar_;
138 QAction* reloadAction_;
139 QAction* openAction_;
140 QAction* revertAction_;
141};
142
143}
144
145#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
Widget for displaying feature flag version history.
Definition FeatureFlagHistoryDialog.hpp:44
void revertVersionRequested(const variability::domain::feature_flags &flag)
Emitted when user requests to revert to a selected version.
QString flagName() const
Returns the name of the feature flag.
Definition FeatureFlagHistoryDialog.hpp:80
const std::vector< variability::domain::feature_flags > & getHistory() const
Returns the loaded history vector for version navigation.
Definition FeatureFlagHistoryDialog.hpp:85
void markAsStale()
Mark the history data as stale and reload.
Definition FeatureFlagHistoryDialog.cpp:456
void openVersionRequested(const variability::domain::feature_flags &flag, int versionNumber)
Emitted when user requests to open a version in read-only mode.
Represents a feature flag in the domain layer.
Definition feature_flags.hpp:31