MythTV  master
imagescanner.h
Go to the documentation of this file.
1 
12 #ifndef IMAGESCANNER_H
13 #define IMAGESCANNER_H
14 
15 #include <QFileInfo>
16 #include <QDir>
17 #include <QElapsedTimer>
18 
19 #include <QRegularExpression>
20 #define REGEXP QRegularExpression
21 #define MATCHES(RE, SUBJECT) RE.match(SUBJECT).hasMatch()
22 
23 #include "imagethumbs.h"
24 
25 
27 template <class DBFS>
29 {
30 public:
31  ImageScanThread(DBFS *dbfs, ImageThumb<DBFS> *thumbGen);
32  ~ImageScanThread() override;
33 
34  void cancel();
35  bool IsScanning();
36  bool ClearsPending();
37  void ChangeState(bool scan);
38  void EnqueueClear(int devId, const QString &action);
39  QStringList GetProgress();
40 
41 protected:
42  void run() override; // MThread
43 
44 private:
45  Q_DISABLE_COPY(ImageScanThread)
46 
47  void SyncSubTree(const QFileInfo &dirInfo, int parentId, int devId,
48  const QString &base);
49  int SyncDirectory(const QFileInfo &dirInfo, int devId,
50  const QString &base, int parentId);
51  void PopulateMetadata(const QString &path, int type, QString &comment,
52 #if QT_VERSION < QT_VERSION_CHECK(5,8,0)
53  uint &time,
54 #else
55  qint64 &time,
56 #endif
57  int &orientation);
58  void SyncFile(const QFileInfo &fileInfo, int devId,
59  const QString &base, int parentId);
60  void CountTree(QDir &dir);
61  void CountFiles(const QStringList &paths);
62  void Broadcast(int progress);
63 
64  using ClearTask = QPair<int, QString>;
65 
66  bool m_scanning {false};
67  QMutex m_mutexState;
68  QList<ClearTask> m_clearQueue;
69  QMutex m_mutexQueue;
70  DBFS &m_dbfs;
72 
82  QStringList m_changedImages;
83 
85  QElapsedTimer m_bcastTimer;
86  int m_progressCount {0};
87  int m_progressTotalCount {0};
88  QMutex m_mutexProgress;
89 
91  QDir m_dir;
94 };
95 
96 #endif // IMAGESCANNER_H
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
def scan(profile, smoonURL, gate)
Definition: scan.py:57
virtual void run(void)
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: mthread.cpp:318
ImageHash m_dbDirMap
Dirs in the Db from last scan, Map<Db filepath, Db Image>
Definition: imagescanner.h:74
QElapsedTimer m_bcastTimer
Elapsed time since last progress event generated.
Definition: imagescanner.h:85
QList< ClearTask > m_clearQueue
Queue of pending Clear requests.
Definition: imagescanner.h:68
ImageHash m_seenDir
Dirs seen by current scan, Map<Db filepath, Earlier Image>
Definition: imagescanner.h:78
QDir m_dir
Global working dir for file detection.
Definition: imagescanner.h:91
REGEXP m_exclusions
Pattern of dir names to ignore whilst scanning.
Definition: imagescanner.h:93
QHash< QString, QString > NameHash
Definition: imagetypes.h:61
QMutex m_mutexProgress
Progress counts mutex.
Definition: imagescanner.h:88
QPair< int, QString > ClearTask
Definition: imagescanner.h:64
#define META_PUBLIC
Definition: mythmetaexp.h:9
NameHash m_seenFile
Files seen by current scan Map <Db filepath, Earlier abs filepath>
Definition: imagescanner.h:80
ImageThumb< DBFS > & m_thumb
Companion thumbnail generator.
Definition: imagescanner.h:71
QMutex m_mutexQueue
Mutex protecting Clear requests.
Definition: imagescanner.h:69
ImageHash m_dbFileMap
Files in the Db from last scan, Map<Db filepath, Db Image>
Definition: imagescanner.h:76
unsigned int uint
Definition: compat.h:140
QMutex m_mutexState
Mutex protecting scan state.
Definition: imagescanner.h:67
QFileInfo fileInfo(filename)
DBFS & m_dbfs
Database/filesystem adapter.
Definition: imagescanner.h:70
Image Scanner thread requires a database/filesystem adapter.
Definition: imagescanner.h:28
#define REGEXP
Definition: imagescanner.h:20
QHash< QString, ImagePtr > ImageHash
Definition: imagetypes.h:168
Creates and manages thumbnails.
QStringList m_changedImages
Ids of dirs/files that have been updates/modified.
Definition: imagescanner.h:82