picturemodel.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. NameRole = Qt::UserRole + 1,
  29. PathRole,
  30. SizeRole,
  31. RatioRole
  32. };
  33. Q_ENUM(PictureRoles)
  34. PictureModel(QObject *parent = nullptr);
  35. ~PictureModel();
  36. int rowCount(const QModelIndex & parent = QModelIndex()) const;
  37. Q_INVOKABLE QVariant data(const int &row, int role = PathRole) const { return data(index(row, 0), role); }
  38. QVariant data(const QModelIndex & index, int role = PathRole) const;
  39. Q_INVOKABLE int requestIndex();
  40. Q_INVOKABLE void retireIndex(int index);
  41. signals:
  42. void countChanged();
  43. protected:
  44. QHash<int, QByteArray> roleNames() const;
  45. private:
  46. class PictureModelPrivate;
  47. PictureModelPrivate *d;
  48. };
  49. #endif // PICTUREMODEL_H