ctkDICOMModel.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 <QAbstractItemModel>
  18. #include <QSqlDatabase>
  19. // CTK includes
  20. #include <ctkPimpl.h>
  21. #include "CTKDICOMCoreExport.h"
  22. class ctkDICOMModelPrivate;
  23. class CTK_DICOM_CORE_EXPORT ctkDICOMModel : public QAbstractItemModel
  24. {
  25. Q_OBJECT
  26. public:
  27. explicit ctkDICOMModel(QObject* parent = 0);
  28. virtual ~ctkDICOMModel();
  29. void setDatabase(const QSqlDatabase& dataBase);
  30. virtual bool canFetchMore ( const QModelIndex & parent ) const;
  31. virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
  32. virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
  33. virtual void fetchMore ( const QModelIndex & parent );
  34. virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
  35. // can return true even if rowCount returns 0, you should use canFetchMore/fetchMore to populate
  36. // the children.
  37. virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
  38. virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole)const;
  39. virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
  40. virtual QModelIndex parent ( const QModelIndex & index ) const;
  41. virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
  42. virtual bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole );
  43. // Sorting resets the model because fetched/unfetched items could disappear/appear respectively.
  44. virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
  45. private:
  46. CTK_DECLARE_PRIVATE(ctkDICOMModel);
  47. };
  48. #endif