1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Remove some Qt 4 specific code

This commit is contained in:
David Rosca 2015-02-26 12:15:58 +01:00
parent ab506ea83a
commit 8d7cfb0e2a
32 changed files with 14 additions and 325 deletions

View File

@ -6,8 +6,8 @@
# #
#------------------------------------------------- #-------------------------------------------------
lessThan(QT_VERSION, 4.7) { lessThan(QT_VERSION, 5.4) {
error("QupZilla requires at least Qt 4.7!") error("QupZilla requires at least Qt 5.4!")
} }
# Create plugins directory first on Mac / Linux # Create plugins directory first on Mac / Linux

View File

@ -60,48 +60,6 @@ haiku-* {
DEFINES *= NO_X11 DEFINES *= NO_X11
} }
# Check for pkg-config availability
!mac:unix:system(pkg-config --version > /dev/null) {
isEqual(QT_MAJOR_VERSION, 5) {
MODNAME = Qt5WebKitWidgets
}
else {
MODNAME = QtWebKit
}
QTWEBKIT_VERSION = $$system(PKG_CONFIG_PATH="$$[QT_INSTALL_LIBS]/pkgconfig" pkg-config --modversion $$MODNAME)
QTWEBKIT_VERSION_MAJOR = $$section(QTWEBKIT_VERSION, ".", 0, 0)
QTWEBKIT_VERSION_MINOR = $$section(QTWEBKIT_VERSION, ".", 1, 1)
isEqual(QT_MAJOR_VERSION, 5) {
greaterThan(QTWEBKIT_VERSION_MAJOR, 4) {
# There is one Qt5WebKitWidgets version now, which has same features as QtWebKit 2.3
DEFINES *= USE_QTWEBKIT_2_2 USE_QTWEBKIT_2_3
}
}
else { # Qt 4
equals(QTWEBKIT_VERSION_MAJOR, 4):greaterThan(QTWEBKIT_VERSION_MINOR, 8) {
# 4.9.x = QtWebKit 2.2
DEFINES *= USE_QTWEBKIT_2_2
}
equals(QTWEBKIT_VERSION_MAJOR, 4):greaterThan(QTWEBKIT_VERSION_MINOR, 9) {
# 4.10.x = QtWebKit 2.3
DEFINES *= USE_QTWEBKIT_2_3
}
}
}
else {
isEqual(QT_VERSION, 4.8.0)|greaterThan(QT_VERSION, 4.8.0) {
DEFINES *= USE_QTWEBKIT_2_2
}
isEqual(QT_MAJOR_VERSION, 5) {
DEFINES *= USE_QTWEBKIT_2_2 USE_QTWEBKIT_2_3
}
}
!mac:unix { !mac:unix {
binary_folder = /usr/bin binary_folder = /usr/bin
library_folder = /usr/lib library_folder = /usr/lib
@ -140,8 +98,7 @@ isEmpty(QMAKE_LRELEASE) {
# Try to use lrelease from PATH # Try to use lrelease from PATH
unix:!exists($$QMAKE_LRELEASE) { unix:!exists($$QMAKE_LRELEASE) {
isEqual(QT_MAJOR_VERSION, 4): QMAKE_LRELEASE = lrelease-qt4 QMAKE_LRELEASE = lrelease
else: QMAKE_LRELEASE = lrelease
} }
} }

View File

@ -27,10 +27,6 @@
#include <QStyleOption> #include <QStyleOption>
#include <QApplication> #include <QApplication>
#if QT_VERSION < 0x050000
#include <QInputContext>
#endif
SideWidget::SideWidget(QWidget* parent) SideWidget::SideWidget(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
@ -208,16 +204,6 @@ QMenu* LineEdit::createContextMenu()
popup->addSeparator(); popup->addSeparator();
popup->addAction(m_editActions[SelectAll]); popup->addAction(m_editActions[SelectAll]);
#if !defined(QT_NO_IM) && QT_VERSION < 0x050000
QInputContext* qic = inputContext();
if (qic) {
QList<QAction*> imActions = qic->actions();
for (int i = 0; i < imActions.size(); ++i) {
popup->addAction(imActions.at(i));
}
}
#endif
// Hack to get QUnicodeControlCharacterMenu // Hack to get QUnicodeControlCharacterMenu
QMenu* tmp = createStandardContextMenu(); QMenu* tmp = createStandardContextMenu();
tmp->setParent(popup); tmp->setParent(popup);

View File

@ -84,11 +84,7 @@ public:
void removeWidget(QWidget* widget) { void removeWidget(QWidget* widget) {
widgets.removeAll(widget); widgets.removeAll(widget);
} }
#if (QT_VERSION < 0x050000)
bool winEvent(MSG* message, long* result);
#else
bool nativeEvent(const QByteArray &eventType, void* _message, long* result); bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif
private: private:
QWidgetList widgets; QWidgetList widgets;
@ -272,15 +268,10 @@ WindowNotifier* QtWin::windowNotifier()
/* Notify all enabled windows that the DWM state changed */ /* Notify all enabled windows that the DWM state changed */
#if (QT_VERSION < 0x050000)
bool WindowNotifier::winEvent(MSG* message, long* result)
{
#else
bool WindowNotifier::nativeEvent(const QByteArray &eventType, void* _message, long* result) bool WindowNotifier::nativeEvent(const QByteArray &eventType, void* _message, long* result)
{ {
Q_UNUSED(eventType) Q_UNUSED(eventType)
MSG* message = static_cast<MSG*>(_message); MSG* message = static_cast<MSG*>(_message);
#endif
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) { if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
bool compositionEnabled = QtWin::isCompositionEnabled(); bool compositionEnabled = QtWin::isCompositionEnabled();
foreach (QWidget* widget, widgets) { foreach (QWidget* widget, widgets) {
@ -296,11 +287,7 @@ bool WindowNotifier::nativeEvent(const QByteArray &eventType, void* _message, lo
} }
} }
} }
#if (QT_VERSION < 0x050000)
return QWidget::winEvent(message, result);
#else
return QWidget::nativeEvent(eventType, _message, result); return QWidget::nativeEvent(eventType, _message, result);
#endif
} }
#ifdef W7API #ifdef W7API

View File

@ -59,7 +59,6 @@
// count .co.uk (and others) as second-level domain // count .co.uk (and others) as second-level domain
static QString toSecondLevelDomain(const QUrl &url) static QString toSecondLevelDomain(const QUrl &url)
{ {
#if QT_VERSION >= 0x040800
const QString topLevelDomain = url.topLevelDomain(); const QString topLevelDomain = url.topLevelDomain();
const QString urlHost = url.host(); const QString urlHost = url.host();
@ -78,19 +77,6 @@ static QString toSecondLevelDomain(const QUrl &url)
} }
return domain + topLevelDomain; return domain + topLevelDomain;
#else
QString domain = url.host();
if (domain.count(QL1C('.')) == 0) {
return QString();
}
while (domain.count(QL1C('.')) != 1) {
domain = domain.mid(domain.indexOf(QL1C('.')) + 1);
}
return domain;
#endif
} }
AdBlockRule::AdBlockRule(const QString &filter, AdBlockSubscription* subscription) AdBlockRule::AdBlockRule(const QString &filter, AdBlockSubscription* subscription)

View File

@ -89,10 +89,6 @@
#include <QToolTip> #include <QToolTip>
#include <QScrollArea> #include <QScrollArea>
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#endif
#ifdef QZ_WS_X11 #ifdef QZ_WS_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
@ -1671,15 +1667,10 @@ void BrowserWindow::applyBlurToMainWindow(bool force)
QtWin::extendFrameIntoClientArea(this, leftMargin, topMargin, rightMargin, bottomMargin); QtWin::extendFrameIntoClientArea(this, leftMargin, topMargin, rightMargin, bottomMargin);
} }
#if (QT_VERSION < 0x050000)
bool BrowserWindow::winEvent(MSG* message, long* result)
{
#else
bool BrowserWindow::nativeEvent(const QByteArray &eventType, void* _message, long* result) bool BrowserWindow::nativeEvent(const QByteArray &eventType, void* _message, long* result)
{ {
Q_UNUSED(eventType) Q_UNUSED(eventType)
MSG* message = static_cast<MSG*>(_message); MSG* message = static_cast<MSG*>(_message);
#endif
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) { if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
Settings settings; Settings settings;
settings.beginGroup("Browser-View-Settings"); settings.beginGroup("Browser-View-Settings");
@ -1716,11 +1707,7 @@ bool BrowserWindow::nativeEvent(const QByteArray &eventType, void* _message, lon
m_useTransparentBackground = false; m_useTransparentBackground = false;
} }
} }
#if (QT_VERSION < 0x050000)
return QMainWindow::winEvent(message, result);
#else
return QMainWindow::nativeEvent(eventType, _message, result); return QMainWindow::nativeEvent(eventType, _message, result);
#endif
} }
void BrowserWindow::paintEvent(QPaintEvent* event) void BrowserWindow::paintEvent(QPaintEvent* event)

View File

@ -231,11 +231,7 @@ private slots:
void applyBlurToMainWindow(bool force = false); void applyBlurToMainWindow(bool force = false);
private: private:
#if (QT_VERSION < 0x050000)
bool winEvent(MSG* message, long* result);
#else
bool nativeEvent(const QByteArray &eventType, void* _message, long* result); bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif
void paintEvent(QPaintEvent* event); void paintEvent(QPaintEvent* event);
bool eventFilter(QObject* object, QEvent* event); bool eventFilter(QObject* object, QEvent* event);

View File

@ -21,11 +21,7 @@
#include <QApplication> #include <QApplication>
#include <QDir> #include <QDir>
#if QT_VERSION < 0x050000
#include <QDesktopServices>
#else
#include <QStandardPaths> #include <QStandardPaths>
#endif
Q_GLOBAL_STATIC(DataPaths, qz_data_paths) Q_GLOBAL_STATIC(DataPaths, qz_data_paths)
@ -104,11 +100,7 @@ void DataPaths::init()
// Config // Config
#if defined(Q_OS_WIN) || defined(Q_OS_OS2) #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
// Use %LOCALAPPDATA%/qupzilla as Config path on Windows // Use %LOCALAPPDATA%/qupzilla as Config path on Windows
#if QT_VERSION < 0x050000
QString dataLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#else
QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#endif
// Backwards compatibility // Backwards compatibility
if (dataLocation.isEmpty()) { if (dataLocation.isEmpty()) {
dataLocation = QDir::homePath() + QLatin1String("/.config/qupzilla"); dataLocation = QDir::homePath() + QLatin1String("/.config/qupzilla");

View File

@ -62,11 +62,7 @@
#include <QTimer> #include <QTimer>
#include <QDir> #include <QDir>
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#else
#include <QStandardPaths> #include <QStandardPaths>
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2) #if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
#include "registerqappassociation.h" #include "registerqappassociation.h"
@ -101,9 +97,7 @@ MainApplication::MainApplication(int &argc, char** argv)
, m_registerQAppAssociation(0) , m_registerQAppAssociation(0)
#endif #endif
{ {
#if QT_VERSION >= 0x050000
setAttribute(Qt::AA_UseHighDpiPixmaps, true); setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif
setApplicationName(QLatin1String("QupZilla")); setApplicationName(QLatin1String("QupZilla"));
setApplicationVersion(Qz::VERSION); setApplicationVersion(Qz::VERSION);

View File

@ -37,11 +37,7 @@
#endif #endif
#ifndef QSL #ifndef QSL
#if QT_VERSION >= 0x050000
#define QSL(x) QStringLiteral(x) #define QSL(x) QStringLiteral(x)
#else
#define QSL(x) QLatin1String(x)
#endif
#endif #endif
#ifndef QL1S #ifndef QL1S

View File

@ -32,9 +32,7 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QNetworkRequest> #include <QNetworkRequest>
#if QT_VERSION >= 0x050000
#include <QUrlQuery> #include <QUrlQuery>
#endif
AutoFill::AutoFill(QObject* parent) AutoFill::AutoFill(QObject* parent)
: QObject(parent) : QObject(parent)

View File

@ -19,9 +19,7 @@
#include "qzregexp.h" #include "qzregexp.h"
#include <QWebEnginePage> #include <QWebEnginePage>
#if QT_VERSION >= 0x050000
#include <QUrlQuery> #include <QUrlQuery>
#endif
PageFormCompleter::PageFormCompleter() PageFormCompleter::PageFormCompleter()
: m_page(0) : m_page(0)
@ -247,13 +245,9 @@ PageFormCompleter::QueryItems PageFormCompleter::createQueryItems(QByteArray dat
// QUrlQuery/QUrl never encodes/decodes + and spaces // QUrlQuery/QUrl never encodes/decodes + and spaces
data.replace('+', ' '); data.replace('+', ' ');
#if QT_VERSION >= 0x050000
QUrlQuery query; QUrlQuery query;
query.setQuery(data); query.setQuery(data);
QueryItems arguments = query.queryItems(QUrl::FullyDecoded); QueryItems arguments = query.queryItems(QUrl::FullyDecoded);
#else
QueryItems arguments = QUrl::fromEncoded("http://foo.com/?" + data).queryItems();
#endif
return arguments; return arguments;
} }

View File

@ -34,11 +34,7 @@
#include <QWebEngineHistory> #include <QWebEngineHistory>
#include <QFileDialog> #include <QFileDialog>
#if QT_VERSION >= 0x050000
#include <QStandardPaths> #include <QStandardPaths>
#else
#include <QDesktopServices>
#endif
DownloadFileHelper::DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog) DownloadFileHelper::DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog)
: QObject() : QObject()
@ -229,22 +225,12 @@ void DownloadFileHelper::optionsDialogAccepted(int finish)
dialog->selectFile(m_h_fileName); dialog->selectFile(m_h_fileName);
QList<QUrl> urls; QList<QUrl> urls;
urls << urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation))
#if QT_VERSION >= 0x050000
QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)) << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation)) << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)); << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
#else
QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
#endif
dialog->setSidebarUrls(urls); dialog->setSidebarUrls(urls);
dialog->open(); dialog->open();

View File

@ -201,10 +201,6 @@ void DownloadItem::finished()
} }
m_item->setSizeHint(sizeHint()); m_item->setSizeHint(sizeHint());
#if QT_VERSION == 0x040700 // Workaround
ui->button->show();
ui->button->hide();
#endif
m_downloading = false; m_downloading = false;
if (m_openAfterFinish) { if (m_openAfterFinish) {
@ -353,10 +349,6 @@ void DownloadItem::stop(bool askForDeleteFile)
ui->button->hide(); ui->button->hide();
m_item->setSizeHint(sizeHint()); m_item->setSizeHint(sizeHint());
#if QT_VERSION == 0x040700 // Workaround
ui->button->show();
ui->button->hide();
#endif
m_downloading = false; m_downloading = false;
emit downloadFinished(false); emit downloadFinished(false);

View File

@ -123,15 +123,10 @@ void DownloadManager::startExternalManager(const QUrl &url)
} }
#ifdef W7TASKBAR #ifdef W7TASKBAR
#if (QT_VERSION < 0x050000)
bool DownloadManager::winEvent(MSG* message, long* result)
{
#else
bool DownloadManager::nativeEvent(const QByteArray &eventType, void* _message, long* result) bool DownloadManager::nativeEvent(const QByteArray &eventType, void* _message, long* result)
{ {
Q_UNUSED(eventType) Q_UNUSED(eventType)
MSG* message = static_cast<MSG*>(_message); MSG* message = static_cast<MSG*>(_message);
#endif
return win7.winEvent(message, result); return win7.winEvent(message, result);
} }
#endif #endif

View File

@ -83,12 +83,8 @@ public slots:
#ifdef W7TASKBAR #ifdef W7TASKBAR
protected: protected:
#if (QT_VERSION < 0x050000)
virtual bool winEvent(MSG* message, long* result);
#else
virtual bool nativeEvent(const QByteArray &eventType, void* _message, long* result); virtual bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif #endif
#endif
private slots: private slots:
void clearList(); void clearList();

View File

@ -1,8 +1,4 @@
isEqual(QT_MAJOR_VERSION, 5) {
QT += webenginewidgets network widgets printsupport sql script gui-private QT += webenginewidgets network widgets printsupport sql script gui-private
} else {
QT += core gui webkit sql network script concurrent
}
TARGET = QupZilla TARGET = QupZilla
TEMPLATE = lib TEMPLATE = lib
@ -231,6 +227,7 @@ SOURCES += \
tools/pagethumbnailer.cpp \ tools/pagethumbnailer.cpp \
tools/plaineditwithlines.cpp \ tools/plaineditwithlines.cpp \
tools/progressbar.cpp \ tools/progressbar.cpp \
tools/qzregexp.cpp \
tools/qztools.cpp \ tools/qztools.cpp \
tools/sqldatabase.cpp \ tools/sqldatabase.cpp \
tools/toolbutton.cpp \ tools/toolbutton.cpp \
@ -434,6 +431,7 @@ HEADERS += \
tools/pagethumbnailer.h \ tools/pagethumbnailer.h \
tools/plaineditwithlines.h \ tools/plaineditwithlines.h \
tools/progressbar.h \ tools/progressbar.h \
tools/qzregexp.h \
tools/qztools.h \ tools/qztools.h \
tools/sqldatabase.h \ tools/sqldatabase.h \
tools/toolbutton.h \ tools/toolbutton.h \
@ -509,16 +507,12 @@ RESOURCES += \
data/icons.qrc \ data/icons.qrc \
data/oxygen-fallback.qrc data/oxygen-fallback.qrc
isEqual(QT_MAJOR_VERSION, 5) {
qtHaveModule(ftp) { qtHaveModule(ftp) {
QT *= ftp QT *= ftp
} else { } else {
include(3rdparty/qftp/qftp.pri) include(3rdparty/qftp/qftp.pri)
} }
SOURCES += tools/qzregexp.cpp
}
!mac:unix { !mac:unix {
target.path = $$library_folder target.path = $$library_folder

View File

@ -28,11 +28,7 @@
#include <QDateTime> #include <QDateTime>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#endif
LocationCompleterRefreshJob::LocationCompleterRefreshJob(const QString &searchString) LocationCompleterRefreshJob::LocationCompleterRefreshJob(const QString &searchString)
: QObject() : QObject()

View File

@ -22,9 +22,7 @@
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QMessageBox> #include <QMessageBox>
#if QT_VERSION >= 0x050000
#include <QUrlQuery> #include <QUrlQuery>
#endif
AdBlockSchemeHandler::AdBlockSchemeHandler() AdBlockSchemeHandler::AdBlockSchemeHandler()
: SchemeHandler() : SchemeHandler()
@ -40,12 +38,7 @@ QNetworkReply* AdBlockSchemeHandler::createRequest(QNetworkAccessManager::Operat
} }
const QUrl url = request.url(); const QUrl url = request.url();
const QList<QPair<QString, QString> > queryItems = const QList<QPair<QString, QString> > queryItems = QUrlQuery(url).queryItems();
#if QT_VERSION >= 0x050000
QUrlQuery(url).queryItems();
#else
url.queryItems();
#endif
QString subscriptionTitle; QString subscriptionTitle;
QString subscriptionUrl; QString subscriptionUrl;

View File

@ -35,11 +35,7 @@
#include <QSettings> #include <QSettings>
#include <QWebSecurityOrigin> #include <QWebSecurityOrigin>
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#else
#include <QWebEnginePage> #include <QWebEnginePage>
#endif
static QString authorString(const char* name, const QString &mail) static QString authorString(const char* name, const QString &mail)
{ {

View File

@ -47,9 +47,7 @@
#include <qregexp.h> #include <qregexp.h>
#include <qstringlist.h> #include <qstringlist.h>
#if QT_VERSION >= 0x050000
#include <QUrlQuery> #include <QUrlQuery>
#endif
/*! /*!
@ -226,22 +224,14 @@ QUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const
QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8()); QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8());
#if QT_VERSION >= 0x050000
QUrlQuery query(retVal); QUrlQuery query(retVal);
#endif
if (m_searchMethod != QLatin1String("post")) { if (m_searchMethod != QLatin1String("post")) {
Parameters::const_iterator end = m_searchParameters.constEnd(); Parameters::const_iterator end = m_searchParameters.constEnd();
Parameters::const_iterator i = m_searchParameters.constBegin(); Parameters::const_iterator i = m_searchParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
#if QT_VERSION >= 0x050000
query.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#else
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#endif
} }
#if QT_VERSION >= 0x050000
retVal.setQuery(query); retVal.setQuery(query);
#endif
} }
return retVal; return retVal;
@ -255,21 +245,13 @@ QByteArray OpenSearchEngine::getPostData(const QString &searchTerm) const
QUrl retVal = QUrl("http://foo.bar"); QUrl retVal = QUrl("http://foo.bar");
#if QT_VERSION >= 0x050000
QUrlQuery query(retVal); QUrlQuery query(retVal);
#endif
Parameters::const_iterator end = m_searchParameters.constEnd(); Parameters::const_iterator end = m_searchParameters.constEnd();
Parameters::const_iterator i = m_searchParameters.constBegin(); Parameters::const_iterator i = m_searchParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
#if QT_VERSION >= 0x050000
query.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#else
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#endif
} }
#if QT_VERSION >= 0x050000
retVal.setQuery(query); retVal.setQuery(query);
#endif
QByteArray data = retVal.toEncoded(QUrl::RemoveScheme); QByteArray data = retVal.toEncoded(QUrl::RemoveScheme);
return data.contains('?') ? data.mid(data.lastIndexOf('?') + 1) : QByteArray(); return data.contains('?') ? data.mid(data.lastIndexOf('?') + 1) : QByteArray();
@ -324,22 +306,14 @@ QUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8()); QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8());
#if QT_VERSION >= 0x050000
QUrlQuery query(retVal); QUrlQuery query(retVal);
#endif
if (m_suggestionsMethod != QLatin1String("post")) { if (m_suggestionsMethod != QLatin1String("post")) {
Parameters::const_iterator end = m_suggestionsParameters.constEnd(); Parameters::const_iterator end = m_suggestionsParameters.constEnd();
Parameters::const_iterator i = m_suggestionsParameters.constBegin(); Parameters::const_iterator i = m_suggestionsParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
#if QT_VERSION >= 0x050000
query.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#else
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#endif
} }
#if QT_VERSION >= 0x050000
retVal.setQuery(query); retVal.setQuery(query);
#endif
} }
return retVal; return retVal;

View File

@ -32,9 +32,7 @@
#include <QSqlQuery> #include <QSqlQuery>
#include <QBuffer> #include <QBuffer>
#if QT_VERSION >= 0x050000
#include <QUrlQuery> #include <QUrlQuery>
#endif
#define ENSURE_LOADED if (!m_settingsLoaded) loadSettings(); #define ENSURE_LOADED if (!m_settingsLoaded) loadSettings();
@ -290,7 +288,6 @@ void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView
parameterUrl = QUrl("http://foo.bar"); parameterUrl = QUrl("http://foo.bar");
} }
#if QT_VERSION >= 0x050000
QUrlQuery query(parameterUrl); QUrlQuery query(parameterUrl);
query.addQueryItem(element.attribute("name"), "%s"); query.addQueryItem(element.attribute("name"), "%s");
@ -304,28 +301,6 @@ void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView
} }
parameterUrl.setQuery(query); parameterUrl.setQuery(query);
#else
QList<QPair<QByteArray, QByteArray> > queryItems;
QPair<QByteArray, QByteArray> item;
item.first = element.attribute("name").toUtf8();
item.second = "%s";
queryItems.append(item);
QWebElementCollection allInputs = formElement.findAll("input");
foreach (QWebElement e, allInputs) {
if (element == e || !e.hasAttribute("name")) {
continue;
}
QPair<QByteArray, QByteArray> item;
item.first = QUrl::toPercentEncoding(e.attribute("name").toUtf8());
item.second = QUrl::toPercentEncoding(e.evaluateJavaScript("this.value").toByteArray());
queryItems.append(item);
}
parameterUrl.setEncodedQueryItems(parameterUrl.encodedQueryItems() + queryItems);
#endif
if (!isPost) { if (!isPost) {
actionUrl = parameterUrl; actionUrl = parameterUrl;

View File

@ -23,11 +23,7 @@
#include "webpage.h" #include "webpage.h"
#include "qtwin.h" #include "qtwin.h"
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#else
#include <QWebEnginePage> #include <QWebEnginePage>
#endif
AboutDialog::AboutDialog(QWidget* parent) AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent), : QDialog(parent),

View File

@ -35,11 +35,7 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QPrinter> #include <QPrinter>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#endif
PageScreen::PageScreen(WebView* view, QWidget* parent) PageScreen::PageScreen(WebView* view, QWidget* parent)
: QDialog(parent) : QDialog(parent)

View File

@ -25,13 +25,8 @@
QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert) QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert)
{ {
#if QT_VERSION >= 0x050000
QString commonName = cert.subjectInfo(QSslCertificate::CommonName).isEmpty() ? QString() : cert.subjectInfo(QSslCertificate::CommonName).at(0); QString commonName = cert.subjectInfo(QSslCertificate::CommonName).isEmpty() ? QString() : cert.subjectInfo(QSslCertificate::CommonName).at(0);
QString organization = cert.subjectInfo(QSslCertificate::Organization).isEmpty() ? QString() : cert.subjectInfo(QSslCertificate::Organization).at(0); QString organization = cert.subjectInfo(QSslCertificate::Organization).isEmpty() ? QString() : cert.subjectInfo(QSslCertificate::Organization).at(0);
#else
QString commonName = cert.subjectInfo(QSslCertificate::CommonName);
QString organization = cert.subjectInfo(QSslCertificate::Organization);
#endif
if (commonName.isEmpty()) { if (commonName.isEmpty()) {
return clearCertSpecialSymbols(organization); return clearCertSpecialSymbols(organization);

View File

@ -26,11 +26,7 @@ HeaderView::HeaderView(QAbstractItemView* parent)
, m_menu(0) , m_menu(0)
, m_resizeOnShow(false) , m_resizeOnShow(false)
{ {
#if QT_VERSION >= 0x050000
setSectionsMovable(true); setSectionsMovable(true);
#else
setMovable(true);
#endif
setStretchLastSection(true); setStretchLastSection(true);
setDefaultAlignment(Qt::AlignLeft); setDefaultAlignment(Qt::AlignLeft);
setMinimumSectionSize(60); setMinimumSectionSize(60);

View File

@ -18,7 +18,6 @@
#include "qzregexp.h" #include "qzregexp.h"
#include "qztools.h" #include "qztools.h"
#if (QT_VERSION >= 0x050000)
QzRegExp::QzRegExp() QzRegExp::QzRegExp()
: QRegularExpression(QString(), QRegularExpression::DotMatchesEverythingOption) : QRegularExpression(QString(), QRegularExpression::DotMatchesEverythingOption)
, m_matchedLength(-1) , m_matchedLength(-1)
@ -83,5 +82,4 @@ QString QzRegExp::cap(int nth) const
return m_capturedTexts.at(nth); return m_capturedTexts.at(nth);
} }
#endif // (QT_VERSION >= 0x050000)

View File

@ -18,13 +18,6 @@
#ifndef QZREGEXP_H #ifndef QZREGEXP_H
#define QZREGEXP_H #define QZREGEXP_H
#include <QObject> // Needed for QT_VERSION
#if (QT_VERSION < 0x050000)
// Qt 4 - use QRegExp directly
#include <QRegExp>
#define QzRegExp QRegExp
#else // Qt 5
#include <QRegularExpression> #include <QRegularExpression>
#include <QStringList> #include <QStringList>
@ -47,6 +40,5 @@ private:
int m_matchedLength; int m_matchedLength;
}; };
#endif // Qt 5
#endif // QZREGEXP_H #endif // QZREGEXP_H

View File

@ -20,11 +20,7 @@
#include <QThread> #include <QThread>
#include <QMutexLocker> #include <QMutexLocker>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#endif
Q_GLOBAL_STATIC(SqlDatabase, qz_sql_database) Q_GLOBAL_STATIC(SqlDatabase, qz_sql_database)

View File

@ -29,14 +29,7 @@
#include <QDir> #include <QDir>
#include <QDateTime> #include <QDateTime>
#include <QTextStream> #include <QTextStream>
#if QT_VERSION >= 0x050000
#include <QWebEnginePage> #include <QWebEnginePage>
#else
#include "qwebkitversion.h"
#endif
#include <qtwebengineglobal.h>
void qupzilla_signal_handler(int s) void qupzilla_signal_handler(int s)
{ {
@ -107,30 +100,6 @@ void qupzilla_signal_handler(int s)
#endif // defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__) #endif // defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__)
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
#if (QT_VERSION < 0x050000)
void msgHandler(QtMsgType type, const char* msg)
{
// Skip this debug message as it may occur in a large amount over time
if (strcmp("QFont::setPixelSize: Pixel size <= 0 (0)", msg) == 0) {
return;
}
switch (type) {
case QtDebugMsg:
case QtWarningMsg:
case QtCriticalMsg:
std::cerr << msg << std::endl;
break;
case QtFatalMsg:
std::cerr << "Fatal: " << msg << std::endl;
abort();
default:
break;
}
}
#else
void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{ {
if (msg.startsWith(QL1S("QSslSocket: cannot resolve SSLv2_"))) if (msg.startsWith(QL1S("QSslSocket: cannot resolve SSLv2_")))
@ -153,24 +122,14 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString
} }
} }
#endif #endif
#endif
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
QT_REQUIRE_VERSION(argc, argv, "4.7.0"); QT_REQUIRE_VERSION(argc, argv, "4.7.0");
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
#if (QT_VERSION < 0x050000)
qInstallMsgHandler(&msgHandler);
#else
qInstallMessageHandler(&msgHandler); qInstallMessageHandler(&msgHandler);
#endif #endif
#endif
#if defined(QZ_WS_X11) && QT_VERSION < 0x050000
// Better overall performance on X11
QApplication::setGraphicsSystem(QSL("raster"));
#endif
#if defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__) #if defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__)
signal(SIGSEGV, qupzilla_signal_handler); signal(SIGSEGV, qupzilla_signal_handler);

View File

@ -1,10 +1,6 @@
include(../defines.pri) include(../defines.pri)
isEqual(QT_MAJOR_VERSION, 5) {
QT += webengine webenginewidgets network widgets printsupport sql script QT += webengine webenginewidgets network widgets printsupport sql script
} else {
QT += core gui webkit sql network script
}
TARGET = qupzilla TARGET = qupzilla
mac: TARGET = QupZilla mac: TARGET = QupZilla

View File

@ -1,11 +1,6 @@
include($$PWD/../../src/defines.pri) include($$PWD/../../src/defines.pri)
isEqual(QT_MAJOR_VERSION, 5) { QT += webenginewidgets network widgets printsupport sql script gui-private testlib
QT += webkitwidgets network widgets printsupport sql script gui-private testlib
} else {
QT += core gui webkit sql network script
CONFIG += qtestlib
}
TARGET = autotests TARGET = autotests