ctkXnatTreeModel.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*=============================================================================
  2. Library: XNAT/Core
  3. Copyright (c) University College London,
  4. Centre for Medical Image Computing
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef ctkXnatTreeModel_h
  16. #define ctkXnatTreeModel_h
  17. #include "ctkXNATCoreExport.h"
  18. #include <QAbstractItemModel>
  19. class ctkXnatObject;
  20. class ctkXnatDataModel;
  21. class ctkXnatTreeModelPrivate;
  22. /**
  23. * @ingroup XNAT_Core
  24. */
  25. class CTK_XNAT_CORE_EXPORT ctkXnatTreeModel : public QAbstractItemModel
  26. {
  27. Q_OBJECT
  28. public:
  29. explicit ctkXnatTreeModel();
  30. virtual ~ctkXnatTreeModel();
  31. virtual QVariant data(const QModelIndex& index, int role) const;
  32. virtual QModelIndex parent(const QModelIndex& child) const;
  33. virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
  34. virtual int rowCount(const QModelIndex& parent) const;
  35. virtual int columnCount(const QModelIndex& parent) const;
  36. virtual bool hasChildren(const QModelIndex& parent) const;
  37. virtual bool canFetchMore(const QModelIndex& parent) const;
  38. virtual void fetchMore(const QModelIndex& parent);
  39. /**
  40. * @brief Convenience method for refreshing an entry of the tree model
  41. * @param The parent item, whose children will be refreshed
  42. */
  43. virtual void refresh(const QModelIndex& parent = QModelIndex());
  44. ctkXnatObject* xnatObject(const QModelIndex& index) const;
  45. void addDataModel(ctkXnatDataModel* dataModel);
  46. void removeDataModel(ctkXnatDataModel* dataModel);
  47. bool removeAllRows(const QModelIndex& parent);
  48. void downloadFile (const QModelIndex& index, const QString& zipFilename);
  49. void addChildNode(const QModelIndex& index, ctkXnatObject *child);
  50. private:
  51. const QScopedPointer<ctkXnatTreeModelPrivate> d_ptr;
  52. Q_DECLARE_PRIVATE(ctkXnatTreeModel)
  53. };
  54. #endif