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

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     models/subkeylistmodel.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "kleo_export.h"
0013 
0014 #include <QAbstractTableModel>
0015 
0016 #include <vector>
0017 
0018 namespace GpgME
0019 {
0020 class Key;
0021 class Subkey;
0022 }
0023 
0024 namespace Kleo
0025 {
0026 
0027 class KLEO_EXPORT SubkeyListModel : public QAbstractTableModel
0028 {
0029     Q_OBJECT
0030 public:
0031     explicit SubkeyListModel(QObject *parent = nullptr);
0032     ~SubkeyListModel() override;
0033 
0034     GpgME::Key key() const;
0035 
0036     enum Columns {
0037         ID,
0038         Type,
0039         ValidFrom,
0040         ValidUntil,
0041         Status,
0042         Strength,
0043         Usage,
0044 
0045         NumColumns,
0046         Icon = ID // which column shall the icon be displayed in?
0047     };
0048 
0049     GpgME::Subkey subkey(const QModelIndex &idx) const;
0050     std::vector<GpgME::Subkey> subkeys(const QList<QModelIndex> &indexes) const;
0051 
0052     using QAbstractTableModel::index;
0053     QModelIndex index(const GpgME::Subkey &subkey, int col = 0) const;
0054     QList<QModelIndex> indexes(const std::vector<GpgME::Subkey> &subkeys) const;
0055 
0056 public Q_SLOTS:
0057     void setKey(const GpgME::Key &key);
0058     void clear();
0059 
0060 public:
0061     int columnCount(const QModelIndex &pidx = QModelIndex()) const override;
0062     int rowCount(const QModelIndex &pidx = QModelIndex()) const override;
0063     QVariant headerData(int section, Qt::Orientation o, int role = Qt::DisplayRole) const override;
0064     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0065 
0066 private:
0067     class Private;
0068     QScopedPointer<Private> const d;
0069 };
0070 
0071 }