Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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

Load blacklist

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