Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #include <mitkNodePredicateAnd.h>
13 #include <mitkNodePredicateData.h>
15 #include <mitkNodePredicateNot.h>
16 #include <mitkNodePredicateOr.h>
18 #include <mitkPlanarFigure.h>
19 #include <mitkProperties.h>
20 #include <mitkRenderingManager.h>
21 #include <mitkStringProperty.h>
22 
26 #include <QmitkCustomVariants.h>
27 #include <QmitkEnums.h>
28 
29 #include <QIcon>
30 #include <QMimeData>
31 #include <QTextStream>
32 
33 #include <map>
34 
35 QmitkDataStorageFilterProxyModel::QmitkDataStorageFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
36 {
37 }
38 
40 {
41 }
42 
44 {
45  m_Predicates.insert(pred);
46  this->invalidateFilter();
47 }
48 
50 {
51  bool removed = m_Predicates.erase(pred) != 0;
52  if (removed)
53  {
54  this->invalidateFilter();
55  }
56  return removed;
57 }
58 
60 {
61  return m_Predicates.find(pred) != m_Predicates.end();
62 }
63 
64 bool QmitkDataStorageFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
65 {
66  QmitkDataStorageTreeModel *model = dynamic_cast<QmitkDataStorageTreeModel *>(this->sourceModel());
67  assert(model);
68 
69  QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
70 
71  for (FilterPredicatesCollection::const_iterator iter = m_Predicates.begin(); iter != m_Predicates.end(); ++iter)
72  {
73  if ((*iter)->CheckNode(model->GetNode(index0)))
74  {
75  return false;
76  }
77  }
78 
79  return true;
80 }
mitk::DataNode::Pointer GetNode(const QModelIndex &index) const
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
bool HasFilterPredicate(mitk::NodePredicateBase::Pointer pred)
bool RemoveFilterPredicate(mitk::NodePredicateBase::Pointer pred)
void AddFilterPredicate(mitk::NodePredicateBase::Pointer pred)