Libkleo

keyfiltermanager.h
1/*
2 keyfiltermanager.h
3
4 This file is part of libkleopatra, the KDE keymanagement library
5 SPDX-FileCopyrightText: 2004 Klarälvdalens Datakonsult AB
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "kleo_export.h"
13
14#include <Libkleo/KeyFilter>
15
16#include <QObject>
17
18#include <gpgme++/global.h>
19
20#include <memory>
21#include <vector>
22
23namespace GpgME
24{
25class Key;
26class UserID;
27}
28
30class QModelIndex;
31class QFont;
32class QColor;
33class QIcon;
34
35namespace Kleo
36{
37
38class KLEO_EXPORT KeyFilterManager : public QObject
39{
40 Q_OBJECT
41public:
42 enum ModelRoles {
43 FilterIdRole = Qt::UserRole,
44 FilterMatchContextsRole,
45 };
46
47protected:
48 explicit KeyFilterManager(QObject *parent = nullptr);
49 ~KeyFilterManager() override;
50
51public:
52 static KeyFilterManager *instance();
53
54 /**
55 * Adds the rule that keys must match @p protocol to all filters.
56 */
57 void alwaysFilterByProtocol(GpgME::Protocol protocol);
58
59 const std::shared_ptr<KeyFilter> &filterMatching(const GpgME::Key &key, KeyFilter::MatchContexts contexts) const;
60 std::vector<std::shared_ptr<KeyFilter>> filtersMatching(const GpgME::Key &key, KeyFilter::MatchContexts contexts) const;
61
62 QAbstractItemModel *model() const;
63
64 const std::shared_ptr<KeyFilter> &keyFilterByID(const QString &id) const;
65 const std::shared_ptr<KeyFilter> &fromModelIndex(const QModelIndex &mi) const;
66 QModelIndex toModelIndex(const std::shared_ptr<KeyFilter> &kf) const;
67
68 void reload();
69
70 QFont font(const GpgME::Key &key, const QFont &baseFont) const;
71 QColor bgColor(const GpgME::Key &key) const;
72 QColor bgColor(const GpgME::UserID &userID) const;
73 QColor fgColor(const GpgME::Key &key) const;
74 QColor fgColor(const GpgME::UserID &userID) const;
75 QIcon icon(const GpgME::Key &key) const;
76
77 class Private;
78
79private:
80 std::unique_ptr<Private> d;
81 static KeyFilterManager *mSelf;
82};
83
84}
const QList< QKeySequence > & reload()
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.