Sayonara Player
CopyThread.h
1 /* CopyThread.h */
2 
3 /* Copyright (C) 2011-2019 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 IMPORT_COPY_THREAD_H
22 #define IMPORT_COPY_THREAD_H
23 
24 #include <QThread>
25 
26 #include "ImportCache.h"
27 #include "Utils/Pimpl.h"
28 
29 namespace Library
30 {
31  class ImportCache;
32 
37  class CopyThread :
38  public QThread
39  {
40  Q_OBJECT
41  PIMPL(CopyThread)
42 
43  public:
44  enum class Mode : uint8_t
45  {
46  Copy=0,
47  Rollback
48  };
49 
50  CopyThread(const QString& target_dir, ImportCachePtr cache, QObject *parent=nullptr);
51  virtual ~CopyThread();
52 
53  int get_n_copied_files() const;
54 
55  bool was_cancelled() const;
56  void cancel();
57 
58  MetaDataList get_copied_metadata() const;
59 
60  void set_mode(CopyThread::Mode mode);
61 
62  private:
63  void clear();
64  void run();
65 
73  void copy();
74  void rollback();
75  void emit_percent(int i, int n);
76 
77 
78  signals:
79  void sig_progress(int);
80  };
81 }
82 
83 #endif
The MetaDataList class.
Definition: MetaDataList.h:37
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:32
The CopyThread class.
Definition: CopyThread.h:37