|
| | LayerTreeModel (MapCanvas *canvas=nullptr, QObject *parent=nullptr) |
| |
| | ~LayerTreeModel () override |
| |
| void | setCanvas (MapCanvas *canvas) |
| | Rebind to a different MapCanvas (called on MDI tab switch). Pass nullptr to detach (empty tree).
|
| |
| MapCanvas * | canvas () const |
| |
| QModelIndex | index (int row, int column, const QModelIndex &parent={}) const override |
| |
| QModelIndex | parent (const QModelIndex &child) const override |
| |
| int | rowCount (const QModelIndex &parent={}) const override |
| |
| int | columnCount (const QModelIndex &parent={}) const override |
| |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| |
| bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
| |
| Qt::ItemFlags | flags (const QModelIndex &index) const override |
| |
| QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
| |
| Qt::DropActions | supportedDropActions () const override |
| |
| bool | canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override |
| |
| bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
| |
| QMimeData * | mimeData (const QModelIndexList &indexes) const override |
| |
| QStringList | mimeTypes () const override |
| |
| OpenSWMMVisLayer * | layerForIndex (const QModelIndex &index) const |
| | Returns the OpenSWMMVisLayer for a layer-row index, or nullptr for category rows / invalid indices.
|
| |
| bool | isCategoryIndex (const QModelIndex &index) const |
| | True if index is a category header row (no associated layer).
|
| |
| bool | isKindIndex (const QModelIndex &index) const |
| |
| OpenSWMMVisLayer * | kindParentLayer (const QModelIndex &index) const |
| |
| int | kindOrdinal (const QModelIndex &index) const |
| |
| bool | isSublayerIndex (const QModelIndex &index) const |
| |
| OpenSWMMVisLayer * | sublayerParentLayer (const QModelIndex &index) const |
| |
| OpenSWMM::Render::ISublayer * | sublayerForIndex (const QModelIndex &index) const |
| |
| bool | reorderCategory (int categoryId, int dstTreeRow) |
| | Slice LTR-2026-09-19 — moves the category group categoryId (an openswmmvis::ui::CategoryId currently shown in the tree) to tree row dstTreeRow, then batch-reorders the canvas layer stack so paint order follows (an undoable ReorderLayersCommand) and records the new group order on the canvas (MapCanvas::setLayerGroupOrder, persisted per project).
|
| |
| int | categoryIdForIndex (const QModelIndex &index) const |
| |
| QModelIndex | indexForCategory (int categoryId) const |
| |
| QModelIndex | indexForLayer (OpenSWMMVisLayer *layer) const |
| |
| QModelIndex | indexForSublayer (OpenSWMMVisLayer *layer, OpenSWMM::Render::ISublayer *sublayer) const |
| |
| void | notifyHostSubOrderChanged () |
| | Slice GUI-2026-05-30 §2 / §3 — notify the model that the sublayer or kind paint-order on a host layer has changed externally (context-menu Move Up / Down or drop). Rebuilds the cached sub-row storage and emits a model reset so the view re-renders in the new order.
|
| |
QAbstractItemModel that mirrors the layer stack of a MapCanvas, grouped by category.
Two-level tree:
Root
├── Category (e.g. "SWMM Model")
│ └── Layer
├── Category (e.g. "Vectors")
│ ├── Layer
│ └── Layer
└── …
Categories are derived from each layer's `OpenSWMMVisLayerType`. A
category is shown only if it contains at least one layer. Within a
category, layers appear in canvas-stack order (top-of-stack first).
Columns: [0] visibility checkbox + layer/category name + icon ·
[1] opacity (layer rows only).
The model reacts to layerAdded / layerRemoved / layerOrderChanged
signals from the canvas so it stays in sync automatically.
Reordering (Slice LTR-2026-09-19): category rows, layer rows and
sublayer rows are all draggable. A layer can only be dropped
inside its own category (its type decides the category, so a
cross-category drop is refused with the forbidden cursor); a
sublayer only inside its host layer. Every drop changes the
canvas paint order (or the host's sublayer paint order) and is
undoable; the canvas keeps the stack grouped by category so the
tree is always an exact picture of the drawing order.
| bool LayerTreeModel::reorderCategory |
( |
int |
categoryId, |
|
|
int |
dstTreeRow |
|
) |
| |
Slice LTR-2026-09-19 — moves the category group categoryId (an openswmmvis::ui::CategoryId currently shown in the tree) to tree row dstTreeRow, then batch-reorders the canvas layer stack so paint order follows (an undoable ReorderLayersCommand) and records the new group order on the canvas (MapCanvas::setLayerGroupOrder, persisted per project).
Tree row 0 = top of tree = highest canvas z-order. Rows are positions among the NON-EMPTY categories the tree displays; dstTreeRow is the row the group occupies after the move. Returns false (no-op) when the id is not shown, the row is out of range, or the move is a no-op.