picturemodel.h 744 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef PICTUREMODEL_H
  2. #define PICTUREMODEL_H
  3. #include <QAbstractListModel>
  4. #include <QUrl>
  5. class PictureModel : public QAbstractListModel
  6. {
  7. Q_OBJECT
  8. Q_PROPERTY (int count READ rowCount NOTIFY countChanged)
  9. public:
  10. enum PictureRoles {
  11. PathRole = Qt::UserRole + 1
  12. };
  13. PictureModel(QObject *parent = nullptr);
  14. ~PictureModel();
  15. int rowCount(const QModelIndex & parent = QModelIndex()) const;
  16. Q_INVOKABLE QUrl randomPicture() const;
  17. QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
  18. signals:
  19. void countChanged();
  20. protected:
  21. QHash<int, QByteArray> roleNames() const;
  22. private:
  23. class PictureModelPrivate;
  24. PictureModelPrivate *d;
  25. };
  26. #endif // PICTUREMODEL_H