VTK  9.2.6
vtkQtTreeView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtTreeView.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
35 #ifndef vtkQtTreeView_h
36 #define vtkQtTreeView_h
37 
38 #include "vtkQtView.h"
39 #include "vtkViewsQtModule.h" // For export macro
40 
41 #include "vtkSmartPointer.h" // Needed for member variables
42 #include <QList> // Needed for member variables
43 #include <QPointer> // Needed for member variables
44 
45 class QAbstractItemDelegate;
46 class QAbstractItemView;
48 class QColumnView;
49 class QItemSelection;
50 class QModelIndex;
51 class QTreeView;
52 class vtkApplyColors;
53 class QVBoxLayout;
55 class QItemSelectionModel;
56 
57 class VTKVIEWSQT_EXPORT vtkQtTreeView : public vtkQtView
58 {
59  Q_OBJECT
60 
61 Q_SIGNALS:
62  void expanded(const QModelIndex&);
63  void collapsed(const QModelIndex&);
64  void updatePreviewWidget(const QModelIndex&);
65 
66 public:
67  static vtkQtTreeView* New();
68  vtkTypeMacro(vtkQtTreeView, vtkQtView);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
77  QWidget* GetWidget() override;
78 
82  void SetShowHeaders(bool);
83 
87  void SetAlternatingRowColors(bool);
88 
92  void SetEnableDragDrop(bool);
93 
97  void SetShowRootNode(bool);
98 
102  void HideColumn(int i);
103 
107  void ShowColumn(int i);
108 
112  void HideAllButFirstColumn();
113 
117  void SetFilterColumn(int i);
118 
122 #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
123  void SetFilterRegExp(const QRegularExpression& pattern);
124 #else
125  void SetFilterRegExp(const QRegExp& pattern);
126 #endif
127 
131  void SetFilterTreeLevel(int level);
132 
136  void Collapse(const QModelIndex& index);
137 
141  void CollapseAll();
142 
146  void Expand(const QModelIndex& index);
147 
153  void ExpandAll();
154 
158  void ExpandToDepth(int depth);
159 
163  void ResizeColumnToContents(int column);
164 
168  void SetUseColumnView(int state);
169 
173  void Update() override;
174 
178  void SetItemDelegate(QAbstractItemDelegate* delegate);
179 
181 
184  void SetColorArrayName(const char* name);
185  const char* GetColorArrayName();
187 
189 
192  void SetColorByArray(bool vis);
193  bool GetColorByArray();
194  vtkBooleanMacro(ColorByArray, bool);
196 
197  void ApplyViewTheme(vtkViewTheme* theme) override;
198 
199 protected:
200  vtkQtTreeView();
201  ~vtkQtTreeView() override;
202 
205 
206 private Q_SLOTS:
207  void slotQtSelectionChanged(const QItemSelection&, const QItemSelection&);
208 
209 private:
210  void SetVTKSelection();
211  vtkMTimeType CurrentSelectionMTime;
212  vtkMTimeType LastInputMTime;
213 
214  vtkSetStringMacro(ColorArrayNameInternal);
215  vtkGetStringMacro(ColorArrayNameInternal);
216 
217  QPointer<QTreeView> TreeView;
218  QPointer<QColumnView> ColumnView;
219  QPointer<QWidget> Widget;
220  QPointer<QVBoxLayout> Layout;
221  QPointer<QItemSelectionModel> SelectionModel;
222  QList<int> HiddenColumns;
223  vtkQtTreeModelAdapter* TreeAdapter;
224  QAbstractItemView* View;
225  char* ColorArrayNameInternal;
226  QFilterTreeProxyModel* TreeFilter;
227 
229 
230  vtkQtTreeView(const vtkQtTreeView&) = delete;
231  void operator=(const vtkQtTreeView&) = delete;
232 };
233 
234 #endif
virtual void ApplyViewTheme(vtkViewTheme *vtkNotUsed(theme))
Apply a theme to the view.
Definition: vtkView.h:156
static vtkView * New()
Adapts a tree to a Qt item model.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
virtual void Update()
Update the view.
virtual QWidget * GetWidget()=0
Get the main container of this view (a QWidget).
virtual void AddRepresentationInternal(vtkDataRepresentation *vtkNotUsed(rep))
Subclass "hooks" for notifying subclasses of vtkView when representations are added or removed...
Definition: vtkView.h:234
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:48
a simple class to control print indentation
Definition: vtkIndent.h:39
The superclass for all representations.
apply colors to a data set.
Superclass for Qt widget-based views.
Definition: vtkQtView.h:31
virtual void RemoveRepresentationInternal(vtkDataRepresentation *vtkNotUsed(rep))
Meant for use by subclasses and vtkRepresentation subclasses.
Definition: vtkView.h:235
A VTK view based on a Qt tree view.
Definition: vtkQtTreeView.h:57