Commit 90b97305 authored by Laurent Montel's avatar Laurent Montel 😁

Don't load settings each time that we create lineedit

parent eaca8058
......@@ -53,11 +53,9 @@ AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq,
, mLastSearchMode(false)
, mSearchExtended(false)
, mUseSemicolonAsSeparator(false)
, mShowOU(false)
, mEnableBalooSearch(true)
, mEnableAkonadiSearch(true)
, mExpandIntern(true)
, mAutoGroupExpand(false)
, mShowRecentAddresses(true)
, mCanDeleteLineEdit(true)
{
......@@ -142,10 +140,6 @@ void AddresseeLineEditPrivate::init()
mCompletionInitialized = true;
}
KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
mShowOU = group.readEntry("ShowOU", false);
mAutoGroupExpand = group.readEntry("AutoGroupExpand", false);
}
connect(q, &AddresseeLineEdit::textCompleted, q, &AddresseeLineEdit::slotEditingFinished);
connect(q, &AddresseeLineEdit::editingFinished, q, &AddresseeLineEdit::slotEditingFinished);
......@@ -648,7 +642,7 @@ void AddresseeLineEditPrivate::slotLDAPSearchData(const KLDAP::LdapResult::List
contact.setEmails(result.email);
QString ou;
if (mShowOU) {
if (AddresseeLineEditManager::self()->showOU()) {
const int depth = result.dn.depth();
for (int i = 0; i < depth; ++i) {
const QString rdnStr = result.dn.rdnString(i);
......@@ -791,17 +785,11 @@ void AddresseeLineEditPrivate::slotAkonadiCollectionsReceived(
void AddresseeLineEditPrivate::slotToggleExpandGroups()
{
setAutoGroupExpand(!autoGroupExpand());
KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
group.writeEntry("AutoGroupExpand", autoGroupExpand());
}
void AddresseeLineEditPrivate::slotShowOUChanged(bool checked)
{
if (checked != mShowOU) {
KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
group.writeEntry("ShowOU", checked);
mShowOU = checked;
}
AddresseeLineEditManager::self()->setShowOU(checked);
}
void AddresseeLineEditPrivate::updateBalooBlackList()
......@@ -863,12 +851,12 @@ void AddresseeLineEditPrivate::setMightBeGroupJobs(const QList<KJob *> &mightBeG
bool AddresseeLineEditPrivate::autoGroupExpand() const
{
return mAutoGroupExpand;
return AddresseeLineEditManager::self()->autoGroupExpand();
}
void AddresseeLineEditPrivate::setAutoGroupExpand(bool autoGroupExpand)
{
mAutoGroupExpand = autoGroupExpand;
AddresseeLineEditManager::self()->setAutoGroupExpand(autoGroupExpand);
}
void AddresseeLineEditPrivate::setExpandIntern(bool b)
......@@ -963,13 +951,9 @@ void AddresseeLineEditPrivate::setUseCompletion(bool useCompletion)
bool AddresseeLineEditPrivate::showOU() const
{
return mShowOU;
return AddresseeLineEditManager::self()->showOU();
}
void AddresseeLineEditPrivate::setShowOU(bool showOU)
{
mShowOU = showOU;
}
void AddresseeLineEditPrivate::loadBalooBlackList()
{
......
......@@ -53,7 +53,6 @@ public:
void doCompletion(bool ctrlT);
bool showOU() const;
void setShowOU(bool showOU);
void setIcon(const QIcon &icon, const QString &tooltip);
......@@ -150,11 +149,9 @@ private:
bool mLastSearchMode;
bool mSearchExtended; //has \" been added?
bool mUseSemicolonAsSeparator;
bool mShowOU;
bool mEnableBalooSearch;
bool mEnableAkonadiSearch;
bool mExpandIntern;
bool mAutoGroupExpand;
bool mShowRecentAddresses;
bool mCanDeleteLineEdit;
};
......
......@@ -26,6 +26,8 @@
#include <QNetworkConfigurationManager>
#include <QTimer>
#include <QCoreApplication>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KLDAP/LdapServer>
#include <AkonadiCore/Session>
using namespace KPIM;
......@@ -33,12 +35,17 @@ using namespace KPIM;
Q_GLOBAL_STATIC(AddresseeLineEditManager, sInstance)
AddresseeLineEditManager::AddresseeLineEditManager()
: mCompletion(new KMailCompletion)
: mShowOU(false)
, mAutoGroupExpand(false)
, mCompletion(new KMailCompletion)
, mAddresseeLineEditAkonadi(new AddresseeLineEditAkonadi(this))
, mAddressessLineEditLdap(new AddresseeLineEditLdap(this))
, mAddressessLineEditBaloo(new AddresseeLineEditBaloo(this))
, mNetworkConfigMgr(new QNetworkConfigurationManager(QCoreApplication::instance()))
{
KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
mShowOU = group.readEntry("ShowOU", false);
mAutoGroupExpand = group.readEntry("AutoGroupExpand", false);
}
AddresseeLineEditManager::~AddresseeLineEditManager()
......@@ -197,3 +204,29 @@ QStringList AddresseeLineEditManager::balooBlackList() const
{
return mAddressessLineEditBaloo->balooBlackList();
}
bool AddresseeLineEditManager::showOU() const
{
return mShowOU;
}
void AddresseeLineEditManager::setShowOU(bool checked)
{
if (checked != mShowOU) {
KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
group.writeEntry("ShowOU", checked);
mShowOU = checked;
}
}
bool AddresseeLineEditManager::autoGroupExpand() const
{
return mAutoGroupExpand;
}
void AddresseeLineEditManager::setAutoGroupExpand(bool autoGroupExpand)
{
mAutoGroupExpand = autoGroupExpand;
KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
group.writeEntry("AutoGroupExpand", mAutoGroupExpand);
}
......@@ -116,7 +116,16 @@ public:
void loadBalooBlackList();
QStringList cleanupEmailList(const QStringList &inputList);
QStringList balooBlackList() const;
bool showOU() const;
void setShowOU(bool showOU);
bool autoGroupExpand() const;
void setAutoGroupExpand(bool autoGroupExpand);
private:
bool mShowOU;
bool mAutoGroupExpand;
KMailCompletion *mCompletion;
AddresseeLineEditAkonadi *mAddresseeLineEditAkonadi;
AddresseeLineEditLdap *mAddressessLineEditLdap;
......
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