VTK
QFilterTreeProxyModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QFilterTreeProxyModel.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 -------------------------------------------------------------------------*/
20 // .NAME QFilterTreeProxyModel - An implementation of a QSortFilterProxyModel
21 // tailored for hierarchical models.
22 //
23 // .SECTION Description
24 // An implementation of a QSortFilterProxyModel tailored for hierarchical
25 // models. It allows you to filter the model based on the content in a
26 // certain column of a certain level in the tree. Indices above that level
27 // in the tree are retained. Indices below the level are kept if their
28 // ancestor at the tree level is kept.
29 //
30 // .SECTION See also
31 
32 #ifndef __QFilterTreeProxyModel_h
33 #define __QFilterTreeProxyModel_h
34 
35 #include "vtkGUISupportQtModule.h" // For export macro
36 #include "QVTKWin32Header.h"
37 #include <QSortFilterProxyModel>
38 
39 class QModelIndex;
40 
41 class VTKGUISUPPORTQT_EXPORT QFilterTreeProxyModel : public QSortFilterProxyModel
42 {
43  Q_OBJECT
44 
45 public:
46 
47  QFilterTreeProxyModel(QObject* p = 0);
49 
50  // Description:
51  // The 0-based level in the tree hierarchy to filter on. The root is level 0.
52  void setFilterTreeLevel(int level);
53 
54 protected:
55 
56  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
57  virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
58 
59 private:
60 
61  int TreeLevel;
62 };
63 
64 #endif