2011-09-30 21:44:18 +02:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2013-02-04 22:48:34 +01:00
|
|
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
2011-09-30 21:44:18 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-09-30 19:22:50 +02:00
|
|
|
#ifndef DOWNLOADFILEHELPER_H
|
|
|
|
#define DOWNLOADFILEHELPER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPixmap>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QUrl>
|
2011-09-30 19:22:50 +02:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include "qz_namespace.h"
|
2011-12-06 19:18:06 +01:00
|
|
|
#include "downloadmanager.h"
|
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
class QFileIconProvider;
|
|
|
|
class QListWidget;
|
|
|
|
|
2011-09-30 19:22:50 +02:00
|
|
|
class DownloadItem;
|
2011-10-07 15:37:49 +02:00
|
|
|
class DownloadManager;
|
2011-11-08 15:20:53 +01:00
|
|
|
class WebPage;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QT_QUPZILLA_EXPORT DownloadFileHelper : public QObject
|
2011-09-30 19:22:50 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-08-14 18:53:55 +02:00
|
|
|
explicit DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog);
|
2011-09-30 19:22:50 +02:00
|
|
|
~DownloadFileHelper();
|
|
|
|
|
|
|
|
void setListWidget(QListWidget* tw) { m_listWidget = tw; }
|
2011-10-07 15:37:49 +02:00
|
|
|
void setDownloadManager(DownloadManager* m) { m_manager = m; }
|
2011-12-06 19:18:06 +01:00
|
|
|
void setLastDownloadOption(const DownloadManager::DownloadOption &option) { m_lastDownloadOption = option; }
|
|
|
|
|
2012-08-14 18:53:55 +02:00
|
|
|
void handleUnsupportedContent(QNetworkReply* reply, const DownloadManager::DownloadInfo &info);
|
2011-09-30 19:22:50 +02:00
|
|
|
|
2013-02-04 22:48:34 +01:00
|
|
|
static QString parseContentDisposition(const QByteArray &header);
|
|
|
|
|
2011-09-30 19:22:50 +02:00
|
|
|
signals:
|
|
|
|
void itemCreated(QListWidgetItem* item, DownloadItem* downItem);
|
|
|
|
|
|
|
|
private slots:
|
2012-02-04 18:45:59 +01:00
|
|
|
void optionsDialogAccepted(int finish = -1);
|
2011-09-30 19:22:50 +02:00
|
|
|
void fileNameChoosed(const QString &name, bool fileNameAutoGenerated = false);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString getFileName(QNetworkReply* reply);
|
|
|
|
|
2011-12-06 19:18:06 +01:00
|
|
|
DownloadManager::DownloadOption m_lastDownloadOption;
|
2011-09-30 19:22:50 +02:00
|
|
|
QString m_lastDownloadPath;
|
|
|
|
QString m_downloadPath;
|
|
|
|
bool m_useNativeDialog;
|
|
|
|
|
|
|
|
QTime* m_timer;
|
|
|
|
QString m_path;
|
|
|
|
QString m_fileName;
|
|
|
|
QString m_userFileName;
|
|
|
|
QString m_h_fileName;
|
|
|
|
QNetworkReply* m_reply;
|
|
|
|
QPixmap m_fileIcon;
|
|
|
|
QUrl m_downloadPage;
|
2012-03-08 12:48:23 +01:00
|
|
|
qint64 m_fileSize;
|
2011-09-30 19:22:50 +02:00
|
|
|
bool m_openFileChoosed;
|
|
|
|
|
|
|
|
QListWidget* m_listWidget;
|
|
|
|
QFileIconProvider* m_iconProvider;
|
2011-10-07 15:37:49 +02:00
|
|
|
DownloadManager* m_manager;
|
2011-09-30 19:22:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOWNLOADFILEHELPER_H
|