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  qint64 &time,
53  int &orientation);
54  void SyncFile(const QFileInfo &fileInfo, int devId,
55  const QString &base, int parentId);
56  void CountTree(QDir &dir);
57  void CountFiles(const QStringList &paths);
58  void Broadcast(int progress);
59 
60  using ClearTask = QPair<int, QString>;
61 
62  bool m_scanning {false};
63  QMutex m_mutexState;
64  QList<ClearTask> m_clearQueue;
65  QMutex m_mutexQueue;
66  DBFS &m_dbfs;
68 
78  QStringList m_changedImages;
79 
81  QElapsedTimer m_bcastTimer;
82  int m_progressCount {0};
83  int m_progressTotalCount {0};
84  QMutex m_mutexProgress;
85 
87  QDir m_dir;
90 };
91 
92 #endif // IMAGESCANNER_H
fileInfo
QFileInfo fileInfo(filename)
NameHash
QHash< QString, QString > NameHash
Definition: imagetypes.h:61
ImageScanThread::m_dbFileMap
ImageHash m_dbFileMap
Files in the Db from last scan, Map<Db filepath, Db Image>
Definition: imagescanner.h:72
ImageScanThread::m_changedImages
QStringList m_changedImages
Ids of dirs/files that have been updates/modified.
Definition: imagescanner.h:78
ImageScanThread::m_bcastTimer
QElapsedTimer m_bcastTimer
Elapsed time since last progress event generated.
Definition: imagescanner.h:81
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:73
ImageScanThread::m_mutexState
QMutex m_mutexState
Mutex protecting scan state.
Definition: imagescanner.h:63
ImageScanThread::m_mutexProgress
QMutex m_mutexProgress
Progress counts mutex.
Definition: imagescanner.h:84
ImageScanThread< ImageDbSg >::ClearTask
QPair< int, QString > ClearTask
Definition: imagescanner.h:60
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:57
ImageScanThread::m_seenDir
ImageHash m_seenDir
Dirs seen by current scan, Map<Db filepath, Earlier Image>
Definition: imagescanner.h:74
ImageThumb
Definition: imagethumbs.h:128
ImageHash
QHash< QString, ImagePtr > ImageHash
Definition: imagetypes.h:160
REGEXP
#define REGEXP
Definition: imagescanner.h:20
ImageScanThread::m_thumb
ImageThumb< DBFS > & m_thumb
Companion thumbnail generator.
Definition: imagescanner.h:67
ImageScanThread::m_exclusions
REGEXP m_exclusions
Pattern of dir names to ignore whilst scanning.
Definition: imagescanner.h:89
ImageScanThread::m_clearQueue
QList< ClearTask > m_clearQueue
Queue of pending Clear requests.
Definition: imagescanner.h:64
ImageScanThread::m_dbDirMap
ImageHash m_dbDirMap
Dirs in the Db from last scan, Map<Db filepath, Db Image>
Definition: imagescanner.h:70
ImageScanThread::m_dir
QDir m_dir
Global working dir for file detection.
Definition: imagescanner.h:87
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:312
ImageScanThread
Image Scanner thread requires a database/filesystem adapter.
Definition: imagescanner.h:29
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
ImageScanThread::m_seenFile
NameHash m_seenFile
Files seen by current scan Map <Db filepath, Earlier abs filepath>
Definition: imagescanner.h:76
ImageScanThread::m_mutexQueue
QMutex m_mutexQueue
Mutex protecting Clear requests.
Definition: imagescanner.h:65
imagethumbs.h
Creates and manages thumbnails.
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
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:66
build_compdb.paths
paths
Definition: build_compdb.py:13