Sun, 07 Sep 2014 04:15:54 +0300
- fixed: missing WIN32 keyword in cmakelists caused the command prompt to show up when ldforge was executed
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
844
11587d419d2f
- changed copyright lines to use my legal name instead of my nickname
Teemu Piippo <crimsondusk64@gmail.com>
parents:
839
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QDialog> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "main.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "basics.h" |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
23 | #include "ldDocument.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | class LDDocument; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | class QFile; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | class PartDownloadRequest; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class Ui_DownloadFrom; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | class QNetworkAccessManager; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | class QNetworkRequest; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | class QNetworkReply; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | class QAbstractButton; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | class PartDownloader : public QDialog |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | { |
794 | 38 | public: |
39 | enum Source | |
40 | { | |
41 | PartsTracker, | |
42 | CustomURL, | |
43 | }; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
794 | 45 | enum Button |
46 | { | |
47 | Download, | |
48 | Abort, | |
49 | Close | |
50 | }; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | |
794 | 52 | enum TableColumn |
53 | { | |
54 | PartLabelColumn, | |
55 | ProgressColumn, | |
56 | }; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | |
794 | 58 | using RequestList = QList<PartDownloadRequest*>; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
794 | 60 | Q_OBJECT |
61 | PROPERTY (public, LDDocumentPtr, primaryFile, setPrimaryFile, STOCK_WRITE) | |
62 | PROPERTY (public, bool, isAborted, setAborted, STOCK_WRITE) | |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
63 | PROPERTY (private, Ui_DownloadFrom*, form, setForm, STOCK_WRITE) |
794 | 64 | PROPERTY (private, QStringList, filesToDownload, setFilesToDownload, STOCK_WRITE) |
65 | PROPERTY (private, RequestList, requests, setRequests, STOCK_WRITE) | |
66 | PROPERTY (private, QPushButton*, downloadButton, setDownloadButton, STOCK_WRITE) | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | |
794 | 68 | public: |
69 | explicit PartDownloader (QWidget* parent = null); | |
70 | virtual ~PartDownloader(); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
72 | void addFile (LDDocumentPtr f); |
794 | 73 | void downloadFile (QString dest, QString url, bool primary); |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
74 | void downloadFromPartsTracker (QString file); |
794 | 75 | QPushButton* getButton (Button i); |
839
5f822ad61875
- part downloader: update the input widget with the corrected part name when guesswork is done
Teemu Piippo <crimsondusk64@gmail.com>
parents:
814
diff
changeset
|
76 | QString getURL(); |
794 | 77 | Source getSource() const; |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
78 | void setSource (Source src); |
794 | 79 | void modifyDestination (QString& dest) const; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | |
794 | 81 | static QString getDownloadPath(); |
82 | static void staticBegin(); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | |
794 | 84 | public slots: |
85 | void buttonClicked (QAbstractButton* btn); | |
86 | void checkIfFinished(); | |
87 | void sourceChanged (int i); | |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
88 | |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
89 | private: |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
90 | Source m_source; |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
91 | QList<LDDocumentPtr> m_files; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | class PartDownloadRequest : public QObject |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | { |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
98 | public: |
865
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
99 | enum class State |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
100 | { |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
101 | Requesting, |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
102 | Downloading, |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
103 | Finished, |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
104 | Failed, |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
105 | }; |
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
106 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
107 | Q_OBJECT |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
108 | PROPERTY (public, int, tableRow, setTableRow, STOCK_WRITE) |
865
6d68840fcb26
- circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
109 | PROPERTY (private, State, state, setState, STOCK_WRITE) |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
110 | PROPERTY (private, PartDownloader*, prompt, setPrompt, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
111 | PROPERTY (private, QString, url, setURL, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
112 | PROPERTY (private, QString, destinaton, setDestination, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
113 | PROPERTY (private, QString, filePath, setFilePath, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
114 | PROPERTY (private, QNetworkAccessManager*, networkManager, setNetworkManager, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
115 | PROPERTY (private, QNetworkReply*, networkReply, setNetworkReply, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
116 | PROPERTY (private, bool, isFirstUpdate, setFirstUpdate, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
117 | PROPERTY (private, int64, numBytesRead, setNumBytesRead, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
118 | PROPERTY (private, int64, numBytesTotal, setNumBytesTotal, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
119 | PROPERTY (private, bool, isPrimary, setPrimary, STOCK_WRITE) |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
120 | PROPERTY (private, QFile*, filePointer, setFilePointer, STOCK_WRITE) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
122 | public: |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
123 | explicit PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
124 | PartDownloadRequest (const PartDownloadRequest&) = delete; |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
125 | virtual ~PartDownloadRequest(); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
126 | void updateToTable(); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
127 | bool isFinished() const; |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
128 | void operator= (const PartDownloadRequest&) = delete; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | |
814
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
130 | public slots: |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
131 | void downloadFinished(); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
132 | void readyRead(); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
133 | void downloadProgress (qint64 recv, qint64 total); |
c8ef30fd0e54
- refactored stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
134 | void abort(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | }; |