ORE Studio 0.0.4
Loading...
Searching...
No Matches
ChangeReasonCategoryDetailDialog.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_CHANGE_REASON_CATEGORY_DETAIL_DIALOG_HPP
21#define ORES_QT_CHANGE_REASON_CATEGORY_DETAIL_DIALOG_HPP
22
23#include <vector>
24#include <QAction>
25#include <QTabWidget>
26#include <QToolBar>
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/DetailDialogBase.hpp"
29#include "ores.qt/ProvenanceWidget.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.dq.api/domain/change_reason_category.hpp"
32
33namespace Ui {
34class ChangeReasonCategoryDetailDialog;
35}
36
37namespace ores::qt {
38
46 Q_OBJECT
47
48private:
49 inline static std::string_view logger_name =
50 "ores.qt.change_reason_category_detail_dialog";
51
52 [[nodiscard]] static auto& lg() {
53 using namespace ores::logging;
54 static auto instance = make_logger(logger_name);
55 return instance;
56 }
57
58public:
59 explicit ChangeReasonCategoryDetailDialog(QWidget* parent = nullptr);
61
62 void setClientManager(ClientManager* clientManager);
63 void setUsername(const std::string& username);
64
65 void setCategory(const dq::domain::change_reason_category& category);
66 dq::domain::change_reason_category getCategory() const;
67 void setCreateMode(bool createMode);
68 void setReadOnly(bool readOnly, int versionNumber = 0);
69 void setHistory(const std::vector<dq::domain::change_reason_category>& history,
70 int versionNumber);
71 void clearDialog();
72 void save();
73
74 QString categoryCode() const;
75 bool isDirty() const { return isDirty_; }
76 bool isReadOnly() const { return isReadOnly_; }
77
78signals:
79 void isDirtyChanged(bool dirty);
80 void categorySaved(const QString& code);
81 void categoryDeleted(const QString& code);
82
83protected:
84 QTabWidget* tabWidget() const override;
85 QWidget* provenanceTab() const override;
86 ProvenanceWidget* provenanceWidget() const override;
87 bool hasUnsavedChanges() const override { return isDirty_; }
88
89private slots:
90 void onSaveClicked();
91 void onDeleteClicked();
92 void onFieldChanged();
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
107private:
108 Ui::ChangeReasonCategoryDetailDialog* ui_;
109 QToolBar* toolBar_;
110 QAction* revertAction_;
111
112 dq::domain::change_reason_category currentCategory_;
113 bool isDirty_;
114 bool isAddMode_;
115 bool isReadOnly_;
116 std::string modifiedByUsername_;
117 ClientManager* clientManager_;
118
119 // Version navigation members
120 std::vector<dq::domain::change_reason_category> history_;
121 int currentHistoryIndex_;
122 QAction* firstVersionAction_;
123 QAction* prevVersionAction_;
124 QAction* nextVersionAction_;
125 QAction* lastVersionAction_;
126};
127
128}
129
130#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Groups change reasons into logical categories.
Definition change_reason_category.hpp:46
Dialog widget for creating and editing change reason categories.
Definition ChangeReasonCategoryDetailDialog.hpp:45
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition ChangeReasonCategoryDetailDialog.cpp:142
bool hasUnsavedChanges() const override
Definition ChangeReasonCategoryDetailDialog.hpp:87
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition ChangeReasonCategoryDetailDialog.cpp:140
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition ChangeReasonCategoryDetailDialog.cpp:141
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