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 
85  void setCheckedNodes(const QStringList& paths);
86  QStringList checkedNodes() const;
88 
94  static int GetIsDerivedRole(int role) { return -role; }
95 
108  {
112  };
113 
115 
119  void setRoleProperty(int role, RoleProperties property);
120  RoleProperties roleProperty(int role) const;
122 
124 
139  bool setData(const QList<QPair<QString, QVariant>>& values, int role);
140  QList<QPair<QString, QVariant>> data(int role) const;
142 
144 
147  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
148  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
149  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
150  QModelIndex parent(const QModelIndex& index = QModelIndex()) const override;
151  QVariant data(const QModelIndex& index, int role) const override;
152  Qt::ItemFlags flags(const QModelIndex& index) const override;
153  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
155 Q_SIGNALS:
162  void modelDataChanged(int role);
163 
164 private:
165  void fireDataChanged(const QModelIndex& root, const QVector<int>& roles);
166 
167  Q_DISABLE_COPY(pqDataAssemblyTreeModel);
168 
169  class pqInternals;
170  QScopedPointer<pqInternals> Internals;
171 
172  bool UserCheckable;
173 };
174 
175 #endif
data
#define PQCOMPONENTS_EXPORT
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