Sayonara Player
LibraryImporter.h
1 /* LibraryImporter.h */
2 
3 /* Copyright (C) 2011-2016 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 #ifndef LIBRARYIMPORTER_H
24 #define LIBRARYIMPORTER_H
25 
26 
27 #include "Helper/Tagging/Tagging.h"
28 #include "Helper/Settings/SayonaraClass.h"
29 #include "ImportCache.h"
30 
31 class DatabaseConnector;
32 class CachingThread;
33 class CopyThread;
34 
35 class LibraryImporter : public QObject, protected SayonaraClass
36 {
37  Q_OBJECT
38 
39  SINGLETON_QOBJECT(LibraryImporter)
40 
41 
42 public:
43 
44  enum class ImportStatus : quint8 {
45  Cancelled,
46  Rollback,
47  Caching,
48  NoTracks,
49  Sleeping,
50  Importing,
51  Imported
52  };
53 
54 signals:
55  void sig_got_metadata(const MetaDataList&);
56  void sig_status_changed(LibraryImporter::ImportStatus);
57  void sig_got_library_dirs(const QStringList& library_dirs);
58  void sig_progress(int);
59 
60  void sig_imported();
61  void sig_triggered();
62 
63 
64 public:
65  void import_files(const QStringList& files);
66  void import_dir(const QString& dirname);
67  void accept_import(const QString& target_dir);
68  void cancel_import();
69  LibraryImporter::ImportStatus get_status() const;
70 
71 
72 private slots:
73 
74  void caching_thread_finished();
75  void copy_thread_finished();
76 
77  void emit_status(LibraryImporter::ImportStatus status);
78 
79  void metadata_changed(const MetaDataList& old_md, const MetaDataList& new_md);
80 
81 private:
82  CachingThread* _cache_thread=nullptr;
83  CopyThread* _copy_thread=nullptr;
84 
85  ImportCache _import_cache;
86 
87  DatabaseConnector* _db=nullptr;
88 
89  ImportStatus _status;
90 
91  QString _lib_path;
92  QString _src_dir;
93 };
94 
95 #endif // LIBRARYIMPORTER_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: DatabaseConnector.h:40
Definition: ImportCache.h:32
Definition: MetaDataList.h:46
Definition: CachingThread.h:33
Definition: LibraryImporter.h:35
Definition: CopyThread.h:36