port C++ code to Qt5
This commit is contained in:
@@ -33,7 +33,12 @@
|
||||
#include <QMetaEnum>
|
||||
#include <QSettings>
|
||||
#include <QFileIconProvider>
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <QWebSettings>
|
||||
#endif
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QUrlQuery>
|
||||
#endif
|
||||
|
||||
#include "DownloadItem.h"
|
||||
#include "DownloadManager.h"
|
||||
@@ -112,6 +117,24 @@ QUrl DownloadManager::redirectUrl(const QUrl& url) const
|
||||
{
|
||||
QUrl redirectUrl = url;
|
||||
if (url.host() == QLatin1String("www.dropbox.com")) {
|
||||
#if QT_VERSION >= 0x050000
|
||||
QUrlQuery urlQuery(url);
|
||||
QList< QPair<QString, QString> > query = urlQuery.queryItems();
|
||||
for (QList< QPair<QString, QString> >::iterator it = query.begin(); it != query.end(); ++it) {
|
||||
if (it->first == QLatin1String("dl")) {
|
||||
if (it->second == QLatin1String("0\r\n")) {
|
||||
urlQuery.removeQueryItem(QLatin1String("dl"));
|
||||
urlQuery.addQueryItem(QLatin1String("dl"), QLatin1String("1\r\n"));
|
||||
}
|
||||
else if (it->second == QLatin1String("0")) {
|
||||
urlQuery.removeQueryItem(QLatin1String("dl"));
|
||||
urlQuery.addQueryItem(QLatin1String("dl"), QLatin1String("1"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
redirectUrl.setQuery(urlQuery);
|
||||
#else
|
||||
QList< QPair<QString, QString> > query = url.queryItems();
|
||||
for (QList< QPair<QString, QString> >::iterator it = query.begin(); it != query.end(); ++it) {
|
||||
if (it->first == QLatin1String("dl")) {
|
||||
@@ -126,6 +149,7 @@ QUrl DownloadManager::redirectUrl(const QUrl& url) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// When the url comes from drag and drop it may end with CR+LF. This may cause problems
|
||||
@@ -193,10 +217,12 @@ void DownloadManager::updateRow()
|
||||
ui->downloadsView->setRowHeight(row, item->minimumSizeHint().height());
|
||||
|
||||
bool remove = false;
|
||||
#if QT_VERSION < 0x050000
|
||||
QWebSettings *globalSettings = QWebSettings::globalSettings();
|
||||
if (!item->downloading()
|
||||
&& globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
|
||||
remove = true;
|
||||
#endif
|
||||
|
||||
if (item->downloadedSuccessfully()
|
||||
&& removePolicy() == DownloadManager::SuccessFullDownload) {
|
||||
|
||||
Reference in New Issue
Block a user