diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,10 +1,6 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml Test) -remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) -remove_definitions(-DQT_NO_CAST_FROM_ASCII) -remove_definitions(-DQT_NO_CAST_TO_ASCII) - include(ECMAddTests) ecm_add_tests( diff --git a/autotests/kactioncollectiontest.cpp b/autotests/kactioncollectiontest.cpp --- a/autotests/kactioncollectiontest.cpp +++ b/autotests/kactioncollectiontest.cpp @@ -232,14 +232,14 @@ QVERIFY(a); QVERIFY(a->parent() == &collection); - QVERIFY(collection.action(KStandardAction::name(KStandardAction::Undo)) == a); + QVERIFY(collection.action(QString::fromLatin1(KStandardAction::name(KStandardAction::Undo))) == a); } void tst_KActionCollection::implicitStandardActionInsertionUsingCut() { KActionCollection collection(static_cast(nullptr)); QAction *cut = KStandardAction::cut(&collection); - QAction *a = collection.action(KStandardAction::name(KStandardAction::Cut)); + QAction *a = collection.action(QString::fromLatin1(KStandardAction::name(KStandardAction::Cut))); QVERIFY(a); QVERIFY(a == cut); } diff --git a/autotests/kxmlgui_unittest.cpp b/autotests/kxmlgui_unittest.cpp --- a/autotests/kxmlgui_unittest.cpp +++ b/autotests/kxmlgui_unittest.cpp @@ -195,7 +195,7 @@ QMap fileToVersionMap; // makes QCOMPARE failures more readable than just temp filenames QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); - QFile fileV2(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "testui.rc"); + QFile fileV2(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("testui.rc")); QVERIFY2(fileV2.open(QIODevice::WriteOnly), qPrintable(fileV2.fileName())); createXmlFile(fileV2, 2, NoFlags); fileToVersionMap.insert(fileV2.fileName(), 2); @@ -239,7 +239,7 @@ QMap fileToVersionMap; // makes QCOMPARE failures more readable than just temp filenames // local file - QFile fileV2(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "testui.rc"); + QFile fileV2(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("testui.rc")); QVERIFY(fileV2.open(QIODevice::WriteOnly)); createXmlFile(fileV2, 2, AddActionProperties | AddModifiedToolBars); fileToVersionMap.insert(fileV2.fileName(), 2); @@ -295,7 +295,7 @@ void debugActions(const QList &actions) { Q_FOREACH (QAction *action, actions) { - qDebug() << (action->isSeparator() ? QString("separator") : action->objectName()); + qDebug() << (action->isSeparator() ? QString::fromLatin1("separator") : action->objectName()); } } @@ -943,7 +943,7 @@ fileReplace.close(); // finally, our local xml file has - QFile fileLocal(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "testui.rc"); + QFile fileLocal(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("testui.rc")); QVERIFY2(fileLocal.open(QIODevice::WriteOnly), qPrintable(fileLocal.fileName())); createXmlFile(fileLocal, 1, AddActionProperties); const QString filenameLocal = fileLocal.fileName(); diff --git a/src/ksendbugmail/CMakeLists.txt b/src/ksendbugmail/CMakeLists.txt --- a/src/ksendbugmail/CMakeLists.txt +++ b/src/ksendbugmail/CMakeLists.txt @@ -1,5 +1,3 @@ -remove_definitions(-DQT_NO_CAST_FROM_ASCII) - set(ksendbugmail_SRCS main.cpp smtp.cpp diff --git a/src/ksendbugmail/main.cpp b/src/ksendbugmail/main.cpp --- a/src/ksendbugmail/main.cpp +++ b/src/ksendbugmail/main.cpp @@ -54,7 +54,7 @@ lstr = i18n("Time out waiting for server interaction."); break; default: - lstr = sm->getLastLine().trimmed(); + lstr = QString::fromLatin1(sm->getLastLine().trimmed()); lstr = i18n("Server said: \"%1\"", lstr); } // qCDebug(DEBUG_KXMLGUI) << lstr; @@ -97,25 +97,25 @@ if (recipient.isEmpty()) { recipient = QStringLiteral("submit@bugs.kde.org"); } else { - if (recipient.at(0) == '\'') { + if (recipient.at(0) == QLatin1Char('\'')) { recipient = recipient.mid(1).left(recipient.length() - 2); } } // qCDebug(DEBUG_KXMLGUI) << "recp" << recipient; if (subject.isEmpty()) { subject = QStringLiteral("(no subject)"); } else { - if (subject.at(0) == '\'') { + if (subject.at(0) == QLatin1Char('\'')) { subject = subject.mid(1).left(subject.length() - 2); } } QTextStream input(stdin, QIODevice::ReadOnly); input.setCodec("UTF-8"); QString text, line; while (!input.atEnd()) { line = input.readLine(); - text += line + "\r\n"; + text += line + QStringLiteral("\r\n"); } // qCDebug(DEBUG_KXMLGUI) << text; @@ -129,7 +129,7 @@ } } else { fromaddr = SystemInformation::userName(); - fromaddr += '@'; + fromaddr += QLatin1Char('@'); fromaddr += QHostInfo::localHostName(); } // qCDebug(DEBUG_KXMLGUI) << "fromaddr \"" << fromaddr << "\""; diff --git a/src/ksendbugmail/smtp.h b/src/ksendbugmail/smtp.h --- a/src/ksendbugmail/smtp.h +++ b/src/ksendbugmail/smtp.h @@ -65,15 +65,15 @@ void setPort(unsigned short int port); void setTimeOut(int timeout); - bool isConnected() + bool isConnected() const { return connected; } - bool isFinished() + bool isFinished() const { return finished; } - QString getLastLine() + QByteArray getLastLine() const { return lastLine; } @@ -119,7 +119,7 @@ } SMTPError; protected: - void processLine(QString *line); + void processLine(QByteArray *line); public Q_SLOTS: void openConnection(); @@ -164,8 +164,8 @@ QTimer interactTimer; char readBuffer[SMTP_READ_BUFFER_SIZE]; - QString lineBuffer; - QString lastLine; + QByteArray lineBuffer; + QByteArray lastLine; QString writeString; }; #endif diff --git a/src/ksendbugmail/smtp.cpp b/src/ksendbugmail/smtp.cpp --- a/src/ksendbugmail/smtp.cpp +++ b/src/ksendbugmail/smtp.cpp @@ -28,7 +28,7 @@ SMTP::SMTP(char *serverhost, unsigned short int port, int timeout) { - serverHost = serverhost; + serverHost = QString::fromUtf8(serverhost); hostPort = port; timeOut = timeout * 1000; @@ -86,27 +86,27 @@ void SMTP::setSenderAddress(const QString &sender) { senderAddress = sender; - int index = senderAddress.indexOf('<'); + int index = senderAddress.indexOf(QLatin1Char('<')); if (index == -1) { return; } senderAddress = senderAddress.mid(index + 1); - index = senderAddress.indexOf('>'); + index = senderAddress.indexOf(QLatin1Char('>')); if (index != -1) { senderAddress = senderAddress.left(index); } senderAddress = senderAddress.simplified(); while (1) { - index = senderAddress.indexOf(' '); + index = senderAddress.indexOf(QLatin1Char(' ')); if (index != -1) { senderAddress = senderAddress.mid(index + 1); // take one side } else { break; } } - index = senderAddress.indexOf('@'); + index = senderAddress.indexOf(QLatin1Char('@')); if (index == -1) { - senderAddress.append("@localhost"); // won't go through without a local mail system + senderAddress.append(QStringLiteral("@localhost")); // won't go through without a local mail system } } @@ -223,7 +223,7 @@ return; } readBuffer[n] = 0; - lineBuffer += readBuffer; + lineBuffer += QByteArray(readBuffer); nl = lineBuffer.indexOf('\n'); if (nl == -1) { return; @@ -257,10 +257,10 @@ emit connectionClosed(); } -void SMTP::processLine(QString *line) +void SMTP::processLine(QByteArray *line) { int i, stat; - QString tmpstr; + QByteArray tmpstr; i = line->indexOf(' '); tmpstr = line->left(i);