Pimcommon

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

KDE's Doxygen guidelines are available online.