File indexing completed on 2024-05-12 04:47:02
0001 #pragma once 0002 0003 #include <QObject> 0004 #include <QStringList> 0005 #include <QFutureWatcher> 0006 0007 #include <MauiKit3/Core/mauilist.h> 0008 0009 #define PIX_QUERY_MAX_LIMIT 20000 0010 0011 namespace FMH 0012 { 0013 class FileLoader; 0014 } 0015 0016 class QFileSystemWatcher; 0017 class QTimer; 0018 0019 class Gallery : public MauiList 0020 { 0021 Q_OBJECT 0022 Q_PROPERTY(QList<QUrl> urls READ urls WRITE setUrls NOTIFY urlsChanged) 0023 Q_PROPERTY(QList<QUrl> folders READ folders NOTIFY foldersChanged FINAL) 0024 Q_PROPERTY(QStringList cities READ cities NOTIFY citiesChanged FINAL) 0025 Q_PROPERTY(QStringList files READ files NOTIFY filesChanged FINAL) 0026 0027 Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) 0028 Q_PROPERTY(bool autoReload READ autoReload WRITE setAutoReload NOTIFY autoReloadChanged) 0029 Q_PROPERTY(int limit READ limit WRITE setlimit NOTIFY limitChanged) 0030 0031 Q_PROPERTY(Status status READ status NOTIFY statusChanged FINAL) 0032 Q_PROPERTY(QString error READ error NOTIFY errorChanged FINAL) 0033 0034 Q_PROPERTY(bool activeGeolocationTags READ activeGeolocationTags WRITE setActiveGeolocationTags NOTIFY activeGeolocationTagsChanged) 0035 0036 public: 0037 enum Status 0038 { 0039 Ready, 0040 Loading, 0041 Error 0042 }; 0043 Q_ENUM(Status) 0044 0045 explicit Gallery(QObject * = nullptr); 0046 ~Gallery(); 0047 0048 void componentComplete() override; 0049 0050 const FMH::MODEL_LIST &items() const override final; 0051 0052 void setUrls(const QList<QUrl> &); 0053 QList<QUrl> urls() const; 0054 0055 void setAutoReload(const bool &); 0056 bool autoReload() const; 0057 0058 QList<QUrl> folders() const; 0059 0060 bool recursive() const; 0061 0062 int limit() const; 0063 0064 QStringList files() const; 0065 0066 const QStringList &cities() const; 0067 0068 Status status() const; 0069 0070 QString error() const; 0071 0072 bool activeGeolocationTags() const; 0073 0074 private: 0075 FMH::FileLoader *m_fileLoader; 0076 QFileSystemWatcher *m_watcher; 0077 QFutureWatcher<void> *m_futureWatcher; 0078 0079 QTimer *m_scanTimer; 0080 FMH::MODEL_LIST list = {}; 0081 0082 QList<QUrl> m_urls; 0083 QStringList m_cities; 0084 QList<QUrl> m_folders; 0085 0086 bool m_autoReload; 0087 bool m_recursive; 0088 bool m_activeGeolocationTags = false; 0089 0090 int m_limit = PIX_QUERY_MAX_LIMIT; 0091 0092 Status m_status = Status::Error; 0093 QString m_error; 0094 0095 void scan(const QList<QUrl> &, const bool & = true, const int & = PIX_QUERY_MAX_LIMIT); 0096 void scanGpsTags(); 0097 0098 void insert(const FMH::MODEL_LIST &); 0099 0100 void insertFolder(const QUrl &); 0101 void insertCity(const QString &); 0102 0103 void setStatus(const Gallery::Status &, const QString& = QString()); 0104 0105 Q_SIGNALS: 0106 void urlsChanged(); 0107 void foldersChanged(); 0108 void autoReloadChanged(); 0109 void recursiveChanged(bool recursive); 0110 0111 void limitChanged(int limit); 0112 0113 void filesChanged(); 0114 0115 void citiesChanged(); 0116 0117 void statusChanged(); 0118 void errorChanged(QString error); 0119 0120 void activeGeolocationTagsChanged(bool activeGeolocationTags); 0121 0122 public Q_SLOTS: 0123 bool remove(const int &); 0124 bool deleteAt(const int &); 0125 0126 void append(const QVariantMap &); 0127 void append(const QString &); 0128 0129 void clear(); 0130 void rescan(); 0131 void load(); 0132 0133 void setRecursive(bool); 0134 void setlimit(int); 0135 0136 int indexOfName(const QString &); 0137 void setActiveGeolocationTags(bool activeGeolocationTags); 0138 void scanImagesText(); 0139 0140 };