VTK  9.3.1
vtkQtTreeModelAdapter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
19 #ifndef vtkQtTreeModelAdapter_h
20 #define vtkQtTreeModelAdapter_h
21 
22 #include "vtkGUISupportQtModule.h" // For export macro
23 
25 #include "vtkType.h" // Needed for vtkIdType
26 #include <QHash> // Needed for the decoration map
27 #include <QVector> // Needed for the index map
28 
29 class QMimeData;
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkSelection;
33 class vtkTree;
35 
36 class VTKGUISUPPORTQT_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
37 {
38  Q_OBJECT
39 
40 public:
41  vtkQtTreeModelAdapter(QObject* parent = nullptr, vtkTree* tree = nullptr);
42  ~vtkQtTreeModelAdapter() override;
43 
45 
48  void SetVTKDataObject(vtkDataObject* data) override;
49  vtkDataObject* GetVTKDataObject() const override;
51 
60  vtkMTimeType GetVTKDataObjectMTime() const;
61 
63 
66  vtkSelection* QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const override;
67  QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
69 
70  void SetKeyColumnName(const char* name) override;
71 
72  void SetColorColumnName(const char* name) override;
73 
77  void setTree(vtkTree* t);
78  vtkTree* tree() const { return this->Tree; }
79 
80  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
81  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
82  Qt::ItemFlags flags(const QModelIndex& index) const override;
83  QVariant headerData(
84  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
85  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
86  QModelIndex parent(const QModelIndex& index) const override;
87  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
88  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
89 
91 
96  Qt::DropActions supportedDragActions() const override;
97  QMimeData* mimeData(const QModelIndexList& indexes) const override;
98  QStringList mimeTypes() const override;
100 
101 protected:
102  void treeModified();
103  void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
104 
108  QVector<QModelIndex> VTKIndexToQtModelIndex;
109  QHash<QModelIndex, QVariant> IndexToDecoration;
110 
111 private:
113  void operator=(const vtkQtTreeModelAdapter&) = delete;
114 };
115 
116 VTK_ABI_NAMESPACE_END
117 #endif
118 // VTK-HeaderTest-Exclude: vtkQtTreeModelAdapter.h
QHash< QModelIndex, QVariant > IndexToDecoration
vtkAdjacentVertexIterator * ChildIterator
Adapts a tree to a Qt item model.
QVector< QModelIndex > VTKIndexToQtModelIndex
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
Iterates through adjacent vertices in a graph.
virtual vtkSelection * QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const =0
Selection conversion from VTK land to Qt land.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:49
int vtkIdType
Definition: vtkType.h:315
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =0
Set/Get the VTK data object as input to this adapter.
Superclass for Qt model adapters.
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
Set/Get the VTK data object as input to this adapter.
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
Selection conversion from VTK land to Qt land.
A rooted tree data structure.
Definition: vtkTree.h:45
general representation of visualization data
Definition: vtkDataObject.h:54