12#include "kleo_export.h"
14#include <Libkleo/KeyFilter>
17#include <QSortFilterProxyModel>
19#include <gpgme++/global.h>
38class KLEO_EXPORT KeyFilterManager :
public QObject
44 FilterMatchContextsRole,
49 explicit KeyFilterManager(QObject *parent =
nullptr);
50 ~KeyFilterManager()
override;
53 static KeyFilterManager *instance();
58 void alwaysFilterByProtocol(GpgME::Protocol protocol);
59 GpgME::Protocol protocol()
const;
61 const std::shared_ptr<KeyFilter> &filterMatching(
const GpgME::Key &key, KeyFilter::MatchContexts contexts)
const;
62 std::vector<std::shared_ptr<KeyFilter>> filtersMatching(
const GpgME::Key &key, KeyFilter::MatchContexts contexts)
const;
64 QAbstractItemModel *model()
const;
66 const std::shared_ptr<KeyFilter> &keyFilterByID(
const QString &
id)
const;
67 const std::shared_ptr<KeyFilter> &fromModelIndex(
const QModelIndex &mi)
const;
68 QModelIndex toModelIndex(
const std::shared_ptr<KeyFilter> &kf)
const;
72 QFont font(
const GpgME::Key &key,
const QFont &baseFont)
const;
73 QColor bgColor(
const GpgME::Key &key)
const;
74 QColor bgColor(
const GpgME::UserID &userID)
const;
75 QColor fgColor(
const GpgME::Key &key)
const;
76 QColor fgColor(
const GpgME::UserID &userID)
const;
77 QIcon icon(
const GpgME::Key &key)
const;
82 void alwaysFilterByProtocolChanged(GpgME::Protocol protocol);
85 std::unique_ptr<Private> d;
86 static KeyFilterManager *mSelf;
89class KLEO_EXPORT KeyFilterModel :
public QSortFilterProxyModel
94 KeyFilterModel(QObject *parent =
nullptr);
95 ~KeyFilterModel()
override;
97 bool isCustomFilter(
int row)
const;
98 void prependCustomFilter(
const std::shared_ptr<KeyFilter> &filter);
100 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
101 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
103 QModelIndex mapToSource(
const QModelIndex &index)
const override;
104 QModelIndex mapFromSource(
const QModelIndex &source_index)
const override;
106 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
107 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
108 QModelIndex parent(
const QModelIndex &)
const override;
109 QVariant data(
const QModelIndex &index,
int role)
const override;
113 const std::unique_ptr<Private> d;
const QList< QKeySequence > & reload()