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 #include <QRegularExpression>
19 
20 #include "imagethumbs.h"
21 
22 
24 template <class DBFS>
26 {
27 public:
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 
38 protected:
39  void run() override; // MThread
40 
41 private:
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};
81  QMutex m_mutexProgress;
82 
84  QDir m_dir;
86  QRegularExpression m_exclusions;
87 };
88 
89 #endif // IMAGESCANNER_H
NameHash
QHash< QString, QString > NameHash
Definition: imagetypes.h:62
ImageScanThread::m_dbFileMap
ImageHash m_dbFileMap
Files in the Db from last scan, Map<Db filepath, Db Image>
Definition: imagescanner.h:69
progress
bool progress
Definition: mythcommflag.cpp:69
ImageScanThread::m_changedImages
QStringList m_changedImages
Ids of dirs/files that have been updates/modified.
Definition: imagescanner.h:75
ImageScanThread::m_bcastTimer
QElapsedTimer m_bcastTimer
Elapsed time since last progress event generated.
Definition: imagescanner.h:78
ImageScanThread::m_mutexState
QMutex m_mutexState
Mutex protecting scan state.
Definition: imagescanner.h:60
ImageScanThread::m_mutexProgress
QMutex m_mutexProgress
Progress counts mutex.
Definition: imagescanner.h:81
ImageScanThread< ImageDbSg >::ClearTask
QPair< int, QString > ClearTask
Definition: imagescanner.h:57
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:55
ImageScanThread::m_seenDir
ImageHash m_seenDir
Dirs seen by current scan, Map<Db filepath, Earlier Image>
Definition: imagescanner.h:71
ImageThumb
Definition: imagethumbs.h:127
ImageHash
QHash< QString, ImagePtr > ImageHash
Definition: imagetypes.h:161
ImageScanThread::m_thumb
ImageThumb< DBFS > & m_thumb
Companion thumbnail generator.
Definition: imagescanner.h:64
ImageScanThread::m_clearQueue
QList< ClearTask > m_clearQueue
Queue of pending Clear requests.
Definition: imagescanner.h:61
ImageScanThread::m_dbDirMap
ImageHash m_dbDirMap
Dirs in the Db from last scan, Map<Db filepath, Db Image>
Definition: imagescanner.h:67
ImageScanThread::m_dir
QDir m_dir
Global working dir for file detection.
Definition: imagescanner.h:84
MThread::run
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
ImageScanThread::m_exclusions
QRegularExpression m_exclusions
Pattern of dir names to ignore whilst scanning.
Definition: imagescanner.h:86
ImageScanThread
Image Scanner thread requires a database/filesystem adapter.
Definition: imagescanner.h:25
ImageScanThread::m_seenFile
NameHash m_seenFile
Files seen by current scan Map <Db filepath, Earlier abs filepath>
Definition: imagescanner.h:73
ImageScanThread::m_mutexQueue
QMutex m_mutexQueue
Mutex protecting Clear requests.
Definition: imagescanner.h:62
imagethumbs.h
Creates and manages thumbnails.
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
build_compdb.action
action
Definition: build_compdb.py:9
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
ImageScanThread::m_dbfs
DBFS & m_dbfs
Database/filesystem adapter.
Definition: imagescanner.h:63
build_compdb.paths
paths
Definition: build_compdb.py:13