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