Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qMRMLSortFilterSubjectHierarchyProxyModel.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6  Queen's University, Kingston, ON, Canada. All Rights Reserved.
7 
8  See COPYRIGHT.txt
9  or http://www.slicer.org/copyright/copyright.txt for details.
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18  and was supported through the Applied Cancer Research Unit program of Cancer Care
19  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20 
21 ==============================================================================*/
22 
23 #ifndef __qMRMLSortFilterSubjectHierarchyProxyModel_h
24 #define __qMRMLSortFilterSubjectHierarchyProxyModel_h
25 
26 // SubjectHierarchy includes
27 #include "qSlicerSubjectHierarchyModuleWidgetsExport.h"
28 
29 // Qt includes
30 #include <QSortFilterProxyModel>
31 
32 // CTK includes
33 #include <ctkVTKObject.h>
34 #include <ctkPimpl.h>
35 
36 class qMRMLSortFilterSubjectHierarchyProxyModelPrivate;
38 class vtkMRMLScene;
39 class QStandardItem;
40 
42 class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qMRMLSortFilterSubjectHierarchyProxyModel : public QSortFilterProxyModel
43 {
44  Q_OBJECT
45  QVTK_OBJECT
46 
48  Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter)
51  Q_PROPERTY(vtkIdType hideItemsUnaffiliatedWithItemID READ hideItemsUnaffiliatedWithItemID WRITE setHideItemsUnaffiliatedWithItemID)
53  Q_PROPERTY(QStringList levelFilter READ levelFilter WRITE setLevelFilter)
56  Q_PROPERTY(QStringList nodeTypes READ nodeTypes WRITE setNodeTypes)
65  Q_PROPERTY(QStringList hideChildNodeTypes READ hideChildNodeTypes WRITE setHideChildNodeTypes)
66 
69  Q_PROPERTY(QStringList includeItemAttributeNamesFilter READ includeItemAttributeNamesFilter WRITE setIncludeItemAttributeNamesFilter)
72  Q_PROPERTY(QStringList includeNodeAttributeNamesFilter READ includeNodeAttributeNamesFilter WRITE setIncludeNodeAttributeNamesFilter)
76  Q_PROPERTY(QStringList excludeItemAttributeNamesFilter READ excludeItemAttributeNamesFilter WRITE setExcludeItemAttributeNamesFilter)
80  Q_PROPERTY(QStringList excludeNodeAttributeNamesFilter READ excludeNodeAttributeNamesFilter WRITE setExcludeNodeAttributeNamesFilter)
81 
84  Q_PROPERTY(QString attributeNameFilter READ attributeNameFilter WRITE setAttributeNameFilter)
89  Q_PROPERTY(QString attributeValueFilter READ attributeValueFilter WRITE setAttributeValueFilter)
90 
91 public:
92  typedef QSortFilterProxyModel Superclass;
93  qMRMLSortFilterSubjectHierarchyProxyModel(QObject *parent=nullptr);
95 
96  Q_INVOKABLE vtkMRMLSubjectHierarchyNode* subjectHierarchyNode()const;
97  Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
98 
99  QString nameFilter()const;
100  QStringList levelFilter()const;
101  QStringList nodeTypes()const;
102  QStringList hideChildNodeTypes()const;
103  QStringList includeItemAttributeNamesFilter()const;
104  QStringList includeNodeAttributeNamesFilter()const;
105  QStringList excludeItemAttributeNamesFilter()const;
106  QStringList excludeNodeAttributeNamesFilter()const;
107  QString attributeValueFilter()const;
108  QString attributeNameFilter()const;
116  Q_INVOKABLE void addItemAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true);
118  Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, QVariant attributeValue, bool include);
120  Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, bool include);
129  Q_INVOKABLE void addNodeAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true, QString className=QString());
131  Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, QVariant attributeValue, bool include, QString className);
133  Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, bool include);
134 
135  Q_INVOKABLE vtkIdType hideItemsUnaffiliatedWithItemID();
136  Q_INVOKABLE void setHideItemsUnaffiliatedWithItemID(vtkIdType itemID);
137 
139  Q_INVOKABLE QModelIndex subjectHierarchySceneIndex()const;
140 
142  Q_INVOKABLE vtkIdType subjectHierarchyItemFromIndex(const QModelIndex& index)const;
143 
145  Q_INVOKABLE QModelIndex indexFromSubjectHierarchyItem(vtkIdType itemID, int column=0)const;
146 
150  Q_INVOKABLE int acceptedItemCount(vtkIdType rootItemID=0)const;
151 
155  bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent)const override;
156 
158  virtual bool filterAcceptsItem(vtkIdType itemID, bool canAcceptIfAnyChildIsAccepted=true)const;
159 
160  Qt::ItemFlags flags(const QModelIndex & index)const override;
161 
162 public slots:
163  void setNameFilter(QString filter);
164  void setAttributeNameFilter(QString filter);
165  void setAttributeValueFilter(QString filter);
166  void setLevelFilter(QStringList filter);
167  void setNodeTypes(const QStringList& types);
168  void setHideChildNodeTypes(const QStringList& types);
169  void setIncludeItemAttributeNamesFilter(QStringList filterList);
170  void setIncludeNodeAttributeNamesFilter(QStringList filterList);
171  void setExcludeItemAttributeNamesFilter(QStringList filterList);
172  void setExcludeNodeAttributeNamesFilter(QStringList filterList);
173 
174 protected:
175 
176  QStandardItem* sourceItem(const QModelIndex& index)const;
177 
178 protected:
179  QScopedPointer<qMRMLSortFilterSubjectHierarchyProxyModelPrivate> d_ptr;
180 
181 private:
184 };
185 
186 #endif
MRML node to represent a complete subject hierarchy tree.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61