src/partdownloader.cpp

Wed, 10 Jan 2018 22:54:09 +0200

author
Santeri Piippo
date
Wed, 10 Jan 2018 22:54:09 +0200
changeset 1226
d1199d965235
parent 1224
5a31b6d4bf81
child 1227
1a26b6502a91
permissions
-rw-r--r--

drop Qt4 support

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
1222
34def2630300 happy new year 2018
Santeri Piippo
parents: 1217
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 #include <QDir>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QPushButton>
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
21 #include <QFileDialog>
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
22 #include <QMessageBox>
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
23 #include <QTableWidget>
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
24 #include "partdownloader.h"
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
25 #include "partdownloadrequest.h"
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
26 #include "ui_partdownloader.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include "basics.h"
962
a4b463a7ee82 Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents: 952
diff changeset
28 #include "mainwindow.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include "ldDocument.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "glRenderer.h"
1012
413ecd6b9801 It worx again!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 994
diff changeset
31 #include "documentmanager.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
33 ConfigOption(QString DownloadFilePath)
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
34 ConfigOption(bool GuessDownloadPaths = true)
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
35 ConfigOption(bool AutoCloseDownloadDialog = true)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
37 const char* g_unofficialLibraryURL = "http://ldraw.org/library/unofficial/";
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
39 PartDownloader::PartDownloader(QWidget* parent) :
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
40 QDialog(parent),
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
41 HierarchyElement(parent),
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
42 ui(*new Ui_PartDownloader),
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
43 m_source(SourceType(0))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
45 ui.setupUi(this);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
46 ui.progressTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
47 m_downloadButton = new QPushButton(tr("Download"));
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
48 ui.buttonBox->addButton(m_downloadButton, QDialogButtonBox::ActionRole);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
49 button(Abort)->setEnabled(false);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
50 connect(ui.source, SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChanged(int)));
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
51 connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 PartDownloader::~PartDownloader()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 {
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
56 delete &ui;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
59 void PartDownloader::checkValidPath()
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
60 {
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
61 QString path = downloadPath();
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
62
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
63 if (path.isEmpty() or not QDir(path).exists())
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
64 {
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
65 QMessageBox::information(this, "Notice", "Please input a path for files to download.");
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
66 path = QFileDialog::getExistingDirectory(this, "Path for downloaded files:");
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
67
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
68 if (path.isEmpty())
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
69 reject();
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
70 else
1224
5a31b6d4bf81 undo config change
Santeri Piippo
parents: 1222
diff changeset
71 config->setDownloadFilePath(path);
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
72 }
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
73 }
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
74
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
75 QString PartDownloader::url()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 {
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
77 QString destination;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
79 switch(sourceType())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 {
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
81 case PartsTracker:
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
82 destination = ui.filename->text();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
83 modifyDestination(destination);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
84 ui.filename->setText(destination);
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
85 return g_unofficialLibraryURL + destination;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
87 case CustomURL:
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
88 return ui.filename->text();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 // Shouldn't happen
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 return "";
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
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
95 void PartDownloader::modifyDestination(QString& dest) const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 dest = dest.simplified();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // If the user doesn't want us to guess, stop right here.
1224
5a31b6d4bf81 undo config change
Santeri Piippo
parents: 1222
diff changeset
100 if (not config->guessDownloadPaths())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 // Ensure .dat extension
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
104 if (dest.right(4) != ".dat")
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 // Remove the existing extension, if any. It may be we're here over a
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 // typo in the .dat extension.
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
108 const int dotpos = dest.lastIndexOf(".");
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
110 if ((dotpos != -1) and(dotpos >= dest.length() - 4))
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
111 dest.chop(dest.length() - dotpos);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 dest += ".dat";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 // If the part starts with s\ or s/, then use parts/s/. Same goes with
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 // 48\ and p/48/.
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
118 if (isOneOf(dest.left(2), "s\\", "s/"))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
120 dest.remove(0, 2);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
121 dest.prepend("parts/s/");
816
9adb822de7b9 - refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 814
diff changeset
122 }
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
123 else if (isOneOf(dest.left(3), "48\\", "48/"))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
125 dest.remove(0, 3);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
126 dest.prepend("p/48/");
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 /* Try determine where to put this part. We have four directories:
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 parts/, parts/s/, p/, and p/48/. If we haven't already specified
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 either parts/ or p/, we need to add it automatically. Part files
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 are numbers wit a possible u prefix for parts with unknown number
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 which can be followed by any of:
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
134 - c**(composites)
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
135 - d**(formed stickers)
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
136 - p**(patterns)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 - a lowercase alphabetic letter for variants
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
139 Subfiles(usually) have an s** prefix, in which case we use parts/s/.
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 Note that the regex starts with a '^' so it won't catch already fully
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 given part file names. */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 QString partRegex = "^u?[0-9]+(c[0-9][0-9]+)*(d[0-9][0-9]+)*[a-z]?(p[0-9a-z][0-9a-z]+)*";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 QString subpartRegex = partRegex + "s[0-9][0-9]+";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 partRegex += "\\.dat$";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 subpartRegex += "\\.dat$";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
148 if (QRegExp(subpartRegex).exactMatch(dest))
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
149 dest.prepend("parts/s/");
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
150 else if (QRegExp(partRegex).exactMatch(dest))
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
151 dest.prepend("parts/");
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
152 else if (not dest.startsWith("parts/") and not dest.startsWith("p/"))
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
153 dest.prepend("p/");
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
156 PartDownloader::SourceType PartDownloader::sourceType() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 {
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
158 return m_source;
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
159 }
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
160
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
161 void PartDownloader::setSourceType(SourceType src)
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
162 {
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
163 m_source = src;
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
164 ui.source->setCurrentIndex(int(src));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
167 void PartDownloader::sourceChanged(int i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 if (i == CustomURL)
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
170 ui.fileNameLabel->setText(tr("URL:"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 else
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
172 ui.fileNameLabel->setText(tr("File name:"));
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
173
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
174 m_source = SourceType(i);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
177 void PartDownloader::buttonClicked(QAbstractButton* btn)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
179 if (btn == button(Close))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 reject();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 }
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
183 else if (btn == button(Abort))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 {
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
185 m_isAborted = true;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
187 for (PartDownloadRequest* req : m_requests)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 req->abort();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 }
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
190 else if (btn == button(Download))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 {
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
192 QString dest = ui.filename->text();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
193 setPrimaryFile(nullptr);
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
194 m_isAborted = false;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
196 if (sourceType() == CustomURL)
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
197 dest = Basename(url());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
199 modifyDestination(dest);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
201 if (QFile::exists(downloadPath() + DIRSLASH + dest))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
203 const QString overwritemsg = format(tr("%1 already exists in download directory. Overwrite?"), dest);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
204 if (not Confirm(tr("Overwrite?"), overwritemsg))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
208 downloadFile(dest, url(), true);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
212 void PartDownloader::downloadFile(QString dest, QString url, bool primary)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 {
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
214 int row = ui.progressTable->rowCount();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 // Don't download files repeadetly.
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
217 if (m_filesToDownload.indexOf(dest) != -1)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
220 print("Downloading %1 from %2\n", dest, url);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
221 modifyDestination(dest);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
222 PartDownloadRequest* req = new PartDownloadRequest(url, dest, primary, this);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 m_filesToDownload << dest;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224 m_requests << req;
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
225 ui.progressTable->insertRow(row);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
226 req->setTableRow(row);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 req->updateToTable();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
228 m_downloadButton->setEnabled(false);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
229 ui.progressTable->setEnabled(true);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
230 ui.filename->setEnabled(false);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
231 ui.source->setEnabled(false);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
232 button(Close)->setEnabled(false);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
233 button(Abort)->setEnabled(true);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
234 button(Download)->setEnabled(false);
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
235 }
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
236
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
237 void PartDownloader::downloadFromPartsTracker(QString file)
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
238 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
239 modifyDestination(file);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
240 downloadFile(file, g_unofficialLibraryURL + file, false);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 void PartDownloader::checkIfFinished()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 bool failed = isAborted();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 // If there is some download still working, we're not finished.
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
248 for (PartDownloadRequest* req : m_requests)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 {
662
2f1bd9112408 - use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
250 if (not req->isFinished())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252
992
5a10b4e7bf4a Refactor PartDownloadRequest
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
253 if (req->failed())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 failed = true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
257 for (PartDownloadRequest* req : m_requests)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 delete req;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 m_requests.clear();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
262 if (primaryFile())
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
263 emit primaryFileDownloaded();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 971
diff changeset
265 for (LDDocument* f : m_files)
867
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
266 f->reloadAllSubfiles();
557cb07dbe57 - now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
267
1224
5a31b6d4bf81 undo config change
Santeri Piippo
parents: 1222
diff changeset
268 if (config->autoCloseDownloadDialog() and not failed)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 // Close automatically if desired.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 accept();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 else
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 // Allow the prompt be closed now.
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
276 button(Abort)->setEnabled(false);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
277 button(Close)->setEnabled(true);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
281 QPushButton* PartDownloader::button(PartDownloader::Button i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
283 switch(i)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 case Download:
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
286 return m_downloadButton;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 case Abort:
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
289 return qobject_cast<QPushButton*>(ui.buttonBox->button(QDialogButtonBox::Abort));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 case Close:
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
292 return qobject_cast<QPushButton*>(ui.buttonBox->button(QDialogButtonBox::Close));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
295 return nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
298 void PartDownloader::addFile(LDDocument* f)
992
5a10b4e7bf4a Refactor PartDownloadRequest
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
299 {
5a10b4e7bf4a Refactor PartDownloadRequest
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
300 m_files << f;
5a10b4e7bf4a Refactor PartDownloadRequest
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
301 }
5a10b4e7bf4a Refactor PartDownloadRequest
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
302
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
303 bool PartDownloader::isAborted() const
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
304 {
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
305 return m_isAborted;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
306 }
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
307
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
308 LDDocument* PartDownloader::primaryFile() const
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
309 {
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
310 return m_primaryFile;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
311 }
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
312
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
313 void PartDownloader::setPrimaryFile(LDDocument* document)
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
314 {
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
315 m_primaryFile = document;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
316 }
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
317
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
318 QString PartDownloader::downloadPath()
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
319 {
1224
5a31b6d4bf81 undo config change
Santeri Piippo
parents: 1222
diff changeset
320 QString path = config->downloadFilePath();
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
321
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
322 if (DIRSLASH[0] != '/')
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1215
diff changeset
323 path.replace(DIRSLASH, "/");
993
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
324
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
325 return path;
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
326 }
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
327
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
328 QTableWidget* PartDownloader::progressTable() const
23436e487f0c Refactor PartDownloader
Teemu Piippo <crimsondusk64@gmail.com>
parents: 992
diff changeset
329 {
994
09e1a3e272ec Split PartDownloadRequest into its own file
Teemu Piippo <crimsondusk64@gmail.com>
parents: 993
diff changeset
330 return ui.progressTable;
992
5a10b4e7bf4a Refactor PartDownloadRequest
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
331 }

mercurial