1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Remove use of QNetworkRequest in LoadRequest

This commit is contained in:
David Rosca 2015-10-06 09:46:23 +02:00
parent 1a87d443c0
commit db058ff194
19 changed files with 29 additions and 102 deletions

View File

@ -53,8 +53,6 @@
#include "adblockrule.h"
#include "adblocksearchtree.h"
class QNetworkRequest;
class QNetworkReply;
class QUrl;
class FollowRedirectReply;

View File

@ -74,7 +74,6 @@
#include <QSqlQuery>
#include <QTextCodec>
#include <QFileDialog>
#include <QNetworkRequest>
#include <QDesktopServices>
#include <QWebEngineHistory>
#include <QWebEngineSettings>
@ -225,10 +224,7 @@ void BrowserWindow::postLaunch()
}
if (addTab) {
QNetworkRequest request(startUrl);
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
m_tabWidget->addView(request, Qz::NT_CleanSelectedTabAtTheEnd);
m_tabWidget->addView(startUrl, Qz::NT_CleanSelectedTabAtTheEnd);
if (startUrl.isEmpty() || startUrl.toString() == QLatin1String("qupzilla:speeddial")) {
locationBar()->setFocus();
@ -237,10 +233,7 @@ void BrowserWindow::postLaunch()
// Something went really wrong .. add one tab
if (m_tabWidget->tabBar()->normalTabsCount() <= 0) {
QNetworkRequest request(m_homepage);
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
m_tabWidget->addView(request, Qz::NT_SelectedTabAtTheEnd);
m_tabWidget->addView(m_homepage, Qz::NT_SelectedTabAtTheEnd);
}
mApp->plugins()->emitMainWindowCreated(this);

View File

@ -30,7 +30,6 @@
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QNetworkRequest>
#include <QWebEngineProfile>
#include <QWebEngineScriptCollection>

View File

@ -24,7 +24,6 @@
class QUrl;
class QWebEnginePage;
class QNetworkRequest;
class WebPage;
class BrowserWindow;

View File

@ -55,8 +55,6 @@ DownloadManager::DownloadManager(QWidget* parent)
ui->clearButton->setIcon(QIcon::fromTheme("edit-clear"));
QzTools::centerWidgetOnScreen(this);
m_networkManager = mApp->networkManager();
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearList()));
QShortcut* clearShortcut = new QShortcut(QKeySequence("CTRL+L"), this);

View File

@ -29,8 +29,6 @@ class DownloadManager;
}
class QUrl;
class QNetworkReply;
class QNetworkRequest;
class QNetworkAccessManager;
class QListWidgetItem;
class QWebEngineDownloadItem;
@ -101,7 +99,6 @@ private:
void keyPressEvent(QKeyEvent* e);
Ui::DownloadManager* ui;
QNetworkAccessManager* m_networkManager;
QBasicTimer m_timer;
QString m_lastDownloadPath;

View File

@ -145,8 +145,7 @@ LoadRequest SearchEnginesManager::searchResult(const Engine &engine, const QStri
QByteArray data = engine.postData;
data.replace("%s", QUrl::toPercentEncoding(string));
QNetworkRequest req(QUrl::fromEncoded(engine.url.toUtf8()));
return LoadRequest(req, LoadRequest::PostOperation, data);
return LoadRequest(QUrl::fromEncoded(engine.url.toUtf8()), LoadRequest::PostOperation, data);
}
LoadRequest SearchEnginesManager::searchResult(const QString &string)

View File

@ -22,7 +22,6 @@
#include <QIcon>
#include <QList>
#include <QVariant>
#include <QNetworkRequest>
#include "qzcommon.h"
#include "opensearchengine.h"

View File

@ -21,9 +21,9 @@
#include "mainapplication.h"
#include "tabwidget.h"
#include "desktopnotificationsfactory.h"
#include "networkmanager.h"
#include <QTimer>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
@ -129,14 +129,17 @@ void Updater::start()
void Updater::startDownloadingUpdateInfo(const QUrl &url)
{
QNetworkAccessManager* manager = new QNetworkAccessManager();
manager->get(QNetworkRequest(QUrl(url)));
QNetworkReply *reply = mApp->networkManager()->get(QNetworkRequest(QUrl(url)));
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downCompleted(QNetworkReply*)));
connect(reply, SIGNAL(finished()), this, SLOT(downCompleted()));
}
void Updater::downCompleted(QNetworkReply* reply)
void Updater::downCompleted()
{
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if (!reply)
return;
QString html = reply->readAll();
if (html.startsWith(QLatin1String("Version:"))) {
@ -149,14 +152,10 @@ void Updater::downCompleted(QNetworkReply* reply)
}
}
reply->manager()->deleteLater();
reply->deleteLater();
}
void Updater::downloadNewVersion()
{
m_window->tabWidget()->addView(QUrl::fromEncoded(QByteArray(Qz::WWWADDRESS) + QByteArray("/download")), tr("Update"), Qz::NT_NotSelectedTab);
}
Updater::~Updater()
{
}

View File

@ -32,7 +32,6 @@ class QUPZILLA_EXPORT Updater : public QObject
Q_OBJECT
public:
explicit Updater(BrowserWindow* window, QObject* parent = 0);
~Updater();
struct QUPZILLA_EXPORT Version {
bool isValid;
@ -53,7 +52,7 @@ public:
};
private slots:
void downCompleted(QNetworkReply* reply);
void downCompleted();
void start();
void downloadNewVersion();

View File

@ -625,11 +625,7 @@ int TabWidget::duplicateTab(int index)
const QString title = webTab->title();
const QByteArray history = webTab->historyData();
QNetworkRequest req(url);
req.setRawHeader("Referer", url.toEncoded());
req.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
int id = addView(req, title, Qz::NT_CleanNotSelectedTab);
int id = addView(url, title, Qz::NT_CleanNotSelectedTab);
weTab(id)->setHistoryData(history);
return id;

View File

@ -19,7 +19,6 @@
#define TABWIDGET_H
#include <QTabWidget>
#include <QNetworkRequest>
#include <QMenu>
#include "tabstackedwidget.h"

View File

@ -17,28 +17,20 @@
* ============================================================ */
#include "loadrequest.h"
#include <QWebEngineView>
LoadRequest::LoadRequest()
: m_operation(GetOperation)
{
}
LoadRequest::LoadRequest(const LoadRequest &other)
: m_request(other.m_request)
: m_url(other.m_url)
, m_operation(other.m_operation)
, m_data(other.m_data)
{
}
LoadRequest::LoadRequest(const QUrl &url)
: m_operation(GetOperation)
{
setUrl(url);
}
LoadRequest::LoadRequest(const QNetworkRequest &req, LoadRequest::Operation op, const QByteArray &data)
: m_request(req)
LoadRequest::LoadRequest(const QUrl &url, LoadRequest::Operation op, const QByteArray &data)
: m_url(url)
, m_operation(op)
, m_data(data)
{
@ -46,7 +38,7 @@ LoadRequest::LoadRequest(const QNetworkRequest &req, LoadRequest::Operation op,
LoadRequest &LoadRequest::operator=(const LoadRequest &other)
{
m_request = other.m_request;
m_url = other.m_url;
m_operation = other.m_operation;
m_data = other.m_data;
return *this;
@ -54,32 +46,22 @@ LoadRequest &LoadRequest::operator=(const LoadRequest &other)
bool LoadRequest::isEmpty() const
{
return m_request.url().isEmpty();
return m_url.isEmpty();
}
QUrl LoadRequest::url() const
{
return m_request.url();
return m_url;
}
void LoadRequest::setUrl(const QUrl &url)
{
m_request.setUrl(url);
m_url = url;
}
QString LoadRequest::urlString() const
{
return QUrl::fromPercentEncoding(m_request.url().toEncoded());
}
QNetworkRequest LoadRequest::networkRequest() const
{
return m_request;
}
void LoadRequest::setNetworkRequest(const QNetworkRequest &req)
{
m_request = req;
return QUrl::fromPercentEncoding(m_url.toEncoded());
}
LoadRequest::Operation LoadRequest::operation() const

View File

@ -18,12 +18,10 @@
#ifndef LOADREQUEST_H
#define LOADREQUEST_H
#include <QNetworkRequest>
#include <QUrl>
#include "qzcommon.h"
class QWebView;
class QUPZILLA_EXPORT LoadRequest
{
public:
@ -34,8 +32,7 @@ public:
LoadRequest();
LoadRequest(const LoadRequest &other);
LoadRequest(const QUrl &url);
LoadRequest(const QNetworkRequest &req, Operation op = GetOperation, const QByteArray &data = QByteArray());
LoadRequest(const QUrl &url, Operation op = GetOperation, const QByteArray &data = QByteArray());
LoadRequest &operator=(const LoadRequest &other);
@ -46,9 +43,6 @@ public:
QString urlString() const;
QNetworkRequest networkRequest() const;
void setNetworkRequest(const QNetworkRequest &req);
Operation operation() const;
void setOperation(Operation op);
@ -56,7 +50,7 @@ public:
void setData(const QByteArray &data);
private:
QNetworkRequest m_request;
QUrl m_url;
Operation m_operation;
QByteArray m_data;
};

View File

@ -46,7 +46,6 @@
#include <QDir>
#include <QTimer>
#include <QDesktopServices>
#include <QNetworkRequest>
#include <QWebEngineHistory>
#include <QClipboard>
#include <QHostInfo>
@ -451,10 +450,7 @@ void WebView::downloadMediaToDisk()
void WebView::openUrlInNewTab(const QUrl &url, Qz::NewTabPositionFlags position)
{
QNetworkRequest request(url);
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
loadInNewTab(request, position);
loadInNewTab(url, position);
}
void WebView::openActionUrl()
@ -495,12 +491,7 @@ void WebView::searchSelectedText()
}
}
LoadRequest req = mApp->searchEnginesManager()->searchResult(engine, selectedText());
QNetworkRequest r = req.networkRequest();
r.setRawHeader("Referer", req.url().toEncoded());
r.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
req.setNetworkRequest(r);
const LoadRequest req = mApp->searchEnginesManager()->searchResult(engine, selectedText());
loadInNewTab(req, Qz::NT_SelectedTab);
}
@ -513,12 +504,7 @@ void WebView::searchSelectedTextInBackgroundTab()
}
}
LoadRequest req = mApp->searchEnginesManager()->searchResult(engine, selectedText());
QNetworkRequest r = req.networkRequest();
r.setRawHeader("Referer", req.url().toEncoded());
r.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
req.setNetworkRequest(r);
const LoadRequest req = mApp->searchEnginesManager()->searchResult(engine, selectedText());
loadInNewTab(req, Qz::NT_NotSelectedTab);
}

View File

@ -102,13 +102,7 @@ void TabbedWebView::slotLoadProgress(int prog)
void TabbedWebView::userLoadAction(const LoadRequest &req)
{
QNetworkRequest request(req.networkRequest());
request.setRawHeader("X-QupZilla-UserLoadAction", QByteArray("1"));
LoadRequest r = req;
r.setNetworkRequest(request);
load(r);
load(req);
}
void TabbedWebView::slotLoadStarted()

View File

@ -22,8 +22,6 @@
#include <QList>
#include <QUrl>
class QNetworkRequest;
class GM_Manager;
class FollowRedirectReply;

View File

@ -25,7 +25,6 @@
class QUrl;
class QWebFrame;
class QNetworkRequest;
class BrowserWindow;
class GM_Script;

View File

@ -27,7 +27,6 @@
#include "tabbedwebview.h"
#include <QTranslator>
#include <QNetworkRequest>
GM_Plugin::GM_Plugin()
: QObject()