Commit 71091736 authored by Laurent Montel's avatar Laurent Montel 😁

Don't load backlist settings each time that we create a lineedit

parent fca6da63
......@@ -27,6 +27,7 @@
#include "addresseelineedit.h"
#include "addresseelineedit_p.h"
#include "Libkdepim/AddresseeLineEditUtil"
#include "addresseelineeditmanager.h"
#include "ldap/ldapclientsearch.h"
#include <KContacts/VCardConverter>
......@@ -630,7 +631,7 @@ void AddresseeLineEdit::configureCompletion()
QScopedPointer<KPIM::CompletionConfigureDialog> dlg(new KPIM::CompletionConfigureDialog(this));
dlg->setRecentAddresses(KPIM::RecentAddresses::self(recentAddressConfig())->addresses());
dlg->setLdapClientSearch(ldapSearch());
dlg->setEmailBlackList(balooBlackList());
dlg->setEmailBlackList(KPIM::AddresseeLineEditManager::self()->balooBlackList());
dlg->load();
if (dlg->exec() && dlg) {
if (dlg->recentAddressWasChanged()) {
......@@ -651,6 +652,11 @@ void AddresseeLineEdit::slotToggleExpandGroups()
group.writeEntry("AutoGroupExpand", autoGroupExpand());
}
QStringList AddresseeLineEdit::cleanupEmailList(const QStringList &inputList)
{
return AddresseeLineEditManager::self()->cleanupEmailList(inputList);
}
void AddresseeLineEdit::loadContacts()
{
const QString recentAddressGroupName = i18n("Recent Addresses");
......@@ -906,11 +912,6 @@ KLDAP::LdapClientSearch *AddresseeLineEdit::ldapSearch() const
return d->ldapSearch();
}
QStringList AddresseeLineEdit::balooBlackList() const
{
return d->balooBlackList();
}
void AddresseeLineEdit::slotEditingFinished()
{
for (KJob *job : d->mightBeGroupJobs()) {
......
......@@ -128,7 +128,6 @@ public:
void updateBalooBlackList();
void updateCompletionOrder();
KLDAP::LdapClientSearch *ldapSearch() const;
QStringList balooBlackList() const;
void setAutoGroupExpand(bool autoGroupExpand);
bool autoGroupExpand() const;
......
......@@ -168,26 +168,11 @@ void AddresseeLineEditPrivate::setIcon(const QIcon &icon, const QString &tooltip
}
}
QStringList AddresseeLineEdit::cleanupEmailList(const QStringList &inputList)
{
return d->cleanupEmailList(inputList);
}
QStringList AddresseeLineEditPrivate::cleanupEmailList(const QStringList &inputList)
{
KPIM::BalooCompletionEmail completionEmail;
completionEmail.setEmailList(inputList);
completionEmail.setBlackList(m_balooBlackList);
completionEmail.setExcludeDomain(m_domainExcludeList);
const QStringList listEmail = completionEmail.cleanupEmailList();
return listEmail;
}
void AddresseeLineEditPrivate::searchInBaloo()
{
const QString trimmedString = m_searchString.trimmed();
Akonadi::Search::PIM::ContactCompleter com(trimmedString, 20);
const QStringList listEmail = cleanupEmailList(com.complete());
const QStringList listEmail = AddresseeLineEditManager::self()->cleanupEmailList(com.complete());
for (const QString &email : listEmail) {
addCompletionItem(email, 1, AddresseeLineEditManager::self()->balooCompletionSource());
}
......@@ -882,11 +867,6 @@ void AddresseeLineEditPrivate::setAutoGroupExpand(bool autoGroupExpand)
mAutoGroupExpand = autoGroupExpand;
}
QStringList AddresseeLineEditPrivate::balooBlackList() const
{
return m_balooBlackList;
}
void AddresseeLineEditPrivate::setExpandIntern(bool b)
{
mExpandIntern = b;
......@@ -989,10 +969,7 @@ void AddresseeLineEditPrivate::setShowOU(bool showOU)
void AddresseeLineEditPrivate::loadBalooBlackList()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
KConfigGroup group(config, "AddressLineEdit");
m_balooBlackList = group.readEntry("BalooBackList", QStringList());
m_domainExcludeList = group.readEntry("ExcludeDomain", QStringList());
AddresseeLineEditManager::self()->loadBalooBlackList();
}
void AddresseeLineEditPrivate::removeCompletionSource(const QString &source)
......
......@@ -40,7 +40,6 @@ class AddresseeLineEditPrivate : public QObject
public:
AddresseeLineEditPrivate(AddresseeLineEdit *qq, bool enableCompletion);
~AddresseeLineEditPrivate();
QStringList cleanupEmailList(const QStringList &inputList);
void loadBalooBlackList();
void alternateColor();
void init();
......@@ -89,7 +88,6 @@ public:
void updateCompletionOrder();
KLDAP::LdapClientSearch *ldapSearch();
QStringList balooBlackList() const;
void setExpandIntern(bool);
bool expandIntern() const;
......@@ -140,8 +138,6 @@ private:
QToolButton *m_toolButton;
QTimer m_delayedQueryTimer;
QColor m_alternateColor;
QStringList m_balooBlackList;
QStringList m_domainExcludeList;
QString m_previousAddresses;
QString m_searchString;
QList<KJob *> mMightBeGroupJobs;
......
......@@ -18,6 +18,9 @@
*/
#include "addresseelineeditbaloo.h"
#include "baloocompletionemail.h"
#include <KConfigGroup>
#include <KSharedConfig>
using namespace KPIM;
......@@ -25,7 +28,7 @@ AddresseeLineEditBaloo::AddresseeLineEditBaloo(AddresseeLineEditManager *address
: mBalooCompletionSource(0)
, mAddressLineStatic(addressLineStatic)
{
loadBalooBlackList();
}
AddresseeLineEditBaloo::~AddresseeLineEditBaloo()
......@@ -42,3 +45,31 @@ void AddresseeLineEditBaloo::setBalooCompletionSource(int value)
{
mBalooCompletionSource = value;
}
QStringList AddresseeLineEditBaloo::balooBlackList() const
{
return mBalooBlackList;
}
QStringList AddresseeLineEditBaloo::domainExcludeList() const
{
return mDomainExcludeList;
}
void AddresseeLineEditBaloo::loadBalooBlackList()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
KConfigGroup group(config, "AddressLineEdit");
mBalooBlackList = group.readEntry("BalooBackList", QStringList());
mDomainExcludeList = group.readEntry("ExcludeDomain", QStringList());
}
QStringList AddresseeLineEditBaloo::cleanupEmailList(const QStringList &inputList)
{
KPIM::BalooCompletionEmail completionEmail;
completionEmail.setEmailList(inputList);
completionEmail.setBlackList(mBalooBlackList);
completionEmail.setExcludeDomain(mDomainExcludeList);
const QStringList listEmail = completionEmail.cleanupEmailList();
return listEmail;
}
......@@ -20,6 +20,8 @@
#ifndef ADDRESSEELINEEDITBALOO_H
#define ADDRESSEELINEEDITBALOO_H
#include <QStringList>
namespace KPIM {
class AddresseeLineEditManager;
class AddresseeLineEditBaloo
......@@ -31,7 +33,15 @@ public:
int balooCompletionSource() const;
void setBalooCompletionSource(int value);
QStringList balooBlackList() const;
QStringList domainExcludeList() const;
void loadBalooBlackList();
QStringList cleanupEmailList(const QStringList &inputList);
private:
QStringList mBalooBlackList;
QStringList mDomainExcludeList;
int mBalooCompletionSource;
AddresseeLineEditManager *mAddressLineStatic;
};
......
......@@ -182,3 +182,18 @@ void AddresseeLineEditManager::restartLdap(const QString &searchString, Addresse
{
mAddressessLineEditLdap->restartLdap(searchString, addressLine);
}
void AddresseeLineEditManager::loadBalooBlackList()
{
mAddressessLineEditBaloo->loadBalooBlackList();
}
QStringList AddresseeLineEditManager::cleanupEmailList(const QStringList &inputList)
{
return mAddressessLineEditBaloo->cleanupEmailList(inputList);
}
QStringList AddresseeLineEditManager::balooBlackList() const
{
return mAddressessLineEditBaloo->balooBlackList();
}
......@@ -113,6 +113,9 @@ public:
void setAddressLineEdit(AddresseeLineEdit *addressLineEdit);
bool isOnline() const;
void loadBalooBlackList();
QStringList cleanupEmailList(const QStringList &inputList);
QStringList balooBlackList() const;
private:
KMailCompletion *mCompletion;
AddresseeLineEditAkonadi *mAddresseeLineEditAkonadi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment