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 
23 namespace GpgME
24 {
25 class Key;
26 class UserID;
27 }
28 
29 class QAbstractItemModel;
30 class QModelIndex;
31 class QFont;
32 class QColor;
33 class QIcon;
34 
35 namespace Kleo
36 {
37 
38 class KLEO_EXPORT KeyFilterManager : public QObject
39 {
40  Q_OBJECT
41 public:
42  enum ModelRoles {
43  FilterIdRole = Qt::UserRole,
44  FilterMatchContextsRole,
45  };
46 
47 protected:
48  explicit KeyFilterManager(QObject *parent = nullptr);
49  ~KeyFilterManager() override;
50 
51 public:
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 
79 private:
80  std::unique_ptr<Private> d;
81  static KeyFilterManager *mSelf;
82 };
83 
84 }
UserRole
const QList< QKeySequence > & reload()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:56:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.