Libkleo

keyfilter.h
1/*
2 keyfilter.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 <QFlags>
15
16#include <algorithm>
17#include <memory>
18
19namespace GpgME
20{
21class Key;
22class UserID;
23}
24
25class QFont;
26class QColor;
27class QString;
28
29namespace Kleo
30{
31
32/**
33 @short An abstract base class key filters
34
35*/
36class KLEO_EXPORT KeyFilter
37{
38public:
39 virtual ~KeyFilter()
40 {
41 }
42
43 enum MatchContext {
44 // clang-format off
45 NoMatchContext = 0x0,
46 Appearance = 0x1,
47 Filtering = 0x2,
48
49 AnyMatchContext = Appearance | Filtering
50 // clang-format on
51 };
52 Q_DECLARE_FLAGS(MatchContexts, MatchContext)
53
54 virtual bool matches(const GpgME::Key &key, MatchContexts ctx) const = 0;
55 virtual bool matches(const GpgME::UserID &userID, MatchContexts ctx) const = 0;
56
57 virtual unsigned int specificity() const = 0;
58 virtual QString id() const = 0;
59 virtual MatchContexts availableMatchContexts() const = 0;
60
61 // not sure if we want these here, but for the time being, it's
62 // the easiest way:
63 virtual QColor fgColor() const = 0;
64 virtual QColor bgColor() const = 0;
65 virtual QString name() const = 0;
66 virtual QString icon() const = 0;
67 virtual QString description() const = 0;
68
69 class FontDescription
70 {
71 public:
72 FontDescription();
73 FontDescription(const FontDescription &other);
74 FontDescription &operator=(const FontDescription &other)
75 {
76 FontDescription copy(other);
77 swap(copy);
78 return *this;
79 }
80 ~FontDescription();
81
82 static FontDescription create(bool bold, bool italic, bool strikeOut);
83 static FontDescription create(const QFont &font, bool bold, bool italic, bool strikeOut);
84
85 QFont font(const QFont &base) const;
86
87 FontDescription resolve(const FontDescription &other) const;
88
89 void swap(FontDescription &other)
90 {
91 std::swap(this->d, other.d);
92 }
93 struct Private;
94
95 private:
96 std::unique_ptr<Private> d;
97 };
98
99 virtual FontDescription fontDescription() const = 0;
100};
101
102Q_DECLARE_OPERATORS_FOR_FLAGS(KeyFilter::MatchContexts)
103
104}
105
106#include <QObject>
107
108Q_DECLARE_METATYPE(Kleo::KeyFilter::MatchContexts)
An abstract base class key filters.
Definition keyfilter.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:51:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.