LibrePCB Developers Documentation
Loading...
Searching...
No Matches
librarydownload.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_EDITOR_LIBRARYDOWNLOAD_H
21#define LIBREPCB_EDITOR_LIBRARYDOWNLOAD_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30#include <memory>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class FileDownload;
38
39namespace editor {
40
41/*******************************************************************************
42 * Class LibraryDownload
43 ******************************************************************************/
44
48class LibraryDownload final : public QObject {
49 Q_OBJECT
50
51public:
52 // Constructors / Destructor
53 LibraryDownload() = delete;
54 LibraryDownload(const LibraryDownload& other) = delete;
55 LibraryDownload(const QUrl& urlToZip, const FilePath& destDir) noexcept;
56 ~LibraryDownload() noexcept;
57
58 // Getters
59 const FilePath& getDestinationDir() const noexcept { return mDestDir; }
60
61 // Setters
62
66 void setExpectedZipFileSize(qint64 bytes) noexcept;
67
71 void setExpectedChecksum(QCryptographicHash::Algorithm algorithm,
72 const QByteArray& checksum) noexcept;
73
74 // Operator Overloadings
76
77public slots:
78
82 void start() noexcept;
83
87 void abort() noexcept;
88
89signals:
90
91 void progressState(const QString& status);
92 void progressPercent(int percent);
93 void finished(bool success, const QString& errMsg);
94 void abortRequested(); // internal signal!
95
96private: // Methods
97 void downloadErrored(const QString& errMsg) noexcept;
98 void downloadAborted() noexcept;
99 void downloadSucceeded() noexcept;
100 FilePath getPathToLibDir() noexcept;
101
102private: // Data
107};
108
109/*******************************************************************************
110 * End of File
111 ******************************************************************************/
112
113} // namespace editor
114} // namespace librepcb
115
116#endif
This class is used to download a file asynchronously in a separate thread.
Definition filedownload.h:46
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The LibraryDownload class.
Definition librarydownload.h:48
FilePath getPathToLibDir() noexcept
Definition librarydownload.cpp:198
void finished(bool success, const QString &errMsg)
void setExpectedChecksum(QCryptographicHash::Algorithm algorithm, const QByteArray &checksum) noexcept
Set the expected checksum of the file to download.
Definition librarydownload.cpp:80
LibraryDownload & operator=(const LibraryDownload &rhs)=delete
FilePath mDestDir
Definition librarydownload.h:104
const FilePath & getDestinationDir() const noexcept
Definition librarydownload.h:59
void progressState(const QString &status)
void setExpectedZipFileSize(qint64 bytes) noexcept
Set the expected size of the requested content.
Definition librarydownload.cpp:71
LibraryDownload(const LibraryDownload &other)=delete
void downloadErrored(const QString &errMsg) noexcept
Definition librarydownload.cpp:137
FilePath mTempDestDir
Definition librarydownload.h:105
~LibraryDownload() noexcept
Definition librarydownload.cpp:63
void abort() noexcept
Abort downloading the library.
Definition librarydownload.cpp:129
void downloadSucceeded() noexcept
Definition librarydownload.cpp:145
void start() noexcept
Start downloading the library.
Definition librarydownload.cpp:95
void downloadAborted() noexcept
Definition librarydownload.cpp:141
std::unique_ptr< FileDownload > mFileDownload
Definition librarydownload.h:103
FilePath mTempZipFile
Definition librarydownload.h:106
Definition occmodel.cpp:76
Definition uuid.h:186