File indexing completed on 2024-05-12 05:17:09

0001 // SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include "kidentitymanagementquick_export.h"
0007 
0008 #include <QHash>
0009 #include <QObject>
0010 
0011 class QModelIndex;
0012 
0013 namespace KIdentityManagementCore
0014 {
0015 class Identity;
0016 }
0017 namespace KIdentityManagementQuick
0018 {
0019 
0020 class KeyUseTypes
0021 {
0022     Q_GADGET
0023 
0024 public:
0025     enum class KeyUse { KeySigningUse, KeyEncryptionUse };
0026     Q_ENUM(KeyUse)
0027 };
0028 
0029 /**
0030  * @brief This interface defines the roles and rolenames that are expected
0031  * in the QtQuick Cryptography editor.
0032  */
0033 class KIDENTITYMANAGEMENTQUICK_EXPORT KeyListModelInterface
0034 {
0035 public:
0036     virtual ~KeyListModelInterface(){};
0037     enum Roles { KeyIdentifierRole = Qt::UserRole + 1, KeyByteArrayRole };
0038 
0039     static QHash<int, QByteArray> roleNames()
0040     {
0041         return {{KeyIdentifierRole, "keyIdentifier"}, {KeyByteArrayRole, "keyByteArray"}};
0042     }
0043 
0044     virtual QModelIndex indexForIdentity(const KIdentityManagementCore::Identity &identity, const KeyUseTypes::KeyUse keyUse) const = 0;
0045 };
0046 }
0047 
0048 Q_DECLARE_INTERFACE(KIdentityManagementQuick::KeyListModelInterface, "KeyListModelInterface")