CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkDICOMModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkDICOMModel_h
22 #define __ctkDICOMModel_h
23 
24 // Qt includes
25 #include <QAbstractItemModel>
26 #include <QMetaType>
27 #include <QSqlDatabase>
28 #include <QStringList>
29 
30 #include "ctkDICOMCoreExport.h"
31 
32 class ctkDICOMModelPrivate;
33 
35 class CTK_DICOM_CORE_EXPORT ctkDICOMModel
36 // : public QStandardItemModel
37  : public QAbstractItemModel
38 {
39  Q_OBJECT
40  typedef QAbstractItemModel Superclass;
41  Q_ENUMS(IndexType)
43  Q_PROPERTY(IndexType endLevel READ endLevel WRITE setEndLevel);
44 public:
45 
46  enum {
47  UIDRole = Qt::UserRole,
48  TypeRole
49  };
50 
51  enum IndexType{
56  ImageType
57  };
58 
59  explicit ctkDICOMModel(QObject* parent = 0);
60  virtual ~ctkDICOMModel();
61 
62  void setDatabase(const QSqlDatabase& dataBase);
63  void setDatabase(const QSqlDatabase& dataBase, const QMap<QString,QVariant>& parameters);
64 
66  ctkDICOMModel::IndexType endLevel()const;
67  void setEndLevel(ctkDICOMModel::IndexType level);
68 
69  virtual bool canFetchMore ( const QModelIndex & parent ) const;
70  virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
71  virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
72  virtual void fetchMore ( const QModelIndex & parent );
73  virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
74  // can return true even if rowCount returns 0, you should use canFetchMore/fetchMore to populate
75  // the children.
76  virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
77  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole)const;
78  virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
79  virtual QModelIndex parent ( const QModelIndex & index ) const;
80  virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
81  virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
82  virtual bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole );
83  // Sorting resets the model because fetched/unfetched items could disappear/appear respectively.
84  virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
85 public Q_SLOTS:
86  virtual void reset();
87 protected:
88  QScopedPointer<ctkDICOMModelPrivate> d_ptr;
89 
90  bool setChildData(const QModelIndex &index, const QVariant &value, int role);
91  bool setParentData(const QModelIndex &index, const QVariant &value, int role);
92 
93 private:
94  Q_DECLARE_PRIVATE(ctkDICOMModel);
95  Q_DISABLE_COPY(ctkDICOMModel);
96 };
97 
99 
100 #endif
ctkDICOMModel::StudyType
@ StudyType
Definition: ctkDICOMModel.h:54
ctkDICOMModel::SeriesType
@ SeriesType
Definition: ctkDICOMModel.h:55
ctkDICOMModel::PatientType
@ PatientType
Definition: ctkDICOMModel.h:53
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(ctkDICOMPersonName)
ctkDICOMModel
Definition: ctkDICOMModel.h:35
ctkDICOMModel::RootType
@ RootType
Definition: ctkDICOMModel.h:52
ctkDICOMModel::IndexType
IndexType
Definition: ctkDICOMModel.h:51
ctkDICOMModel::d_ptr
QScopedPointer< ctkDICOMModelPrivate > d_ptr
Definition: ctkDICOMModel.h:88