picturemodel.h 863 B

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