picturemodel.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /****************************************************************************
  2. ** Artriculate: Art comes tumbling down
  3. ** Copyright (C) 2016 Chaos Reins
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ****************************************************************************/
  18. #ifndef PICTUREMODEL_H
  19. #define PICTUREMODEL_H
  20. #include <QAbstractListModel>
  21. #include <QUrl>
  22. class PictureModel : public QAbstractListModel
  23. {
  24. Q_OBJECT
  25. Q_PROPERTY (int count READ rowCount NOTIFY countChanged)
  26. public:
  27. enum PictureRoles {
  28. PathRole = Qt::UserRole + 1
  29. };
  30. PictureModel(QObject *parent = nullptr);
  31. ~PictureModel();
  32. int rowCount(const QModelIndex & parent = QModelIndex()) const;
  33. Q_INVOKABLE QUrl randomPicture() const;
  34. QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
  35. signals:
  36. void countChanged();
  37. protected:
  38. QHash<int, QByteArray> roleNames() const;
  39. private:
  40. class PictureModelPrivate;
  41. PictureModelPrivate *d;
  42. };
  43. #endif // PICTUREMODEL_H