File indexing completed on 2024-05-12 05:21:34
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QHash> 0010 #include <QImage> 0011 #include <QJsonObject> 0012 #include <QString> 0013 0014 #include <memory> 0015 #include <unordered_map> 0016 0017 class KZip; 0018 class QIODevice; 0019 0020 namespace KPkPass 0021 { 0022 struct ImageCacheKey { 0023 QString name; 0024 unsigned int dpr; 0025 bool operator==(const ImageCacheKey &) const = default; 0026 }; 0027 } 0028 0029 template<> 0030 struct std::hash<KPkPass::ImageCacheKey> { 0031 std::size_t operator()(const KPkPass::ImageCacheKey &key) const noexcept 0032 { 0033 return std::hash<QString>{}(key.name) ^ std::hash<unsigned int>{}(key.dpr); 0034 } 0035 }; 0036 0037 namespace KPkPass 0038 { 0039 class PassPrivate 0040 { 0041 public: 0042 /** The pass data structure of the pass.json file. */ 0043 QJsonObject passData() const; 0044 /** Localized message for the given key. */ 0045 QString message(const QString &key) const; 0046 0047 void parse(); 0048 bool parseMessages(const QString &lang); 0049 0050 QList<Field> fields(QLatin1StringView fieldType, const Pass *q) const; 0051 0052 static Pass *fromData(std::unique_ptr<QIODevice> device, QObject *parent); 0053 0054 std::unique_ptr<QIODevice> buffer; 0055 std::unique_ptr<KZip> zip; 0056 QJsonObject passObj; 0057 QHash<QString, QString> messages; 0058 Pass::Type passType; 0059 std::unordered_map<ImageCacheKey, QImage> m_images; 0060 }; 0061 }