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
attributetablepanel.h
Go to the documentation of this file.
1
17#ifndef ATTRIBUTETABLEPANEL_H
18#define ATTRIBUTETABLEPANEL_H
19
22
23#include <QPointer>
24#include <QSet>
25#include <QWidget>
26
27class QAction;
28class QButtonGroup;
29class QComboBox;
30class QLabel;
31class QLineEdit;
32class QPushButton;
33class QRadioButton;
34class QSortFilterProxyModel;
35class QStyledItemDelegate;
36class QTableView;
37class QToolBar;
41class GISVectorLayer;
42class GISVectorAttributeTableModel; // read-only OGR-feature source (defined in the .cpp)
43class MapCanvas;
44class MeshAttributeTableModel; // 2D mesh vertices / edges / cells source
45class SWMM2DMeshLayer;
47
48namespace openswmmvis { struct ColumnSpec; }
49
50class AttributeTablePanel : public QWidget
51{
52 Q_OBJECT
53public:
54 explicit AttributeTablePanel(QWidget *parent = nullptr);
55 ~AttributeTablePanel() override;
56
59 void setProject(SWMMModelLayer *layer,
60 SelectionManager *selMgr,
61 MapCanvas *canvas = nullptr);
62
65 void refresh();
66
76
80 void refreshHeaders();
81
87
99 [[nodiscard]] QString selectionAsTsv() const;
100
113 int deleteObjects(const QStringList &names);
114
119 [[nodiscard]] bool featureSourceIsEditable() const;
120
126
130 [[nodiscard]] bool categoryIsDeletable() const;
131
137 [[nodiscard]] QAction *copyAction() const { return m_copyAct; }
138
139public slots:
142
146 void onObjectEditedExternally(const QString &name);
147
148signals:
153 void objectEdited(const QString &name);
154
155private slots:
156 void onCategoryChanged(int comboIdx);
157 void onTableSelectionChanged();
158 void onSelectionManagerChanged(const QSet<SWMMObjectRef> &current,
159 const QSet<SWMMObjectRef> &added,
160 const QSet<SWMMObjectRef> &removed);
161 void onShowSelectedOnlyToggled(bool on);
162 void onZoomToSelectedClicked();
163
167 void onRowHeaderDoubleClicked(int row);
168 void onExportCsvClicked();
169 void onContextMenuRequested(const QPoint &pos);
170 void onChangeTypeTriggered();
171
177 void deleteSelectedRows();
178
180 void onQueryApplyClicked();
182 void onQueryClearClicked();
183
184 // Slice Z.3 — Selection ops driven by the current query. The
185 // five modes are presented as radios on one row + one Apply
186 // button (Round-4 follow-up 2026-05-12); this slot reads the
187 // active radio and dispatches.
188 void onSelectionApplyClicked();
189
190private:
191 bool eventFilter(QObject *watched, QEvent *event) override;
192
193 void buildUi();
195
199 void saveColumnWidths(SWMMModelLayer::Category cat) const;
200
203 void restoreColumnWidths(SWMMModelLayer::Category cat);
204
207 void saveColumnWidths(const QString &sourceKey) const;
208 void restoreColumnWidths(const QString &sourceKey);
209
216 void ensureMinColumnWidths();
217
221 void installColumnDelegates();
222
225 void installColumnDelegates(const QList<openswmmvis::ColumnSpec> &specs,
226 int clearUpTo);
227
231 QList<QStyledItemDelegate *> m_installedDelegates;
232
236 void bindMeshSource(const QString &key);
240 void bindGisSource(GISVectorLayer *gis);
241
244 [[nodiscard]] bool meshSourceActive() const;
245
249 QSet<SWMMObjectRef> meshRefs(bool applyQuery) const;
250
253 void meshSelectionToBus();
254 void meshSelectionFromBus(const QSet<SWMMObjectRef> &current);
255
258 [[nodiscard]] bool gisSourceActive() const;
259 void gisSelectionToBus();
260 void gisSelectionFromBus(const QSet<SWMMObjectRef> &current);
261
266 QSet<SWMMObjectRef> matchedRefs() const;
267
269 QSet<SWMMObjectRef> allCategoryRefs() const;
270
278 QList<int> selectedSourceRows() const;
279 void applyValueToSelectedRows(int column, const QList<int> &sourceRows,
280 const QVariant &value);
281 QVariant promptBulkValue(int column, const QVariant &current,
282 bool *ok) const;
283
284 QPointer<SWMMModelLayer> m_layer;
285 QPointer<SelectionManager> m_selMgr;
286 QPointer<MapCanvas> m_canvas;
287
288 QComboBox *m_categoryCombo = nullptr;
289 QTableView *m_view = nullptr;
290 QToolBar *m_toolbar = nullptr;
291 QAction *m_copyAct = nullptr;
292 SWMMAttributeTableModel *m_model = nullptr;
293 TabularDataTableModel *m_tabularModel = nullptr;
294 GISVectorAttributeTableModel *m_gisModel = nullptr;
295 MeshAttributeTableModel *m_meshModel = nullptr;
296 QSortFilterProxyModel *m_proxy = nullptr;
297
298 // Slice Z.2 — Query bar
299 QLineEdit *m_queryEdit = nullptr;
300 QPushButton *m_queryApply = nullptr;
301 QPushButton *m_queryClear = nullptr;
302 QLabel *m_queryStatus = nullptr;
303
304 // Slice Z.3 — Selection-op radios + single Apply button. IDs
305 // assigned to the buttons in `buildUi()` are read back in
306 // `onSelectionApplyClicked()` and dispatched to the matching
307 // SelectionManager op.
308 enum SelectionMode {
309 SelReplace = 0,
310 SelAdd = 1,
311 SelSubtract = 2,
312 SelIntersect = 3,
313 SelInvert = 4,
314 };
315 QButtonGroup *m_selGroup = nullptr;
316 QRadioButton *m_selReplaceR = nullptr;
317 QRadioButton *m_selAddR = nullptr;
318 QRadioButton *m_selSubtractR = nullptr;
319 QRadioButton *m_selIntersectR = nullptr;
320 QRadioButton *m_selInvertR = nullptr;
321
322 bool m_applyingFromBus = false;
323 bool m_showSelectedOnly = false;
324 bool m_suppressEditForward = false;
325};
326
327#endif // ATTRIBUTETABLEPANEL_H
Definition attributetablepanel.h:51
void copySelectionToClipboard()
Definition attributetablepanel.cpp:1946
QAction * copyAction() const
Definition attributetablepanel.h:137
void showLayerSource(OpenSWMMVisLayer *layer)
Definition attributetablepanel.cpp:1246
void onObjectEditedExternally(const QString &name)
Definition attributetablepanel.cpp:2608
bool categoryIsDeletable() const
Definition attributetablepanel.cpp:2649
void setProject(SWMMModelLayer *layer, SelectionManager *selMgr, MapCanvas *canvas=nullptr)
Definition attributetablepanel.cpp:938
~AttributeTablePanel() override
Definition attributetablepanel.cpp:658
void setResultsSource(SWMMResultsLayer *layer)
Definition attributetablepanel.cpp:1029
bool featureSourceIsEditable() const
Definition attributetablepanel.cpp:2769
int deleteObjects(const QStringList &names)
Definition attributetablepanel.cpp:2663
void refresh()
Definition attributetablepanel.cpp:1039
void objectEdited(const QString &name)
void refreshHeaders()
Definition attributetablepanel.cpp:1034
int deleteSelectedFeatures()
Definition attributetablepanel.cpp:2777
QString selectionAsTsv() const
Definition attributetablepanel.cpp:1894
Definition attributetablepanel.cpp:120
A map layer backed by a GDAL/OGR vector dataset.
Definition gisvectorlayer.h:103
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
Definition meshattributetablemodel.h:50
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
Definition swmm2dmeshlayer.h:64
Definition swmmattributetablemodel.h:111
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
Overlays time-stepped simulation results on the SWMM network geometry.
Definition swmmresultslayer.h:96
Owner of the canonical selection set for one SWMM project.
Definition selectionmanager.h:112
Definition tabulardatalayer.h:28
Definition tabulardatatablemodel.h:28
bool ok
Definition inpmeshwriter.cpp:575
const char * key
Definition meshcellparams.cpp:24
SwmmCategory
Stable ordinal categorising every SWMM-element kind that has per-kind styling, per-kind tree rows,...
Definition swmm_category.h:28
Definition aquiferprovider.h:21
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
int pos
Definition queryparser.cpp:36
QString name
Definition sectionmodelbuilders.cpp:474
ObjectType
Coarse object kind. Mirrors the engine's logical groupings; finer subtypes (e.g. junction vs outfall)...
Definition selectionmanager.h:39
Map layer that renders an OpenSWMMEngine network (nodes, links, subcatchments, rain gages) and provid...