Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
36class qMRMLSortFilterSubjectHierarchyProxyModelPrivate;
38class vtkMRMLScene;
39class QStandardItem;
40
41class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qMRMLSortFilterSubjectHierarchyProxyModel : public QSortFilterProxyModel
42{
43 Q_OBJECT
44 QVTK_OBJECT
45
47 Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter)
57 Q_PROPERTY(QStringList levelFilter READ levelFilter WRITE setLevelFilter)
58
61 Q_PROPERTY(QStringList nodeTypes READ nodeTypes WRITE setNodeTypes)
71
86
96
97public:
98 typedef QSortFilterProxyModel Superclass;
101
103 Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
104
105 QString nameFilter()const;
106 QStringList levelFilter()const;
107 QStringList nodeTypes()const;
108 QStringList hideChildNodeTypes()const;
113 QString attributeValueFilter()const;
114 QString attributeNameFilter()const;
122 Q_INVOKABLE void addItemAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true);
124 Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, QVariant attributeValue, bool include);
126 Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, bool include);
135 Q_INVOKABLE void addNodeAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true, QString className=QString());
137 Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, QVariant attributeValue, bool include, QString className);
139 Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, bool include);
140
143
146
148 Q_INVOKABLE QModelIndex subjectHierarchySceneIndex()const;
149
151 Q_INVOKABLE vtkIdType subjectHierarchyItemFromIndex(const QModelIndex& index)const;
152
154 Q_INVOKABLE QModelIndex indexFromSubjectHierarchyItem(vtkIdType itemID, int column=0)const;
155
159 Q_INVOKABLE int acceptedItemCount(vtkIdType rootItemID=0)const;
160
164 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent)const override;
165
166 Qt::ItemFlags flags(const QModelIndex & index)const override;
167
168public slots:
169 void setNameFilter(QString filter);
170 void setAttributeNameFilter(QString filter);
171 void setAttributeValueFilter(QString filter);
172 void setLevelFilter(QStringList filter);
173 void setNodeTypes(const QStringList& types);
174 void setHideChildNodeTypes(const QStringList& types);
175 void setIncludeItemAttributeNamesFilter(QStringList filterList);
176 void setIncludeNodeAttributeNamesFilter(QStringList filterList);
177 void setExcludeItemAttributeNamesFilter(QStringList filterList);
178 void setExcludeNodeAttributeNamesFilter(QStringList filterList);
179
180protected:
195
197 virtual AcceptType filterAcceptsItem(vtkIdType itemID, bool canAcceptIfAnyChildIsAccepted=true)const;
198
199 QStandardItem* sourceItem(const QModelIndex& index)const;
200
201protected:
202 QScopedPointer<qMRMLSortFilterSubjectHierarchyProxyModelPrivate> d_ptr;
203
204private:
208};
209
210#endif
QScopedPointer< qMRMLSortFilterSubjectHierarchyProxyModelPrivate > d_ptr
Q_INVOKABLE int acceptedItemCount(vtkIdType rootItemID=0) const
virtual AcceptType filterAcceptsItem(vtkIdType itemID, bool canAcceptIfAnyChildIsAccepted=true) const
Filters items to decide which to display in the view.
void setExcludeNodeAttributeNamesFilter(QStringList filterList)
void setIncludeNodeAttributeNamesFilter(QStringList filterList)
Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, QVariant attributeValue, bool include)
Remove single item attribute filter specifying each attribute.
Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, QVariant attributeValue, bool include, QString className)
Remove single node attribute filter specifying each attribute.
Q_INVOKABLE QModelIndex indexFromSubjectHierarchyItem(vtkIdType itemID, int column=0) const
Retrieve an index for a given a subject hierarchy item ID.
void setNodeTypes(const QStringList &types)
void setHideItemsUnaffiliatedWithItemID(vtkIdType itemID)
Qt::ItemFlags flags(const QModelIndex &index) const override
Q_INVOKABLE void addNodeAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true, QString className=QString())
Q_INVOKABLE vtkMRMLScene * mrmlScene() const
void setLevelFilter(QStringList filter)
QStringList levelFilter
Filter to show only items of a certain level (and their parents). If empty, then show all.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Q_INVOKABLE vtkMRMLSubjectHierarchyNode * subjectHierarchyNode() const
Q_INVOKABLE QModelIndex subjectHierarchySceneIndex() const
Retrieve the index of the MRML scene (the root item) in the subject hierarchy tree.
Q_INVOKABLE void addItemAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true)
void setExcludeItemAttributeNamesFilter(QStringList filterList)
void setAttributeValueFilter(QString filter)
void setHideChildNodeTypes(const QStringList &types)
QStandardItem * sourceItem(const QModelIndex &index) const
qMRMLSortFilterSubjectHierarchyProxyModel(QObject *parent=nullptr)
QVTK_OBJECTQString nameFilter
Filter to show only items that contain the string in their names. Empty by default.
Q_INVOKABLE vtkIdType subjectHierarchyItemFromIndex(const QModelIndex &index) const
Retrieve the associated subject hierarchy item ID from a model index.
void setIncludeItemAttributeNamesFilter(QStringList filterList)
A set of MRML Nodes that supports serialization and undo/redo.
MRML node to represent a complete subject hierarchy tree.