Sayonara Player
CopyThread.h
1 /* CopyThread.h */
2 
3 /* Copyright (C) 2011-2017 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 class QString;
30 class MetaDataList;
31 
32 namespace Library
33 {
34  class ImportCache;
35 
40  class CopyThread :
41  public QThread
42  {
43  Q_OBJECT
44  PIMPL(CopyThread)
45 
46  public:
47  enum class Mode : uint8_t
48  {
49  Copy=0,
50  Rollback
51  };
52 
53  CopyThread(const QString& target_dir, ImportCachePtr cache, QObject *parent=nullptr);
54  virtual ~CopyThread();
55 
56  int get_n_copied_files() const;
57 
58  bool was_cancelled() const;
59  void cancel();
60 
61  MetaDataList get_copied_metadata() const;
62 
63  void set_mode(CopyThread::Mode mode);
64 
65  private:
66  void clear();
67  void run();
68 
76  void copy();
77  void rollback();
78  void emit_percent(int i, int n);
79 
80 
81  signals:
82  void sig_progress(int);
83  };
84 }
85 
86 #endif
The MetaDataList class.
Definition: MetaDataList.h:38
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:31
The CopyThread class.
Definition: CopyThread.h:40