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 
15 class GameHandler;
16 class RomInfo;
17 
19 {
20  QString system;
21  QString gametype;
22  QString romfile;
23  QString rompath;
24  QString romname;
25  bool indb { false };
26 };
27 
28 using RomFileInfoList = QList< RomFileInfo >;
29 
30 class GameScannerThread : public MThread
31 {
32  public:
33  explicit GameScannerThread(void);
34  ~GameScannerThread() override = default;
35 
36  void run(void) override; // MThread
37 
38  void SetHandlers(QList<GameHandler*> handlers) { m_handlers = std::move(handlers); };
39  void SetProgressDialog(MythUIProgressDialog *dialog) { m_dialog = dialog; };
40 
41  bool getDataChanged() const { return m_dbDataChanged; };
42 
43  private:
44 
45  static void removeOrphan(int id);
46 
47  void verifyFiles();
48  void updateDB();
49 
50  bool buildFileList();
51 
52  void SendProgressEvent(uint progress, uint total = 0,
53  QString message = QString());
54 
55  bool m_hasGUI;
56 
57  QList<GameHandler*> m_handlers;
58 
60  QList<uint> m_remove;
61  QList<RomInfo*> m_dbgames;
62 
64 
65  bool m_dbDataChanged {false};
66 };
67 
68 class GameScanner : public QObject
69 {
70  Q_OBJECT
71 
72  public:
73  GameScanner();
74  ~GameScanner() override;
75 
76  void doScan(QList<GameHandler*> handlers);
77  void doScanAll(void);
78 
79  signals:
80  void finished(bool);
81 
82  public slots:
83  void finishedScan();
84 
85  private:
87 };
88 
89 #endif
GameScanner::doScanAll
void doScanAll(void)
Definition: gamescan.cpp:227
GameScannerThread::buildFileList
bool buildFileList()
Definition: gamescan.cpp:130
RomFileInfo
Definition: gamescan.h:18
GameScannerThread::getDataChanged
bool getDataChanged() const
Definition: gamescan.h:41
RomFileInfo::gametype
QString gametype
Definition: gamescan.h:21
GameHandler
Definition: gamehandler.h:60
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:71
GameScannerThread::m_remove
QList< uint > m_remove
Definition: gamescan.h:60
RomFileInfo::romname
QString romname
Definition: gamescan.h:24
GameScanner
Definition: gamescan.h:68
GameScanner::GameScanner
GameScanner()
Definition: gamescan.cpp:184
GameScannerThread::SetHandlers
void SetHandlers(QList< GameHandler * > handlers)
Definition: gamescan.h:38
GameScannerThread::m_handlers
QList< GameHandler * > m_handlers
Definition: gamescan.h:57
GameScannerThread::run
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
MythUIProgressDialog
Definition: mythprogressdialog.h:59
GameScanner::finished
void finished(bool)
GameScannerThread::GameScannerThread
GameScannerThread(void)
Definition: gamescan.cpp:23
GameScanner::finishedScan
void finishedScan()
Definition: gamescan.cpp:249
GameScannerThread::SendProgressEvent
void SendProgressEvent(uint progress, uint total=0, QString message=QString())
Definition: gamescan.cpp:174
RomFileInfo::romfile
QString romfile
Definition: gamescan.h:22
GameScanner::~GameScanner
~GameScanner() override
Definition: gamescan.cpp:189
handlers
static QList< GameHandler * > * handlers
Definition: gamehandler.cpp:23
GameScannerThread::~GameScannerThread
~GameScannerThread() override=default
GameScannerThread::m_files
RomFileInfoList m_files
Definition: gamescan.h:59
uint
unsigned int uint
Definition: compat.h:140
GameScannerThread::m_dbgames
QList< RomInfo * > m_dbgames
Definition: gamescan.h:61
RomFileInfoList
QList< RomFileInfo > RomFileInfoList
Definition: gamescan.h:28
GameScannerThread::removeOrphan
static void removeOrphan(int id)
Definition: gamescan.cpp:49
RomFileInfo::system
QString system
Definition: gamescan.h:20
RomInfo
Definition: rominfo.h:12
GameScannerThread::SetProgressDialog
void SetProgressDialog(MythUIProgressDialog *dialog)
Definition: gamescan.h:39
GameScannerThread::m_hasGUI
bool m_hasGUI
Definition: gamescan.h:55
GameScannerThread::updateDB
void updateDB()
Definition: gamescan.cpp:101
GameScannerThread
Definition: gamescan.h:30
GameScannerThread::m_dbDataChanged
bool m_dbDataChanged
Definition: gamescan.h:65
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
RomFileInfo::rompath
QString rompath
Definition: gamescan.h:23
GameScannerThread::verifyFiles
void verifyFiles()
Definition: gamescan.cpp:60
RomFileInfo::indb
bool indb
Definition: gamescan.h:25
GameScanner::m_scanThread
GameScannerThread * m_scanThread
Definition: gamescan.h:86
GameScanner::doScan
void doScan(QList< GameHandler * > handlers)
Definition: gamescan.cpp:195
GameScannerThread::m_dialog
MythUIProgressDialog * m_dialog
Definition: gamescan.h:63