Commit 562d429e authored by Laurent Montel's avatar Laurent Montel 😁

Continue to move some code to specific class

parent f559fc91
......@@ -69,7 +69,7 @@ AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq,
AddresseeLineEditPrivate::~AddresseeLineEditPrivate()
{
if (AddresseeLineEditManager::self()->ldapSearch() && AddresseeLineEditManager::self()->addressLineEdit() == q) {
stopLDAPLookup();
AddresseeLineEditManager::self()->stopLDAPLookup();
}
}
......@@ -77,7 +77,7 @@ void AddresseeLineEditPrivate::restartTime(const QString &searchString)
{
if (useCompletion() && AddresseeLineEditManager::self()->ldapTimer()) {
if (AddresseeLineEditManager::self()->ldapText() != searchString || AddresseeLineEditManager::self()->addressLineEdit() != q) {
stopLDAPLookup();
AddresseeLineEditManager::self()->stopLDAPLookup();
}
AddresseeLineEditManager::self()->setLdapText(searchString);
......@@ -175,31 +175,6 @@ void AddresseeLineEditPrivate::setIcon(const QIcon &icon, const QString &tooltip
}
}
void AddresseeLineEditPrivate::startLoadingLDAPEntries()
{
QString text(AddresseeLineEditManager::self()->ldapText());
// TODO cache last?
QString prevAddr;
const int index = text.lastIndexOf(QLatin1Char(','));
if (index >= 0) {
prevAddr = text.left(index + 1) + QLatin1Char(' ');
text = text.mid(index + 1, 255).trimmed();
}
if (text.isEmpty()) {
return;
}
AddresseeLineEditManager::self()->ldapSearch()->startSearch(text);
}
void AddresseeLineEditPrivate::stopLDAPLookup()
{
AddresseeLineEditManager::self()->ldapSearch()->cancelSearch();
AddresseeLineEditManager::self()->setAddressLineEdit(nullptr);
}
QStringList AddresseeLineEdit::cleanupEmailList(const QStringList &inputList)
{
return d->cleanupEmailList(inputList);
......@@ -682,7 +657,7 @@ void AddresseeLineEditPrivate::slotStartLDAPLookup()
if (AddresseeLineEditManager::self()->addressLineEdit() != q) {
return;
}
startLoadingLDAPEntries();
AddresseeLineEditManager::self()->startLoadingLDAPEntries();
}
}
......@@ -751,7 +726,7 @@ KLDAP::LdapClientSearch *AddresseeLineEditPrivate::ldapSearch()
void AddresseeLineEditPrivate::slotUserCancelled(const QString &cancelText)
{
if (AddresseeLineEditManager::self()->ldapSearch() && AddresseeLineEditManager::self()->addressLineEdit() == q) {
stopLDAPLookup();
AddresseeLineEditManager::self()->stopLDAPLookup();
}
q->callUserCancelled(m_previousAddresses + cancelText); // in KLineEdit
......
......@@ -44,8 +44,6 @@ public:
void loadBalooBlackList();
void alternateColor();
void init();
void startLoadingLDAPEntries();
void stopLDAPLookup();
void setCompletedItems(const QStringList &items, bool autoSuggest);
void addCompletionItem(const QString &string, int weight, int source, const QStringList *keyWords = nullptr);
const QStringList adjustedCompletionItems(bool fullSearch);
......
......@@ -124,3 +124,23 @@ void AddresseeLineEditLdap::setAddressLineEdit(AddresseeLineEdit *addressLineEdi
{
mAddressLineEdit = addressLineEdit;
}
void AddresseeLineEditLdap::startLoadingLDAPEntries()
{
QString text(mLdapText);
// TODO cache last?
QString prevAddr;
const int index = text.lastIndexOf(QLatin1Char(','));
if (index >= 0) {
prevAddr = text.left(index + 1) + QLatin1Char(' ');
text = text.mid(index + 1, 255).trimmed();
}
if (text.isEmpty()) {
return;
}
mLdapSearch->startSearch(text);
}
......@@ -54,6 +54,7 @@ public:
AddresseeLineEdit *addressLineEdit() const;
void setAddressLineEdit(AddresseeLineEdit *addressLineEdit);
void startLoadingLDAPEntries();
private:
// maps LDAP client indices to completion source indices
// the assumption that they are always the first n indices in s_static->completion
......
......@@ -168,3 +168,13 @@ void AddresseeLineEditManager::setLdapText(const QString &ldapText)
mAddressessLineEditLdap->setLdapText(ldapText);
}
void AddresseeLineEditManager::stopLDAPLookup()
{
mAddressessLineEditLdap->ldapSearch()->cancelSearch();
mAddressessLineEditLdap->setAddressLineEdit(nullptr);
}
void AddresseeLineEditManager::startLoadingLDAPEntries()
{
mAddressessLineEditLdap->startLoadingLDAPEntries();
}
......@@ -95,6 +95,8 @@ public:
QTimer *ldapTimer() const;
bool isLdapClientToCompletionSourceMapContains(int value) const;
int ldapClientToCompletionSourceValue(int value) const;
void stopLDAPLookup();
void startLoadingLDAPEntries();
//Baloo
int balooCompletionSource() const;
......
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