src/partdownloader.h

Fri, 21 Dec 2018 21:43:06 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 21 Dec 2018 21:43:06 +0200
changeset 1431
2e0e2c696605
parent 1326
69a90bd2dba2
permissions
-rw-r--r--

things

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
1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
3 * Copyright (C) 2013 - 2018 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"
1145
02264bf0108d Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1072
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;
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
28 class Ui_PartDownloader;
655
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;
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
33 class QTableWidget;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
35 class PartDownloader : public QDialog, public HierarchyElement
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 {
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
37 Q_OBJECT
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
38
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
39 public:
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
40 enum SourceType
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
41 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
42 PartsTracker,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
43 CustomURL,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
44 };
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
46 enum Button
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
47 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
48 Download,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
49 Abort,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
50 Close
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
51 };
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
53 enum TableColumn
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
54 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
55 PartLabelColumn,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
56 ProgressColumn,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 784
diff changeset
57 };
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
59 explicit PartDownloader(QWidget* parent = nullptr);
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
60 virtual ~PartDownloader();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
62 void addFile(LDDocument* file);
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
63 QAbstractButton *button(Button which);
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
64 void checkValidPath();
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
65 void downloadFile (QString dest, QString url, bool isPrimary);
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
66 void downloadFromPartsTracker (QString file);
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
67 QString downloadPath();
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
68 bool isAborted() const;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
69 void modifyDestination (QString& dest) const;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
70 LDDocument* primaryFile() const;
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
71 QTableWidget* progressTable() const;
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
72 void setPrimaryFile (LDDocument* document);
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
73 void setSourceType (SourceType src);
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
74 SourceType sourceType() const;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
75 QString url();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
1046
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
77 public slots:
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
78 void buttonClicked (QAbstractButton* btn);
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
79 void checkIfFinished();
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
80 void sourceChanged (int i);
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
81
f4a7b56c7eb2 Cleanup PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1014
diff changeset
82
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
83 signals:
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
84 void primaryFileDownloaded();
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
85
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
86 private:
1048
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
87 Ui_PartDownloader& _ui;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
88 QStringList _filesToDownload;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
89 QVector<PartDownloadRequest*> _requests;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
90 QPushButton* _downloadButton;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
91 SourceType _source;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
92 QVector<LDDocument*> _files;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
93 LDDocument* _primaryFile;
7b778aa2eff2 Change "m_" prefix to "_" in members of PartDownloader
Teemu Piippo <teemu@hecknology.net>
parents: 1047
diff changeset
94 bool _isAborted;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 };

mercurial