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
qMRMLSortFilterSegmentsProxyModel.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4 Queen's University, Kingston, ON, Canada. All Rights Reserved.
5
6 See COPYRIGHT.txt
7 or http://www.slicer.org/copyright/copyright.txt for details.
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 This file was originally developed by Kyle Sunderland, PerkLab, Queen's University
16 and was supported through CANARIE's Research Software Program, and Cancer
17 Care Ontario.
18
19==============================================================================*/
20
21#ifndef __qMRMLSortFilterSegmentsProxyModel_h
22#define __qMRMLSortFilterSegmentsProxyModel_h
23
24// Segmentation includes
25#include "qSlicerSegmentationsModuleWidgetsExport.h"
26
27// Qt includes
28#include <QSortFilterProxyModel>
29
30// CTK includes
31#include <ctkVTKObject.h>
32#include <ctkPimpl.h>
33
34class qMRMLSortFilterSegmentsProxyModelPrivate;
35class QStandardItem;
37class vtkMRMLScene;
38
39class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSortFilterSegmentsProxyModel : public QSortFilterProxyModel
40{
41 Q_OBJECT
42 QVTK_OBJECT
43
45 Q_PROPERTY(bool filterEnabled READ filterEnabled WRITE setFilterEnabled)
47 Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter)
49 Q_PROPERTY(QString textFilter READ textFilter WRITE setTextFilter)
50
51public:
52 typedef QSortFilterProxyModel Superclass;
53 qMRMLSortFilterSegmentsProxyModel(QObject *parent=nullptr);
55
58
61 Q_INVOKABLE void setHideSegments(const QStringList& segmentIDs);
62 Q_INVOKABLE QStringList hideSegments()const;
63
64 bool filterEnabled()const;
65 QString nameFilter()const;
66 QString textFilter()const;
67
72 Q_INVOKABLE bool showStatus(int status) const;
73
75 Q_INVOKABLE QString segmentIDFromIndex(const QModelIndex& index)const;
76
78 Q_INVOKABLE QModelIndex indexFromSegmentID(QString segmentID, int column=0)const;
79
83 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent)const override;
84
86 virtual bool filterAcceptsItem(QString segmentID)const;
87
89 Qt::ItemFlags flags(const QModelIndex & index)const override;
90
95 Q_INVOKABLE void setShowStatus(int status, bool shown);
96
97public slots:
99 void setNameFilter(QString filter);
100 void setTextFilter(QString filter);
101
102signals:
106
107protected:
108 QStandardItem* sourceItem(const QModelIndex& index)const;
109
110protected:
111 QScopedPointer<qMRMLSortFilterSegmentsProxyModelPrivate> d_ptr;
112
113private:
114 Q_DECLARE_PRIVATE(qMRMLSortFilterSegmentsProxyModel);
115 Q_DISABLE_COPY(qMRMLSortFilterSegmentsProxyModel);
116};
117
118#endif
Q_INVOKABLE vtkMRMLSegmentationNode * segmentationNode() const
Returns the segmentation node in the source model.
Q_INVOKABLE QModelIndex indexFromSegmentID(QString segmentID, int column=0) const
Retrieve an index for a given a segment ID.
qMRMLSortFilterSegmentsProxyModel(QObject *parent=nullptr)
void setNameFilter(QString filter)
Q_INVOKABLE bool showStatus(int status) const
QVTK_OBJECTbool filterEnabled
Whether the filter should be applied.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
QStandardItem * sourceItem(const QModelIndex &index) const
Q_INVOKABLE QStringList hideSegments() const
Q_INVOKABLE void setShowStatus(int status, bool shown)
QString nameFilter
Filter to show only items that contain the string in their names. Empty by default.
virtual bool filterAcceptsItem(QString segmentID) const
Filters items to decide which to display in the view.
void setTextFilter(QString filter)
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the flags for the current index.
QScopedPointer< qMRMLSortFilterSegmentsProxyModelPrivate > d_ptr
void setFilterEnabled(bool filterEnabled)
Q_INVOKABLE QString segmentIDFromIndex(const QModelIndex &index) const
Retrieve the associated segment ID from a model index.
Q_INVOKABLE void setHideSegments(const QStringList &segmentIDs)
QString textFilter
Filter to show only items that contain the string in their names or within tag values....
A set of MRML Nodes that supports serialization and undo/redo.
MRML node containing segmentations.