Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
d852f500
Commit
d852f500
authored
Nov 04, 2020
by
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
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/extractorinputtest.cpp
View file @
d852f500
...
...
@@ -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
;
...
...
autotests/jsonlddocumenttest.cpp
View file @
d852f500
...
...
@@ -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"
));
...
...
src/datatypes/datatypes_p.h
View file @
d852f500
...
...
@@ -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
(...);
type
def
decltype
(
test
<
T
>
(
nullptr
))
type
;
using
type
=
decltype
(
test
<
T
>
(
nullptr
));
static
constexpr
const
bool
is_valid
=
!
std
::
is_same
<
type
,
T
>::
value
;
};
...
...
src/extractorengine.cpp
View file @
d852f500
...
...
@@ -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
();
...
...
src/file.cpp
View file @
d852f500
...
...
@@ -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
))
{
...
...
src/jsonlddocument.cpp
View file @
d852f500
...
...
@@ -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
{};
}
...
...
src/osm/datatypes.h
View file @
d852f500
...
...
@@ -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.
...
...
src/pdf/popplerglobalparams.cpp
View file @
d852f500
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment