Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkMimeTypes.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 
17 #include "QmitkMimeTypes.h"
18 
19 const QString QmitkMimeTypes::DataNodePtrs = "application/x-qmitk-datanode-ptrs";
20 const QString QmitkMimeTypes::DataStorageTreeItemPtrs = "application/x-qmitk-datastorage-treeitem-ptrs";
21 
22 #include <iostream>
23 
24 #include <QDataStream>
25 
26 QList<mitk::DataNode *> QmitkMimeTypes::ToDataNodePtrList(const QByteArray &ba)
27 {
28  QDataStream ds(ba);
29  QList<mitk::DataNode *> result;
30  while (!ds.atEnd())
31  {
32  quintptr dataNodePtr;
33  ds >> dataNodePtr;
34  result.push_back(reinterpret_cast<mitk::DataNode *>(dataNodePtr));
35  }
36  return result;
37 }
38 
39 QList<mitk::DataNode *> QmitkMimeTypes::ToDataNodePtrList(const QMimeData *mimeData)
40 {
41  if (mimeData == nullptr || !mimeData->hasFormat(QmitkMimeTypes::DataNodePtrs))
42  {
43  return QList<mitk::DataNode *>();
44  }
45  return ToDataNodePtrList(mimeData->data(QmitkMimeTypes::DataNodePtrs));
46 }
static QList< mitk::DataNode * > ToDataNodePtrList(const QByteArray &ba)
static const QString DataNodePtrs
static const QString DataStorageTreeItemPtrs