src/download.cpp

changeset 538
2f85d4d286e5
parent 526
b29b6fc45ba9
child 539
72ad83a67165
equal deleted inserted replaced
537:1add0ee96fb3 538:2f85d4d286e5
95 str dest; 95 str dest;
96 96
97 switch (src) 97 switch (src)
98 { case PartsTracker: 98 { case PartsTracker:
99 dest = ui->fname->text(); 99 dest = ui->fname->text();
100 modifyDest (dest); 100 modifyDestination (dest);
101 return str (k_UnofficialURL) + dest; 101 return str (k_UnofficialURL) + dest;
102 102
103 case CustomURL: 103 case CustomURL:
104 return ui->fname->text(); 104 return ui->fname->text();
105 } 105 }
108 return ""; 108 return "";
109 } 109 }
110 110
111 // ============================================================================= 111 // =============================================================================
112 // ----------------------------------------------------------------------------- 112 // -----------------------------------------------------------------------------
113 void PartDownloader::modifyDest (str& dest) const 113 void PartDownloader::modifyDestination (str& dest) const
114 { dest = dest.simplified(); 114 { dest = dest.simplified();
115 115
116 // If the user doesn't want us to guess, stop right here. 116 // If the user doesn't want us to guess, stop right here.
117 if (net_guesspaths == false) 117 if (net_guesspaths == false)
118 return; 118 return;
200 setAborted (false); 200 setAborted (false);
201 201
202 if (getSource() == CustomURL) 202 if (getSource() == CustomURL)
203 dest = basename (getURL()); 203 dest = basename (getURL());
204 204
205 modifyDest (dest); 205 modifyDestination (dest);
206 206
207 if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest)) 207 if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest))
208 { const str overwritemsg = fmt (tr ("%1 already exists in download directory. Overwrite?"), dest); 208 { const str overwritemsg = fmt (tr ("%1 already exists in download directory. Overwrite?"), dest);
209 if (!confirm (tr ("Overwrite?"), overwritemsg)) 209 if (!confirm (tr ("Overwrite?"), overwritemsg))
210 return; 210 return;
228 228
229 // Don't download files repeadetly. 229 // Don't download files repeadetly.
230 if (m_filesToDownload.indexOf (dest) != -1) 230 if (m_filesToDownload.indexOf (dest) != -1)
231 return; 231 return;
232 232
233 modifyDest (dest); 233 modifyDestination (dest);
234 log ("DOWNLOAD: %1 -> %2\n", url, PartDownloader::getDownloadPath() + DIRSLASH + dest); 234 log ("DOWNLOAD: %1 -> %2\n", url, PartDownloader::getDownloadPath() + DIRSLASH + dest);
235 PartDownloadRequest* req = new PartDownloadRequest (url, dest, primary, this); 235 PartDownloadRequest* req = new PartDownloadRequest (url, dest, primary, this);
236 236
237 m_filesToDownload << dest; 237 m_filesToDownload << dest;
238 m_requests << req; 238 m_requests << req;
262 262
263 // Update everything now 263 // Update everything now
264 if (primaryFile()) 264 if (primaryFile())
265 { LDFile::setCurrent (primaryFile()); 265 { LDFile::setCurrent (primaryFile());
266 reloadAllSubfiles(); 266 reloadAllSubfiles();
267 g_win->fullRefresh(); 267 g_win->doFullRefresh();
268 g_win->R()->resetAngles(); 268 g_win->R()->resetAngles();
269 } 269 }
270 270
271 if (net_autoclose && !failed) 271 if (net_autoclose && !failed)
272 { // Close automatically if desired. 272 { // Close automatically if desired.
428 428
429 if (!err || err->fileRef().isEmpty()) 429 if (!err || err->fileRef().isEmpty())
430 continue; 430 continue;
431 431
432 str dest = err->fileRef(); 432 str dest = err->fileRef();
433 m_prompt->modifyDest (dest); 433 m_prompt->modifyDestination (dest);
434 m_prompt->downloadFile (dest, str (PartDownloader::k_UnofficialURL) + dest, false); 434 m_prompt->downloadFile (dest, str (PartDownloader::k_UnofficialURL) + dest, false);
435 } 435 }
436 436
437 if (m_primary) 437 if (m_primary)
438 { addRecentFile (m_fpath); 438 { addRecentFile (m_fpath);

mercurial