libquentier  0.5.0
The library for rich desktop clients of Evernote service
FileCopier.h
1 /*
2  * Copyright 2018-2020 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_UTILITY_FILE_COPIER_H
20 #define LIB_QUENTIER_UTILITY_FILE_COPIER_H
21 
22 #include <quentier/types/ErrorString.h>
23 #include <quentier/utility/Linkage.h>
24 #include <quentier/utility/Macros.h>
25 
26 #include <QObject>
27 #include <QString>
28 
29 QT_FORWARD_DECLARE_CLASS(QDebug)
30 QT_FORWARD_DECLARE_CLASS(QTextStream)
31 
32 namespace quentier {
33 
34 QT_FORWARD_DECLARE_CLASS(FileCopierPrivate)
35 
36 class QUENTIER_EXPORT FileCopier: public QObject
37 {
38  Q_OBJECT
39 public:
40  explicit FileCopier(QObject * parent = nullptr);
41 
42  enum class State
43  {
44  Idle = 0,
45  Copying,
46  Cancelling
47  };
48 
49  friend QDebug & operator<<(QDebug & dbg, const State state);
50  friend QTextStream & operator<<(QTextStream & strm, const State state);
51 
52  State state() const;
53 
54  QString sourceFilePath() const;
55  QString destinationFilePath() const;
56 
57  double currentProgress() const;
58 
59 Q_SIGNALS:
60  void progressUpdate(double progress);
61  void finished(QString sourcePath, QString destPath);
62  void cancelled(QString sourcePath, QString destPath);
63  void notifyError(ErrorString error);
64 
65 public Q_SLOTS:
66  void copyFile(QString sourcePath, QString destPath);
67  void cancel();
68 
69 private:
70  Q_DISABLE_COPY(FileCopier)
71 
72 private:
73  FileCopierPrivate * d_ptr;
74  Q_DECLARE_PRIVATE(FileCopier)
75 };
76 
77 } // namespace quentier
78 
79 #endif // LIB_QUENTIER_UTILITY_FILE_COPIER_H
quentier::ErrorString
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:44
quentier::FileCopier
Definition: FileCopier.h:37