Commit 4dbade0a authored by Laurent Montel's avatar Laurent Montel 😁

Load blacklist

parent b1913f20
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "addresseelineedit.h" #include "addresseelineedit.h"
#include "ldap/ldapclientsearch.h" #include "ldap/ldapclientsearch.h"
#include "completionordereditor.h" #include "completionordereditor.h"
#include "addressline/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.h"
#include "kmailcompletion.h" #include "kmailcompletion.h"
#include <Akonadi/Contact/ContactSearchJob> #include <Akonadi/Contact/ContactSearchJob>
...@@ -233,7 +233,7 @@ public: ...@@ -233,7 +233,7 @@ public:
m_delayedQueryTimer.setSingleShot(true); m_delayedQueryTimer.setSingleShot(true);
connect( &m_delayedQueryTimer, SIGNAL(timeout()), q, SLOT(slotTriggerDelayedQueries()) ); connect( &m_delayedQueryTimer, SIGNAL(timeout()), q, SLOT(slotTriggerDelayedQueries()) );
} }
void loadBalooBlackList();
QStringList cleanupBalooContact(const QStringList &lst); QStringList cleanupBalooContact(const QStringList &lst);
void alternateColor(); void alternateColor();
void init(); void init();
...@@ -262,9 +262,11 @@ public: ...@@ -262,9 +262,11 @@ public:
void searchInBaloo(); void searchInBaloo();
void slotTriggerDelayedQueries(); void slotTriggerDelayedQueries();
void slotShowOUChanged( bool ); void slotShowOUChanged( bool );
void slotConfigureBalooBlackList();
static KCompletion::CompOrder completionOrder(); static KCompletion::CompOrder completionOrder();
AddresseeLineEdit *q; AddresseeLineEdit *q;
QStringList m_balooBlackList;
QString m_previousAddresses; QString m_previousAddresses;
QString m_searchString; QString m_searchString;
bool m_useCompletion; bool m_useCompletion;
...@@ -336,6 +338,7 @@ void AddresseeLineEdit::Private::init() ...@@ -336,6 +338,7 @@ void AddresseeLineEdit::Private::init()
KConfigGroup group( KGlobal::config(), "AddressLineEdit" ); KConfigGroup group( KGlobal::config(), "AddressLineEdit" );
m_showOU = group.readEntry( "ShowOU", false ); m_showOU = group.readEntry( "ShowOU", false );
loadBalooBlackList();
} }
} }
...@@ -364,6 +367,7 @@ void AddresseeLineEdit::Private::stopLDAPLookup() ...@@ -364,6 +367,7 @@ void AddresseeLineEdit::Private::stopLDAPLookup()
s_static->ldapLineEdit = 0; s_static->ldapLineEdit = 0;
} }
QStringList AddresseeLineEdit::Private::cleanupBalooContact(const QStringList &lst) QStringList AddresseeLineEdit::Private::cleanupBalooContact(const QStringList &lst)
{ {
if (lst.isEmpty()) if (lst.isEmpty())
...@@ -1012,6 +1016,22 @@ void AddresseeLineEdit::Private::slotShowOUChanged(bool checked) ...@@ -1012,6 +1016,22 @@ void AddresseeLineEdit::Private::slotShowOUChanged(bool checked)
} }
} }
void AddresseeLineEdit::Private::slotConfigureBalooBlackList()
{
QPointer<KPIM::BlackListBalooEmailCompletionDialog> dlg = new KPIM::BlackListBalooEmailCompletionDialog(q);
dlg->setEmailBlackList(m_balooBlackList);
if (dlg->exec()) {
loadBalooBlackList();
}
delete dlg;
}
void AddresseeLineEdit::Private::loadBalooBlackList()
{
KConfigGroup group( KGlobal::config(), "AddressLineEdit" );
m_balooBlackList = group.readEntry( "Baloo Back List", QStringList() );
}
AddresseeLineEdit::AddresseeLineEdit( QWidget *parent, bool enableCompletion ) AddresseeLineEdit::AddresseeLineEdit( QWidget *parent, bool enableCompletion )
: KLineEdit( parent ), d( new Private( this, enableCompletion ) ) : KLineEdit( parent ), d( new Private( this, enableCompletion ) )
{ {
...@@ -1368,6 +1388,12 @@ QMenu *AddresseeLineEdit::createStandardContextMenu() ...@@ -1368,6 +1388,12 @@ QMenu *AddresseeLineEdit::createStandardContextMenu()
connect(showOU, SIGNAL(triggered(bool)), this, SLOT(slotShowOUChanged(bool))); connect(showOU, SIGNAL(triggered(bool)), this, SLOT(slotShowOUChanged(bool)));
menu->addAction(showOU); menu->addAction(showOU);
} }
//Add i18n in kf5
QAction *configureBalooBlackList = new QAction(QLatin1String( "Configure Email Blacklist" ),menu);
connect(configureBalooBlackList, SIGNAL(triggered(bool)), this, SLOT(slotConfigureBalooBlackList(bool)));
menu->addAction(configureBalooBlackList);
return menu; return menu;
} }
#endif #endif
......
...@@ -195,6 +195,7 @@ private: ...@@ -195,6 +195,7 @@ private:
Q_PRIVATE_SLOT( d, void slotAkonadiSearchResult( KJob * ) ) Q_PRIVATE_SLOT( d, void slotAkonadiSearchResult( KJob * ) )
Q_PRIVATE_SLOT( d, void slotAkonadiCollectionsReceived( const Akonadi::Collection::List & ) ) Q_PRIVATE_SLOT( d, void slotAkonadiCollectionsReceived( const Akonadi::Collection::List & ) )
Q_PRIVATE_SLOT( d, void slotTriggerDelayedQueries() ) Q_PRIVATE_SLOT( d, void slotTriggerDelayedQueries() )
Q_PRIVATE_SLOT( d, void slotConfigureBalooBlackList() )
//@endcond //@endcond
}; };
......
...@@ -76,7 +76,7 @@ void BlackListBalooEmailListTest::shouldFillListWithAlreadyBlackListedEmail() ...@@ -76,7 +76,7 @@ void BlackListBalooEmailListTest::shouldFillListWithAlreadyBlackListedEmail()
void BlackListBalooEmailListTest::shouldReturnChangedItems() void BlackListBalooEmailListTest::shouldReturnChangedItems()
{ {
KPIM::BlackListBalooEmailList blackList; KPIM::BlackListBalooEmailList blackList;
QStringList emails = QStringList() << QLatin1String("foo") << QLatin1String("bla") << QLatin1String("bli"); const QStringList emails = QStringList() << QLatin1String("foo") << QLatin1String("bla") << QLatin1String("bli");
blackList.setEmailBlackList(emails); blackList.setEmailBlackList(emails);
blackList.slotEmailFound(emails); blackList.slotEmailFound(emails);
QListWidgetItem *item = blackList.item(1); QListWidgetItem *item = blackList.item(1);
......
...@@ -79,6 +79,11 @@ BlackListBalooEmailCompletionDialog::~BlackListBalooEmailCompletionDialog() ...@@ -79,6 +79,11 @@ BlackListBalooEmailCompletionDialog::~BlackListBalooEmailCompletionDialog()
writeConfig(); writeConfig();
} }
void BlackListBalooEmailCompletionDialog::setEmailBlackList(const QStringList &list)
{
mEmailList->setEmailBlackList(list);
}
void BlackListBalooEmailCompletionDialog::slotSearchLineEditChanged(const QString &text) void BlackListBalooEmailCompletionDialog::slotSearchLineEditChanged(const QString &text)
{ {
mSearchButton->setEnabled(text.trimmed().count() > 2); mSearchButton->setEnabled(text.trimmed().count() > 2);
......
...@@ -34,6 +34,8 @@ public: ...@@ -34,6 +34,8 @@ public:
explicit BlackListBalooEmailCompletionDialog(QWidget *parent=0); explicit BlackListBalooEmailCompletionDialog(QWidget *parent=0);
~BlackListBalooEmailCompletionDialog(); ~BlackListBalooEmailCompletionDialog();
void setEmailBlackList(const QStringList &list);
private slots: private slots:
void slotSave(); void slotSave();
void slotSearch(); void slotSearch();
......
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