Sayonara Player
CopyThread.h
1 /* CopyThread.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 IMPORT_COPY_THREAD_H
24 #define IMPORT_COPY_THREAD_H
25 
26 #include <QThread>
27 #include <QString>
28 #include <QMap>
29 #include <QString>
30 #include <QStringList>
31 
32 #include "ImportCache.h"
33 #include "Helper/Settings/SayonaraClass.h"
34 
35 
36 class CopyThread :
37  public QThread,
38  protected SayonaraClass
39 {
40  Q_OBJECT
41 
42 public:
43 
44  enum class Mode : quint8 {
45  Copy=0,
46  Rollback
47  };
48 
49  CopyThread(const QString& target_dir, const ImportCache& cache, QObject *parent=nullptr);
50 
51  int get_n_copied_files() const;
52 
53  bool was_cancelled() const;
54  void cancel();
55 
56  MetaDataList get_copied_metadata() const;
57 
58  void set_mode(CopyThread::Mode mode);
59  CopyThread::Mode get_mode() const;
60 
61 
62 private:
63 
64  MetaDataList _v_md;
65  QString _target_dir;
66  QStringList _lst_copied_files;
67  int _copied_files;
68  Mode _mode;
69  int _percent;
70  bool _cancelled;
71 
72  ImportCache _cache;
73 
74 
75 private:
76 
77  void clear();
78  void run();
79  void copy();
80  void rollback();
81  void emit_percent(int i, int n);
82 
83 
84 signals:
85  void sig_progress(int);
86 
87 
88 };
89 
90 
91 #endif
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: ImportCache.h:32
Definition: MetaDataList.h:46
Definition: CopyThread.h:36