00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "QmitkDataNodeSelection.h" 00019 00020 #include <QmitkEnums.h> 00021 #include <QmitkCustomVariants.h> 00022 00023 #include <mitkDataNodeObject.h> 00024 00025 QmitkDataNodeSelection::QmitkDataNodeSelection() 00026 { 00027 00028 } 00029 00030 QmitkDataNodeSelection::QmitkDataNodeSelection( 00031 const QItemSelection& sel) : 00032 mitk::DataNodeSelection(), berry::QtItemSelection(sel) 00033 { 00034 QModelIndexList indexes = sel.indexes(); 00035 for (QModelIndexList::const_iterator index = indexes.constBegin(); index 00036 != indexes.constEnd(); ++index) 00037 { 00038 QVariant data = index->data(QmitkDataNodeRole); 00039 mitk::DataNode::Pointer node = 00040 data.value<mitk::DataNode::Pointer> (); 00041 if (node.IsNotNull()) 00042 { 00043 berry::Object::Pointer obj(new mitk::DataNodeObject(node)); 00044 mitk::DataNodeSelection::m_Selection->push_back(obj); 00045 } 00046 } 00047 } 00048 00049 berry::Object::Pointer QmitkDataNodeSelection::GetFirstElement() const 00050 { 00051 return mitk::DataNodeSelection::GetFirstElement(); 00052 } 00053 00054 QmitkDataNodeSelection::iterator QmitkDataNodeSelection::Begin() const 00055 { 00056 return mitk::DataNodeSelection::Begin(); 00057 } 00058 00059 QmitkDataNodeSelection::iterator QmitkDataNodeSelection::End() const 00060 { 00061 return mitk::DataNodeSelection::End(); 00062 } 00063 00064 int QmitkDataNodeSelection::Size() const 00065 { 00066 return mitk::DataNodeSelection::Size(); 00067 } 00068 00069 QmitkDataNodeSelection::ContainerType::Pointer QmitkDataNodeSelection::ToVector() const 00070 { 00071 return mitk::DataNodeSelection::ToVector(); 00072 } 00073 00074 bool QmitkDataNodeSelection::IsEmpty() const 00075 { 00076 return mitk::DataNodeSelection::IsEmpty(); 00077 } 00078 00079 bool QmitkDataNodeSelection::operator==(const berry::Object* obj) const 00080 { 00081 return mitk::DataNodeSelection::operator==(obj); 00082 }