Commit 22e3ff03 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some compile qt6 error

parent 562644fe
Pipeline #180681 passed with stage
in 15 minutes and 10 seconds
......@@ -21,6 +21,7 @@ class QButtonGroup;
class QCheckBox;
class QCsvModel;
class QTableView;
class QTextCodec;
class CSVImportDialog : public QDialog
{
......
......@@ -9,6 +9,7 @@
#include <QAbstractTableModel>
class QIODevice;
class CsvParser;
class QTextCodec;
class QCsvModel : public QAbstractTableModel
{
Q_OBJECT
......
......@@ -7,6 +7,7 @@
#include "qcsvreader.h"
#include <KLocalizedString>
#include <QIODevice>
#include <QStringList>
#include <QTextCodec>
#include <QTextStream>
......
......@@ -9,6 +9,7 @@
#include <QObject>
#include <memory>
class QTextCodec;
class QIODevice;
......
......@@ -200,7 +200,11 @@ void GMXImportExportPluginInterface::doExport(QFile *fp, const KContacts::Addres
}
QTextStream t(fp);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
t.setCodec("ISO 8859-1");
#else
t.setEncoding(QStringConverter::Latin1);
#endif
using AddresseeMap = QMap<int, const KContacts::Addressee *>;
AddresseeMap addresseeMap;
......@@ -438,7 +442,11 @@ void GMXImportExportPluginInterface::importGMX()
QDateTime dt;
QTextStream gmxStream(&file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
gmxStream.setCodec("ISO 8859-1");
#else
gmxStream.setEncoding(QStringConverter::Latin1);
#endif
QString line;
QString line2;
line = gmxStream.readLine();
......
......@@ -83,7 +83,11 @@ void LDifImportExportPluginInterface::importLdifFile(const QString &fileName)
}
QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("ISO 8859-1");
#else
stream.setEncoding(QStringConverter::Latin1);
#endif
const QString wholeFile = stream.readAll();
const QDateTime dtDefault = QFileInfo(file).lastModified();
......
......@@ -64,15 +64,35 @@ void GnuPGWKSMessagePart::parseContent(KMime::Content *node)
// sections 4.3 and 4.4
for (const auto &line : lines) {
if (line.startsWith(QLatin1String("type:"))) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mType = stringToType(line.midRef(sizeof("type:") - 1).trimmed());
#else
mType = stringToType(QStringView(line).mid(sizeof("type:") - 1).trimmed());
#endif
} else if (line.startsWith(QLatin1String("sender:"))) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mSender = line.midRef(sizeof("sender:") - 1).trimmed().toString();
#else
mSender = QStringView(line).mid(sizeof("sender:") - 1).trimmed().toString();
#endif
} else if (line.startsWith(QLatin1String("address:"))) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mAddress = line.midRef(sizeof("address:") - 1).trimmed().toString();
#else
mAddress = QStringView(line).mid(sizeof("address:") - 1).trimmed().toString();
#endif
} else if (line.startsWith(QLatin1String("fingerprint:"))) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mFingerprint = line.midRef(sizeof("fingerprint:") - 1).trimmed().toString();
#else
mFingerprint = QStringView(line).mid(sizeof("fingerprint:") - 1).trimmed().toString();
#endif
} else if (line.startsWith(QLatin1String("nonce:"))) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
mNonce = line.midRef(sizeof("nonce:") - 1).trimmed().toString();
#else
mNonce = QStringView(line).mid(sizeof("nonce:") - 1).trimmed().toString();
#endif
}
}
}
......@@ -69,14 +69,26 @@ bool ApplicationPGPKeyFormatter::render(const MimeTreeParser::MessagePartPtr &ms
GrantleeTheme::Engine engine;
engine.localizer()->setApplicationDomain(QByteArrayLiteral("messageviewer_application_gnupgwks_plugin"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>::create();
#else
auto loader = QSharedPointer<KTextTemplate::FileSystemTemplateLoader>::create();
#endif
loader->setTemplateDirs({QStringLiteral(":/")});
engine.addTemplateLoader(loader);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Grantlee::Template tpl = engine.loadByName(QStringLiteral("pgpkeymessagepart.html"));
#else
KTextTemplate::Template tpl = engine.loadByName(QStringLiteral("pgpkeymessagepart.html"));
#endif
if (tpl->error()) {
qWarning() << tpl->errorString();
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Grantlee::Context ctx;
#else
KTextTemplate::Context ctx;
#endif
ctx.setLocalizer(engine.localizer());
QObject block;
......@@ -106,7 +118,11 @@ bool ApplicationPGPKeyFormatter::render(const MimeTreeParser::MessagePartPtr &ms
ctx.insert(QStringLiteral("block"), &block);
ctx.insert(QStringLiteral("style"), &style);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Grantlee::OutputStream s(htmlWriter->stream());
#else
KTextTemplate::OutputStream s(htmlWriter->stream());
#endif
tpl->render(&s, &ctx);
return true;
}
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