src/partDownloader.cpp

changeset 971
c00f9665a9f8
parent 970
c8aae45afd85
child 978
4603d8fd063e
equal deleted inserted replaced
970:c8aae45afd85 971:c00f9665a9f8
51 51
52 // ============================================================================= 52 // =============================================================================
53 // 53 //
54 QString PartDownloader::getDownloadPath() 54 QString PartDownloader::getDownloadPath()
55 { 55 {
56 QString path = m_config->downloadFilePath; 56 QString path = m_config->downloadFilePath();
57 57
58 if (DIRSLASH[0] != '/') 58 if (DIRSLASH[0] != '/')
59 path.replace (DIRSLASH, "/"); 59 path.replace (DIRSLASH, "/");
60 60
61 return path; 61 return path;
107 path = QFileDialog::getExistingDirectory (this, "Path for downloaded files:"); 107 path = QFileDialog::getExistingDirectory (this, "Path for downloaded files:");
108 108
109 if (path.isEmpty()) 109 if (path.isEmpty())
110 return false; 110 return false;
111 111
112 m_config->downloadFilePath = path; 112 m_config->setDownloadFilePath (path);
113 } 113 }
114 114
115 return true; 115 return true;
116 } 116 }
117 117
143 void PartDownloader::modifyDestination (QString& dest) const 143 void PartDownloader::modifyDestination (QString& dest) const
144 { 144 {
145 dest = dest.simplified(); 145 dest = dest.simplified();
146 146
147 // If the user doesn't want us to guess, stop right here. 147 // If the user doesn't want us to guess, stop right here.
148 if (not m_config->guessDownloadPaths) 148 if (not m_config->guessDownloadPaths())
149 return; 149 return;
150 150
151 // Ensure .dat extension 151 // Ensure .dat extension
152 if (dest.right (4) != ".dat") 152 if (dest.right (4) != ".dat")
153 { 153 {
252 if (getSource() == CustomURL) 252 if (getSource() == CustomURL)
253 dest = Basename (getURL()); 253 dest = Basename (getURL());
254 254
255 modifyDestination (dest); 255 modifyDestination (dest);
256 256
257 if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest)) 257 if (QFile::exists (getDownloadPath() + DIRSLASH + dest))
258 { 258 {
259 const QString overwritemsg = format (tr ("%1 already exists in download directory. Overwrite?"), dest); 259 const QString overwritemsg = format (tr ("%1 already exists in download directory. Overwrite?"), dest);
260 if (not Confirm (tr ("Overwrite?"), overwritemsg)) 260 if (not Confirm (tr ("Overwrite?"), overwritemsg))
261 return; 261 return;
262 } 262 }
330 } 330 }
331 331
332 for (LDDocument* f : m_files) 332 for (LDDocument* f : m_files)
333 f->reloadAllSubfiles(); 333 f->reloadAllSubfiles();
334 334
335 if (m_config->autoCloseDownloadDialog and not failed) 335 if (m_config->autoCloseDownloadDialog() and not failed)
336 { 336 {
337 // Close automatically if desired. 337 // Close automatically if desired.
338 accept(); 338 accept();
339 } 339 }
340 else 340 else
370 QObject (parent), 370 QObject (parent),
371 m_state (State::Requesting), 371 m_state (State::Requesting),
372 m_prompt (parent), 372 m_prompt (parent),
373 m_url (url), 373 m_url (url),
374 m_destinaton (dest), 374 m_destinaton (dest),
375 m_filePath (PartDownloader::getDownloadPath() + DIRSLASH + dest), 375 m_filePath (parent->getDownloadPath() + DIRSLASH + dest),
376 m_networkManager (new QNetworkAccessManager), 376 m_networkManager (new QNetworkAccessManager),
377 m_isFirstUpdate (true), 377 m_isFirstUpdate (true),
378 m_isPrimary (primary), 378 m_isPrimary (primary),
379 m_filePointer (null) 379 m_filePointer (null)
380 { 380 {

mercurial