ctkDICOMModel.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. #ifndef __ctkDICOMModel_h
  11. #define __ctkDICOMModel_h
  12. // Qt includes
  13. #include <QAbstractItemModel>
  14. #include <QSqlDatabase>
  15. // CTK includes
  16. #include <ctkPimpl.h>
  17. #include "CTKDICOMCoreExport.h"
  18. class ctkDICOMModelPrivate;
  19. class CTK_DICOM_CORE_EXPORT ctkDICOMModel : public QAbstractItemModel
  20. {
  21. Q_OBJECT
  22. public:
  23. explicit ctkDICOMModel(QObject* parent = 0);
  24. virtual ~ctkDICOMModel();
  25. void setDatabase(const QSqlDatabase& dataBase);
  26. virtual bool canFetchMore ( const QModelIndex & parent ) const;
  27. virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
  28. virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
  29. virtual void fetchMore ( const QModelIndex & parent );
  30. virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
  31. // can return true even if rowCount returns 0, you should use canFetchMore/fetchMore to populate
  32. // the children.
  33. virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
  34. virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole)const;
  35. virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
  36. virtual QModelIndex parent ( const QModelIndex & index ) const;
  37. virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
  38. virtual bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole );
  39. // Sorting resets the model because fetched/unfetched items could disappear/appear respectively.
  40. virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
  41. private:
  42. CTK_DECLARE_PRIVATE(ctkDICOMModel);
  43. };
  44. #endif