MythTV  master
musicfilescanner.h
Go to the documentation of this file.
1 #ifndef MUSICFILESCANNER_H
2 #define MUSICFILESCANNER_H
3 
4 // MythTV
5 #include "mythmetaexp.h"
6 
7 // Qt headers
8 #include <QCoreApplication>
9 
10 using IdCache = QMap<QString, int>;
11 
13 {
14  Q_DECLARE_TR_FUNCTIONS(MusicFileScanner)
15 
17  {
21  kBoth
22  };
23 
25  {
26  QString startDir;
27  MusicFileLocation location {kFileSystem};
28  };
29 
30  using MusicLoadedMap = QMap <QString, MusicFileData>;
31  public:
32  MusicFileScanner(bool force = false);
33  ~MusicFileScanner(void) = default;
34 
35  void SearchDirs(const QStringList &dirList);
36 
37  static bool IsRunning(void);
38 
39  private:
40  void BuildFileList(QString &directory, MusicLoadedMap &music_files, MusicLoadedMap &art_files, int parentid);
41  static int GetDirectoryId(const QString &directory, const int &parentid);
42  static bool HasFileChanged(const QString &filename, const QString &date_modified);
43  void AddFileToDB(const QString &filename, const QString &startDir);
44  void RemoveFileFromDB (const QString &filename, const QString &startDir);
45  void UpdateFileInDB(const QString &filename, const QString &startDir);
46  void ScanMusic(MusicLoadedMap &music_files);
47  void ScanArtwork(MusicLoadedMap &music_files);
48  static void cleanDB();
49  static bool IsArtFile(const QString &filename);
50  static bool IsMusicFile(const QString &filename);
51 
52  static void updateLastRunEnd(void);
53  static void updateLastRunStart(void);
54  static void updateLastRunStatus(QString &status);
55 
56  QStringList m_startDirs;
61 
62  uint m_tracksTotal {0};
63  uint m_tracksUnchanged {0};
64  uint m_tracksAdded {0};
65  uint m_tracksRemoved {0};
66  uint m_tracksUpdated {0};
67  uint m_coverartTotal {0};
68  uint m_coverartUnchanged {0};
69  uint m_coverartAdded {0};
70  uint m_coverartRemoved {0};
71  uint m_coverartUpdated {0};
72 
73  bool m_forceupdate {false};
74 };
75 
76 #endif // MUSICFILESCANNER_H
MusicFileScanner::MusicLoadedMap
QMap< QString, MusicFileData > MusicLoadedMap
Definition: musicfilescanner.h:30
force
bool force
Definition: mythtv/programs/mythcommflag/main.cpp:68
MusicFileScanner::MusicFileLocation
MusicFileLocation
Definition: musicfilescanner.h:16
updateLastRunStart
bool updateLastRunStart(void)
Definition: filldata.cpp:48
BuildFileList
static QStringList BuildFileList(const QString &dir, const QStringList &filters)
Definition: mythplugins/mythmusic/mythmusic/main.cpp:454
MusicFileScanner::m_artistid
IdCache m_artistid
Definition: musicfilescanner.h:58
mythmetaexp.h
ScanMusic
static int ScanMusic(const MythUtilCommandLineParser &cmdline)
Definition: musicmetautils.cpp:181
MusicFileScanner::kFileSystem
@ kFileSystem
Definition: musicfilescanner.h:18
MusicFileScanner::m_albumid
IdCache m_albumid
Definition: musicfilescanner.h:60
updateLastRunEnd
bool updateLastRunEnd(void)
Definition: filldata.cpp:40
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:634
MusicFileScanner::m_directoryid
IdCache m_directoryid
Definition: musicfilescanner.h:57
uint
unsigned int uint
Definition: compat.h:140
MusicFileScanner
Definition: musicfilescanner.h:12
MusicFileScanner::m_genreid
IdCache m_genreid
Definition: musicfilescanner.h:59
dirList
QStringList dirList
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1169
MusicFileScanner::kNeedUpdate
@ kNeedUpdate
Definition: musicfilescanner.h:20
updateLastRunStatus
bool updateLastRunStatus(QString &status)
Definition: filldata.cpp:57
MusicFileScanner::MusicFileData::startDir
QString startDir
Definition: musicfilescanner.h:26
MusicFileScanner::MusicFileData
Definition: musicfilescanner.h:24
MusicFileScanner::m_startDirs
QStringList m_startDirs
Definition: musicfilescanner.h:56
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
IdCache
QMap< QString, int > IdCache
Definition: musicfilescanner.h:10
MusicFileScanner::kDatabase
@ kDatabase
Definition: musicfilescanner.h:19