Pimcommon

addresseelineeditmanager.h
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <Akonadi/Collection>
10#include <QMap>
11
12#include <Akonadi/Item>
13#include <Akonadi/Session>
14#include <KLDAPCore/LdapClientSearch>
15#include <QList>
16#include <QPointer>
17
18#include <QColor>
19
20class QTimer;
21class QNetworkConfigurationManager;
22namespace PimCommon
23{
24class KMailCompletion;
25class AddresseeLineEdit;
26class AddresseeLineEditAkonadi;
27class AddresseeLineEditLdap;
28class AddresseeLineEditBaloo;
29class AddresseeLineEditManager
30{
31public:
32 using CompletionItemsMap = QMap<QString, QPair<int, int>>;
33
34 AddresseeLineEditManager();
35
36 ~AddresseeLineEditManager();
37
38 static AddresseeLineEditManager *self();
39
40 void updateCollectionWeights();
41
42 void updateLDAPWeights();
43 void updateCompletionOrder();
44
45 [[nodiscard]] int addCompletionSource(const QString &source, int weight);
46 void removeCompletionSource(const QString &source);
47
48 CompletionItemsMap completionItemMap;
49 QStringList completionSources;
50
51 // The weights associated with the completion sources in s_static->completionSources.
52 // Both are maintained by addCompletionSource(), don't attempt to modify those yourself.
53 QMap<QString, int> completionSourceWeights;
54
55 // holds the cached mapping from akonadi collection id to the completion source index
56 struct collectionInfo {
57 collectionInfo()
58 : index(-1)
59 , enabled(true)
60 {
61 }
62
63 collectionInfo(int idx, bool _enabled)
64 : index(idx)
65 , enabled(_enabled)
66 {
67 }
68
69 int index;
70 bool enabled;
71 };
72
73 QMap<Akonadi::Collection::Id, collectionInfo> akonadiCollectionToCompletionSourceMap;
74 // a list of akonadi items (contacts) that have not had their collection fetched yet
75 Akonadi::Item::List akonadiPendingItems;
76 QList<QPointer<Akonadi::Job>> akonadiJobsInFlight;
77
78 // Ldap
79 void initializeLdap();
80 [[nodiscard]] QString ldapText() const;
81 void setLdapText(const QString &ldapText);
82 KLDAPCore::LdapClientSearch *ldapSearch() const;
83 QTimer *ldapTimer() const;
84 [[nodiscard]] bool isLdapClientToCompletionSourceMapContains(int value) const;
85 [[nodiscard]] int ldapClientToCompletionSourceValue(int value) const;
86 void stopLDAPLookup();
87 void startLoadingLDAPEntries();
88 void restartLdap(const QString &searchString, AddresseeLineEdit *addressLine);
89
90 // Baloo
91 [[nodiscard]] int balooCompletionSource() const;
92 void setBalooCompletionSource(int value);
93
94 // Akonadi
95 [[nodiscard]] Akonadi::Session *akonadiSession() const;
96
97 [[nodiscard]] KMailCompletion *completion() const;
98
99 [[nodiscard]] AddresseeLineEdit *addressLineEdit() const;
100 void setAddressLineEdit(AddresseeLineEdit *addressLineEdit);
101 [[nodiscard]] bool isOnline() const;
102
103 void loadBalooBlackList();
104 [[nodiscard]] QStringList cleanupEmailList(const QStringList &inputList);
105 [[nodiscard]] QStringList balooBlackList() const;
106
107 [[nodiscard]] bool showOU() const;
108 void setShowOU(bool showOU);
109
110 [[nodiscard]] bool autoGroupExpand() const;
111 void setAutoGroupExpand(bool checked);
112
113 [[nodiscard]] QColor alternateColor() const;
114
115 [[nodiscard]] QStringList cleanupRecentAddressEmailList(const QStringList &inputList);
116
117private:
118 QStringList mRecentAddressEmailList;
119 QStringList mRecentCleanupAddressEmailList;
120 mutable QColor mAlternateColor;
121 bool mShowOU = false;
122 bool mAutoGroupExpand = false;
123 KMailCompletion *const mCompletion;
124 AddresseeLineEditAkonadi *const mAddresseeLineEditAkonadi;
125 AddresseeLineEditLdap *const mAddressessLineEditLdap;
126 AddresseeLineEditBaloo *const mAddressessLineEditBaloo;
127};
128}
folderdialogacltab.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.