LibrePCB Developers Documentation
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/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class FileDownload;
36
37namespace editor {
38
39/*******************************************************************************
40 * Class LibraryDownload
41 ******************************************************************************/
42
46class LibraryDownload final : public QObject {
47 Q_OBJECT
48
49public:
50 // Constructors / Destructor
51 LibraryDownload() = delete;
52 LibraryDownload(const LibraryDownload& other) = delete;
53 LibraryDownload(const QUrl& urlToZip, const FilePath& destDir) noexcept;
54 ~LibraryDownload() noexcept;
55
56 // Getters
57 const FilePath& getDestinationDir() const noexcept { return mDestDir; }
58
59 // Setters
60
64 void setExpectedZipFileSize(qint64 bytes) noexcept;
65
69 void setExpectedChecksum(QCryptographicHash::Algorithm algorithm,
70 const QByteArray& checksum) noexcept;
71
72 // Operator Overloadings
74
75public slots:
76
80 void start() noexcept;
81
85 void abort() noexcept;
86
87signals:
88
89 void progressState(const QString& status);
90 void progressPercent(int percent);
91 void finished(bool success, const QString& errMsg);
92 void abortRequested(); // internal signal!
93
94private: // Methods
95 void downloadErrored(const QString& errMsg) noexcept;
96 void downloadAborted() noexcept;
97 void downloadSucceeded() noexcept;
98 FilePath getPathToLibDir() noexcept;
99
100private: // Data
105};
106
107/*******************************************************************************
108 * End of File
109 ******************************************************************************/
110
111} // namespace editor
112} // namespace librepcb
113
114#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:129
The LibraryDownload class.
Definition: librarydownload.h:46
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:102
const FilePath & getDestinationDir() const noexcept
Definition: librarydownload.h:57
void progressState(const QString &status)
void setExpectedZipFileSize(qint64 bytes) noexcept
Set the expected size of the requested content.
Definition: librarydownload.cpp:71
QScopedPointer< FileDownload > mFileDownload
Definition: librarydownload.h:101
LibraryDownload(const LibraryDownload &other)=delete
void downloadErrored(const QString &errMsg) noexcept
Definition: librarydownload.cpp:137
FilePath mTempDestDir
Definition: librarydownload.h:103
~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
FilePath mTempZipFile
Definition: librarydownload.h:104
Definition: occmodel.cpp:77