Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KPkPass
Commits
cd037f03
Commit
cd037f03
authored
Mar 10, 2018
by
Volker Krause
Browse files
Add support for more top-level keys
parent
0c13720c
Changes
3
Hide whitespace changes
Inline
Side-by-side
autotests/pkpasstest.cpp
View file @
cd037f03
...
...
@@ -36,11 +36,18 @@ private slots:
QVERIFY
(
pass
);
QCOMPARE
(
pass
->
type
(),
KPkPass
::
Pass
::
BoardingPass
);
QCOMPARE
(
pass
->
serialNumber
(),
QLatin1String
(
"1234"
));
QCOMPARE
(
pass
->
description
(),
QLatin1String
(
"description"
));
QCOMPARE
(
pass
->
organizationName
(),
QLatin1String
(
"KDE"
));
QCOMPARE
(
pass
->
logoText
(),
QLatin1String
(
"Boarding Pass"
));
QCOMPARE
(
pass
->
backgroundColor
(),
QColor
(
61
,
174
,
233
));
QCOMPARE
(
pass
->
relevantDate
(),
QDateTime
(
QDate
(
2017
,
9
,
17
),
QTime
(
0
,
4
,
0
),
Qt
::
UTC
));
QCOMPARE
(
pass
->
fields
().
size
(),
12
);
QCOMPARE
(
pass
->
expirationDate
(),
QDateTime
(
QDate
(
2017
,
9
,
18
),
QTime
(
0
,
0
,
36
),
Qt
::
UTC
));
QCOMPARE
(
pass
->
isVoided
(),
false
);
QCOMPARE
(
pass
->
groupingIdentifier
(),
QLatin1String
(
""
));
QCOMPARE
(
pass
->
fields
().
size
(),
12
);
auto
headers
=
pass
->
headerFields
();
QCOMPARE
(
headers
.
size
(),
2
);
auto
field
=
headers
.
at
(
0
);
...
...
src/pkpass/pass.cpp
View file @
cd037f03
...
...
@@ -241,6 +241,21 @@ Pass::Pass(Type passType, QObject *parent)
Pass
::~
Pass
()
=
default
;
Pass
::
Type
Pass
::
type
()
const
{
return
d
->
passType
;
}
QString
Pass
::
description
()
const
{
return
d
->
passObj
.
value
(
QLatin1String
(
"description"
)).
toString
();
}
QString
Pass
::
organizationName
()
const
{
return
d
->
passObj
.
value
(
QLatin1String
(
"organizationName"
)).
toString
();
}
QString
Pass
::
passTypeIdentifier
()
const
{
return
d
->
passObj
.
value
(
QLatin1String
(
"passTypeIdentifier"
)).
toString
();
...
...
@@ -251,9 +266,19 @@ QString Pass::serialNumber() const
return
d
->
passObj
.
value
(
QLatin1String
(
"serialNumber"
)).
toString
();
}
Pass
::
Type
Pass
::
typ
e
()
const
QDateTime
Pass
::
expirationDat
e
()
const
{
return
d
->
passType
;
return
QDateTime
::
fromString
(
d
->
passObj
.
value
(
QLatin1String
(
"expirationDate"
)).
toString
(),
Qt
::
ISODate
);
}
bool
Pass
::
isVoided
()
const
{
return
d
->
passObj
.
value
(
QLatin1String
(
"voided"
)).
toString
()
==
QLatin1String
(
"true"
);
}
QDateTime
Pass
::
relevantDate
()
const
{
return
QDateTime
::
fromString
(
d
->
passObj
.
value
(
QLatin1String
(
"relevantDate"
)).
toString
(),
Qt
::
ISODate
);
}
static
QColor
parseColor
(
const
QString
&
s
)
...
...
@@ -277,6 +302,11 @@ QColor Pass::foregroundColor() const
return
parseColor
(
d
->
passObj
.
value
(
QLatin1String
(
"foregroundColor"
)).
toString
());
}
QString
Pass
::
groupingIdentifier
()
const
{
return
d
->
passObj
.
value
(
QLatin1String
(
"groupingIdentifier"
)).
toString
();
}
QColor
Pass
::
labelColor
()
const
{
const
auto
c
=
parseColor
(
d
->
passObj
.
value
(
QLatin1String
(
"labelColor"
)).
toString
());
...
...
@@ -309,11 +339,6 @@ QImage Pass::logo(unsigned int devicePixelRatio) const
return
img
;
}
QDateTime
Pass
::
relevantDate
()
const
{
return
QDateTime
::
fromString
(
d
->
passObj
.
value
(
QLatin1String
(
"relevantDate"
)).
toString
(),
Qt
::
ISODate
);
}
QString
Pass
::
authenticationToken
()
const
{
return
d
->
passObj
.
value
(
QLatin1String
(
"authenticationToken"
)).
toString
();
...
...
src/pkpass/pass.h
View file @
cd037f03
...
...
@@ -49,27 +49,35 @@ class PassPrivate;
class
KPKPASS_EXPORT
Pass
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
Type
type
READ
type
CONSTANT
)
Q_PROPERTY
(
QString
description
READ
description
CONSTANT
)
Q_PROPERTY
(
QString
organizationName
READ
organizationName
CONSTANT
)
Q_PROPERTY
(
QString
passTypeIdentifier
READ
passTypeIdentifier
CONSTANT
)
Q_PROPERTY
(
QString
serialNumber
READ
serialNumber
CONSTANT
)
Q_PROPERTY
(
Type
type
READ
type
CONSTANT
)
Q_PROPERTY
(
QDateTime
expirationDate
READ
expirationDate
CONSTANT
)
Q_PROPERTY
(
bool
isVoided
READ
isVoided
CONSTANT
)
Q_PROPERTY
(
QDateTime
relevantDate
READ
relevantDate
CONSTANT
)
Q_PROPERTY
(
QColor
backgroundColor
READ
backgroundColor
CONSTANT
)
Q_PROPERTY
(
QColor
foregroundColor
READ
foregroundColor
CONSTANT
)
Q_PROPERTY
(
QString
groupingIdentifier
READ
groupingIdentifier
CONSTANT
)
Q_PROPERTY
(
QColor
labelColor
READ
labelColor
CONSTANT
)
Q_PROPERTY
(
QString
logoText
READ
logoText
CONSTANT
)
Q_PROPERTY
(
QDateTime
relevantDate
READ
relevantDate
CONSTANT
)
Q_PROPERTY
(
QString
authenticationToken
READ
authenticationToken
CONSTANT
)
Q_PROPERTY
(
QString
webServiceUrl
READ
webServiceUrl
CONSTANT
)
// needs to be QVariantList just for QML (Grantlee would also work with QVector<Field>
Q_PROPERTY
(
QVariantList
barcodes
READ
barcodesVariant
CONSTANT
)
Q_PROPERTY
(
QVariantList
auxiliaryFields
READ
auxiliaryFieldsVariant
CONSTANT
)
Q_PROPERTY
(
QVariantList
backFields
READ
backFieldsVariant
CONSTANT
)
Q_PROPERTY
(
QVariantList
headerFields
READ
headerFieldsVariant
CONSTANT
)
Q_PROPERTY
(
QVariantList
primaryFields
READ
primaryFieldsVariant
CONSTANT
)
Q_PROPERTY
(
QVariantList
secondaryFields
READ
secondaryFieldsVariant
CONSTANT
)
Q_PROPERTY
(
QVariantList
barcodes
READ
barcodesVariant
CONSTANT
)
public:
virtual
~
Pass
();
...
...
@@ -84,16 +92,32 @@ public:
Q_ENUM
(
Type
)
Type
type
()
const
;
// standard keys
QString
description
()
const
;
QString
organizationName
()
const
;
QString
passTypeIdentifier
()
const
;
QString
serialNumber
()
const
;
// expiration keys
QDateTime
expirationDate
()
const
;
bool
isVoided
()
const
;
// relevance keys
// TODO locations, maxDistance
QDateTime
relevantDate
()
const
;
// visual appearance keys
/** Returns all barcodes defined in the pass. */
QVector
<
Barcode
>
barcodes
()
const
;
QColor
backgroundColor
()
const
;
QColor
foregroundColor
()
const
;
QString
groupingIdentifier
()
const
;
QColor
labelColor
()
const
;
QString
logoText
()
const
;
QImage
logo
(
unsigned
int
devicePixelRatio
=
1
)
const
;
QDateTime
relevantDate
()
const
;
// web service keys
QString
authenticationToken
()
const
;
QString
webServiceUrl
()
const
;
...
...
@@ -108,9 +132,6 @@ public:
/** Returns all fields found in this pass. */
QVector
<
Field
>
fields
()
const
;
/** Returns all barcodes defined in the pass. */
QVector
<
Barcode
>
barcodes
()
const
;
/** Create a appropriate sub-class based on the pkpass file type. */
static
Pass
*
fromData
(
const
QByteArray
&
data
,
QObject
*
parent
=
nullptr
);
/** Create a appropriate sub-class based on the pkpass file type. */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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