Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
qMRMLSortFilterProxyModel.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware Inc.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Julien Finet, Kitware Inc.
17 and was partially funded by NIH grant 3P41RR013218-12S1
18
19==============================================================================*/
20
21#ifndef __qMRMLSortFilterProxyModel_h
22#define __qMRMLSortFilterProxyModel_h
23
24// Qt includes
25#include <QSortFilterProxyModel>
26#include <QStringList>
27class QStandardItem;
28
29// CTK includes
30#include <ctkVTKObject.h>
31
32// qMRML includes
33#include "qMRMLWidgetsExport.h"
34
35class vtkMRMLNode;
36class vtkMRMLScene;
37class qMRMLAbstractItemHelper;
38class qMRMLSceneModel;
39class qMRMLSortFilterProxyModelPrivate;
40
43class QMRML_WIDGETS_EXPORT qMRMLSortFilterProxyModel : public QSortFilterProxyModel
44{
45 Q_OBJECT
46 QVTK_OBJECT
47
51 Q_PROPERTY(QStringList nodeTypes READ nodeTypes WRITE setNodeTypes)
52
53
57 Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden)
58
63
69
79
85 Q_ENUMS(FilterType)
90 Q_PROPERTY(bool showAll READ showAll WRITE setShowAll STORED false)
94 Q_PROPERTY(bool hideAll READ hideAll WRITE setHideAll STORED false)
95
100 Q_PROPERTY(QStringList hiddenNodeIDs READ hiddenNodeIDs WRITE setHiddenNodeIDs)
101
106 Q_PROPERTY(QStringList visibleNodeIDs READ visibleNodeIDs WRITE setVisibleNodeIDs)
107
112
113public:
120
121 typedef QSortFilterProxyModel Superclass;
122 qMRMLSortFilterProxyModel(QObject* parent = nullptr);
124
127
129 Q_INVOKABLE QModelIndex mrmlSceneIndex() const;
130
132 Q_INVOKABLE vtkMRMLNode* mrmlNodeFromIndex(const QModelIndex& index) const;
133
135 Q_INVOKABLE QModelIndex indexFromMRMLNode(vtkMRMLNode* node, int column = 0) const;
136
140 QStringList nodeTypes() const;
141 void setNodeTypes(const QStringList& nodeTypes);
142
146 bool showHidden() const;
147
152 QStringList showHiddenForTypes() const;
153 void setShowHiddenForTypes(const QStringList& nodeTypes);
154
158 Q_INVOKABLE void addAttribute(const QString& nodeType, const QString& attributeName, const QVariant& attributeValue = QVariant());
161 Q_INVOKABLE void removeAttribute(const QString& nodeType, const QString& attributeName);
162
165 Q_INVOKABLE QVariant attributeFilter(const QString& nodeType, const QString& attributeName) const;
166
170 void setShowChildNodeTypes(bool show);
171 bool showChildNodeTypes() const;
172
177 void setHideChildNodeTypes(const QStringList& nodeTypes);
179 QStringList hideChildNodeTypes() const;
180
183 void setHiddenNodeIDs(const QStringList& nodeIDsToHide);
186 QStringList hiddenNodeIDs() const;
187
190 void setVisibleNodeIDs(const QStringList& nodeIDsToShow);
193 QStringList visibleNodeIDs() const;
194
198 void setHideNodesUnaffiliatedWithNodeID(const QString& nodeID);
202
208 bool showAll() const;
211 bool hideAll() const;
212
214 Q_INVOKABLE qMRMLSceneModel* sceneModel() const;
215
216public slots:
219 void setShowHidden(bool);
220
226 void setShowAll(bool show);
229 void setHideAll(bool hide);
230
231 // TODO Add setMRMLScene() to propagate to the scene model
232protected:
251
259 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
265
266 QStandardItem* sourceItem(const QModelIndex& index) const;
267
268protected:
269 QScopedPointer<qMRMLSortFilterProxyModelPrivate> d_ptr;
270
271private:
272 Q_DECLARE_PRIVATE(qMRMLSortFilterProxyModel);
273 Q_DISABLE_COPY(qMRMLSortFilterProxyModel);
274};
275
276#endif
void setHideChildNodeTypes(const QStringList &nodeTypes)
QStringList nodeTypes() const
QStringList showHiddenForTypes() const
Q_INVOKABLE void addAttribute(const QString &nodeType, const QString &attributeName, const QVariant &attributeValue=QVariant())
void setShowChildNodeTypes(bool show)
Q_INVOKABLE void removeAttribute(const QString &nodeType, const QString &attributeName)
QString hideNodesUnaffiliatedWithNodeID() const
void setShowAll(bool show)
QScopedPointer< qMRMLSortFilterProxyModelPrivate > d_ptr
QStandardItem * sourceItem(const QModelIndex &index) const
Q_INVOKABLE QVariant attributeFilter(const QString &nodeType, const QString &attributeName) const
Q_INVOKABLE QModelIndex indexFromMRMLNode(vtkMRMLNode *node, int column=0) const
Retrieve an index for a given vtkMRMLNode.
virtual AcceptType filterAcceptsNode(vtkMRMLNode *node) const
qMRMLSortFilterProxyModel(QObject *parent=nullptr)
void setVisibleNodeIDs(const QStringList &nodeIDsToShow)
void setHiddenNodeIDs(const QStringList &nodeIDsToHide)
void setHideAll(bool hide)
void setFilterType(FilterType filterType)
QStringList hiddenNodeIDs() const
QStringList hideChildNodeTypes() const
Q_INVOKABLE QModelIndex mrmlSceneIndex() const
Retrieve the MRML scene index.
Q_INVOKABLE vtkMRMLNode * mrmlNodeFromIndex(const QModelIndex &index) const
Retrieve the associated vtkMRMLNode.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void setShowHiddenForTypes(const QStringList &nodeTypes)
bool showChildNodeTypes() const
void setNodeTypes(const QStringList &nodeTypes)
Q_INVOKABLE qMRMLSceneModel * sceneModel() const
Return the scene model used as input if any.
QStringList visibleNodeIDs() const
~qMRMLSortFilterProxyModel() override
vtkMRMLScene * mrmlScene() const
Retrieve the associated MRML scene.
FilterType filterType() const
void setHideNodesUnaffiliatedWithNodeID(const QString &nodeID)
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.