src/partdownloadrequest.cpp

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 1330
9155a6b153f3
permissions
-rw-r--r--

things

994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu 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: 1265
diff changeset
3 * Copyright (C) 2013 - 2018 Teemu Piippo
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QDir>
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
20 #include <QFileInfo>
1156
c20ee66b6705 Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
21 #include <QMessageBox>
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <QNetworkAccessManager>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <QNetworkRequest>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include <QNetworkReply>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include <QTableWidget>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include <QProgressBar>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include <QLabel>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 #include "partdownloader.h"
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include "partdownloadrequest.h"
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "mainwindow.h"
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
31 #include "documentmanager.h"
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 PartDownloadRequest::PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent) :
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 QObject (parent),
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
35 HierarchyElement (parent),
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 m_state (State::Requesting),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 m_prompt (parent),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 m_url (url),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 m_destination (dest),
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
40 m_filePath (parent->downloadPath() + "/" + dest),
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 m_networkManager (new QNetworkAccessManager),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 m_isFirstUpdate (true),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 m_isPrimary (primary),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 m_filePointer (nullptr)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 // Make sure that we have a valid destination.
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
47 QFileInfo destination {m_filePath};
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
48 QDir downloadDir {parent->downloadPath()};
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
49 QString relativePath = QFileInfo {dest}.path();
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
51 if (not downloadDir.exists(relativePath))
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 {
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
53 print("Creating %1...\n", relativePath);
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
55 if (not downloadDir.mkpath(relativePath))
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
56 {
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
57 QMessageBox::critical(
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
58 m_window,
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
59 tr("Error"),
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
60 format(tr("Couldn't create the directory %1!"), relativePath)
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
61 );
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
62 }
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 m_networkReply = m_networkManager->get (QNetworkRequest (QUrl (url)));
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 connect (networkReply(), SIGNAL (finished()), this, SLOT (downloadFinished()));
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 connect (networkReply(), SIGNAL (readyRead()), this, SLOT (readFromNetworkReply()));
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 connect (networkReply(), SIGNAL (downloadProgress (qint64, qint64)),
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 this, SLOT (updateDownloadProgress (qint64, qint64)));
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 PartDownloadRequest::~PartDownloadRequest() {}
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 bool PartDownloadRequest::failed() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 return m_state == State::Failed;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 int PartDownloadRequest::tableRow() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 return m_tableRow;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 void PartDownloadRequest::setTableRow (int value)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 m_tableRow = value;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 PartDownloader* PartDownloadRequest::prompt() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 return m_prompt;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 QString PartDownloadRequest::url() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 return m_url;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 QString PartDownloadRequest::destination() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 return m_destination;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 QString PartDownloadRequest::filePath() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 return m_filePath;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 bool PartDownloadRequest::isFirstUpdate() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 return m_isFirstUpdate;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 qint64 PartDownloadRequest::numBytesRead() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 return m_numBytesRead;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 qint64 PartDownloadRequest::numBytesTotal() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 return m_numBytesTotal;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 bool PartDownloadRequest::isPrimary() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 return m_isPrimary;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 QNetworkReply* PartDownloadRequest::networkReply() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 return m_networkReply;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 void PartDownloadRequest::updateToTable()
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 QTableWidget* table = prompt()->progressTable();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 switch (m_state)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 case State::Requesting:
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 case State::Downloading:
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 QWidget* cellwidget = table->cellWidget (tableRow(), PartDownloader::ProgressColumn);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 QProgressBar* progressBar = qobject_cast<QProgressBar*> (cellwidget);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 if (not progressBar)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 progressBar = new QProgressBar;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 table->setCellWidget (tableRow(), PartDownloader::ProgressColumn, progressBar);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 progressBar->setRange (0, numBytesTotal());
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 progressBar->setValue (numBytesRead());
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 break;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 case State::Finished:
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 case State::Failed:
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 const QString text = (m_state == State::Finished)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 ? "<b><span style=\"color: #080\">FINISHED</span></b>"
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 : "<b><span style=\"color: #800\">FAILED</span></b>";
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 QLabel* lb = new QLabel (text);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 lb->setAlignment (Qt::AlignCenter);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 table->setCellWidget (tableRow(), PartDownloader::ProgressColumn, lb);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 break;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 QLabel* label = qobject_cast<QLabel*> (table->cellWidget (tableRow(), PartDownloader::PartLabelColumn));
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 if (isFirstUpdate())
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 label = new QLabel (format ("<b>%1</b>", destination()), table);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 table->setCellWidget (tableRow(), PartDownloader::PartLabelColumn, label);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 // Make sure that the cell is big enough to contain the label
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 if (table->columnWidth (PartDownloader::PartLabelColumn) < label->width())
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 table->setColumnWidth (PartDownloader::PartLabelColumn, label->width());
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 m_isFirstUpdate = false;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 void PartDownloadRequest::downloadFinished()
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 if (networkReply()->error() != QNetworkReply::NoError)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 {
1330
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
190 // The state must be set before popping a modal dialog or we may deal with
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
191 // signals with an invalid state.
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
192 m_state = State::Failed;
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
193 print("Unable to download %1: %2\n", destination(), networkReply()->errorString());
9155a6b153f3 Used more Qt file info stuff
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
194
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 if (isPrimary() and not prompt()->isAborted())
1156
c20ee66b6705 Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
196 QMessageBox::critical(m_window, tr("Error"), networkReply()->errorString());
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 else if (m_state != State::Failed)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 m_state = State::Finished;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 m_numBytesRead = numBytesTotal();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 updateToTable();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 if (m_filePointer)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 m_filePointer->close();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 delete m_filePointer;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 m_filePointer = nullptr;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 if (m_state == State::Failed)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 QFile::remove (filePath());
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 if (m_state != State::Finished)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 prompt()->checkIfFinished();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 return;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222 // Try to load this file now.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
223 LDDocument* document = m_documents->openDocument (filePath(), false, not isPrimary());
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
225 if (document == nullptr)
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 return;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // Iterate through this file and check for errors. If there's any that stems
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 // from unknown file references, try resolve that by downloading the reference.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
230 for (LDObject* obj : document->objects())
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 {
1265
f05683924e86 reimplemented detection of broken references in PartDownloadRequest::downloadFinished
Santeri Piippo
parents: 1156
diff changeset
232 LDSubfileReference* reference = dynamic_cast<LDSubfileReference*>(obj);
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233
1265
f05683924e86 reimplemented detection of broken references in PartDownloadRequest::downloadFinished
Santeri Piippo
parents: 1156
diff changeset
234 if (reference and reference->fileInfo(m_documents) == nullptr)
f05683924e86 reimplemented detection of broken references in PartDownloadRequest::downloadFinished
Santeri Piippo
parents: 1156
diff changeset
235 prompt()->downloadFromPartsTracker(reference->referenceName());
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
238 prompt()->addFile (document);
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 if (isPrimary())
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
242 m_documents->addRecentFile (filePath());
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
243 prompt()->setPrimaryFile (document);
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 prompt()->checkIfFinished();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
248
1135
8e0691be0b6f Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
249 void PartDownloadRequest::updateDownloadProgress (qint64 recv, qint64 total)
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 m_numBytesRead = recv;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 m_numBytesTotal = total;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 m_state = State::Downloading;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 updateToTable();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 void PartDownloadRequest::readFromNetworkReply()
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 if (m_state == State::Failed)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 return;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 if (m_filePointer == nullptr)
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 m_filePath.replace ("\\", "/");
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 // We have already asked the user whether we can overwrite so we're good to go here.
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 m_filePointer = new QFile (filePath().toLocal8Bit());
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 if (not m_filePointer->open (QIODevice::WriteOnly))
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 {
1156
c20ee66b6705 Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
271 QMessageBox::critical(m_window, tr("Error"), format(tr("Couldn't open %1 for writing: %2"), filePath(), strerror(errno)));
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 m_state = State::Failed;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 networkReply()->abort();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 updateToTable();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 prompt()->checkIfFinished();
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 return;
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 m_filePointer->write (networkReply()->readAll());
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 bool PartDownloadRequest::isFinished() const
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 return isOneOf (m_state, State::Finished, State::Failed);
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 }
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 void PartDownloadRequest::abort()
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 {
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290 networkReply()->abort();
1156
c20ee66b6705 Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
291 }

mercurial