7#include "addresseelineeditmanager.h"
8#include "addresseelineeditakonadi.h"
9#include "addresseelineeditakonadisearch.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 AddresseeLineEditAkonadiSearch)
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();
59 mAddressessLineEditLdap->setLdapActivitiesAbstract(ldapActivities);
62void AddresseeLineEditManager::updateCollectionWeights()
64 akonadiCollectionToCompletionSourceMap.
clear();
67void AddresseeLineEditManager::updateLDAPWeights()
69 mAddressessLineEditLdap->updateLDAPWeights();
72int AddresseeLineEditManager::addCompletionSource(
const QString &source,
int weight)
75 if (it == completionSourceWeights.
end()) {
76 completionSourceWeights.
insert(source, weight);
78 completionSourceWeights[source] = weight;
81 const int sourceIndex = completionSources.
indexOf(source);
82 if (sourceIndex == -1) {
83 completionSources.
append(source);
84 return completionSources.
size() - 1;
90void AddresseeLineEditManager::removeCompletionSource(
const QString &source)
93 if (it != completionSourceWeights.
end()) {
94 completionSourceWeights.
remove(source);
101 return mAddresseeLineEditAkonadi->akonadiSession();
109AddresseeLineEdit *AddresseeLineEditManager::addressLineEdit()
const
111 return mAddressessLineEditLdap->addressLineEdit();
114void AddresseeLineEditManager::setAddressLineEdit(AddresseeLineEdit *addressLineEdit)
116 mAddressessLineEditLdap->setAddressLineEdit(addressLineEdit);
119bool AddresseeLineEditManager::isOnline()
const
125 qCWarning(PIMCOMMONAKONADI_LOG) <<
"Couldn't find a working backend for QNetworkInformation";
132 return mAddressessLineEditLdap->ldapSearch();
135QTimer *AddresseeLineEditManager::ldapTimer()
const
137 return mAddressessLineEditLdap->ldapTimer();
140int AddresseeLineEditManager::ldapClientToCompletionSourceValue(
int value)
const
142 return mAddressessLineEditLdap->ldapClientToCompletionSourceValue(value);
145bool AddresseeLineEditManager::isLdapClientToCompletionSourceMapContains(
int value)
const
147 return mAddressessLineEditLdap->isLdapClientToCompletionSourceMapContains(value);
150int AddresseeLineEditManager::balooCompletionSource()
const
152 return mAddressessLineEditBaloo->akonadiSearchCompletionSource();
155void AddresseeLineEditManager::setBalooCompletionSource(
int value)
157 mAddressessLineEditBaloo->setAkonadiSearchCompletionSource(value);
160void AddresseeLineEditManager::initializeLdap()
162 mAddressessLineEditLdap->init();
165QString AddresseeLineEditManager::ldapText()
const
167 return mAddressessLineEditLdap->ldapText();
170void AddresseeLineEditManager::setLdapText(
const QString &ldapText)
172 mAddressessLineEditLdap->setLdapText(ldapText);
175void AddresseeLineEditManager::stopLDAPLookup()
177 mAddressessLineEditLdap->stopLDAPLookup();
180void AddresseeLineEditManager::startLoadingLDAPEntries()
182 mAddressessLineEditLdap->startLoadingLDAPEntries();
185void AddresseeLineEditManager::restartLdap(
const QString &searchString, AddresseeLineEdit *addressLine)
187 mAddressessLineEditLdap->restartLdap(searchString, addressLine);
190void AddresseeLineEditManager::loadBalooBlackList()
192 mAddressessLineEditBaloo->loadAkonadiSearchBlackList();
197 if (inputList != mRecentAddressEmailList) {
198 mRecentCleanupAddressEmailList = mAddressessLineEditBaloo->cleanupEmailList(inputList);
199 mRecentAddressEmailList = inputList;
201 return mRecentCleanupAddressEmailList;
206 return mAddressessLineEditBaloo->cleanupEmailList(inputList);
209QStringList AddresseeLineEditManager::balooBlackList()
const
211 return mAddressessLineEditBaloo->akonadiSearchBlackList();
214bool AddresseeLineEditManager::showOU()
const
219void AddresseeLineEditManager::setShowOU(
bool checked)
221 if (checked != mShowOU) {
223 group.writeEntry(
"ShowOU", checked);
228bool AddresseeLineEditManager::autoGroupExpand()
const
230 return mAutoGroupExpand;
233void AddresseeLineEditManager::setAutoGroupExpand(
bool checked)
235 if (mAutoGroupExpand != checked) {
236 mAutoGroupExpand = checked;
238 group.writeEntry(
"AutoGroupExpand", mAutoGroupExpand);
242QColor AddresseeLineEditManager::alternateColor()
const
244 if (!mAlternateColor.
isValid()) {
248 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