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
38public:
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 [[nodiscard]] QString key() const;
47 /** Localized label for display describing this field. */
48 [[nodiscard]] 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 [[nodiscard]] QVariant value() const;
55 /** Value of this field, as a localized string for display.
56 * Use this rather than value() for display.
57 */
58 [[nodiscard]] QString valueDisplayString() const;
59
60 /** The localized change message for this value. */
61 [[nodiscard]] QString changeMessage() const;
62
63 /** Text alignment. */
64 [[nodiscard]] Qt::Alignment textAlignment() const;
65
66private:
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}
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 Fri Nov 8 2024 12:07:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.