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

Move QNetworkConfigurationManager in manager class

parent ac710c07
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
#include <ldap/ldapclientsearch.h> #include <ldap/ldapclientsearch.h>
#include <addressline/addresslineedit/baloocompletionemail.h> #include <addressline/addresslineedit/baloocompletionemail.h>
#include <akonadi/contact/contactsearchjob.h> #include <akonadi/contact/contactsearchjob.h>
#include <QNetworkConfigurationManager>
static QNetworkConfigurationManager *s_networkConfigMgr = nullptr;
namespace KPIM { namespace KPIM {
AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq, bool enableCompletion) AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq, bool enableCompletion)
...@@ -64,10 +62,6 @@ AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq, ...@@ -64,10 +62,6 @@ AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq,
, mShowRecentAddresses(true) , mShowRecentAddresses(true)
, mCanDeleteLineEdit(true) , mCanDeleteLineEdit(true)
{ {
if (!s_networkConfigMgr) {
s_networkConfigMgr = new QNetworkConfigurationManager(QCoreApplication::instance());
}
m_delayedQueryTimer.setSingleShot(true); m_delayedQueryTimer.setSingleShot(true);
connect(&m_delayedQueryTimer, &QTimer::timeout, this, &AddresseeLineEditPrivate::slotTriggerDelayedQueries); connect(&m_delayedQueryTimer, &QTimer::timeout, this, &AddresseeLineEditPrivate::slotTriggerDelayedQueries);
} }
...@@ -677,7 +671,7 @@ void AddresseeLineEditPrivate::slotReturnPressed(const QString &) ...@@ -677,7 +671,7 @@ void AddresseeLineEditPrivate::slotReturnPressed(const QString &)
void AddresseeLineEditPrivate::slotStartLDAPLookup() void AddresseeLineEditPrivate::slotStartLDAPLookup()
{ {
if (s_networkConfigMgr->isOnline()) { if (AddresseeLineEditManager::self()->isOnline()) {
const KCompletion::CompletionMode mode = q->completionMode(); const KCompletion::CompletionMode mode = q->completionMode();
if (mode == KCompletion::CompletionNone) { if (mode == KCompletion::CompletionNone) {
return; return;
......
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
#include <Libkdepim/LdapClient> #include <Libkdepim/LdapClient>
#include <KLocalizedString> #include <KLocalizedString>
#include <QNetworkConfigurationManager>
#include <QTimer> #include <QTimer>
#include <QCoreApplication>
#include <KLDAP/LdapServer> #include <KLDAP/LdapServer>
#include <AkonadiCore/Session> #include <AkonadiCore/Session>
using namespace KPIM; using namespace KPIM;
...@@ -35,6 +37,7 @@ AddresseeLineEditManager::AddresseeLineEditManager() ...@@ -35,6 +37,7 @@ AddresseeLineEditManager::AddresseeLineEditManager()
, mAddresseeLineEditAkonadi(new AddresseeLineEditAkonadi(this)) , mAddresseeLineEditAkonadi(new AddresseeLineEditAkonadi(this))
, mAddressessLineEditLdap(new AddresseeLineEditLdap(this)) , mAddressessLineEditLdap(new AddresseeLineEditLdap(this))
, mAddressessLineEditBaloo(new AddresseeLineEditBaloo(this)) , mAddressessLineEditBaloo(new AddresseeLineEditBaloo(this))
, mNetworkConfigMgr(new QNetworkConfigurationManager(QCoreApplication::instance()))
{ {
} }
...@@ -115,6 +118,11 @@ void AddresseeLineEditManager::setAddressLineEdit(AddresseeLineEdit *addressLine ...@@ -115,6 +118,11 @@ void AddresseeLineEditManager::setAddressLineEdit(AddresseeLineEdit *addressLine
mAddressessLineEditLdap->setAddressLineEdit(addressLineEdit); mAddressessLineEditLdap->setAddressLineEdit(addressLineEdit);
} }
bool AddresseeLineEditManager::isOnline() const
{
return mNetworkConfigMgr->isOnline();
}
KLDAP::LdapClientSearch *AddresseeLineEditManager::ldapSearch() const KLDAP::LdapClientSearch *AddresseeLineEditManager::ldapSearch() const
{ {
return mAddressessLineEditLdap->ldapSearch(); return mAddressessLineEditLdap->ldapSearch();
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <ldap/ldapclientsearch.h> #include <ldap/ldapclientsearch.h>
#include <qstringlist.h> #include <qstringlist.h>
class QTimer; class QTimer;
class QNetworkConfigurationManager;
namespace KPIM { namespace KPIM {
class KMailCompletion; class KMailCompletion;
class AddresseeLineEdit; class AddresseeLineEdit;
...@@ -107,12 +108,14 @@ public: ...@@ -107,12 +108,14 @@ public:
AddresseeLineEdit *addressLineEdit() const; AddresseeLineEdit *addressLineEdit() const;
void setAddressLineEdit(AddresseeLineEdit *addressLineEdit); void setAddressLineEdit(AddresseeLineEdit *addressLineEdit);
bool isOnline() const;
private: private:
KMailCompletion *mCompletion; KMailCompletion *mCompletion;
AddresseeLineEditAkonadi *mAddresseeLineEditAkonadi; AddresseeLineEditAkonadi *mAddresseeLineEditAkonadi;
AddresseeLineEditLdap *mAddressessLineEditLdap; AddresseeLineEditLdap *mAddressessLineEditLdap;
AddresseeLineEditBaloo *mAddressessLineEditBaloo; AddresseeLineEditBaloo *mAddressessLineEditBaloo;
QNetworkConfigurationManager *mNetworkConfigMgr;
}; };
} }
#endif // ADDRESSEELINEEDITSTATIC_H #endif // ADDRESSEELINEEDITSTATIC_H
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