Skip to content

Commit

Permalink
More qt6 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Mar 14, 2024
1 parent 50da149 commit 9c74f6c
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Certificates/CertificateHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/chatview_webkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -132,7 +132,7 @@ class ChatViewPrivate {
}
post = match.capturedEnd(0);
}
ret.append(msg.midRef(post));
ret.append(QStringView{msg}.mid(post));
return ret;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/filecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pluginhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/psicon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class PsiCon::Private : public QObject {

std::pair<PsiAccount *, QString> 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()) // <acoount_uuid>/sharedfile/<file_hash>
return { nullptr, QString() };
Expand Down
8 changes: 4 additions & 4 deletions src/rtparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/textutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static void emojiconifyPlainText(RTParse &p, const QString &in)
QLatin1String(
R"html(<span style="font-family: 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji'; font-size:1.5em">)html")
#endif
+ in.midRef(emojisStartIdx, idx - emojisStartIdx) + QLatin1String("</span>"));
+ QStringView{in}.mid(emojisStartIdx, idx - emojisStartIdx) + QLatin1String("</span>"));
};
while (!(ref = reg.findEmoji(in, idx)).isEmpty()) {
if (emojisStartIdx == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/optionstree/optionstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions src/tools/optionstree/optionstreereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ QStringList OptionsTreeReader::readStringList()
break;

if (isStartElement()) {
if (name() == "item") {
if (name() == QLatin1String{"item"}) {
list << readElementText();
}
}
Expand All @@ -139,7 +139,7 @@ QVariantList OptionsTreeReader::readVariantList()
break;

if (isStartElement()) {
if (name() == "item") {
if (name() == QLatin1String{"item"}) {
list << readVariant(attributes().value("type").toString());
}
}
Expand All @@ -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();
}
}
Expand All @@ -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();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/tools/tunecontroller/filetunecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/tools/tunecontroller/tunecontrollermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <QPluginLoader>
#include <QtCore>
#include <QLatin1Char>

/**
* \class TuneControllerManager
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/tabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/x11windowsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <QRect>
#include <QSet>
#include <QWidget>
#include <QX11Info>
//#include <QX11Info>
#include <QtCore>

// TODO: Find a way to include Xlib here and not redefine Atom and Window types
Expand Down

0 comments on commit 9c74f6c

Please sign in to comment.