#pragma once #include #include #include #include #include #include class ScreenshotModel : public QAbstractListModel { Q_OBJECT QML_ELEMENT Q_PROPERTY(QString directoryPath READ directoryPath WRITE setDirectoryPath NOTIFY directoryPathChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) public: enum Roles { UrlRole = Qt::UserRole + 1, FileNameRole, CreatedRole, SizeRole, }; explicit ScreenshotModel(QObject *parent = nullptr); ~ScreenshotModel() override; QString directoryPath() const; void setDirectoryPath(const QString &path); int count() const; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; Q_INVOKABLE void refresh(); Q_SIGNALS: void directoryPathChanged(); void countChanged(); private: struct ScreenshotEntry { QString filePath; QString fileName; QDateTime created; qint64 size = 0; }; void setEntries(QVector entries); QString m_directoryPath; QVector m_entries; QFutureWatcher> m_watcher; int m_refreshToken = 0; };