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

Modernize code using auto/using/std::make_unique

parent 2fe52fa1
Pipeline #39448 passed with stage
in 10 minutes and 19 seconds
......@@ -25,7 +25,7 @@ private Q_SLOTS:
QTest::newRow("empty") << QByteArray() << ExtractorInput::Unknown;
QTest::newRow("html") << QByteArray("<html>") << ExtractorInput::Html;
QTest::newRow("html padded") << QByteArray(" <!DOCTYPE html>") << ExtractorInput::Html;
QTest::newRow("json") << QByteArray("{\"@type\": \"Foo\"}") << ExtractorInput::JsonLd;
QTest::newRow("json") << QByteArray(R"({"@type": "Foo"})") << ExtractorInput::JsonLd;
QTest::newRow("json padded") << QByteArray(" []") << ExtractorInput::JsonLd;
QTest::newRow("pkpass") << QByteArray("PK\x03\x04") << ExtractorInput::PkPass;
QTest::newRow("pdf") << QByteArray("%PDF") << ExtractorInput::Pdf;
......
......@@ -178,7 +178,7 @@ private Q_SLOTS:
auto data = datas.at(0);
QVERIFY(data.canConvert<Flight>());
Flight flight = data.value<Flight>();
auto flight = data.value<Flight>();
QCOMPARE(flight.flightNumber(), QLatin1String("1234"));
QCOMPARE(flight.departureAirport().iataCode(), QLatin1String("TXL"));
QCOMPARE(flight.departureAirport().name(), QLatin1String("Berlin Tegel"));
......
......@@ -31,7 +31,7 @@ template <typename T>
struct base_type {
template <typename U> static typename U::super_type test(typename U::super_type*);
template <typename U> static T test(...);
typedef decltype(test<T>(nullptr)) type;
using type = decltype(test<T>(nullptr));
static constexpr const bool is_valid = !std::is_same<type, T>::value;
};
......
......@@ -50,6 +50,7 @@
#include <QProcess>
#include <cstring>
#include <memory>
using namespace KItinerary;
......@@ -311,7 +312,7 @@ void ExtractorEnginePrivate::openDocument()
m_data.clear();
break;
case ExtractorInput::Email:
m_ownedMimeContent.reset(new KMime::Message);
m_ownedMimeContent = std::make_unique<KMime::Message>();
m_ownedMimeContent->setContent(KMime::CRLFtoLF(m_data));
m_ownedMimeContent->parse();
m_data.clear();
......
......@@ -20,6 +20,7 @@
#include <QJsonObject>
#include <QString>
#include <QUuid>
#include <memory>
using namespace KItinerary;
......@@ -67,9 +68,9 @@ void File::setFileName(const QString &fileName)
bool File::open(File::OpenMode mode) const
{
if (d->device) {
d->zipFile.reset(new KZip(d->device));
d->zipFile = std::make_unique<KZip>(d->device);
} else {
d->zipFile.reset(new KZip(d->fileName));
d->zipFile = std::make_unique<KZip>(d->fileName);
}
if (!d->zipFile->open(mode == File::Write ? QIODevice::WriteOnly : QIODevice::ReadOnly)) {
......
......@@ -343,7 +343,7 @@ static QJsonValue toJsonValue(const QVariant &v)
}
if (v.canConvert<QVariantList>()) {
QSequentialIterable iterable = v.value<QSequentialIterable>();
auto iterable = v.value<QSequentialIterable>();
if (iterable.size() == 0) {
return {};
}
......
......@@ -16,7 +16,7 @@
namespace OSM {
/** OSM element identifier. */
typedef int64_t Id;
using Id = int64_t;
/** Coordinate, stored as 1e7 * degree to avoid floating point precision issues,
* and offset to unsigned values to make the z-order curve work.
......
......@@ -12,6 +12,8 @@
#ifdef HAVE_POPPLER
#include <GlobalParams.h>
#include <memory>
using namespace KItinerary;
static std::unique_ptr<GlobalParams> s_globalParams;
......@@ -19,7 +21,7 @@ static std::unique_ptr<GlobalParams> s_globalParams;
PopplerGlobalParams::PopplerGlobalParams()
{
if (!s_globalParams) {
s_globalParams.reset(new GlobalParams);
s_globalParams = std::make_unique<GlobalParams>();
}
#if KPOPPLER_VERSION <= QT_VERSION_CHECK(0, 82, 0)
......
Markdown is supported
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