File indexing completed on 2024-05-12 04:45:58
0001 #pragma once 0002 0003 #include <QObject> 0004 0005 #include <MauiKit3/Core/mauilist.h> 0006 #include "utils/clip.h" 0007 0008 #define CINEMA_QUERY_MAX_LIMIT 20000 0009 0010 namespace FMH 0011 { 0012 class FileLoader; 0013 } 0014 0015 class QFileSystemWatcher; 0016 class VideosModel : public MauiList 0017 { 0018 Q_OBJECT 0019 Q_PROPERTY(QStringList urls READ urls WRITE setUrls NOTIFY urlsChanged RESET resetUrls) 0020 Q_PROPERTY(QList<QUrl> folders READ folders NOTIFY foldersChanged FINAL) 0021 Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) 0022 Q_PROPERTY(bool autoScan READ autoScan WRITE setAutoScan NOTIFY autoScanChanged) 0023 Q_PROPERTY(bool autoReload READ autoReload WRITE setAutoReload NOTIFY autoReloadChanged) 0024 Q_PROPERTY(int limit READ limit WRITE setlimit NOTIFY limitChanged) 0025 Q_PROPERTY(QStringList files READ files NOTIFY filesChanged FINAL) 0026 0027 public: 0028 explicit VideosModel(QObject *parent = nullptr); 0029 0030 const FMH::MODEL_LIST &items() const override final; 0031 0032 void setUrls(const QStringList &urls); 0033 QStringList urls() const; 0034 void resetUrls(); 0035 0036 void setAutoScan(const bool &value); 0037 bool autoScan() const; 0038 0039 void setAutoReload(const bool &value); 0040 bool autoReload() const; 0041 0042 QList<QUrl> folders() const; 0043 0044 bool recursive() const; 0045 0046 int limit() const; 0047 QStringList files() const; 0048 0049 private: 0050 FMH::FileLoader *m_fileLoader; 0051 QFileSystemWatcher *m_watcher; 0052 0053 QStringList m_urls; 0054 QList<QUrl> m_folders; 0055 bool m_autoReload; 0056 bool m_autoScan; 0057 0058 FMH::MODEL_LIST list; 0059 0060 void scan(const QStringList &urls, const bool &recursive = true, const int &limit = CINEMA_QUERY_MAX_LIMIT); 0061 0062 void insert(const FMH::MODEL_LIST &items); 0063 0064 void insertFolder(const QUrl &path); 0065 0066 bool m_recursive; 0067 0068 int m_limit = CINEMA_QUERY_MAX_LIMIT; 0069 0070 Q_SIGNALS: 0071 void urlsChanged(); 0072 void foldersChanged(); 0073 void autoReloadChanged(); 0074 void autoScanChanged(); 0075 0076 void recursiveChanged(bool recursive); 0077 0078 void limitChanged(int limit); 0079 0080 void filesChanged(); 0081 0082 public Q_SLOTS: 0083 bool remove(const int &index); 0084 bool deleteAt(const int &index); 0085 0086 void append(const QVariantMap &item); 0087 void appendUrl(const QString &url); 0088 // void appendAt(const QString &url, const int &pos); 0089 0090 void clear(); 0091 void rescan(); 0092 0093 void setRecursive(bool recursive); 0094 void setlimit(int limit); 0095 0096 // QQmlParserStatus interface 0097 public: 0098 void classBegin() override final; 0099 void componentComplete() override final; 0100 };