Fix functions and macros using to support both Qt4 and Qt5.

This commit is contained in:
Vladimir Golovnev (Glassez)
2013-09-21 11:59:58 +04:00
committed by sledgehammer999
parent 763d8a392f
commit ce3aac5f9d
51 changed files with 260 additions and 181 deletions

View File

@@ -168,7 +168,11 @@ void HttpConnection::translateDocument(QString& data) {
if (isTranslationNeeded) {
int context_index = 0;
while(context_index < context_count && translation == word) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1);
#else
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1);
#endif
++context_index;
}
}

View File

@@ -141,10 +141,10 @@ Submit Query
m_error = true;
return;
} else {
boundary = "--" + boundaryRegexNotQuoted.cap(1).toAscii();
boundary = "--" + boundaryRegexNotQuoted.cap(1).toLatin1();
}
} else {
boundary = "--" + boundaryRegexQuoted.cap(1).toAscii();
boundary = "--" + boundaryRegexQuoted.cap(1).toLatin1();
}
qDebug() << "Boundary is " << boundary;
QList<QByteArray> parts = splitRawData(m_data, boundary);

View File

@@ -156,7 +156,11 @@ void HttpServer::disableHttps() {
}
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
void HttpServer::incomingConnection(qintptr socketDescriptor)
#else
void HttpServer::incomingConnection(int socketDescriptor)
#endif
{
QTcpSocket *serverSocket;
#ifndef QT_NO_OPENSSL

View File

@@ -75,7 +75,11 @@ public:
#endif
private:
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
void incomingConnection(qintptr socketDescriptor);
#else
void incomingConnection(int socketDescriptor);
#endif
private slots:
void UnbanTimerEvent();

View File

@@ -58,7 +58,7 @@ QString json::toJson(const QVariant& v) {
QString result = "\"";
for (int i=0; i<s.size(); ++i) {
const QChar ch = s[i];
switch(ch.toAscii())
switch(ch.toLatin1())
{
case '\b':
result += "\\b";

View File

@@ -130,8 +130,8 @@ QString prefjson::getPreferences()
data.add("web_ui_password", pref.getWebUiPassword());
data.add("bypass_local_auth", !pref.isWebUiLocalAuthEnabled());
data.add("use_https", pref.isWebUiHttpsEnabled());
data.add("ssl_key", QString::fromAscii(pref.getWebUiHttpsKey()));
data.add("ssl_cert", QString::fromAscii(pref.getWebUiHttpsCertificate()));
data.add("ssl_key", QString::fromLatin1(pref.getWebUiHttpsKey()));
data.add("ssl_cert", QString::fromLatin1(pref.getWebUiHttpsCertificate()));
// DynDns
data.add("dyndns_enabled", pref.isDynDNSEnabled());
data.add("dyndns_service", pref.getDynDNSService());
@@ -317,12 +317,12 @@ void prefjson::setPreferences(const QString& json)
pref.setWebUiHttpsEnabled(m["use_https"].toBool());
#ifndef QT_NO_OPENSSL
if (m.contains("ssl_key")) {
QByteArray raw_key = m["ssl_key"].toString().toAscii();
QByteArray raw_key = m["ssl_key"].toString().toLatin1();
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
pref.setWebUiHttpsKey(raw_key);
}
if (m.contains("ssl_cert")) {
QByteArray raw_cert = m["ssl_cert"].toString().toAscii();
QByteArray raw_cert = m["ssl_cert"].toString().toLatin1();
if (!QSslCertificate(raw_cert).isNull())
pref.setWebUiHttpsCertificate(raw_cert);
}