File indexing completed on 2025-04-27 04:04:21
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2017 Atul Sharma <atulsharma406@gmail.com> 0003 * SPDX-FileCopyrightText: (C) 2017 by Marco Martin <mart@kde.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef IMAGEFOLDERMODEL_H 0009 #define IMAGEFOLDERMODEL_H 0010 0011 #include <QSize> 0012 #include <QVariant> 0013 #include <kdirmodel.h> 0014 0015 class QTimer; 0016 0017 /** 0018 * This class provides a QML binding to KDirModel 0019 * Provides an easy way to navigate a filesystem from within QML 0020 * 0021 * @author Marco Martin <mart@kde.org> 0022 */ 0023 class ImageFolderModel : public KDirModel 0024 { 0025 Q_OBJECT 0026 0027 /** 0028 * @property string The url we want to browse. it may be an absolute path or a correct url of any protocol KIO supports 0029 */ 0030 Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) 0031 0032 /** 0033 * @property count Total number of rows 0034 */ 0035 Q_PROPERTY(int count READ count NOTIFY countChanged) 0036 0037 public: 0038 explicit ImageFolderModel(QObject *parent = nullptr); 0039 0040 QHash<int, QByteArray> roleNames() const override; 0041 0042 void setUrl(QUrl &url); 0043 QUrl url() const; 0044 0045 QVariant data(const QModelIndex &index, int role) const override; 0046 int count() const 0047 { 0048 return rowCount(); 0049 } 0050 0051 Q_INVOKABLE int indexForUrl(const QString &url) const; 0052 0053 Q_INVOKABLE QVariantMap get(int index) const; 0054 0055 /** 0056 * Helper method to empty the trash 0057 */ 0058 Q_INVOKABLE void emptyTrash(); 0059 0060 void jobFinished(); 0061 0062 Q_SIGNALS: 0063 void countChanged(); 0064 void urlChanged(); 0065 void finishedLoading(); 0066 0067 private: 0068 QStringList m_mimeTypes; 0069 QString m_imagePath; 0070 }; 0071 0072 #endif // IMAGEFOLDERMODEL_H