16#ifndef QGSMESHDATASETGROUPTREE_H
17#define QGSMESHDATASETGROUPTREE_H
26#include <QItemSelection>
27#include <QStandardItemModel>
28#include <QStyledItemDelegate>
30#include <QSortFilterProxyModel>
47 QMenu *
createSaveMenu(
int groupIndex, QMenu *parentMenu =
nullptr );
57 void saveDatasetGroup(
int datasetGroup,
const QString &driver,
const QString &fileSuffix );
81 QVariant
data(
const QModelIndex &
index,
int role )
const override;
82 Qt::ItemFlags
flags(
const QModelIndex &
index )
const override;
83 QVariant
headerData(
int section, Qt::Orientation orientation,
84 int role = Qt::DisplayRole )
const override;
85 QModelIndex
index(
int row,
int column,
86 const QModelIndex &
parent = QModelIndex() )
const override;
87 QModelIndex
parent(
const QModelIndex &
index )
const override;
88 int rowCount(
const QModelIndex &
parent = QModelIndex() )
const override;
119 std::unique_ptr<QgsMeshDatasetGroupTreeItem> mRootItem;
133 QVariant
data(
const QModelIndex &
index,
int role )
const override;
134 bool setData(
const QModelIndex &
index,
const QVariant &value,
int role )
override;
135 Qt::ItemFlags
flags(
const QModelIndex &
index )
const override;
136 QVariant
headerData(
int section, Qt::Orientation orientation,
int role )
const override;
140 QString textDisplayed(
const QModelIndex &
index )
const;
141 QColor backGroundColor(
const QModelIndex &
index )
const;
154 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
155 QVariant
data(
const QModelIndex &index,
int role )
const override;
173 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
176 int mActiveScalarGroupIndex = -1;
177 int mActiveVectorGroupIndex = -1;
192 void paint( QPainter *painter,
193 const QStyleOptionViewItem &option,
194 const QModelIndex &index )
const override;
197 QRect
iconRect(
const QRect &rect,
bool isVector )
const;
199 QSize
sizeHint(
const QStyleOptionViewItem &option,
200 const QModelIndex &index )
const override;
202 const QPixmap mScalarSelectedPixmap;
203 const QPixmap mScalarDeselectedPixmap;
204 const QPixmap mVectorSelectedPixmap;
205 const QPixmap mVectorDeselectedPixmap;
207 QRect
iconRect(
const QRect &rect,
int pos )
const;
231 void selectAllGroups();
232 void deselectAllGroups();
235 void contextMenuEvent( QContextMenuEvent *event )
override;
238 void removeCurrentItem();
239 void onDatasetGroupSaved(
const QString &uri );
245 void selectAllItem(
bool isChecked );
246 QMenu *createContextMenu();
268 int activeScalarGroup()
const;
271 int activeVectorGroup()
const;
276 void mousePressEvent( QMouseEvent *event )
override;
280 void setActiveScalarGroup(
int group );
283 void setActiveVectorGroup(
int group );
293 void setActiveGroup();
313 int rowCount(
const QModelIndex &parent )
const override;
314 QVariant data(
const QModelIndex &index,
int role )
const override;
316 void setDisplayProviderName(
bool displayProviderName );
318 QStringList variableNames()
const;
322 bool mDisplayProviderName =
false;
Tree widget for display of the mesh dataset groups.
void activeVectorGroupChanged(int groupIndex)
Selected dataset group for vectors changed. -1 for invalid group.
void activeScalarGroupChanged(int groupIndex)
Selected dataset group for contours changed. -1 for invalid group.
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
void setActiveVectorGroup(int group)
Sets active vector group.
int activeScalarGroup() const
Returns index of active group for contours.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void setActiveScalarGroup(int group)
Sets active group for contours.
Qt::ItemFlags flags(const QModelIndex &index) const override
void syncToLayer(QgsMeshLayer *layer)
Add groups to the model from mesh layer.
int activeVectorGroup() const
Returns index of active group for vectors.
QVariant data(const QModelIndex &index, int role) const override
Delegate to display tree item with a contours and vector selector.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
QRect iconRect(const QRect &rect, bool isVector) const
Icon rectangle for given item rectangle.
Tree item for display of the mesh dataset groups.
Item Model for QgsMeshDatasetGroupTreeItem.
QgsMeshDatasetGroupTreeItem * datasetGroupTreeItem(int groupIndex)
Returns the dataset group tree item with index, keeps ownership.
QVariant data(const QModelIndex &index, int role) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void syncToLayer(QgsMeshLayer *layer)
Synchronizes groups to the model from mesh layer.
bool isEnabled(const QModelIndex &index) const
Returns whether the dataset groups related to the QModelIndex is set as enabled.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void resetDefault(QgsMeshLayer *meshLayer)
Resets all groups with default state from the mesh layer.
@ IsActiveVectorDatasetGroup
@ IsActiveScalarDatasetGroup
QgsMeshDatasetGroupTreeItem * datasetGroupTreeRootItem()
Returns the dataset group root tree item, keeps ownership.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void removeItem(const QModelIndex &index)
Removes an item from the tree.
QModelIndex parent(const QModelIndex &index) const override
void setAllGroupsAsEnabled(bool isEnabled)
Sets all groups as enabled.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setPersistentDatasetGroup(const QModelIndex &index, const QString &uri)
Sets the dataset group as persistent with specified uri and for specified index.
Qt::ItemFlags flags(const QModelIndex &index) const override
Tree widget for display of the mesh dataset groups.
Represents a mesh layer supporting display of data on structured or unstructured meshes.