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; |
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 } |
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 { |