1 /* ReloadThread.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 /*
23  * ReloadThread.h
24  *
25  *  Created on: Jun 19, 2011
26  *      Author: Michael Lugmair (Lucio Carreras)
27  */
28 
29 #ifndef RELOADTHREAD_H_
30 #define RELOADTHREAD_H_
31 
32 #include "Utils/Library/LibraryNamespaces.h"
33 #include "Utils/Pimpl.h"
34 
35 #include <QThread>
36 #include <QDir>
37 
38 namespace Library
39 {
40 	class ReloadThread :
41 			public QThread
42 	{
43 		Q_OBJECT
44 		PIMPL(ReloadThread)
45 
46 	signals:
47 		void sigReloadingLibrary(const QString& message, int progress);
48 		void sigNewBlockSaved();
49 
50 	public:
51 		explicit ReloadThread(QObject* parent);
52 		~ReloadThread() override;
53 
54 		void pause();
55 		void goon();
56 		void stop();
57 		bool isRunning() const;
58 		void setQuality(ReloadQuality quality);
59 		void setLibrary(LibraryId id, const QString& libraryPath);
60 
61 	protected:
62 		virtual void run() override;
63 
64 	private:
65 		bool			getAndSaveAllFiles(const QHash<QString, MetaData>& pathMetadataMap);
66 		QStringList		getFilesRecursive(QDir base_dir);
67 		QStringList		filterValidFiles(const QDir& dir, const QStringList& filesInDir);
68 		void			storeMetadataBlock(const MetaDataList& v_md);
69 	};
70 }
71 
72 #endif /* RELOADTHREAD_H_ */
73