PictureModel.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef PICTUREMODEL_H
  2. #define PICTUREMODEL_H
  3. #include <QAbstractListModel>
  4. #include "Picture.h"
  5. #include "gallery-core_global.h"
  6. class Album;
  7. class DatabaseManager;
  8. class AlbumModel;
  9. class GALLERYCORE_EXPORT PictureModel : public QAbstractListModel {
  10. Q_OBJECT
  11. public:
  12. enum PictureRole {
  13. FilePathRole = Qt::UserRole + 1,
  14. };
  15. explicit PictureModel(const AlbumModel& albumModel, QObject* parent = 0);
  16. QModelIndex addPicture(const Picture& picture);
  17. // QAbstractItemModel interface
  18. int rowCount(const QModelIndex& parent) const override;
  19. QVariant data(const QModelIndex& index, int role) const override;
  20. bool removeRows(int row, int count, const QModelIndex& parent) override;
  21. void setAlbumId(int albumId);
  22. void clearAlbum();
  23. public slots:
  24. void deletePcituresForAlbum();
  25. private:
  26. void loadPictures(int albumId);
  27. bool isIndexValid(const QModelIndex& index) const;
  28. private:
  29. DatabaseManager& mDb;
  30. int mAlbumId;
  31. std::unique_ptr<std::vector<std::unique_ptr<Picture>>> mPictures;
  32. };
  33. #endif // PICTUREMODEL_H