pqDataAssemblyTreeModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqDataAssemblyTreeModel_h
5 #define pqDataAssemblyTreeModel_h
6 
7 #include "pqComponentsModule.h" // for exports
8 #include <QAbstractItemModel>
9 #include <QPair> // for QPair
10 #include <QScopedPointer> // for QScopedPointer.
11 
12 class vtkDataAssembly;
13 
28 class PQCOMPONENTS_EXPORT pqDataAssemblyTreeModel : public QAbstractItemModel
29 {
30  Q_OBJECT;
31  typedef QAbstractItemModel Superclass;
32 
33 public:
34  pqDataAssemblyTreeModel(QObject* parent = nullptr);
35  ~pqDataAssemblyTreeModel() override;
36 
40  void setDataAssembly(vtkDataAssembly* assembly);
41  vtkDataAssembly* dataAssembly() const;
42 
44 
47  void setUserCheckable(bool);
48  bool userCheckable() const { return this->UserCheckable; }
50 
52 
56  int nodeId(const QModelIndex& idx) const;
57  QList<int> nodeId(const QModelIndexList& idxes) const;
59 
61 
64  QModelIndex index(int nodeId) const;
65  QModelIndexList index(const QList<int>& nodeIds) const;
67 
69 
86  void setCheckedNodes(const QStringList& paths);
87  QStringList checkedNodes(bool leafNodesOnly = false) const;
89 
95  static int GetIsDerivedRole(int role) { return -role; }
96 
109  {
113  };
114 
116 
120  void setRoleProperty(int role, RoleProperties property);
121  RoleProperties roleProperty(int role) const;
123 
125 
140  bool setData(const QList<QPair<QString, QVariant>>& values, int role);
141  QList<QPair<QString, QVariant>> data(int role) const;
143 
145 
148  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
149  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
150  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
151  QModelIndex parent(const QModelIndex& index = QModelIndex()) const override;
152  QVariant data(const QModelIndex& index, int role) const override;
153  Qt::ItemFlags flags(const QModelIndex& index) const override;
154  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
156 Q_SIGNALS:
163  void modelDataChanged(int role);
164 
165 private:
166  void fireDataChanged(const QModelIndex& root, const QVector<int>& roles);
167 
168  Q_DISABLE_COPY(pqDataAssemblyTreeModel);
169 
170  class pqInternals;
171  QScopedPointer<pqInternals> Internals;
172 
173  bool UserCheckable;
174 };
175 
176 #endif
data
static int GetIsDerivedRole(int role)
For custom roles, use this function to convert that role into a role that can be used in data() to ge...
bool userCheckable() const
Get whether the model is user-checkable.
RoleProperties
Supported role properties.
QAbstractItemModel implementation for vtkDataAssembly.
index