CustusX  20.03-rc1
An IGT application
cxDICOMModel.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 __DICOMModel_h
22 #define __DICOMModel_h
23 
24 #include "org_custusx_dicom_Export.h"
25 
26 // Qt includes
27 #include <QAbstractItemModel>
28 #include <QMetaType>
29 #include <QSharedPointer>
30 #include <QStringList>
31 class ctkDICOMDatabase;
32 
33 namespace cx
34 {
35 
36 class DICOMModelPrivate;
37 
39 class org_custusx_dicom_EXPORT DICOMModel
40 // : public QStandardItemModel
41  : public QAbstractItemModel
42 {
43  Q_OBJECT
44  typedef QAbstractItemModel Superclass;
45 public:
46 
47  enum {
48  UIDRole = Qt::UserRole,
49  TypeRole
50  };
51 
52  enum IndexType{
58  NoneType
59  };
60 
61  explicit DICOMModel(QObject* parent = 0);
62  virtual ~DICOMModel();
63 
64  void setDatabase(QSharedPointer<ctkDICOMDatabase> dataBase);
65 
67  DICOMModel::IndexType endLevel()const;
68  void setEndLevel(DICOMModel::IndexType level);
69 
70  virtual bool canFetchMore ( const QModelIndex & parent ) const;
71  virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
72  virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
73  virtual void fetchMore ( const QModelIndex & parent );
74 // virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
75  // can return true even if rowCount returns 0, you should use canFetchMore/fetchMore to populate
76  // the children.
77  virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
78  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole)const;
79  virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
80  virtual QModelIndex parent ( const QModelIndex & index ) const;
81  virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
82  // Sorting resets the model because fetched/unfetched items could disappear/appear respectively.
83 // virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
84  virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
85 public Q_SLOTS:
86  virtual void reset();
87 protected:
88  QScopedPointer<DICOMModelPrivate> d_ptr;
89 
90 private:
91  Q_DECLARE_PRIVATE(DICOMModel);
92  Q_DISABLE_COPY(DICOMModel);
93 };
94 
95 } // namespace cx
96 
98 
99 #endif
Q_DECLARE_METATYPE(QPersistentModelIndex)
QScopedPointer< DICOMModelPrivate > d_ptr
Definition: cxDICOMModel.h:88
Namespace for all CustusX production code.