Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryQtItemSelection.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
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 
17 #include "berryQtItemSelection.h"
18 
19 #include "berryQModelIndexObject.h"
20 
21 namespace berry {
22 
24 {
25 
26 }
27 
28 QtItemSelection::QtItemSelection(const QItemSelection& sel)
29 : m_Selection(new ContainerType())
30 {
31  QModelIndexList indexes = sel.indexes();
32  for (QModelIndexList::const_iterator index = indexes.constBegin(); index != indexes.constEnd(); ++index)
33  {
34  Object::Pointer indexObj(new QModelIndexObject(*index));
35  m_Selection->push_back(indexObj);
36  }
37 }
38 
39 QItemSelection QtItemSelection::GetQItemSelection() const
40 {
41  return m_QItemSelection;
42 }
43 
45 {
46  return m_Selection->empty();
47 }
48 
50 {
51  if (m_Selection->empty()) return Object::Pointer();
52 
53  return *(m_Selection->begin());
54 }
55 
57  {
58  return m_Selection->begin();
59  }
60 
62  {
63  return m_Selection->end();
64  }
65 
67  {
68  return (int) m_Selection->size();
69  }
70 
72  {
73  return m_Selection;
74  }
75 
76  bool QtItemSelection::operator==(const Object* obj) const
77  {
78  if (const IStructuredSelection* other = dynamic_cast<const IStructuredSelection*>(obj))
79  {
80  return m_Selection == other->ToVector();
81  }
82 
83  return false;
84  }
85 
86 }
ContainerType::Pointer ToVector() const override
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:78
ContainerType::const_iterator iterator
iterator End() const override
bool IsEmpty() const override
bool operator==(const Object *obj) const override
iterator Begin() const override
Object::Pointer GetFirstElement() const override
QItemSelection GetQItemSelection() const
int Size() const override