2011-09-30 21:44:18 +02:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 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 <QTime>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QTemporaryFile>
|
|
|
|
#include <QFileIconProvider>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
2011-12-06 19:18:06 +01:00
|
|
|
#include "downloadmanager.h"
|
|
|
|
|
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;
|
2011-09-30 19:22:50 +02:00
|
|
|
class DownloadFileHelper : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-11-08 15:20:53 +01:00
|
|
|
explicit DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog, WebPage* page);
|
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; }
|
|
|
|
|
2011-09-30 19:22:50 +02:00
|
|
|
void handleUnsupportedContent(QNetworkReply* reply, bool askWhatToDo);
|
|
|
|
|
|
|
|
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;
|
|
|
|
bool m_openFileChoosed;
|
|
|
|
|
|
|
|
QListWidget* m_listWidget;
|
|
|
|
QFileIconProvider* m_iconProvider;
|
2011-10-07 15:37:49 +02:00
|
|
|
DownloadManager* m_manager;
|
2011-11-08 15:20:53 +01:00
|
|
|
WebPage* m_webPage;
|
2011-09-30 19:22:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOWNLOADFILEHELPER_H
|