Commit e1de598e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make some code compiles against qt6

parent 5d3c044b
Pipeline #193546 passed with stage
in 1 minute and 37 seconds
......@@ -69,7 +69,11 @@ KGpgGroupNodePrivate::findGroupEntry(QFile &conffile, QTextStream &stream, QStri
// remove "group "
parsedLine.remove(0, 6);
if (parsedLine.startsWith(m_name)) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (parsedLine.midRef(m_name.length()).trimmed().startsWith(QLatin1Char('='))) {
#else
if (QStringView(parsedLine).mid(m_name.length()).trimmed().startsWith(QLatin1Char('='))) {
#endif
if (index >= 0) {
// multiple definitions of the same group, drop the second one
continue;
......
......@@ -332,8 +332,11 @@ KGpgKeyNode::compareId(const QString &other) const
return (other.compare(m_key->fingerprint(), Qt::CaseInsensitive) == 0);
const QString comId = m_key->fullId().isEmpty() ? m_key->fingerprint() : m_key->fullId();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return (other.rightRef(comId.length()).compare(comId.rightRef(other.length()), Qt::CaseInsensitive) == 0);
#else
return (QStringView(other).right(comId.length()).compare(QStringView(comId).right(other.length()), Qt::CaseInsensitive) == 0);
#endif
}
bool
......
......@@ -20,7 +20,11 @@ KGpgRefNode::KGpgRefNode(KGpgExpandableNode *parent, const QString &keyid)
KGpgExpandableNode *pnd = parent;
do {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_selfsig = (pnd->getId().rightRef(keyid.length()).compare(keyid) == 0);
#else
m_selfsig = (QStringView(pnd->getId()).right(keyid.length()).compare(keyid) == 0);
#endif
if (m_selfsig)
m_keynode = pnd->toKeyNode();
else
......
......@@ -8,6 +8,7 @@
#include <KXmlGuiWindow>
#include <QUrl>
#include <QTextCodec>
class KToggleAction;
class QAction;
......
......@@ -137,7 +137,7 @@ KgpgKeyInfo::KgpgKeyInfo(KGpgKeyNode *node, KGpgItemModel *model, QWidget *paren
mainLayout->addWidget(buttonBox);
connect(m_owtrust, QOverload<int>::of(&QComboBox::activated), this, &KgpgKeyInfo::slotChangeTrust);
connect(m_photoid, QOverload<const QString &>::of(&QComboBox::activated), this, &KgpgKeyInfo::slotLoadPhoto);
connect(m_photoid, &QComboBox::textActivated, this, &KgpgKeyInfo::slotLoadPhoto);
connect(m_email, &KUrlLabel::leftClickedUrl, this, &KgpgKeyInfo::slotOpenUrl);
connect(keychange, &KGpgChangeKey::done, this, &KgpgKeyInfo::slotApplied);
connect(m_disable, &QCheckBox::toggled, this, &KgpgKeyInfo::slotDisableKey);
......
......@@ -292,7 +292,11 @@ KGpgFirstAssistant::next()
if (!defaultID.isEmpty()) {
for (int i = 0; i < CBdefault->count(); i++) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (CBdefault->itemData(i).toString().rightRef(defaultID.length()).compare(defaultID) == 0) {
#else
if (QStringView(CBdefault->itemData(i).toString()).right(defaultID.length()).compare(defaultID) == 0) {
#endif
CBdefault->setCurrentIndex(i);
break;
}
......
......@@ -363,7 +363,11 @@ KeyListProxyModelPrivate::nodeLessThan(const KGpgNode *left, const KGpgNode *rig
return (left->getCreation() < right->getCreation());
default:
Q_ASSERT(column == KEYCOLUMN_ID);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return (left->getId().rightRef(m_idLength).compare(right->getId().rightRef(m_idLength)) < 0);
#else
return (QStringView(left->getId()).right(m_idLength).compare(QStringView(right->getId()).right(m_idLength)) < 0);
#endif
}
}
......
......@@ -511,7 +511,11 @@ KGpgItemModel::refreshGroups()
bool
KGpgItemModel::isDefaultKey(const KGpgNode *node) const
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return !m_default.isEmpty() && (node->getId().rightRef(m_default.length()).compare(m_default) == 0);
#else
return !m_default.isEmpty() && (QStringView(node->getId()).right(m_default.length()).compare(m_default) == 0);
#endif
}
void
......
......@@ -57,7 +57,11 @@ KGpgTextOrFileTransaction::setText(const QString &text)
break;
const QString charset = QLatin1String("Charset: ");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (text.midRef(begin, charset.length()) == charset) {
#else
if (QStringView(text).mid(begin, charset.length()) == charset) {
#endif
QString cs = text.mid(begin + charset.length(), nextlf - begin - charset.length());
if (!getProcess()->setCodec(cs.toLatin1()))
qCDebug(KGPG_LOG_GENERAL) << "unsupported charset found in header" << cs;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment