libquentier 0.8.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
FileCopier.h
1/*
2 * Copyright 2018-2024 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#pragma once
20
21#include <quentier/types/ErrorString.h>
22#include <quentier/utility/Linkage.h>
23
24#include <QObject>
25#include <QString>
26
27class QDebug;
28class QTextStream;
29
30namespace quentier {
31
32class FileCopierPrivate;
33
34class QUENTIER_EXPORT FileCopier : public QObject
35{
37public:
38 explicit FileCopier(QObject * parent = nullptr);
39
40 enum class State
41 {
42 Idle = 0,
43 Copying,
44 Cancelling
45 };
46
47 friend QDebug & operator<<(QDebug & dbg, State state);
48 friend QTextStream & operator<<(QTextStream & strm, State state);
49
50 [[nodiscard]] State state() const;
51
52 [[nodiscard]] QString sourceFilePath() const;
53 [[nodiscard]] QString destinationFilePath() const;
54
55 [[nodiscard]] double currentProgress() const;
56
58 void progressUpdate(double progress);
59 void finished(QString sourcePath, QString destPath);
60 void cancelled(QString sourcePath, QString destPath);
61 void notifyError(ErrorString error);
62
63public Q_SLOTS:
64 void copyFile(QString sourcePath, QString destPath);
65 void cancel();
66
67private:
69
70private:
71 FileCopierPrivate * d_ptr;
72 Q_DECLARE_PRIVATE(FileCopier)
73};
74
75} // namespace quentier
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition ErrorString.h:43
Definition FileCopier.h:35
The Result template class represents the bare bones result monad implementation which either contains...
Definition Result.h:38