VTK  9.3.20240419
vtkQtTreeView.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 vtkQtTreeView_h
20 #define vtkQtTreeView_h
21 
22 #include "vtkQtView.h"
23 #include "vtkViewsQtModule.h" // For export macro
24 
25 #include "vtkSmartPointer.h" // Needed for member variables
26 #include <QList> // Needed for member variables
27 #include <QPointer> // Needed for member variables
28 
29 class QAbstractItemDelegate;
30 class QAbstractItemView;
31 class QColumnView;
32 class QItemSelection;
33 class QModelIndex;
34 class QTreeView;
35 class QItemSelectionModel;
36 class QVBoxLayout;
37 
38 VTK_ABI_NAMESPACE_BEGIN
40 class vtkApplyColors;
42 
43 class VTKVIEWSQT_EXPORT vtkQtTreeView : public vtkQtView
44 {
45  Q_OBJECT
46 
47 Q_SIGNALS:
48  void expanded(const QModelIndex&);
49  void collapsed(const QModelIndex&);
50  void updatePreviewWidget(const QModelIndex&);
51 
52 public:
53  static vtkQtTreeView* New();
54  vtkTypeMacro(vtkQtTreeView, vtkQtView);
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
63  QWidget* GetWidget() override;
64 
68  void SetShowHeaders(bool);
69 
74 
78  void SetEnableDragDrop(bool);
79 
83  void SetShowRootNode(bool);
84 
88  void HideColumn(int i);
89 
93  void ShowColumn(int i);
94 
99 
103  void SetFilterColumn(int i);
104 
108 #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
109  void SetFilterRegExp(const QRegularExpression& pattern);
110 #else
111  void SetFilterRegExp(const QRegExp& pattern);
112 #endif
113 
118 
122  void Collapse(const QModelIndex& index);
123 
127  void CollapseAll();
128 
132  void Expand(const QModelIndex& index);
133 
139  void ExpandAll();
140 
144  void ExpandToDepth(int depth);
145 
149  void ResizeColumnToContents(int column);
150 
154  void SetUseColumnView(int state);
155 
159  void Update() override;
160 
164  void SetItemDelegate(QAbstractItemDelegate* delegate);
165 
167 
170  void SetColorArrayName(const char* name);
171  const char* GetColorArrayName();
173 
175 
178  void SetColorByArray(bool vis);
180  vtkBooleanMacro(ColorByArray, bool);
182 
183  void ApplyViewTheme(vtkViewTheme* theme) override;
184 
185 protected:
187  ~vtkQtTreeView() override;
188 
191 
192 private Q_SLOTS:
193  void slotQtSelectionChanged(const QItemSelection&, const QItemSelection&);
194 
195 private: // NOLINT(readability-redundant-access-specifiers)
196  void SetVTKSelection();
197  vtkMTimeType CurrentSelectionMTime;
198  vtkMTimeType LastInputMTime;
199 
200  vtkSetStringMacro(ColorArrayNameInternal);
201  vtkGetStringMacro(ColorArrayNameInternal);
202 
203  QPointer<QTreeView> TreeView;
204  QPointer<QColumnView> ColumnView;
205  QPointer<QWidget> Widget;
206  QPointer<QVBoxLayout> Layout;
207  QPointer<QItemSelectionModel> SelectionModel;
208  QList<int> HiddenColumns;
209  vtkQtTreeModelAdapter* TreeAdapter;
210  QAbstractItemView* View;
211  char* ColorArrayNameInternal;
212  QFilterTreeProxyModel* TreeFilter;
213 
215 
216  vtkQtTreeView(const vtkQtTreeView&) = delete;
217  void operator=(const vtkQtTreeView&) = delete;
218 };
219 
220 VTK_ABI_NAMESPACE_END
221 #endif
apply colors to a data set.
The superclass for all representations.
a simple class to control print indentation
Definition: vtkIndent.h:108
Adapts a tree to a Qt item model.
A VTK view based on a Qt tree view.
Definition: vtkQtTreeView.h:44
void SetFilterTreeLevel(int level)
The column used to filter on.
void SetShowRootNode(bool)
Show the root node of the tree (default is OFF)
void SetColorByArray(bool vis)
Whether to color vertices.
void ApplyViewTheme(vtkViewTheme *theme) override
void SetUseColumnView(int state)
Set whether to use a QColumnView (QTreeView is the default)
void SetFilterRegExp(const QRegularExpression &pattern)
The column used to filter on.
void ExpandToDepth(int depth)
Expands all expandable items to the given depth.
void SetColorArrayName(const char *name)
The array to use for coloring items in view.
void RemoveRepresentationInternal(vtkDataRepresentation *rep) override
void Collapse(const QModelIndex &index)
Collapses the model item specified by the index.
void AddRepresentationInternal(vtkDataRepresentation *rep) override
void SetFilterColumn(int i)
The column used to filter on.
bool GetColorByArray()
Whether to color vertices.
void updatePreviewWidget(const QModelIndex &)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void CollapseAll()
Collapses all expanded items.
void HideAllButFirstColumn()
Hide all but the first column in the view.
static vtkQtTreeView * New()
void Expand(const QModelIndex &index)
Expands the model item specified by the index.
~vtkQtTreeView() override
void collapsed(const QModelIndex &)
QWidget * GetWidget() override
Get the main container of this view (a QWidget).
void SetEnableDragDrop(bool)
Have the view alternate its row colors (default is OFF)
void ResizeColumnToContents(int column)
Resizes the column given to the size of its contents.
void ShowColumn(int i)
Show the column of the given index in the view.
void SetShowHeaders(bool)
Have the view show/hide its column headers (default is ON)
void SetItemDelegate(QAbstractItemDelegate *delegate)
Set item delegate to something custom.
void HideColumn(int i)
Hide the column of the given index from being shown in the view.
void SetAlternatingRowColors(bool)
Have the view alternate its row colors (default is OFF)
const char * GetColorArrayName()
The array to use for coloring items in view.
void ExpandAll()
Expands all expandable items.
void expanded(const QModelIndex &)
void Update() override
Updates the view.
Superclass for Qt widget-based views.
Definition: vtkQtView.h:27
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:123
@ level
Definition: vtkX3D.h:395
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270