File indexing completed on 2025-01-05 04:55:46

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     models/useridlistmodel.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB
0006     SPDX-FileCopyrightText: 2016 Andre Heinecke <aheinecke@gnupg.org>
0007     SPDX-FileCopyrightText: 2021 g10 Code GmbH
0008     SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0009 
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011 */
0012 
0013 #pragma once
0014 
0015 #include "kleo_export.h"
0016 
0017 #include <QAbstractItemModel>
0018 
0019 #include <gpgme++/key.h> // since Signature is nested in UserID...
0020 
0021 #include <memory>
0022 
0023 class UIDModelItem;
0024 
0025 namespace Kleo
0026 {
0027 
0028 class KLEO_EXPORT UserIDListModel : public QAbstractItemModel
0029 {
0030     Q_OBJECT
0031 public:
0032     enum class Column {
0033         Id,
0034         Name,
0035         Email,
0036         ValidFrom,
0037         ValidUntil,
0038         Status,
0039         Exportable,
0040         Tags,
0041         TrustSignatureDomain,
0042     };
0043 
0044     explicit UserIDListModel(QObject *parent = nullptr);
0045     ~UserIDListModel() override;
0046 
0047     GpgME::Key key() const;
0048 
0049 public:
0050     GpgME::UserID userID(const QModelIndex &index) const;
0051     QList<GpgME::UserID> userIDs(const QModelIndexList &indexes) const;
0052     GpgME::UserID::Signature signature(const QModelIndex &index) const;
0053     QList<GpgME::UserID::Signature> signatures(const QModelIndexList &indexes) const;
0054     void enableRemarks(bool value);
0055 
0056 public Q_SLOTS:
0057     void setKey(const GpgME::Key &key);
0058 
0059 public:
0060     int columnCount(const QModelIndex &pindex = QModelIndex()) const override;
0061     int rowCount(const QModelIndex &pindex = QModelIndex()) const override;
0062     QVariant headerData(int section, Qt::Orientation o, int role = Qt::DisplayRole) const override;
0063     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0064 
0065     QModelIndex index(int row, int col, const QModelIndex &parent = QModelIndex()) const override;
0066     QModelIndex parent(const QModelIndex &index) const override;
0067 
0068 private:
0069     GpgME::Key mKey;
0070     bool mRemarksEnabled = false;
0071     std::unique_ptr<UIDModelItem> mRootItem;
0072 };
0073 
0074 }