Fix compilation with Qt5.

This commit is contained in:
sledgehammer999 2014-05-01 22:53:29 +03:00
parent ba1f4a9b7f
commit ef3f7d18c9
4 changed files with 29 additions and 2 deletions

View file

@ -36,8 +36,12 @@
#ifndef DISABLE_GUI
#if defined(QBT_STATIC_QT)
#include <QtPlugin>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_IMPORT_PLUGIN(QICOPlugin)
#else
Q_IMPORT_PLUGIN(qico)
#endif
#endif
#include <QMessageBox>
#include <QStyleFactory>
#include <QStyle>

View file

@ -30,6 +30,7 @@
#ifndef __BITTORRENT_H__
#define __BITTORRENT_H__
#include <QMap>
#include <QHash>
#include <QUrl>
#include <QStringList>

View file

@ -31,6 +31,9 @@
#include <QHttpRequestHeader>
#include <QTcpSocket>
#include <QUrl>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QUrlQuery>
#endif
#include <libtorrent/bencode.hpp>
#include <libtorrent/entry.hpp>
@ -109,8 +112,13 @@ void QTracker::readRequest()
// OK, this is a GET request
// Parse GET parameters
QHash<QString, QString> get_parameters;
QUrl url = QUrl::fromEncoded(http_request.path().toAscii());
QUrl url = QUrl::fromEncoded(http_request.path().toLatin1());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QUrlQuery query(url);
QListIterator<QPair<QString, QString> > i(query.queryItems());
#else
QListIterator<QPair<QString, QString> > i(url.queryItems());
#endif
while (i.hasNext()) {
QPair<QString, QString> pair = i.next();
get_parameters[pair.first] = pair.second;

View file

@ -31,6 +31,9 @@
#include "httprequestparser.h"
#include <QUrl>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QUrlQuery>
#endif
#include <QDebug>
HttpRequestParser::HttpRequestParser(): m_error(false)
@ -69,11 +72,16 @@ void HttpRequestParser::writeHeader(const QByteArray& ba) {
m_error = false;
// Parse header
m_header = QHttpRequestHeader(ba);
QUrl url = QUrl::fromEncoded(m_header.path().toAscii());
QUrl url = QUrl::fromEncoded(m_header.path().toLatin1());
m_path = url.path();
// Parse GET parameters
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QUrlQuery query(url);
QListIterator<QPair<QString, QString> > i(query.queryItems());
#else
QListIterator<QPair<QString, QString> > i(url.queryItems());
#endif
while (i.hasNext()) {
QPair<QString, QString> pair = i.next();
m_getMap[pair.first] = pair.second;
@ -102,8 +110,14 @@ void HttpRequestParser::writeMessage(const QByteArray& ba) {
// Parse POST data
if (m_header.contentType() == "application/x-www-form-urlencoded") {
QUrl url;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString tmp(m_data);
QUrlQuery query(tmp);
QListIterator<QPair<QString, QString> > i(query.queryItems());
#else
url.setEncodedQuery(m_data);
QListIterator<QPair<QString, QString> > i(url.queryItems());
#endif
while (i.hasNext()) {
QPair<QString, QString> pair = i.next();
m_postMap[pair.first] = pair.second;