VTK  9.3.20240418
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);
43 
45 
49  vtkDataObject* GetVTKDataObject() const override;
51 
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
Iterates through adjacent vertices in a graph.
general representation of visualization data
Superclass for Qt model adapters.
Adapts a tree to a Qt item model.
void SetVTKDataObject(vtkDataObject *data) override
Set/Get the VTK data object as input to this adapter.
vtkAdjacentVertexIterator * ChildIterator
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void setTree(vtkTree *t)
Set up the model based on the current tree.
QHash< QModelIndex, QVariant > IndexToDecoration
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QMimeData * mimeData(const QModelIndexList &indexes) const override
If drag/drop is enabled in the view, the model will package up the current pedigreeid vtkSelection in...
void SetColorColumnName(const char *name) override
Qt::DropActions supportedDragActions() const override
If drag/drop is enabled in the view, the model will package up the current pedigreeid vtkSelection in...
vtkSelection * QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const override
Selection conversion from VTK land to Qt land.
vtkMTimeType GetVTKDataObjectMTime() const
Get the stored VTK data object modification time of when the adaption to a Qt model was done.
void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index)
QModelIndex parent(const QModelIndex &index) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QStringList mimeTypes() const override
If drag/drop is enabled in the view, the model will package up the current pedigreeid vtkSelection in...
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const override
Selection conversion from VTK land to Qt land.
QVector< QModelIndex > VTKIndexToQtModelIndex
vtkDataObject * GetVTKDataObject() const override
Set/Get the VTK data object as input to this adapter.
vtkQtTreeModelAdapter(QObject *parent=nullptr, vtkTree *tree=nullptr)
void SetKeyColumnName(const char *name) override
~vtkQtTreeModelAdapter() override
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:159
A rooted tree data structure.
Definition: vtkTree.h:145
@ orientation
Definition: vtkX3D.h:262
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
@ data
Definition: vtkX3D.h:315
int vtkIdType
Definition: vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270