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 ImportCache;
31 class MetaDataList;
32 
37 class CopyThread :
38  public QThread
39 {
40  Q_OBJECT
41  PIMPL(CopyThread)
42 
43 public:
44 
45  enum class Mode : uint8_t
46  {
47  Copy=0,
48  Rollback
49  };
50 
51  CopyThread(const QString& target_dir, ImportCachePtr cache, QObject *parent=nullptr);
52  virtual ~CopyThread();
53 
54  int get_n_copied_files() const;
55 
56  bool was_cancelled() const;
57  void cancel();
58 
59  MetaDataList get_copied_metadata() const;
60 
61  void set_mode(CopyThread::Mode mode);
62 
63 
64 private:
65 
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 #endif
The ImportCache class.
Definition: ImportCache.h:35
The MetaDataList class.
Definition: MetaDataList.h:38
The CopyThread class.
Definition: CopyThread.h:37