Fri, 02 Aug 2013 18:42:06 +0300
added missing files
426 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 Santeri 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 | #ifndef LDFORGE_DOWNLOAD_H | |
20 | #define LDFORGE_DOWNLOAD_H | |
21 | ||
22 | #include <QDialog> | |
23 | #include "common.h" | |
24 | ||
25 | class Ui_DownloadFrom; | |
26 | class QNetworkAccessManager; | |
27 | class QNetworkRequest; | |
28 | class QNetworkReply; | |
29 | ||
30 | // ============================================================================= | |
31 | // ----------------------------------------------------------------------------- | |
32 | extern class PartDownloader { | |
33 | public: | |
34 | constexpr static const char* k_OfficialURL = "http://ldraw.org/library/official/", | |
35 | *k_UnofficialURL = "http://ldraw.org/library/unofficial/"; | |
36 | ||
37 | PartDownloader() {} | |
38 | void download(); | |
39 | void operator()() { download(); } | |
40 | } g_PartDownloader; | |
41 | ||
42 | // ============================================================================= | |
43 | // ----------------------------------------------------------------------------- | |
44 | class PartDownloadPrompt : public QDialog { | |
45 | Q_OBJECT | |
46 | ||
47 | public: | |
48 | enum Source { | |
49 | OfficialLibrary, | |
50 | PartsTracker, | |
51 | CustomURL, | |
52 | }; | |
53 | ||
54 | explicit PartDownloadPrompt (QWidget* parent = null); | |
55 | virtual ~PartDownloadPrompt(); | |
56 | str getURL(); | |
57 | ||
58 | public slots: | |
59 | void sourceChanged (int i); | |
60 | void startDownload(); | |
61 | ||
62 | protected: | |
63 | Ui_DownloadFrom* ui; | |
64 | friend class PartDownloadRequest; | |
65 | }; | |
66 | ||
67 | // ============================================================================= | |
68 | // ----------------------------------------------------------------------------- | |
69 | class PartDownloadRequest : public QObject { | |
70 | PROPERTY (int, tableRow, setTableRow) | |
71 | ||
72 | public: | |
73 | explicit PartDownloadRequest (str url, PartDownloadPrompt* parent); | |
74 | void updateToTable(); | |
75 | ||
76 | private: | |
77 | PartDownloadPrompt* m_prompt; | |
78 | str m_url; | |
79 | QNetworkAccessManager* m_nam; | |
80 | QNetworkReply* m_reply; | |
81 | }; | |
82 | ||
83 | #endif // LDFORGE_DOWNLOAD_H |