ctkDICOMModel.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkDICOMModel_h
  15. #define __ctkDICOMModel_h
  16. // Qt includes
  17. #include <QStandardItemModel>
  18. #include <QSqlDatabase>
  19. #include "ctkDICOMCoreExport.h"
  20. class ctkDICOMModelPrivate;
  21. class CTK_DICOM_CORE_EXPORT ctkDICOMModel
  22. // : public QStandardItemModel
  23. : public QAbstractItemModel
  24. {
  25. Q_OBJECT
  26. typedef QAbstractItemModel Superclass;
  27. public:
  28. enum {
  29. UIDRole = Qt::UserRole,
  30. TypeRole
  31. };
  32. enum IndexType{
  33. RootType,
  34. PatientType,
  35. StudyType,
  36. SeriesType,
  37. ImageType
  38. };
  39. explicit ctkDICOMModel(QObject* parent = 0);
  40. virtual ~ctkDICOMModel();
  41. void setDatabase(const QSqlDatabase& dataBase);
  42. void setDisplayLevel(ctkDICOMModel::IndexType level);
  43. virtual bool canFetchMore ( const QModelIndex & parent ) const;
  44. virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
  45. virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
  46. virtual void fetchMore ( const QModelIndex & parent );
  47. virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
  48. // can return true even if rowCount returns 0, you should use canFetchMore/fetchMore to populate
  49. // the children.
  50. virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
  51. virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole)const;
  52. virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
  53. virtual QModelIndex parent ( const QModelIndex & index ) const;
  54. virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
  55. virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
  56. virtual bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole );
  57. // Sorting resets the model because fetched/unfetched items could disappear/appear respectively.
  58. virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
  59. public slots:
  60. virtual void reset();
  61. protected:
  62. QScopedPointer<ctkDICOMModelPrivate> d_ptr;
  63. private:
  64. Q_DECLARE_PRIVATE(ctkDICOMModel);
  65. Q_DISABLE_COPY(ctkDICOMModel);
  66. };
  67. #endif