SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
ruleseditordialog.h
Go to the documentation of this file.
1
26#ifndef OPENSWMMVIS_UI_DIALOGS_RULESEDITORDIALOG_H
27#define OPENSWMMVIS_UI_DIALOGS_RULESEDITORDIALOG_H
28
29#include <QDialog>
30#include <QPointer>
31
32class QFrame;
33class QLabel;
34class QLineEdit;
35class QListView;
36class QPushButton;
37class QSortFilterProxyModel;
38class QSplitter;
39class QToolButton;
40class QUndoStack;
41
42class SWMMModelLayer;
43
44namespace openswmmvis::controls {
45class ControlRuleProvider;
46class ControlRuleRegistry;
47class RuleValidator;
48}
49
50namespace openswmmvis::ui {
51
52class RuleCodeEditor;
53class RuleListModel;
54
55class RulesEditorDialog : public QDialog
56{
57 Q_OBJECT
58public:
59 enum class Mode { Edit, CreateNew };
60 Q_ENUM(Mode)
61
63 QUndoStack *undoStack,
64 QWidget *parent = nullptr);
66
70 QUndoStack *undoStack,
71 QWidget *parent = nullptr);
72
80 static QString pickControlRule(SWMMModelLayer *layer,
81 QUndoStack *undoStack,
82 const QString &initialName,
83 QWidget *parent = nullptr);
84
87 void openForRule(const QString &name);
88
89 Mode mode() const noexcept { return m_mode; }
91
92 // ── Test hooks ──────────────────────────────────────────────────────
93
94 QListView *listView() const noexcept { return m_listView; }
95 RuleCodeEditor *codeEditor() const noexcept { return m_codeEditor; }
96 RuleListModel *listModel() const noexcept { return m_listModel; }
97 QString pendingName() const;
98 bool isCreateEnabled() const;
99 void submitCreateNew();
100 void invokeNew();
101 void invokeDelete();
102 bool renameCurrent(const QString &newName);
103 void flushPendingEdit();
104
105protected:
106 void closeEvent(QCloseEvent *e) override;
107
108private slots:
109 void onListSelectionChanged_();
110 void onCodeEditorTextChanged_();
111 void onCodeEditorFocusOut_();
112 void onAddClicked_();
113 void onDeleteClicked_();
114 void onRenameClicked_();
115 void onSearchTextChanged_(const QString &text);
116 void onCancelCreateClicked_();
117 void onCreateNewNameChanged_(const QString &text);
118 void onCreateNewSubmit_();
119 void onProviderRenamed_(openswmmvis::controls::ControlRuleProvider *p,
120 const QString &prev, const QString &now);
121 void onProviderValidationChanged_();
122
123private:
124 void buildUi_();
125 void buildCreateCard_();
127 void updateValidationBanner_();
129
130 QPointer<SWMMModelLayer> m_layer;
131 QUndoStack *m_undoStack = nullptr;
132 QPointer<openswmmvis::controls::ControlRuleProvider> m_current;
133 Mode m_mode = Mode::Edit;
134
135 QSplitter *m_splitter = nullptr;
136
137 // Pane 1: list
138 QLineEdit *m_searchEdit = nullptr;
139 QListView *m_listView = nullptr;
140 RuleListModel *m_listModel = nullptr;
141 QSortFilterProxyModel *m_listProxy = nullptr;
142 QToolButton *m_addBtn = nullptr;
143 QToolButton *m_delBtn = nullptr;
144 QToolButton *m_renameBtn = nullptr;
145
146 // Pane 2: editor
147 QLabel *m_nameLabel = nullptr;
148 QToolButton *m_renameBodyBtn = nullptr;
149 QFrame *m_validationBanner = nullptr;
150 QLabel *m_validationLabel = nullptr;
151 RuleCodeEditor *m_codeEditor = nullptr;
152 QToolButton *m_validateNowBtn = nullptr;
153
154 openswmmvis::controls::RuleValidator *m_validator = nullptr;
155
156 // CreateNew-mode UI (always built; hidden in Edit mode and revealed
157 // by the "+ Add" button or the createNew factory).
158 QFrame *m_createCard = nullptr;
159 QLineEdit *m_createNameEdit = nullptr;
160 QLabel *m_createValidationLbl = nullptr;
161 QPushButton *m_createBtn = nullptr;
162 QPushButton *m_cancelCreateBtn = nullptr;
163
164 // Internal state
165 bool m_suppressTextSignal = false;
166 bool m_dirty = false;
167};
168
169} // namespace openswmmvis::ui
170
171#endif // OPENSWMMVIS_UI_DIALOGS_RULESEDITORDIALOG_H
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
Definition controlruleprovider.h:45
Definition controlruleregistry.h:38
Definition rulevalidator.h:32
Definition rulecodeeditor.h:38
Definition rulelistmodel.h:51
Definition ruleseditordialog.h:56
void submitCreateNew()
Definition ruleseditordialog.cpp:505
QString pendingName() const
Definition ruleseditordialog.cpp:495
void openForRule(const QString &name)
Bring the dialog forward and select name in the list (no-op if absent).
Definition ruleseditordialog.cpp:593
Mode
Definition ruleseditordialog.h:59
RuleListModel * listModel() const noexcept
Definition ruleseditordialog.h:96
void flushPendingEdit()
Definition ruleseditordialog.cpp:433
bool renameCurrent(const QString &newName)
Definition ruleseditordialog.cpp:565
RuleCodeEditor * codeEditor() const noexcept
Definition ruleseditordialog.h:95
void invokeDelete()
Definition ruleseditordialog.cpp:539
Mode mode() const noexcept
Definition ruleseditordialog.h:89
static RulesEditorDialog * createNew(SWMMModelLayer *layer, QUndoStack *undoStack, QWidget *parent=nullptr)
Slice BM.0-Add-New factory: same dialog, started in CreateNew mode. Caller owns the returned dialog.
Definition ruleseditordialog.cpp:94
bool isCreateEnabled() const
Definition ruleseditordialog.cpp:500
openswmmvis::controls::ControlRuleProvider * currentProvider() const noexcept
Definition ruleseditordialog.cpp:133
void closeEvent(QCloseEvent *e) override
Definition ruleseditordialog.cpp:604
QListView * listView() const noexcept
Definition ruleseditordialog.h:94
void invokeNew()
Definition ruleseditordialog.cpp:451
static QString pickControlRule(SWMMModelLayer *layer, QUndoStack *undoStack, const QString &initialName, QWidget *parent=nullptr)
Modal pick / create / edit entry point — mirrors TimeseriesEditorDialog::pickTimeseries....
Definition ruleseditordialog.cpp:104
int e
Definition inpmeshreader.cpp:41
ArrowPlacement p
Definition linesymbollayer.cpp:27
Definition controlruleprovider.h:34
Definition openswmmvislayer.h:43
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
QString text
Definition queryparser.cpp:35
QString name
Definition sectionmodelbuilders.cpp:474