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 
25 #include <QObject>
26 #include <QString>
27 
28 QT_FORWARD_DECLARE_CLASS(QDebug)
29 QT_FORWARD_DECLARE_CLASS(QTextStream)
30 
31 namespace quentier {
32 
33 QT_FORWARD_DECLARE_CLASS(FileCopierPrivate)
34 
35 class QUENTIER_EXPORT FileCopier : public QObject
36 {
37  Q_OBJECT
38 public:
39  explicit FileCopier(QObject * parent = nullptr);
40 
41  enum class State
42  {
43  Idle = 0,
44  Copying,
45  Cancelling
46  };
47 
48  friend QDebug & operator<<(QDebug & dbg, const State state);
49  friend QTextStream & operator<<(QTextStream & strm, const State state);
50 
51  State state() const;
52 
53  QString sourceFilePath() const;
54  QString destinationFilePath() const;
55 
56  double currentProgress() const;
57 
58 Q_SIGNALS:
59  void progressUpdate(double progress);
60  void finished(QString sourcePath, QString destPath);
61  void cancelled(QString sourcePath, QString destPath);
62  void notifyError(ErrorString error);
63 
64 public Q_SLOTS:
65  void copyFile(QString sourcePath, QString destPath);
66  void cancel();
67 
68 private:
69  Q_DISABLE_COPY(FileCopier)
70 
71 private:
72  FileCopierPrivate * d_ptr;
73  Q_DECLARE_PRIVATE(FileCopier)
74 };
75 
76 } // namespace quentier
77 
78 #endif // LIB_QUENTIER_UTILITY_FILE_COPIER_H
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:44
Definition: FileCopier.h:36