KPkPass

pass.h
1 /*
2  SPDX-FileCopyrightText: 2017-2018 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KPKPASS_PASS_H
8 #define KPKPASS_PASS_H
9 
10 #include "kpkpass_export.h"
11 #include "field.h"
12 
13 #include <QObject>
14 #include <QVector>
15 
16 #include <memory>
17 
18 class QByteArray;
19 class QColor;
20 class QDateTime;
21 class QString;
22 class QUrl;
23 class QVariant;
24 
25 namespace KPkPass {
26 
27 class Barcode;
28 class Location;
29 class PassPrivate;
30 
35 class KPKPASS_EXPORT Pass : public QObject
36 {
37  Q_OBJECT
38  Q_PROPERTY(Type type READ type CONSTANT)
39 
40  Q_PROPERTY(QString description READ description CONSTANT)
41  Q_PROPERTY(QString organizationName READ organizationName CONSTANT)
42  Q_PROPERTY(QString passTypeIdentifier READ passTypeIdentifier CONSTANT)
43  Q_PROPERTY(QString serialNumber READ serialNumber CONSTANT)
44 
45  Q_PROPERTY(QDateTime expirationDate READ expirationDate CONSTANT)
46  Q_PROPERTY(bool isVoided READ isVoided CONSTANT)
47 
48  Q_PROPERTY(QDateTime relevantDate READ relevantDate CONSTANT)
49 
50  Q_PROPERTY(QColor backgroundColor READ backgroundColor CONSTANT)
51  Q_PROPERTY(QColor foregroundColor READ foregroundColor CONSTANT)
52  Q_PROPERTY(QString groupingIdentifier READ groupingIdentifier CONSTANT)
53  Q_PROPERTY(QColor labelColor READ labelColor CONSTANT)
54  Q_PROPERTY(QString logoText READ logoText CONSTANT)
55 
56  // needs to be QVariantList just for QML (Grantlee would also work with QVector<Field>
57  Q_PROPERTY(QVariantList barcodes READ barcodesVariant CONSTANT)
58  Q_PROPERTY(QVariantList auxiliaryFields READ auxiliaryFieldsVariant CONSTANT)
59  Q_PROPERTY(QVariantList backFields READ backFieldsVariant CONSTANT)
60  Q_PROPERTY(QVariantList headerFields READ headerFieldsVariant CONSTANT)
61  Q_PROPERTY(QVariantList primaryFields READ primaryFieldsVariant CONSTANT)
62  Q_PROPERTY(QVariantList secondaryFields READ secondaryFieldsVariant CONSTANT)
63  Q_PROPERTY(QVariantList locations READ locationsVariant CONSTANT)
64  Q_PROPERTY(QVariantMap field READ fieldsVariantMap CONSTANT)
65 
66 public:
67  virtual ~Pass();
68 
70  enum Type {
72  Coupon,
73  EventTicket,
74  Generic,
75  StoreCard
76  };
77  Q_ENUM(Type)
78  Q_REQUIRED_RESULT Type type() const;
79 
80  // standard keys
81  Q_REQUIRED_RESULT QString description() const;
82  Q_REQUIRED_RESULT QString organizationName() const;
83  Q_REQUIRED_RESULT QString passTypeIdentifier() const;
84  Q_REQUIRED_RESULT QString serialNumber() const;
85 
86  // expiration keys
87  Q_REQUIRED_RESULT QDateTime expirationDate() const;
88  Q_REQUIRED_RESULT bool isVoided() const;
89 
90  // relevance keys
92  Q_REQUIRED_RESULT QVector<Location> locations() const;
94  Q_REQUIRED_RESULT int maximumDistance() const;
95  Q_REQUIRED_RESULT QDateTime relevantDate() const;
96 
97  // visual appearance keys
99  Q_REQUIRED_RESULT QVector<Barcode> barcodes() const;
100  Q_REQUIRED_RESULT QColor backgroundColor() const;
101  Q_REQUIRED_RESULT QColor foregroundColor() const;
102  Q_REQUIRED_RESULT QString groupingIdentifier() const;
103  Q_REQUIRED_RESULT QColor labelColor() const;
104  Q_REQUIRED_RESULT QString logoText() const;
105 
110  QImage image(const QString &baseName, unsigned int devicePixelRatio = 1) const;
112  QImage icon(unsigned int devicePixelRatio = 1) const;
114  QImage logo(unsigned int devicePixelRatio = 1) const;
116  QImage strip(unsigned int devicePixelRatio = 1) const;
118  QImage background(unsigned int devicePixelRatio = 1) const;
120  QImage footer(unsigned int devicePixelRatio = 1) const;
122  QImage thumbnail(unsigned int devicePixelRatio = 1) const;
123 
124  // web service keys
125  Q_REQUIRED_RESULT QString authenticationToken() const;
126  Q_REQUIRED_RESULT QUrl webServiceUrl() const;
130  Q_REQUIRED_RESULT QUrl passUpdateUrl() const;
131 
132  QVector<Field> auxiliaryFields() const;
133  QVector<Field> backFields() const;
134  QVector<Field> headerFields() const;
135  QVector<Field> primaryFields() const;
136  QVector<Field> secondaryFields() const;
137 
139  Field field(const QString &key) const;
141  QVector<Field> fields() const;
142 
144  static Pass *fromData(const QByteArray &data, QObject *parent = nullptr);
146  static Pass *fromFile(const QString &fileName, QObject *parent = nullptr);
147 
148 protected:
150  friend class Barcode;
151  friend class Field;
152  friend class PassPrivate;
153  explicit Pass (Type passType, QObject *parent = nullptr);
154  std::unique_ptr<PassPrivate> d;
156 
157 private:
158  QVariantList auxiliaryFieldsVariant() const;
159  QVariantList backFieldsVariant() const;
160  QVariantList headerFieldsVariant() const;
161  QVariantList primaryFieldsVariant() const;
162  QVariantList secondaryFieldsVariant() const;
163  QVariantList barcodesVariant() const;
164  QVariantList locationsVariant() const;
165  QVariantMap fieldsVariantMap() const;
166 };
167 
168 }
169 
170 #endif // KPKPASS_PASS_H
Field element in a KPkPass::Pass.
Definition: field.h:28
A pass barcode element.
Definition: barcode.h:27
Base class for a pkpass file.
Definition: pass.h:35
Boarding pass.
Definition: boardingpass.h:15
Type
Type of the pass.
Definition: pass.h:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 23:24:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.