KPkPass

field.h
1 /*
2  SPDX-FileCopyrightText: 2017-2018 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "kpkpass_export.h"
10 
11 #include <QMetaType>
12 #include <QString>
13 
14 #include <memory>
15 
16 class QJsonObject;
17 
18 namespace KPkPass
19 {
20 class Pass;
21 class PassPrivate;
22 class FieldPrivate;
23 class FieldTest;
24 
25 /** Field element in a KPkPass::Pass.
26  * @see https://developer.apple.com/library/content/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/FieldDictionary.html
27  */
28 class KPKPASS_EXPORT Field
29 {
30  Q_GADGET
31  Q_PROPERTY(QString key READ key CONSTANT)
32  Q_PROPERTY(QString label READ label CONSTANT)
33  Q_PROPERTY(QVariant value READ value CONSTANT)
34  Q_PROPERTY(QString valueDisplayString READ valueDisplayString CONSTANT)
35  Q_PROPERTY(QString changeMessage READ changeMessage CONSTANT)
36  Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment CONSTANT)
37 
38 public:
39  Field();
40  Field(const Field &);
41  Field(Field &&);
42  ~Field();
43  Field &operator=(const Field &);
44 
45  /** Field key, unique in the pass but not meant for display. */
46  Q_REQUIRED_RESULT QString key() const;
47  /** Localized label for display describing this field. */
48  Q_REQUIRED_RESULT QString label() const;
49 
50  /** Value of this field.
51  * This can either be a localized string (most common), a date/time value or a number.
52  * Use this for data extraction, prefer valueDisplayString() for displaying data.
53  */
54  Q_REQUIRED_RESULT QVariant value() const;
55  /** Value of this field, as a localized string for display.
56  * Use this rather than value() for display.
57  */
58  Q_REQUIRED_RESULT QString valueDisplayString() const;
59 
60  /** The localized change message for this value. */
61  Q_REQUIRED_RESULT QString changeMessage() const;
62 
63  /** Text alignment. */
64  Q_REQUIRED_RESULT Qt::Alignment textAlignment() const;
65 
66 private:
67  friend class PassPrivate;
68  friend class FieldTest;
69  explicit Field(const QJsonObject &obj, const Pass *pass);
70 
71  std::shared_ptr<FieldPrivate> d;
72 };
73 
74 }
typedef Alignment
Base class for a pkpass file.
Definition: pass.h:34
Field element in a KPkPass::Pass.
Definition: field.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 03:55:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.