7#include "addresseelineeditmanager.h"
8#include "addresseelineeditakonadi.h"
9#include "addresseelineeditbaloo.h"
10#include "addresseelineeditldap.h"
11#include "kmailcompletion.h"
13#include "pimcommonakonadi_debug.h"
14#include <KColorScheme>
15#include <KConfigGroup>
16#include <KLDAPCore/LdapClient>
17#include <KSharedConfig>
18#include <QCoreApplication>
19#include <QNetworkInformation>
24Q_GLOBAL_STATIC(AddresseeLineEditManager, sInstance)
26AddresseeLineEditManager::AddresseeLineEditManager()
29 , mAddressessLineEditLdap(new AddresseeLineEditLdap(this))
30 , mAddressessLineEditBaloo(new AddresseeLineEditBaloo)
33 mShowOU = group.readEntry(
"ShowOU",
false);
34 mAutoGroupExpand = group.readEntry(
"AutoGroupExpand",
false);
37AddresseeLineEditManager::~AddresseeLineEditManager()
41 delete mAddresseeLineEditAkonadi;
42 delete mAddressessLineEditLdap;
43 delete mAddressessLineEditBaloo;
46AddresseeLineEditManager *AddresseeLineEditManager::self()
51void AddresseeLineEditManager::updateCompletionOrder()
54 updateCollectionWeights();
57void AddresseeLineEditManager::updateCollectionWeights()
59 akonadiCollectionToCompletionSourceMap.
clear();
62void AddresseeLineEditManager::updateLDAPWeights()
64 mAddressessLineEditLdap->updateLDAPWeights();
67int AddresseeLineEditManager::addCompletionSource(
const QString &source,
int weight)
70 if (it == completionSourceWeights.
end()) {
71 completionSourceWeights.
insert(source, weight);
73 completionSourceWeights[source] = weight;
76 const int sourceIndex = completionSources.
indexOf(source);
77 if (sourceIndex == -1) {
78 completionSources.
append(source);
79 return completionSources.
size() - 1;
85void AddresseeLineEditManager::removeCompletionSource(
const QString &source)
88 if (it != completionSourceWeights.
end()) {
89 completionSourceWeights.
remove(source);
96 return mAddresseeLineEditAkonadi->akonadiSession();
104AddresseeLineEdit *AddresseeLineEditManager::addressLineEdit()
const
106 return mAddressessLineEditLdap->addressLineEdit();
109void AddresseeLineEditManager::setAddressLineEdit(AddresseeLineEdit *addressLineEdit)
111 mAddressessLineEditLdap->setAddressLineEdit(addressLineEdit);
114bool AddresseeLineEditManager::isOnline()
const
120 qCWarning(PIMCOMMONAKONADI_LOG) <<
"Couldn't find a working backend for QNetworkInformation";
127 return mAddressessLineEditLdap->ldapSearch();
130QTimer *AddresseeLineEditManager::ldapTimer()
const
132 return mAddressessLineEditLdap->ldapTimer();
135int AddresseeLineEditManager::ldapClientToCompletionSourceValue(
int value)
const
137 return mAddressessLineEditLdap->ldapClientToCompletionSourceValue(value);
140bool AddresseeLineEditManager::isLdapClientToCompletionSourceMapContains(
int value)
const
142 return mAddressessLineEditLdap->isLdapClientToCompletionSourceMapContains(value);
145int AddresseeLineEditManager::balooCompletionSource()
const
147 return mAddressessLineEditBaloo->balooCompletionSource();
150void AddresseeLineEditManager::setBalooCompletionSource(
int value)
152 mAddressessLineEditBaloo->setBalooCompletionSource(value);
155void AddresseeLineEditManager::initializeLdap()
157 mAddressessLineEditLdap->init();
160QString AddresseeLineEditManager::ldapText()
const
162 return mAddressessLineEditLdap->ldapText();
165void AddresseeLineEditManager::setLdapText(
const QString &ldapText)
167 mAddressessLineEditLdap->setLdapText(ldapText);
170void AddresseeLineEditManager::stopLDAPLookup()
172 mAddressessLineEditLdap->stopLDAPLookup();
175void AddresseeLineEditManager::startLoadingLDAPEntries()
177 mAddressessLineEditLdap->startLoadingLDAPEntries();
180void AddresseeLineEditManager::restartLdap(
const QString &searchString, AddresseeLineEdit *addressLine)
182 mAddressessLineEditLdap->restartLdap(searchString, addressLine);
185void AddresseeLineEditManager::loadBalooBlackList()
187 mAddressessLineEditBaloo->loadBalooBlackList();
192 if (inputList != mRecentAddressEmailList) {
193 mRecentCleanupAddressEmailList = mAddressessLineEditBaloo->cleanupEmailList(inputList);
194 mRecentAddressEmailList = inputList;
196 return mRecentCleanupAddressEmailList;
201 return mAddressessLineEditBaloo->cleanupEmailList(inputList);
204QStringList AddresseeLineEditManager::balooBlackList()
const
206 return mAddressessLineEditBaloo->balooBlackList();
209bool AddresseeLineEditManager::showOU()
const
214void AddresseeLineEditManager::setShowOU(
bool checked)
216 if (checked != mShowOU) {
218 group.writeEntry(
"ShowOU", checked);
223bool AddresseeLineEditManager::autoGroupExpand()
const
225 return mAutoGroupExpand;
228void AddresseeLineEditManager::setAutoGroupExpand(
bool checked)
230 if (mAutoGroupExpand != checked) {
231 mAutoGroupExpand = checked;
233 group.writeEntry(
"AutoGroupExpand", mAutoGroupExpand);
237QColor AddresseeLineEditManager::alternateColor()
const
239 if (!mAlternateColor.
isValid()) {
243 return mAlternateColor;
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
The AddresseeLineEditAkonadi class.
KMailCompletion allows lookup of email addresses by keyword.
void clear() override
clears internal keyword map and calls KCompletion::clear.
bool isValid() const const
void append(QList< T > &&value)
qsizetype size() const const
iterator find(const Key &key)
iterator insert(const Key &key, const T &value)
size_type remove(const Key &key)
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const