File indexing completed on 2024-04-28 04:33:07

0001 /*
0002     SPDX-FileCopyrightText: 2018 Chinmoy Ranjan Pradhan <chinmoyrp65@gmail.com
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SIGNATUREMODEL_H
0008 #define SIGNATUREMODEL_H
0009 
0010 #include <QAbstractItemModel>
0011 
0012 namespace Okular
0013 {
0014 class Document;
0015 }
0016 
0017 class SignatureModelPrivate;
0018 
0019 class SignatureModel : public QAbstractItemModel
0020 {
0021     Q_OBJECT
0022 
0023     Q_PROPERTY(int count READ count NOTIFY countChanged)
0024 
0025 public:
0026     enum {
0027         FormRole = Qt::UserRole + 1000,
0028         PageRole,
0029         ReadableStatusRole,
0030         ReadableModificationSummary,
0031         SignerNameRole,
0032         SigningTimeRole,
0033         SigningLocationRole,
0034         SigningReasonRole,
0035         CertificateModelRole,
0036         SignatureRevisionIndexRole,
0037         IsUnsignedSignatureRole
0038     };
0039 
0040     explicit SignatureModel(Okular::Document *doc, QObject *parent = nullptr);
0041     ~SignatureModel() override;
0042 
0043     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0044     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0045     bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
0046     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
0047     QModelIndex parent(const QModelIndex &index) const override;
0048     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0049 
0050     int count() const
0051     {
0052         return rowCount();
0053     }
0054 
0055     QHash<int, QByteArray> roleNames() const override;
0056 
0057     Q_INVOKABLE bool saveSignedVersion(int signatureRevisionIndex, const QUrl &filePath) const;
0058 
0059 Q_SIGNALS:
0060     void countChanged();
0061 
0062 private:
0063     Q_DECLARE_PRIVATE(SignatureModel)
0064     QScopedPointer<SignatureModelPrivate> d_ptr;
0065 };
0066 
0067 #endif