Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkDataStorageFilterProxyModel.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #include <mitkNodePredicateAnd.h>
17 #include <mitkNodePredicateData.h>
19 #include <mitkNodePredicateNot.h>
20 #include <mitkNodePredicateOr.h>
22 #include <mitkPlanarFigure.h>
23 #include <mitkProperties.h>
24 #include <mitkRenderingManager.h>
25 #include <mitkStringProperty.h>
26 
30 #include <QmitkCustomVariants.h>
31 #include <QmitkEnums.h>
32 
33 #include <QIcon>
34 #include <QMimeData>
35 #include <QTextStream>
36 
37 #include <map>
38 
39 QmitkDataStorageFilterProxyModel::QmitkDataStorageFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
40 {
41 }
42 
44 {
45 }
46 
48 {
49  m_Predicates.insert(pred);
50  this->invalidateFilter();
51 }
52 
54 {
55  bool removed = m_Predicates.erase(pred) != 0;
56  if (removed)
57  {
58  this->invalidateFilter();
59  }
60  return removed;
61 }
62 
64 {
65  return m_Predicates.find(pred) != m_Predicates.end();
66 }
67 
68 bool QmitkDataStorageFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
69 {
70  QmitkDataStorageTreeModel *model = dynamic_cast<QmitkDataStorageTreeModel *>(this->sourceModel());
71  assert(model);
72 
73  QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
74 
75  for (FilterPredicatesCollection::const_iterator iter = m_Predicates.begin(); iter != m_Predicates.end(); ++iter)
76  {
77  if ((*iter)->CheckNode(model->GetNode(index0)))
78  {
79  return false;
80  }
81  }
82 
83  return true;
84 }
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
bool HasFilterPredicate(mitk::NodePredicateBase::Pointer pred)
bool RemoveFilterPredicate(mitk::NodePredicateBase::Pointer pred)
mitk::DataNode::Pointer GetNode(const QModelIndex &index) const
void AddFilterPredicate(mitk::NodePredicateBase::Pointer pred)