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

KDE's Doxygen guidelines are available online.