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
swmmobjecttreemodel.h
Go to the documentation of this file.
1
22#ifndef SWMMOBJECTTREEMODEL_H
23#define SWMMOBJECTTREEMODEL_H
24
25#include <QAbstractItemModel>
26#include <QPointer>
27#include <QVector>
28
31
32class SWMMObjectTreeModel : public QAbstractItemModel
33{
34 Q_OBJECT
35
36public:
37 // Extra data-role id's used by the panel when translating model
38 // indices into SWMMObjectRef / (Category, row) tuples. Kept outside
39 // Qt::UserRole so nothing collides with the delegate's own roles.
40 enum Role {
41 RoleCategory = Qt::UserRole + 10, // int(SWMMModelLayer::Category)
42 RoleRow = Qt::UserRole + 11, // row within category
43 RoleIsLeaf = Qt::UserRole + 12, // bool
44 RoleObjectRef = Qt::UserRole + 13, // QVariant::fromValue<SWMMObjectRef>
45 // Slice BM.0 — non-spatial data-objects section.
46 RoleSection = Qt::UserRole + 14, // int(Section)
47 RoleDataCategory = Qt::UserRole + 15, // int(SWMMModelLayer::DataCategory)
48 };
49
51 enum Section : int {
55 };
56
57 explicit SWMMObjectTreeModel(QObject *parent = nullptr);
59
63 void setLayer(SWMMModelLayer *layer);
64
69
73
76 QModelIndex indexFor(SWMMModelLayer::Category c, int row) const;
77
81 QModelIndex indexFor(const SWMMObjectRef &ref) const;
82
84 Section sectionAtTopRow(int topRow) const;
85
90
94
95 // ── QAbstractItemModel interface ─────────────────────────────────────
96 QModelIndex index(int row, int column,
97 const QModelIndex &parent = {}) const override;
98 QModelIndex parent(const QModelIndex &child) const override;
99 int rowCount(const QModelIndex &parent = {}) const override;
100 int columnCount(const QModelIndex &parent = {}) const override;
101 QVariant data(const QModelIndex &index,
102 int role = Qt::DisplayRole) const override;
103 bool setData(const QModelIndex &index,
104 const QVariant &value,
105 int role = Qt::EditRole) override;
106 Qt::ItemFlags flags(const QModelIndex &index) const override;
107 QVariant headerData(int section, Qt::Orientation orientation,
108 int role = Qt::DisplayRole) const override;
109
110 // Drag-and-drop for category reordering (Slice T.2).
111 Qt::DropActions supportedDropActions() const override;
112 QStringList mimeTypes() const override;
113 QMimeData *mimeData(const QModelIndexList &indexes) const override;
114 bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
115 int row, int column,
116 const QModelIndex &parent) const override;
117 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
118 int row, int column,
119 const QModelIndex &parent) override;
120
121public slots:
125 void reload();
126
133 void scheduleReload();
134
135private:
136 bool m_reloadPending = false;
137
138 // internalId sentinels for top-level rows. Leaf rows store their
139 // parent row index as internalId instead — leaf internalId is always
140 // < kSeparatorId so the discriminator is unambiguous.
141 static constexpr quintptr kCategoryId = std::numeric_limits<quintptr>::max();
142 static constexpr quintptr kDataCategoryId = std::numeric_limits<quintptr>::max() - 1;
143 static constexpr quintptr kSeparatorId = std::numeric_limits<quintptr>::max() - 2;
144
145 QPointer<SWMMModelLayer> m_layer;
146
147 // Visible-category list — excludes categories with 0 members so the
148 // tree doesn't show empty "Pumps (0)" / etc. headers. Built on
149 // reload(); index i in this vector is the model's top-level row for
150 // that category.
151 QVector<SWMMModelLayer::Category> m_visible;
152
153 // Slice BM.0 — visible data-object categories (non-spatial). Same
154 // contract as m_visible: empty categories are omitted. Rendered
155 // below m_visible with a non-selectable separator row between when
156 // both sections are non-empty.
157 QVector<SWMMModelLayer::DataCategory> m_visibleData;
158};
159
160#endif // SWMMOBJECTTREEMODEL_H
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
DataCategory
Slice BM.0 — non-spatial data-object categories surfaced below the spatial section in the Object Brow...
Definition swmmmodellayer.h:182
Definition swmmobjecttreemodel.h:33
SWMMModelLayer::Category categoryAtTopRow(int topRow) const
Definition swmmobjecttreemodel.cpp:257
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition swmmobjecttreemodel.cpp:539
int rowCount(const QModelIndex &parent={}) const override
Definition swmmobjecttreemodel.cpp:361
QMimeData * mimeData(const QModelIndexList &indexes) const override
Definition swmmobjecttreemodel.cpp:611
int topRowForDataCategory(SWMMModelLayer::DataCategory c) const
Definition swmmobjecttreemodel.cpp:295
~SWMMObjectTreeModel() override
void reload()
Definition swmmobjecttreemodel.cpp:229
int columnCount(const QModelIndex &parent={}) const override
Definition swmmobjecttreemodel.cpp:376
SWMMModelLayer::DataCategory dataCategoryAtTopRow(int topRow) const
Definition swmmobjecttreemodel.cpp:283
void scheduleReload()
Definition swmmobjecttreemodel.cpp:219
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition swmmobjecttreemodel.cpp:491
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition swmmobjecttreemodel.cpp:670
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition swmmobjecttreemodel.cpp:381
Section
Definition swmmobjecttreemodel.h:51
@ SectionNetwork
Spatial categories (Junctions … Rain Gages)
Definition swmmobjecttreemodel.h:52
@ SectionData
Non-spatial data objects (Curves … Inlets)
Definition swmmobjecttreemodel.h:54
@ SectionDivider
Visual separator row (non-selectable)
Definition swmmobjecttreemodel.h:53
Role
Definition swmmobjecttreemodel.h:40
@ RoleCategory
Definition swmmobjecttreemodel.h:41
@ RoleSection
Definition swmmobjecttreemodel.h:46
@ RoleRow
Definition swmmobjecttreemodel.h:42
@ RoleIsLeaf
Definition swmmobjecttreemodel.h:43
@ RoleDataCategory
Definition swmmobjecttreemodel.h:47
@ RoleObjectRef
Definition swmmobjecttreemodel.h:44
QStringList mimeTypes() const override
Definition swmmobjecttreemodel.cpp:605
Qt::DropActions supportedDropActions() const override
Definition swmmobjecttreemodel.cpp:600
Section sectionAtTopRow(int topRow) const
Definition swmmobjecttreemodel.cpp:272
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition swmmobjecttreemodel.cpp:587
QModelIndex indexFor(SWMMModelLayer::Category c, int row) const
Definition swmmobjecttreemodel.cpp:304
void setLayer(SWMMModelLayer *layer)
Definition swmmobjecttreemodel.cpp:162
int topRowForCategory(SWMMModelLayer::Category c) const
Definition swmmobjecttreemodel.cpp:264
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Definition swmmobjecttreemodel.cpp:639
SWMM_FilePathRole role
Definition ioportabilitynormalizer.cpp:22
int index
Position in m_quadRegions / m_quadReports.
Definition meshgenerator.cpp:153
SwmmCategory
Stable ordinal categorising every SWMM-element kind that has per-kind styling, per-kind tree rows,...
Definition swmm_category.h:28
EdgeRef ref
Definition pslgminsize.cpp:377
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Identifies a single SWMM object.
Definition selectionmanager.h:32
Map layer that renders an OpenSWMMEngine network (nodes, links, subcatchments, rain gages) and provid...