MythTV master
videoscan.h
Go to the documentation of this file.
1#ifndef VIDEO_SCANNER_H
2#define VIDEO_SCANNER_H
3
4#include <map>
5#include <set>
6#include <utility>
7#include <vector>
8
9// Qt headers
10#include <QObject> // for moc
11#include <QStringList>
12#include <QEvent>
13#include <QCoreApplication>
14
15// MythTV headers
16#include "libmythbase/mthread.h"
19
21
22class META_PUBLIC VideoScanner : public QObject
23{
24 Q_OBJECT
25
26 public:
28 ~VideoScanner() override;
29
30 void doScan(const QStringList &dirs);
31 void doScanAll(void);
32
33 signals:
34 void finished(bool);
35
36 public slots:
37 void finishedScan();
38
39 private:
40 class VideoScannerThread *m_scanThread {nullptr};
41 bool m_cancel {false};
42};
43
44class META_PUBLIC VideoScanChanges : public QEvent
45{
46 public:
47 VideoScanChanges(QList<int> adds, QList<int> movs,
48 QList<int>dels) : QEvent(kEventType),
49 m_additions(std::move(adds)), m_moved(std::move(movs)),
50 m_deleted(std::move(dels)) {}
51 ~VideoScanChanges() override = default;
52
53 QList<int> m_additions; // newly added intids
54 QList<int> m_moved; // intids moved to new filename
55 QList<int> m_deleted; // orphaned/deleted intids
56
57 static const Type kEventType;
58};
59
61{
63
64 public:
65 explicit VideoScannerThread(QObject *parent);
66 ~VideoScannerThread() override;
67
68 void run() override; // MThread
69 void SetDirs(QStringList dirs);
70 void SetHosts(const QStringList &hosts);
71 void SetProgressDialog(MythUIProgressDialog *dialog) { m_dialog = dialog; };
72 QStringList GetOfflineSGHosts(void) { return m_offlineSGHosts; };
73 bool getDataChanged() const { return m_dbDataChanged; };
74
75 void ResetCounts() { m_addList.clear(); m_movList.clear(); m_delList.clear(); };
76
77 private:
78
80 {
81 bool check {false};
82 QString host;
83 };
84
85 using PurgeList = std::vector<std::pair<int, QString> >;
86 using FileCheckList = std::map<QString, CheckStruct>;
87
88 void removeOrphans(unsigned int id, const QString &filename);
89
90 void verifyFiles(FileCheckList &files, PurgeList &remove);
91 bool updateDB(const FileCheckList &add, const PurgeList &remove);
92 bool buildFileList(const QString &directory,
93 const QStringList &imageExtensions,
94 FileCheckList &filelist) const;
95
96 void SendProgressEvent(uint progress, uint total = 0,
97 QString messsage = QString());
98
99 QObject *m_parent {nullptr};
100
101 bool m_listUnknown {false};
102 bool m_removeAll {false};
103 bool m_keepAll {false};
104 bool m_hasGUI {false};
105 QStringList m_directories;
106 QStringList m_liveSGHosts;
107 QStringList m_offlineSGHosts;
108
109 VideoMetadataListManager *m_dbMetadata {nullptr};
110 MythUIProgressDialog *m_dialog {nullptr};
111
112 QList<int> m_addList; // newly added intids
113 QList<int> m_movList; // intids moved to new filename
114 QList<int> m_delList; // orphaned/deleted intids
115 bool m_dbDataChanged {false};
116};
117
118META_PUBLIC bool RemoteGetActiveBackends(QStringList *list);
119
120#endif
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
QList< int > m_additions
Definition: videoscan.h:53
VideoScanChanges(QList< int > adds, QList< int > movs, QList< int >dels)
Definition: videoscan.h:47
QList< int > m_deleted
Definition: videoscan.h:55
QList< int > m_moved
Definition: videoscan.h:54
static const Type kEventType
Definition: videoscan.h:57
~VideoScanChanges() override=default
std::vector< std::pair< int, QString > > PurgeList
Definition: videoscan.h:85
QList< int > m_addList
Definition: videoscan.h:112
bool getDataChanged() const
Definition: videoscan.h:73
void ResetCounts()
Definition: videoscan.h:75
std::map< QString, CheckStruct > FileCheckList
Definition: videoscan.h:86
Q_DECLARE_TR_FUNCTIONS(VideoScannerThread)
QStringList GetOfflineSGHosts(void)
Definition: videoscan.h:72
QList< int > m_movList
Definition: videoscan.h:113
void SetProgressDialog(MythUIProgressDialog *dialog)
Definition: videoscan.h:71
QList< int > m_delList
Definition: videoscan.h:114
QStringList m_offlineSGHosts
Definition: videoscan.h:107
QStringList m_liveSGHosts
Definition: videoscan.h:106
QStringList m_directories
Definition: videoscan.h:105
void finished(bool)
unsigned int uint
Definition: compat.h:68
#define META_PUBLIC
Definition: mythmetaexp.h:9
void run(const QString &name, Class *object, void(Class::*fn)())
Definition: mconcurrent.h:137
STL namespace.
META_PUBLIC bool RemoteGetActiveBackends(QStringList *list)
return list of backends currently connected to the master
Definition: videoscan.cpp:487