src/partdownloader.h

changeset 994
09e1a3e272ec
parent 993
23436e487f0c
child 1014
f0a8ecb6a357
child 1217
314e12e23c3a
equal deleted inserted replaced
993:23436e487f0c 994:09e1a3e272ec
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 - 2015 Teemu Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program 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 General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #pragma once
20 #include <QDialog>
21 #include "main.h"
22 #include "basics.h"
23 #include "ldDocument.h"
24
25 class LDDocument;
26 class QFile;
27 class PartDownloadRequest;
28 class Ui_DownloadFrom;
29 class QNetworkAccessManager;
30 class QNetworkRequest;
31 class QNetworkReply;
32 class QAbstractButton;
33
34 class PartDownloader : public QDialog, public HierarchyElement
35 {
36 Q_OBJECT
37
38 public:
39 enum SourceType
40 {
41 PartsTracker,
42 CustomURL,
43 };
44
45 enum Button
46 {
47 Download,
48 Abort,
49 Close
50 };
51
52 enum TableColumn
53 {
54 PartLabelColumn,
55 ProgressColumn,
56 };
57
58 using RequestList = QList<PartDownloadRequest*>;
59
60 explicit PartDownloader (QWidget* parent = nullptr);
61 virtual ~PartDownloader();
62
63 void addFile (LDDocument* f);
64 QPushButton* button (Button i);
65 Q_SLOT void buttonClicked (QAbstractButton* btn);
66 Q_SLOT void checkIfFinished();
67 void checkValidPath();
68 void downloadFile (QString dest, QString url, bool primary);
69 void downloadFromPartsTracker (QString file);
70 QString downloadPath();
71 bool isAborted() const;
72 void modifyDestination (QString& dest) const;
73 LDDocument* primaryFile() const;
74 class QTableWidget* progressTable() const;
75 void setPrimaryFile (LDDocument* document);
76 void setSourceType (SourceType src);
77 Q_SLOT void sourceChanged (int i);
78 SourceType sourceType() const;
79 QString url();
80
81 signals:
82 void primaryFileDownloaded();
83
84 private:
85 class Ui_PartDownloader& ui;
86 QStringList m_filesToDownload;
87 RequestList m_requests;
88 QPushButton* m_downloadButton;
89 SourceType m_source;
90 QList<LDDocument*> m_files;
91 LDDocument* m_primaryFile;
92 bool m_isAborted;
93 };

mercurial