1 /* LibraryImporter.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 #ifndef LIBRARYIMPORTER_H
22 #define LIBRARYIMPORTER_H
23 
24 #include "Utils/Pimpl.h"
25 #include <QObject>
26 
27 class LocalLibrary;
28 
29 namespace Library
30 {
31 	/**
32 	 * @brief The LibraryImporter class
33 	 * @ingroup Library
34 	 */
35 	class Importer :
36 			public QObject
37 	{
38 		Q_OBJECT
39 		PIMPL(Importer)
40 
41 	public:
42 		explicit Importer(LocalLibrary* library);
43 		~Importer();
44 
45 		enum class ImportStatus : uint8_t
46 		{
47 			Cancelled,
48 			Rollback,
49 			Caching,
50 			NoTracks,
51 			NoValidTracks,
52 			CachingFinished,
53 			Importing,
54 			Imported
55 		};
56 
57 	signals:
58 		void sigMetadataCached(const MetaDataList& tracks);
59 		void sigStatusChanged(Importer::ImportStatus);
60 		void sigProgress(int percent);
61 		void sigCachedFilesChanged();
62 		void sigTargetDirectoryChanged(const QString& targetDir);
63 		void sigTriggered();
64 
65 	public:
66 		bool isRunning() const;
67 		void importFiles(const QStringList& files, const QString& targetDir);
68 		void acceptImport(const QString& targetDir);
69 		bool cancelImport();
70 		void reset();
71 		int cachedFileCount() const;
72 
73 		Importer::ImportStatus status() const;
74 
75 	private slots:
76 		void cachingThreadFinished();
77 		void copyThreadFinished();
78 		void emitStatus(Importer::ImportStatus status);
79 		void metadataChanged();
80 	};
81 }
82 
83 #endif // LIBRARYIMPORTER_H
84