KPkPass

field.h
1/*
2 SPDX-FileCopyrightText: 2017-2018 Volker Krause <vkrause@kde.org>
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
16class QJsonObject;
17
18namespace KPkPass
19{
20class Pass;
21class PassPrivate;
22class FieldPrivate;
23class 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 */
28class 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 Q_PROPERTY(QString currencyCode READ currencyCode CONSTANT)
38
39public:
40 Field();
41 Field(const Field &);
42 Field(Field &&);
43 ~Field();
44 Field &operator=(const Field &);
45
46 /** Field key, unique in the pass but not meant for display. */
47 [[nodiscard]] QString key() const;
48 /** Localized label for display describing this field. */
49 [[nodiscard]] QString label() const;
50
51 /** Value of this field.
52 * This can either be a localized string (most common), a date/time value or a number.
53 * Use this for data extraction, prefer valueDisplayString() for displaying data.
54 */
55 [[nodiscard]] QVariant value() const;
56 /** Value of this field, as a localized string for display.
57 * Use this rather than value() for display.
58 */
59 [[nodiscard]] QString valueDisplayString() const;
60
61 /** The localized change message for this value. */
62 [[nodiscard]] QString changeMessage() const;
63
64 /** Text alignment. */
65 [[nodiscard]] Qt::Alignment textAlignment() const;
66
67 /** Currency code. */
68 [[nodiscard]] QString currencyCode() const;
69
70private:
71 friend class PassPrivate;
72 friend class FieldTest;
73 explicit Field(const QJsonObject &obj, const Pass *pass);
74
75 std::shared_ptr<FieldPrivate> d;
76};
77
78}
Field element in a KPkPass::Pass.
Definition field.h:29
Base class for a pkpass file.
Definition pass.h:35
typedef Alignment
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.