From 9c74f6cb6f24860fe489da366d23f1aa4dae54d0 Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Thu, 14 Mar 2024 19:26:44 +0300 Subject: [PATCH] More qt6 fixes --- src/Certificates/CertificateHelpers.cpp | 2 +- src/chatview_webkit.cpp | 4 ++-- src/filecache.cpp | 4 ++-- src/libpsi | 2 +- src/pluginhost.cpp | 2 +- src/psicon.cpp | 2 +- src/rtparse.cpp | 8 ++++---- src/textutil.cpp | 2 +- src/tools/optionstree/optionstree.cpp | 4 ++-- src/tools/optionstree/optionstreereader.cpp | 16 ++++++++-------- src/tools/tunecontroller/filetunecontroller.cpp | 4 ++++ .../tunecontroller/tunecontrollermanager.cpp | 3 ++- src/widgets/tabbar.cpp | 2 +- src/x11windowsystem.h | 2 +- 14 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/Certificates/CertificateHelpers.cpp b/src/Certificates/CertificateHelpers.cpp index 3b4766834..d3ab1362a 100644 --- a/src/Certificates/CertificateHelpers.cpp +++ b/src/Certificates/CertificateHelpers.cpp @@ -59,7 +59,7 @@ CertificateCollection CertificateHelpers::allCertificates(const QStringList &sto if (!f.open(QIODevice::ReadOnly)) continue; QDomDocument doc; - bool ok = doc.setContent(&f); + bool ok = bool(doc.setContent(&f)); f.close(); if (!ok) continue; diff --git a/src/chatview_webkit.cpp b/src/chatview_webkit.cpp index 2b36b3aa8..ece7a84af 100644 --- a/src/chatview_webkit.cpp +++ b/src/chatview_webkit.cpp @@ -111,7 +111,7 @@ class ChatViewPrivate { auto id = XMPP::Hash::from(QStringRef(&idStr)); auto item = account_->psi()->fileSharingManager()->item(id); - ret.append(msg.midRef(post, match.capturedStart(0) - post)); + ret.append(QStringView{msg}.mid(post, match.capturedStart(0) - post)); if (item) { auto vm = item->metaData(); QString attrs; @@ -132,7 +132,7 @@ class ChatViewPrivate { } post = match.capturedEnd(0); } - ret.append(msg.midRef(post)); + ret.append(QStringView{msg}.mid(post)); return ret; } }; diff --git a/src/filecache.cpp b/src/filecache.cpp index b8c5e4aeb..09027c3bc 100644 --- a/src/filecache.cpp +++ b/src/filecache.cpp @@ -169,8 +169,8 @@ FileCache::FileCache(const QString &cacheDir, QObject *parent) : auto ind = s.indexOf('+'); if (ind == -1) continue; - auto type = XMPP::Hash::parseType(s.leftRef(ind)); - auto ba = QByteArray::fromHex(s.midRef(ind + 1).toLatin1()); + auto type = XMPP::Hash::parseType(QStringView{s}.left(ind)); + auto ba = QByteArray::fromHex(QStringView{s}.mid(ind + 1).toLatin1()); XMPP::Hash hash(type, ba); if (hash.isValid() && ba.size()) { item->addHashSum(hash); diff --git a/src/libpsi b/src/libpsi index c7fc891c0..56e130d46 160000 --- a/src/libpsi +++ b/src/libpsi @@ -1 +1 @@ -Subproject commit c7fc891c0864dde744fb5990ec02a524a9dda03a +Subproject commit 56e130d46067ead767396e7f3b0e1b046954a8b8 diff --git a/src/pluginhost.cpp b/src/pluginhost.cpp index bd37d183f..be79990e0 100644 --- a/src/pluginhost.cpp +++ b/src/pluginhost.cpp @@ -214,7 +214,7 @@ void PluginHost::updateMetadata() QString data = md.value(QLatin1String("icon")).toString(); if (data.startsWith("base64:")) { - rawIcon_ = QByteArray::fromBase64(data.midRef(6).toLatin1()); + rawIcon_ = QByteArray::fromBase64(QStringView{data}.mid(6).toLatin1()); QPixmap pix; pix.loadFromData(rawIcon_); icon_ = QIcon(pix); diff --git a/src/psicon.cpp b/src/psicon.cpp index d2c8373aa..434543215 100644 --- a/src/psicon.cpp +++ b/src/psicon.cpp @@ -255,7 +255,7 @@ class PsiCon::Private : public QObject { std::pair uriToShareSource(const QString &path) { - auto pathParts = path.midRef(sizeof("/psi/account")).split('/'); + auto pathParts = QStringView{path}.mid(sizeof("/psi/account")).split('/'); if (pathParts.size() < 3 || pathParts[1] != QLatin1String("sharedfile") || pathParts[2].isEmpty()) // /sharedfile/ return { nullptr, QString() }; diff --git a/src/rtparse.cpp b/src/rtparse.cpp index ece0ff8b9..d146f8217 100644 --- a/src/rtparse.cpp +++ b/src/rtparse.cpp @@ -47,10 +47,10 @@ QString RTParse::next() QStringRef s; int n = in.indexOf('>', v_at); if (n == -1) { - s = in.midRef(v_at); + s = QStringView{in}.mid(v_at); } else { ++n; - s = in.midRef(v_at, n - v_at); + s = QStringView{in}.mid(v_at, n - v_at); } v_at += s.length(); out += s; @@ -60,10 +60,10 @@ QString RTParse::next() QStringRef s; int x = in.indexOf('<', v_at); if (x == -1) { - s = in.midRef(v_at); + s = QStringView{in}.mid(v_at); v_atEnd = true; } else { - s = in.midRef(v_at, x - v_at); + s = QStringView{in}.mid(v_at, x - v_at); } v_at += s.length(); // printf("chunk = '%s'\n", s.latin1()); diff --git a/src/textutil.cpp b/src/textutil.cpp index f37db9cbf..da7b99295 100644 --- a/src/textutil.cpp +++ b/src/textutil.cpp @@ -301,7 +301,7 @@ static void emojiconifyPlainText(RTParse &p, const QString &in) QLatin1String( R"html()html") #endif - + in.midRef(emojisStartIdx, idx - emojisStartIdx) + QLatin1String("")); + + QStringView{in}.mid(emojisStartIdx, idx - emojisStartIdx) + QLatin1String("")); }; while (!(ref = reg.findEmoji(in, idx)).isEmpty()) { if (emojisStartIdx == -1) { diff --git a/src/tools/optionstree/optionstree.cpp b/src/tools/optionstree/optionstree.cpp index ded7dcfa7..acc758216 100644 --- a/src/tools/optionstree/optionstree.cpp +++ b/src/tools/optionstree/optionstree.cpp @@ -190,11 +190,11 @@ void OptionsTree::mapPut(const QString &basename, const QVariant &key, const QSt bool mapKeyListLessThanByNumber(const QString &s1, const QString &s2) { int dotpos = s1.lastIndexOf('.'); - if (s1.leftRef(dotpos + 1).compare(s2.leftRef(dotpos + 1)) == 0) { + if (QStringView{s1}.left(dotpos + 1).compare(QStringView{s2}.left(dotpos + 1)) == 0) { QString name1 = s1.mid(dotpos + 1), name2 = s2.mid(dotpos + 1); if (name1[0] == 'm' && name2[0] == 'm') { bool ok1 = false, ok2 = false; - unsigned int n1 = name1.midRef(1).toUInt(&ok1), n2 = name2.midRef(1).toUInt(&ok2); + unsigned int n1 = QStringView{name1}.mid(1).toUInt(&ok1), n2 = QStringView{name2}.mid(1).toUInt(&ok2); if (ok1 && ok2) { return n1 < n2; } diff --git a/src/tools/optionstree/optionstreereader.cpp b/src/tools/optionstree/optionstreereader.cpp index 7c19e37c7..61dfb7e97 100644 --- a/src/tools/optionstree/optionstreereader.cpp +++ b/src/tools/optionstree/optionstreereader.cpp @@ -121,7 +121,7 @@ QStringList OptionsTreeReader::readStringList() break; if (isStartElement()) { - if (name() == "item") { + if (name() == QLatin1String{"item"}) { list << readElementText(); } } @@ -139,7 +139,7 @@ QVariantList OptionsTreeReader::readVariantList() break; if (isStartElement()) { - if (name() == "item") { + if (name() == QLatin1String{"item"}) { list << readVariant(attributes().value("type").toString()); } } @@ -157,9 +157,9 @@ QSize OptionsTreeReader::readSize() break; if (isStartElement()) { - if (name() == "width") { + if (name() == QLatin1String{"width"}) { width = readElementText().toInt(); - } else if (name() == "height") { + } else if (name() == QLatin1String{"height"}) { height = readElementText().toInt(); } } @@ -177,13 +177,13 @@ QRect OptionsTreeReader::readRect() break; if (isStartElement()) { - if (name() == "width") { + if (name() == QLatin1String{"width"}) { width = readElementText().toInt(); - } else if (name() == "height") { + } else if (name() == QLatin1String{"height"}) { height = readElementText().toInt(); - } else if (name() == "x") { + } else if (name() == QLatin1String{"x"}) { x = readElementText().toInt(); - } else if (name() == "y") { + } else if (name() == QLatin1String{"y"}) { y = readElementText().toInt(); } } diff --git a/src/tools/tunecontroller/filetunecontroller.cpp b/src/tools/tunecontroller/filetunecontroller.cpp index b0a55e1e6..30ee0feaa 100644 --- a/src/tools/tunecontroller/filetunecontroller.cpp +++ b/src/tools/tunecontroller/filetunecontroller.cpp @@ -77,7 +77,11 @@ void FileTuneController::check() QFile file(_songFile); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) stream.setCodec("UTF-8"); +#else + stream.setEncoding(QStringConverter::Utf8); +#endif stream.setAutoDetectUnicode(true); _currentTune.setName(stream.readLine()); _currentTune.setArtist(stream.readLine()); diff --git a/src/tools/tunecontroller/tunecontrollermanager.cpp b/src/tools/tunecontroller/tunecontrollermanager.cpp index 6e3421c8d..e3f83a7bc 100644 --- a/src/tools/tunecontroller/tunecontrollermanager.cpp +++ b/src/tools/tunecontroller/tunecontrollermanager.cpp @@ -28,6 +28,7 @@ #include #include +#include /** * \class TuneControllerManager @@ -127,7 +128,7 @@ bool TuneControllerManager::checkTune(const Tune &tune) const { if (!tuneTitleFilterPattern_.isEmpty() && !tune.name().isEmpty()) { QRegularExpression tuneTitleFilter(tuneTitleFilterPattern_); - if (tuneTitleFilter.isValid() && tuneTitleFilter.exactMatch(tune.name())) { + if (tuneTitleFilter.isValid() && tuneTitleFilter.match(QLatin1Char('^') + tune.name() + QLatin1Char('^')).hasMatch()) { return false; } } diff --git a/src/widgets/tabbar.cpp b/src/widgets/tabbar.cpp index dfd866b14..7393666a1 100644 --- a/src/widgets/tabbar.cpp +++ b/src/widgets/tabbar.cpp @@ -279,7 +279,7 @@ void TabBar::Private::layoutTabs() tab.rect.setSize(tabSizeHint(tab)); // Make pinned tab if need if (i < pinnedTabs) { - tab.text = tab.text.left(tab.text.leftRef(PINNED_CHARS).contains("&") ? (PINNED_CHARS + 1) : PINNED_CHARS); + tab.text = tab.text.left(QStringView{tab.text}.left(PINNED_CHARS).contains("&") ? (PINNED_CHARS + 1) : PINNED_CHARS); tab.rect.setWidth(pinnedTabWidth); } hackedTabs << tab; diff --git a/src/x11windowsystem.h b/src/x11windowsystem.h index 58acbbc2b..3c279e8db 100644 --- a/src/x11windowsystem.h +++ b/src/x11windowsystem.h @@ -4,7 +4,7 @@ #include #include #include -#include +//#include #include // TODO: Find a way to include Xlib here and not redefine Atom and Window types