ORE Studio 0.0.4
Loading...
Searching...
No Matches
SystemSettingDetailDialog.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_SYSTEM_SETTING_DETAIL_DIALOG_HPP
21#define ORES_QT_SYSTEM_SETTING_DETAIL_DIALOG_HPP
22
23#include <vector>
24#include <QAction>
25#include <QIntValidator>
26#include <QToolBar>
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/DetailDialogBase.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.variability.api/domain/system_setting.hpp"
31
32namespace Ui {
33class SystemSettingDetailDialog;
34}
35
36namespace ores::qt {
37
45 Q_OBJECT
46
47private:
48 inline static std::string_view logger_name =
49 "ores.qt.system_setting_detail_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
57public:
58 explicit SystemSettingDetailDialog(QWidget* parent = nullptr);
60
61 void setClientManager(ClientManager* clientManager);
62 void setUsername(const std::string& username);
63
64 void setSystemSetting(const variability::domain::system_setting& flag);
65 variability::domain::system_setting getSystemSetting() const;
66 void setCreateMode(bool createMode);
67 void setReadOnly(bool readOnly, int versionNumber = 0);
68 void setHistory(const std::vector<variability::domain::system_setting>& history,
69 int versionNumber);
70 void clearDialog();
71 void save();
72
73 QString systemSettingName() const;
74 bool isDirty() const { return isDirty_; }
75 bool isReadOnly() const { return isReadOnly_; }
76
77signals:
78 void isDirtyChanged(bool dirty);
79 void systemSettingSaved(const QString& name);
80 void systemSettingDeleted(const QString& name);
81
82protected:
83 QTabWidget* tabWidget() const override;
84 QWidget* provenanceTab() const override;
85 ProvenanceWidget* provenanceWidget() const override;
86 bool hasUnsavedChanges() const override { return isDirty_; }
87
88private slots:
89 void onSaveClicked();
90 void onDeleteClicked();
91 void onFieldChanged();
92 void onDataTypeChanged();
93
94 // Version navigation slots
95 void onFirstVersionClicked();
96 void onPrevVersionClicked();
97 void onNextVersionClicked();
98 void onLastVersionClicked();
99
100private:
101 void updateSaveButtonState();
102 void closeParentWindow();
103 void displayCurrentVersion();
104 void updateVersionNavButtonStates();
105 void showVersionNavActions(bool visible);
106 void populateValueWidgets(const std::string& dataType, const std::string& value);
107 void switchValuePage(const QString& dataType);
108 [[nodiscard]] QString currentValueText() const;
109
110private:
111 Ui::SystemSettingDetailDialog* ui_;
112 QToolBar* toolBar_;
113 QAction* revertAction_;
114 QIntValidator* intValidator_;
115
117 bool isDirty_;
118 bool isAddMode_;
119 bool isReadOnly_;
120 std::string modifiedByUsername_;
121 ClientManager* clientManager_;
122
123 // Version navigation members
124 std::vector<variability::domain::system_setting> history_;
125 int currentHistoryIndex_;
126 QAction* firstVersionAction_;
127 QAction* prevVersionAction_;
128 QAction* nextVersionAction_;
129 QAction* lastVersionAction_;
130};
131
132}
133
134#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
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:74
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39
Dialog widget for creating and editing system settings.
Definition SystemSettingDetailDialog.hpp:44
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition SystemSettingDetailDialog.cpp:173
bool hasUnsavedChanges() const override
Definition SystemSettingDetailDialog.hpp:86
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition SystemSettingDetailDialog.cpp:171
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition SystemSettingDetailDialog.cpp:172
Represents a typed system setting in the domain layer.
Definition system_setting.hpp:35