src/partDownloader.cpp

changeset 967
eb586d3e1a6a
parent 966
a834e43a57da
child 968
4b93b7963456
equal deleted inserted replaced
966:a834e43a57da 967:eb586d3e1a6a
165 if (isOneOf (dest.left (2), "s\\", "s/")) 165 if (isOneOf (dest.left (2), "s\\", "s/"))
166 { 166 {
167 dest.remove (0, 2); 167 dest.remove (0, 2);
168 dest.prepend ("parts/s/"); 168 dest.prepend ("parts/s/");
169 } 169 }
170 elif (isOneOf (dest.left (3), "48\\", "48/")) 170 else if (isOneOf (dest.left (3), "48\\", "48/"))
171 { 171 {
172 dest.remove (0, 3); 172 dest.remove (0, 3);
173 dest.prepend ("p/48/"); 173 dest.prepend ("p/48/");
174 } 174 }
175 175
192 partRegex += "\\.dat$"; 192 partRegex += "\\.dat$";
193 subpartRegex += "\\.dat$"; 193 subpartRegex += "\\.dat$";
194 194
195 if (QRegExp (subpartRegex).exactMatch (dest)) 195 if (QRegExp (subpartRegex).exactMatch (dest))
196 dest.prepend ("parts/s/"); 196 dest.prepend ("parts/s/");
197 elif (QRegExp (partRegex).exactMatch (dest)) 197 else if (QRegExp (partRegex).exactMatch (dest))
198 dest.prepend ("parts/"); 198 dest.prepend ("parts/");
199 elif (not dest.startsWith ("parts/") and not dest.startsWith ("p/")) 199 else if (not dest.startsWith ("parts/") and not dest.startsWith ("p/"))
200 dest.prepend ("p/"); 200 dest.prepend ("p/");
201 } 201 }
202 202
203 // ============================================================================= 203 // =============================================================================
204 // 204 //
233 { 233 {
234 if (btn == getButton (Close)) 234 if (btn == getButton (Close))
235 { 235 {
236 reject(); 236 reject();
237 } 237 }
238 elif (btn == getButton (Abort)) 238 else if (btn == getButton (Abort))
239 { 239 {
240 setAborted (true); 240 setAborted (true);
241 241
242 for (PartDownloadRequest* req : requests()) 242 for (PartDownloadRequest* req : requests())
243 req->abort(); 243 req->abort();
244 } 244 }
245 elif (btn == getButton (Download)) 245 else if (btn == getButton (Download))
246 { 246 {
247 QString dest = form()->fname->text(); 247 QString dest = form()->fname->text();
248 setPrimaryFile (nullptr); 248 setPrimaryFile (nullptr);
249 setAborted (false); 249 setAborted (false);
250 250
465 Critical (networkReply()->errorString()); 465 Critical (networkReply()->errorString());
466 466
467 print ("Unable to download %1: %2\n", m_destinaton, networkReply()->errorString()); 467 print ("Unable to download %1: %2\n", m_destinaton, networkReply()->errorString());
468 setState (State::Failed); 468 setState (State::Failed);
469 } 469 }
470 elif (state() != State::Failed) 470 else if (state() != State::Failed)
471 { 471 {
472 setState (State::Finished); 472 setState (State::Finished);
473 } 473 }
474 474
475 setNumBytesRead (numBytesTotal()); 475 setNumBytesRead (numBytesTotal());

mercurial