diff --git a/src/core/forwardingslavebase.cpp b/src/core/forwardingslavebase.cpp --- a/src/core/forwardingslavebase.cpp +++ b/src/core/forwardingslavebase.cpp @@ -17,9 +17,6 @@ Boston, MA 02110-1301, USA. */ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - #include "forwardingslavebase.h" #include "../pathhelpers_p.h" @@ -91,7 +88,7 @@ { bool result = true; - if (url.scheme() == q->mProtocol) { + if (url.scheme() == QLatin1String(q->mProtocol)) { result = q->rewriteUrl(url, newURL); } else { newURL = url; diff --git a/src/core/kremoteencoding.cpp b/src/core/kremoteencoding.cpp --- a/src/core/kremoteencoding.cpp +++ b/src/core/kremoteencoding.cpp @@ -16,9 +16,6 @@ Boston, MA 02110-1301, USA. */ -// TODO: remove me -#undef QT_NO_CAST_FROM_BYTEARRAY - #include "kremoteencoding.h" #include @@ -97,7 +94,8 @@ const char *KRemoteEncoding::encoding() const { - return d->m_codec->name(); + // KF6 TODO: return QByteArray + return d->m_codec->name().constData(); } int KRemoteEncoding::encodingMib() const diff --git a/src/core/slavebase.h b/src/core/slavebase.h --- a/src/core/slavebase.h +++ b/src/core/slavebase.h @@ -1029,6 +1029,12 @@ virtual void virtual_hook(int id, void *data); private: + // Convenience function converting mProtocol to QString as unsupportedActionErrorString(), which + // is used in many places in the code, takes a QString parameter + inline const QString protocolName() const { + return QString::fromLatin1(mProtocol); + } + // This helps catching missing tr()/i18n() calls in error(). void error(int _errid, const QByteArray &_text); void send(int cmd, const QByteArray &arr = QByteArray()); diff --git a/src/core/slavebase.cpp b/src/core/slavebase.cpp --- a/src/core/slavebase.cpp +++ b/src/core/slavebase.cpp @@ -21,9 +21,6 @@ * **/ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - #include "slavebase.h" #include @@ -210,7 +207,7 @@ KIO_STATE_ASSERT(finalState(), Q_FUNC_INFO, qUtf8Printable(QStringLiteral("%1 did not call finished() or error()! Please fix the %2 KIO slave") - .arg(cmdName) + .arg(QLatin1String(cmdName)) .arg(QCoreApplication::applicationName()))); // Force the command into finished state. We'll not reach this for Debug builds // that fail the assertion. For Release builds we'll have made sure that the @@ -226,7 +223,7 @@ KIO_STATE_ASSERT(!finalState(), Q_FUNC_INFO, qUtf8Printable(QStringLiteral("%1 called finished() or error(), but it's not supposed to! Please fix the %2 KIO slave") - .arg(cmdName) + .arg(QLatin1String(cmdName)) .arg(QCoreApplication::applicationName()))); } @@ -903,97 +900,97 @@ void SlaveBase::openConnection() { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CONNECT)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_CONNECT)); } void SlaveBase::closeConnection() { } // No response! void SlaveBase::stat(QUrl const &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_STAT)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_STAT)); } void SlaveBase::put(QUrl const &, int, JobFlags) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_PUT)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_PUT)); } void SlaveBase::special(const QByteArray &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SPECIAL)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_SPECIAL)); } void SlaveBase::listDir(QUrl const &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_LISTDIR)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_LISTDIR)); } void SlaveBase::get(QUrl const &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_GET)); } void SlaveBase::open(QUrl const &, QIODevice::OpenMode) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_OPEN)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_OPEN)); } void SlaveBase::read(KIO::filesize_t) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_READ)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_READ)); } void SlaveBase::write(const QByteArray &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_WRITE)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_WRITE)); } void SlaveBase::seek(KIO::filesize_t) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SEEK)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_SEEK)); } void SlaveBase::close() { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CLOSE)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_CLOSE)); } void SlaveBase::mimetype(QUrl const &url) { get(url); } void SlaveBase::rename(QUrl const &, QUrl const &, JobFlags) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_RENAME)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_RENAME)); } void SlaveBase::symlink(QString const &, QUrl const &, JobFlags) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SYMLINK)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_SYMLINK)); } void SlaveBase::copy(QUrl const &, QUrl const &, int, JobFlags) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_COPY)); } void SlaveBase::del(QUrl const &, bool) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_DEL)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_DEL)); } void SlaveBase::setLinkDest(const QUrl &, const QString &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SETLINKDEST)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_SETLINKDEST)); } void SlaveBase::mkdir(QUrl const &, int) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MKDIR)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_MKDIR)); } void SlaveBase::chmod(QUrl const &, int) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CHMOD)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_CHMOD)); } void SlaveBase::setModificationTime(QUrl const &, const QDateTime &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SETMODIFICATIONTIME)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_SETMODIFICATIONTIME)); } void SlaveBase::chown(QUrl const &, const QString &, const QString &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CHOWN)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_CHOWN)); } void SlaveBase::setSubUrl(QUrl const &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SUBURL)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_SUBURL)); } void SlaveBase::multiGet(const QByteArray &) { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MULTI_GET)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_MULTI_GET)); } void SlaveBase::slave_status() @@ -1500,7 +1497,7 @@ switch(id) { case GetFileSystemFreeSpace: { - error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_FILESYSTEMFREESPACE)); + error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(protocolName(), CMD_FILESYSTEMFREESPACE)); } break; } } diff --git a/src/filewidgets/kencodingfiledialog.cpp b/src/filewidgets/kencodingfiledialog.cpp --- a/src/filewidgets/kencodingfiledialog.cpp +++ b/src/filewidgets/kencodingfiledialog.cpp @@ -20,9 +20,6 @@ Boston, MA 02110-1301, USA. */ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - #include "kencodingfiledialog.h" #include "kfilewidget.h" @@ -88,7 +85,7 @@ d->encoding->clear(); QString sEncoding = encoding; - QString systemEncoding = QTextCodec::codecForLocale()->name(); + QString systemEncoding = QLatin1String(QTextCodec::codecForLocale()->name()); if (sEncoding.isEmpty() || sEncoding == QLatin1String("System")) { sEncoding = systemEncoding; } @@ -102,12 +99,13 @@ if (found) { d->encoding->addItem(encoding); - if ((codecForEnc->name() == sEncoding) || (encoding == sEncoding)) { + const QString codecName = QLatin1String(codecForEnc->name()); + if ((codecName == sEncoding) || (encoding == sEncoding)) { d->encoding->setCurrentIndex(insert); foundRequested = true; } - if ((codecForEnc->name() == systemEncoding) || (encoding == systemEncoding)) { + if ((codecName == systemEncoding) || (encoding == systemEncoding)) { system = insert; } insert++; diff --git a/src/filewidgets/kfileplacesitem.cpp b/src/filewidgets/kfileplacesitem.cpp --- a/src/filewidgets/kfileplacesitem.cpp +++ b/src/filewidgets/kfileplacesitem.cpp @@ -318,15 +318,15 @@ } KBookmark KFilePlacesItem::createSystemBookmark(KBookmarkManager *manager, - const QString &translationContext, - const QString &untranslatedLabel, + const char *translationContext, + const QByteArray &untranslatedLabel, const QUrl &url, const QString &iconName) { Q_UNUSED(translationContext); // parameter is only necessary to force the caller // to provide a marked-for-translation string for the label, with context - KBookmark bookmark = createBookmark(manager, untranslatedLabel, url, iconName); + KBookmark bookmark = createBookmark(manager, QString::fromUtf8(untranslatedLabel), url, iconName); if (!bookmark.isNull()) { bookmark.setMetaDataItem(QStringLiteral("isSystemItem"), QStringLiteral("true")); } @@ -349,7 +349,7 @@ KBookmark KFilePlacesItem::createTagBookmark(KBookmarkManager *manager, const QString &tag) { - KBookmark bookmark = createSystemBookmark(manager, tag, tag, QUrl(QLatin1String("tags:/") + tag), QLatin1String("tag")); + KBookmark bookmark = createSystemBookmark(manager, tag.toUtf8().data(), tag.toUtf8(), QUrl(QLatin1String("tags:/") + tag), QLatin1String("tag")); bookmark.setMetaDataItem(QStringLiteral("tag"), tag); bookmark.setMetaDataItem(QStringLiteral("isSystemItem"), QStringLiteral("true")); diff --git a/src/filewidgets/kfileplacesitem_p.h b/src/filewidgets/kfileplacesitem_p.h --- a/src/filewidgets/kfileplacesitem_p.h +++ b/src/filewidgets/kfileplacesitem_p.h @@ -76,8 +76,8 @@ const QString &iconName, KFilePlacesItem *after = nullptr); static KBookmark createSystemBookmark(KBookmarkManager *manager, - const QString &translationContext, - const QString &untranslatedLabel, + const char *translationContext, + const QByteArray &untranslatedLabel, const QUrl &url, const QString &iconName); static KBookmark createDeviceBookmark(KBookmarkManager *manager, diff --git a/src/filewidgets/kfileplacesmodel.cpp b/src/filewidgets/kfileplacesmodel.cpp --- a/src/filewidgets/kfileplacesmodel.cpp +++ b/src/filewidgets/kfileplacesmodel.cpp @@ -18,9 +18,6 @@ */ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - #include "kfileplacesmodel.h" #include "kfileplacesitem_p.h" @@ -184,7 +181,9 @@ } if (!existingBookmarks.contains(QUrl(tagsUrlBase))) { - KBookmark alltags = KFilePlacesItem::createSystemBookmark(bookmarkManager, QStringLiteral("All tags"), i18n("All tags"), QUrl(tagsUrlBase), QStringLiteral("tag")); + KBookmark alltags = KFilePlacesItem::createSystemBookmark(bookmarkManager, "All tags" + , i18n("All tags").toUtf8().data() + , QUrl(tagsUrlBase), QStringLiteral("tag")); } } @@ -276,7 +275,6 @@ }; if (root.first().isNull() || !QFile::exists(file)) { - // NOTE: The context for these I18NC_NOOP calls has to be "KFile System Bookmarks". // The real i18nc call is made later, with this context, so the two must match. // createSystemBookmark actually does nothing with its second argument, the context, @@ -342,7 +340,7 @@ setDefaultMetadataItemForGroup(RecentlySavedType); // Move The recently used bookmarks below the trash, making it the first element in the Recent group - KBookmark trashBookmark = bookmarkForUrl(QUrl("trash:/")); + KBookmark trashBookmark = bookmarkForUrl(QUrl(QStringLiteral("trash:/"))); if (!trashBookmark.isNull()) { root.moveBookmark(recentFilesBookmark, trashBookmark); root.moveBookmark(recentDirectoriesBookmark, recentFilesBookmark); diff --git a/src/ioslaves/ftp/CMakeLists.txt b/src/ioslaves/ftp/CMakeLists.txt --- a/src/ioslaves/ftp/CMakeLists.txt +++ b/src/ioslaves/ftp/CMakeLists.txt @@ -1,8 +1,6 @@ project(kioslave-ftp) -remove_definitions(-DQT_NO_CAST_FROM_ASCII) # TODO REMOVE - include(ConfigureChecks.cmake) configure_file(config-kioslave-ftp.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kioslave-ftp.h ) diff --git a/src/ioslaves/ftp/ftp.cpp b/src/ioslaves/ftp/ftp.cpp --- a/src/ioslaves/ftp/ftp.cpp +++ b/src/ioslaves/ftp/ftp.cpp @@ -1217,7 +1217,7 @@ // When deleting a directory, we must exit from it first // The last command probably went into it (to stat it) if (!isfile) { - (void) ftpFolder(q->remoteEncoding()->directory(url)); // ignore errors + (void) ftpFolder(q->remoteEncoding()->decode(q->remoteEncoding()->directory(url))); // ignore errors } const QByteArray cmd = (isfile ? "DELE " : "RMD ") + q->remoteEncoding()->encode(url); @@ -2343,7 +2343,7 @@ bool FtpInternal::isSocksProxyScheme(const QString &scheme) { - return scheme == "socks" || scheme == "socks5"; + return scheme == QLatin1String("socks") || scheme == QLatin1String("socks5"); } bool FtpInternal::isSocksProxy() const diff --git a/src/kcms/kio/kcookiespolicies.cpp b/src/kcms/kio/kcookiespolicies.cpp --- a/src/kcms/kio/kcookiespolicies.cpp +++ b/src/kcms/kio/kcookiespolicies.cpp @@ -24,9 +24,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - // Own #include "kcookiespolicies.h" @@ -177,7 +174,7 @@ KCookiesPolicySelectionDlg pdlg (this); pdlg.setWindowTitle (i18nc ("@title:window", "Change Cookie Policy")); - pdlg.setPolicy (KCookieAdvice::strToAdvice (mDomainPolicyMap.value(oldDomain))); + pdlg.setPolicy (KCookieAdvice::strToAdvice(QString::fromLatin1(mDomainPolicyMap.value(oldDomain)))); pdlg.setEnableHostEdit (state, oldDomain); if (pdlg.exec() && !pdlg.domain().isEmpty()) { @@ -366,22 +363,23 @@ group.writeEntry ("AcceptSessionCookies", state); QString advice; - if (mUi.rbPolicyAccept->isChecked()) - advice = KCookieAdvice::adviceToStr (KCookieAdvice::Accept); - else if (mUi.rbPolicyAcceptForSession->isChecked()) - advice = KCookieAdvice::adviceToStr (KCookieAdvice::AcceptForSession); - else if (mUi.rbPolicyReject->isChecked()) - advice = KCookieAdvice::adviceToStr (KCookieAdvice::Reject); - else - advice = KCookieAdvice::adviceToStr (KCookieAdvice::Ask); + if (mUi.rbPolicyAccept->isChecked()) { + advice = QString::fromLatin1(KCookieAdvice::adviceToStr(KCookieAdvice::Accept)); + } else if (mUi.rbPolicyAcceptForSession->isChecked()) { + advice = QString::fromLatin1(KCookieAdvice::adviceToStr(KCookieAdvice::AcceptForSession)); + } else if (mUi.rbPolicyReject->isChecked()) { + advice = QString::fromLatin1(KCookieAdvice::adviceToStr(KCookieAdvice::Reject)); + } else { + advice = QString::fromLatin1(KCookieAdvice::adviceToStr(KCookieAdvice::Ask)); + } group.writeEntry ("CookieGlobalAdvice", advice); QStringList domainConfig; QMapIterator it (mDomainPolicyMap); while (it.hasNext()) { it.next(); - const QString policy = tolerantToAce(it.key()) + QLatin1Char(':') + QLatin1String(it.value()); + const QString policy = QLatin1String(tolerantToAce(it.key())) + QLatin1Char(':') + QLatin1String(it.value()); domainConfig << policy; } diff --git a/src/kcms/kio/smbrodlg.cpp b/src/kcms/kio/smbrodlg.cpp --- a/src/kcms/kio/smbrodlg.cpp +++ b/src/kcms/kio/smbrodlg.cpp @@ -18,9 +18,6 @@ Boston, MA 02110-1301, USA. */ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - // Own #include "smbrodlg.h" @@ -122,7 +119,7 @@ unsigned int a2 = qc2.toLatin1() - 'A'; unsigned int a3 = qc3.toLatin1() - '0'; unsigned int num = ((a1 & 0x3F) << 10) | ((a2& 0x1F) << 5) | (a3 & 0x1F); - password[i] = QChar((uchar)((num - 17) ^ 173)); // restore + password[i] = QLatin1Char((num - 17) ^ 173); // restore } m_passwordLe->setText(password); @@ -149,9 +146,9 @@ unsigned int a1 = (num & 0xFC00) >> 10; unsigned int a2 = (num & 0x3E0) >> 5; unsigned int a3 = (num & 0x1F); - scrambled += (char)(a1+'0'); - scrambled += (char)(a2+'A'); - scrambled += (char)(a3+'0'); + scrambled += QLatin1Char((char)(a1+'0')); + scrambled += QLatin1Char((char)(a2+'A')); + scrambled += QLatin1Char((char)(a3+'0')); } group.writeEntry( "Password", scrambled); diff --git a/src/kioexec/main.cpp b/src/kioexec/main.cpp --- a/src/kioexec/main.cpp +++ b/src/kioexec/main.cpp @@ -19,9 +19,6 @@ Boston, MA 02110-1301, USA. */ -// TODO: remove me -#undef QT_NO_CAST_FROM_ASCII - #include "main.h" #include "kio_version.h" #include "kioexecdinterface.h" @@ -199,7 +196,7 @@ // Store modification times QList::Iterator it = fileList.begin(); for (; it != fileList.end() ; ++it) { - QFileInfo info(QFile::encodeName(it->path)); + QFileInfo info(it->path); it->time = info.lastModified(); QUrl url = QUrl::fromLocalFile(it->path); list << url; @@ -262,7 +259,7 @@ QThread::currentThread()->sleep(sleepSecs); const QString parentDir = info.path(); qDebug() << sleepSecs << "seconds have passed, deleting" << info.filePath(); - QFile(QFile::encodeName(src)).remove(); + QFile(src).remove(); // NOTE: this is not necessarily a temporary directory. if (QDir().rmdir(parentDir)) { qDebug() << "Removed empty parent directory" << parentDir; diff --git a/src/kpasswdserver/autotests/CMakeLists.txt b/src/kpasswdserver/autotests/CMakeLists.txt --- a/src/kpasswdserver/autotests/CMakeLists.txt +++ b/src/kpasswdserver/autotests/CMakeLists.txt @@ -1,8 +1,5 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/.. ) -remove_definitions(-DQT_NO_CAST_FROM_ASCII) -remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) - set (kpasswdserver_test_SRCS kpasswdservertest.cpp ../kpasswdserver.cpp diff --git a/src/kpasswdserver/autotests/kpasswdservertest.cpp b/src/kpasswdserver/autotests/kpasswdservertest.cpp --- a/src/kpasswdserver/autotests/kpasswdservertest.cpp +++ b/src/kpasswdserver/autotests/kpasswdservertest.cpp @@ -301,7 +301,7 @@ QList authInfos; for (int i=0; i < 10; ++i) { KIO::AuthInfo info; - info.url = QUrl("http://www.example.com/test" + QString::number(i) + ".html"); + info.url = QUrl(QLatin1String("http://www.example.com/test") + QString::number(i) + QLatin1String(".html")); authInfos << info; } @@ -322,7 +322,7 @@ QList authInfos; for (int i=0; i < 10; ++i) { KIO::AuthInfo info; - info.url = QUrl("http://www.example.com/test" + QString::number(i) + ".html"); + info.url = QUrl(QLatin1String("http://www.example.com/test") + QString::number(i) + QStringLiteral(".html")); authInfos << info; }