00001 /*========================================================================= 00002 00003 Program: MITK 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 https://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 00019 #ifndef QMITKDATASTORAGELISTMODEL_H_ 00020 #define QMITKDATASTORAGELISTMODEL_H_ 00021 00022 //# Own includes 00023 // mitk 00024 #include "mitkDataStorage.h" 00025 #include "mitkNodePredicateBase.h" 00026 #include "mitkCommon.h" 00027 // Qmitk 00028 00029 //# Toolkit includes 00030 // Qt 00031 #include <QAbstractListModel> 00032 // stl 00033 #include <vector> 00034 00035 class QMITK_EXPORT QmitkDataStorageListModel: public QAbstractListModel 00036 { 00037 public: 00038 //# Ctors / Dtor 00042 QmitkDataStorageListModel(mitk::DataStorage::Pointer dataStorage = 0, mitk::NodePredicateBase* pred = 0, QObject* parent = 0); 00043 ~QmitkDataStorageListModel(); 00044 00045 00046 //# Getter / Setter 00047 void SetDataStorage(mitk::DataStorage::Pointer dataStorage); 00048 mitk::DataStorage::Pointer GetDataStorage() const; 00049 00050 void SetPredicate(mitk::NodePredicateBase* pred); 00051 mitk::NodePredicateBase* GetPredicate() const; 00052 00053 std::vector<mitk::DataNode*> GetDataNodes() const; 00054 00055 mitk::DataNode::Pointer getNode(const QModelIndex &index) const; 00056 00057 //# From QAbstractListModel 00058 Qt::ItemFlags flags(const QModelIndex& index) const; 00059 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; 00060 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 00061 int rowCount(const QModelIndex& parent = QModelIndex()) const; 00062 00067 virtual void NodeAdded(const mitk::DataNode* node); 00072 virtual void NodeRemoved(const mitk::DataNode* node); 00073 00078 virtual void OnModified(const itk::Object *caller, const itk::EventObject &event); 00079 00084 virtual void OnDelete(const itk::Object *caller, const itk::EventObject &event); 00085 00086 protected: 00090 void reset(); 00091 00096 mitk::NodePredicateBase::Pointer m_NodePredicate; 00097 00102 mitk::DataStorage* m_DataStorage; 00103 00107 unsigned long m_DataStorageDeleteObserverTag; 00108 00112 std::vector<mitk::DataNode*> m_DataNodes; 00113 00117 std::vector<unsigned long> m_DataNodesModifiedObserversTags; 00118 00122 bool m_BlockEvents; 00123 }; 00124 00125 #endif /* QMITKDATASTORAGELISTMODEL_H_ */