File indexing completed on 2024-05-12 05:21:34
0001 /* 0002 SPDX-FileCopyrightText: 2017-2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "kpkpass_export.h" 0010 0011 #include <QMetaType> 0012 #include <QString> 0013 0014 #include <memory> 0015 0016 class QJsonObject; 0017 0018 namespace KPkPass 0019 { 0020 class Pass; 0021 class PassPrivate; 0022 class FieldPrivate; 0023 class FieldTest; 0024 0025 /** Field element in a KPkPass::Pass. 0026 * @see https://developer.apple.com/library/content/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/FieldDictionary.html 0027 */ 0028 class KPKPASS_EXPORT Field 0029 { 0030 Q_GADGET 0031 Q_PROPERTY(QString key READ key CONSTANT) 0032 Q_PROPERTY(QString label READ label CONSTANT) 0033 Q_PROPERTY(QVariant value READ value CONSTANT) 0034 Q_PROPERTY(QString valueDisplayString READ valueDisplayString CONSTANT) 0035 Q_PROPERTY(QString changeMessage READ changeMessage CONSTANT) 0036 Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment CONSTANT) 0037 0038 public: 0039 Field(); 0040 Field(const Field &); 0041 Field(Field &&); 0042 ~Field(); 0043 Field &operator=(const Field &); 0044 0045 /** Field key, unique in the pass but not meant for display. */ 0046 [[nodiscard]] QString key() const; 0047 /** Localized label for display describing this field. */ 0048 [[nodiscard]] QString label() const; 0049 0050 /** Value of this field. 0051 * This can either be a localized string (most common), a date/time value or a number. 0052 * Use this for data extraction, prefer valueDisplayString() for displaying data. 0053 */ 0054 [[nodiscard]] QVariant value() const; 0055 /** Value of this field, as a localized string for display. 0056 * Use this rather than value() for display. 0057 */ 0058 [[nodiscard]] QString valueDisplayString() const; 0059 0060 /** The localized change message for this value. */ 0061 [[nodiscard]] QString changeMessage() const; 0062 0063 /** Text alignment. */ 0064 [[nodiscard]] Qt::Alignment textAlignment() const; 0065 0066 private: 0067 friend class PassPrivate; 0068 friend class FieldTest; 0069 explicit Field(const QJsonObject &obj, const Pass *pass); 0070 0071 std::shared_ptr<FieldPrivate> d; 0072 }; 0073 0074 }