MythTV  master
gamescan.h
Go to the documentation of this file.
1 #ifndef GAMESCAN_H
2 #define GAMESCAN_H
3 
4 #include <map>
5 #include <set>
6 #include <utility>
7 
8 #include <QMap>
9 #include <QObject> // for moc
10 #include <QStringList>
11 
12 #include "mthread.h"
13 
14 class QStringList;
15 
17 class GameHandler;
18 class RomInfo;
19 
21 {
22  QString system;
23  QString gametype;
24  QString romfile;
25  QString rompath;
26  QString romname;
27  bool indb { false };
28 };
29 
30 using RomFileInfoList = QList< RomFileInfo >;
31 
32 class GameScannerThread : public MThread
33 {
34  public:
35  explicit GameScannerThread(void);
36  ~GameScannerThread() override = default;
37 
38  void run(void) override; // MThread
39 
40  void SetHandlers(QList<GameHandler*> handlers) { m_handlers = std::move(handlers); };
41  void SetProgressDialog(MythUIProgressDialog *dialog) { m_dialog = dialog; };
42 
43  bool getDataChanged() const { return m_dbDataChanged; };
44 
45  private:
46 
47  static void removeOrphan(int id);
48 
49  void verifyFiles();
50  void updateDB();
51 
52  bool buildFileList();
53 
54  void SendProgressEvent(uint progress, uint total = 0,
55  QString message = QString());
56 
57  bool m_hasGUI;
58 
59  QList<GameHandler*> m_handlers;
60 
62  QList<uint> m_remove;
63  QList<RomInfo*> m_dbgames;
64 
66 
67  bool m_dbDataChanged {false};
68 };
69 
70 class GameScanner : public QObject
71 {
72  Q_OBJECT
73 
74  public:
75  GameScanner();
76  ~GameScanner() override;
77 
78  void doScan(QList<GameHandler*> handlers);
79  void doScanAll(void);
80 
81  signals:
82  void finished(bool);
83 
84  public slots:
85  void finishedScan();
86 
87  private:
89 };
90 
91 #endif
bool indb
Definition: gamescan.h:27
void doScan(QList< GameHandler * > handlers)
Definition: gamescan.cpp:195
void verifyFiles()
Definition: gamescan.cpp:58
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
void doScanAll(void)
Definition: gamescan.cpp:227
bool getDataChanged() const
Definition: gamescan.h:43
GameScannerThread * m_scanThread
Definition: gamescan.h:88
MythUIProgressDialog * m_dialog
Definition: gamescan.h:65
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: gamescan.cpp:29
bool buildFileList()
Definition: gamescan.cpp:129
unsigned int slots[4]
Definition: element.cpp:38
QList< uint > m_remove
Definition: gamescan.h:62
void SetHandlers(QList< GameHandler * > handlers)
Definition: gamescan.h:40
QString romfile
Definition: gamescan.h:24
void finished(bool)
QList< GameHandler * > m_handlers
Definition: gamescan.h:59
~GameScannerThread() override=default
QString romname
Definition: gamescan.h:26
QList< RomInfo * > m_dbgames
Definition: gamescan.h:63
void finishedScan()
Definition: gamescan.cpp:249
RomFileInfoList m_files
Definition: gamescan.h:61
GameScannerThread(void)
Definition: gamescan.cpp:23
unsigned int uint
Definition: compat.h:140
~GameScanner() override
Definition: gamescan.cpp:189
void SendProgressEvent(uint progress, uint total=0, QString message=QString())
Definition: gamescan.cpp:174
static QList< GameHandler * > * handlers
Definition: gamehandler.cpp:23
QString rompath
Definition: gamescan.h:25
QString gametype
Definition: gamescan.h:23
QList< RomFileInfo > RomFileInfoList
Definition: gamescan.h:30
static void removeOrphan(int id)
Definition: gamescan.cpp:47
void SetProgressDialog(MythUIProgressDialog *dialog)
Definition: gamescan.h:41
QString system
Definition: gamescan.h:22
bool m_dbDataChanged
Definition: gamescan.h:67