LibrePCB Developers Documentation
asynccopyoperation.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_ASYNCCOPYOPERATION_H
21#define LIBREPCB_CORE_ASYNCCOPYOPERATION_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "filepath.h"
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35/*******************************************************************************
36 * Class AsyncCopyOperation
37 ******************************************************************************/
38
43class AsyncCopyOperation final : public QThread {
44 Q_OBJECT
45
46public:
47 // Constructors / Destructor
49 AsyncCopyOperation(const AsyncCopyOperation& other) = delete;
50 AsyncCopyOperation(const FilePath& source, const FilePath& destination,
51 QObject* parent = nullptr) noexcept;
52 ~AsyncCopyOperation() noexcept;
53
54 // Getters
55 const FilePath& getSource() const noexcept { return mSource; }
56 const FilePath& getDestination() const noexcept { return mDestination; }
57
58 // General Methods
59
71 void abort() noexcept;
72
73 // Operator Overloadings
74 AsyncCopyOperation& operator=(const AsyncCopyOperation& rhs) = delete;
75
76signals:
77 void started();
78 void progressStatus(const QString& status);
79 void progressPercent(int percent);
80 void succeeded();
81 void failed(const QString& error);
82 void finished();
83
84private: // Methods
85 void run() noexcept override;
86
87private: // Data
90 volatile bool mAbort;
91};
92
93/*******************************************************************************
94 * End of File
95 ******************************************************************************/
96
97} // namespace librepcb
98
99#endif
High-level helper class to asynchronously and recursively copy directories with progress indicator.
Definition: asynccopyoperation.h:43
void run() noexcept override
Definition: asynccopyoperation.cpp:63
FilePath mDestination
Definition: asynccopyoperation.h:89
volatile bool mAbort
Definition: asynccopyoperation.h:90
FilePath mSource
Definition: asynccopyoperation.h:88
AsyncCopyOperation(const AsyncCopyOperation &other)=delete
const FilePath & getSource() const noexcept
Definition: asynccopyoperation.h:55
void progressPercent(int percent)
void progressStatus(const QString &status)
void abort() noexcept
Abort a running copy operation.
Definition: asynccopyoperation.cpp:53
const FilePath & getDestination() const noexcept
Definition: asynccopyoperation.h:56
void failed(const QString &error)
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
Definition: occmodel.cpp:77