VTK
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 -------------------------------------------------------------------------*/
34 #ifndef __vtkQtTreeView_h
35 #define __vtkQtTreeView_h
36 
37 #include "QVTKWin32Header.h"
38 #include "vtkQtView.h"
39 
40 #include <QList>
41 #include <QPointer>
43 #include "vtkSmartPointer.h"
44 #include "QFilterTreeProxyModel.h"
45 
46 class QAbstractItemDelegate;
47 class QAbstractItemView;
48 class QColumnView;
49 class QItemSelection;
50 class QTreeView;
51 class vtkApplyColors;
52 class QVBoxLayout;
54 class QItemSelectionModel;
55 
56 class QVTK_EXPORT vtkQtTreeView : public vtkQtView
57 {
58 Q_OBJECT
59 
60 signals:
61  void expanded(const QModelIndex&);
62  void collapsed(const QModelIndex&);
63  void updatePreviewWidget(const QModelIndex&);
64 
65 public:
66  static vtkQtTreeView *New();
67  vtkTypeMacro(vtkQtTreeView, vtkQtView);
68  void PrintSelf(ostream& os, vtkIndent indent);
69 
73  virtual QWidget* GetWidget();
74 
76  void SetShowHeaders(bool);
77 
79  void SetAlternatingRowColors(bool);
80 
82  void SetEnableDragDrop(bool);
83 
85  void SetShowRootNode(bool);
86 
88  void HideColumn(int i);
89 
91  void ShowColumn(int i);
92 
94  void HideAllButFirstColumn();
95 
97  void SetFilterColumn(int i);
98 
100  void SetFilterRegExp(const QRegExp& pattern);
101 
103  void SetFilterTreeLevel(int level);
104 
106  void Collapse( const QModelIndex & index );
107 
109  void CollapseAll();
110 
112  void Expand ( const QModelIndex & index );
113 
116  void ExpandAll ();
117 
119  void ExpandToDepth ( int depth );
120 
122  void ResizeColumnToContents ( int column );
123 
125  void SetUseColumnView(int state);
126 
128  virtual void Update();
129 
131  void SetItemDelegate(QAbstractItemDelegate* delegate);
132 
134 
135  void SetColorArrayName(const char* name);
136  const char* GetColorArrayName();
138 
140 
141  void SetColorByArray(bool vis);
142  bool GetColorByArray();
143  vtkBooleanMacro(ColorByArray, bool);
145 
146  virtual void ApplyViewTheme(vtkViewTheme* theme);
147 
148 protected:
149  vtkQtTreeView();
150  ~vtkQtTreeView();
151 
154 
155 private slots:
156  void slotQtSelectionChanged(const QItemSelection&,const QItemSelection&);
157 
158 private:
159  void SetVTKSelection();
160  unsigned long CurrentSelectionMTime;
161  unsigned long LastInputMTime;
162 
163  vtkSetStringMacro(ColorArrayNameInternal);
164  vtkGetStringMacro(ColorArrayNameInternal);
165 
166  QPointer<QTreeView> TreeView;
167  QPointer<QColumnView> ColumnView;
168  QPointer<QWidget> Widget;
169  QPointer<QVBoxLayout> Layout;
170  QPointer<QItemSelectionModel> SelectionModel;
171  QList<int> HiddenColumns;
172  vtkQtTreeModelAdapter* TreeAdapter;
173  QAbstractItemView* View;
174  char* ColorArrayNameInternal;
175  QFilterTreeProxyModel* TreeFilter;
176 
178 
179  vtkQtTreeView(const vtkQtTreeView&); // Not implemented.
180  void operator=(const vtkQtTreeView&); // Not implemented.
181 
182 };
183 
184 #endif