picturemodel.h 978 B

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