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 1fad61ca authored by Laurent Montel's avatar Laurent Montel 😁

Exclude some domain

parent a7e26e14
......@@ -267,6 +267,7 @@ public:
AddresseeLineEdit *q;
QStringList m_balooBlackList;
QStringList m_domainExcludeList;
QString m_previousAddresses;
QString m_searchString;
bool m_useCompletion;
......@@ -387,6 +388,12 @@ void AddresseeLineEdit::Private::searchInBaloo()
Baloo::PIM::ContactCompleter com(trimmedString, 20);
const QStringList listEmail = cleanupBalooContact(com.complete());
Q_FOREACH (const QString& email, listEmail) {
Q_FOREACH(const QString &excludeDomain, m_domainExcludeList) {
if (email.endsWith(excludeDomain)) {
continue;
}
}
if (!m_balooBlackList.contains(email)) {
addCompletionItem(email, 1, s_static->balooCompletionSource);
}
......@@ -1033,6 +1040,7 @@ void AddresseeLineEdit::Private::loadBalooBlackList()
KSharedConfig::Ptr config = KSharedConfig::openConfig( QLatin1String("kpimbalooblacklist") );
KConfigGroup group( config, "AddressLineEdit" );
m_balooBlackList = group.readEntry( "BalooBackList", QStringList() );
m_domainExcludeList = group.readEntry("ExcludeDomain", QStringList());
}
AddresseeLineEdit::AddresseeLineEdit( QWidget *parent, bool enableCompletion )
......
......@@ -63,6 +63,15 @@ void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
QVERIFY(unselectButton);
QLabel *excludeDomainLabel = qFindChild<QLabel *>(&widget, QLatin1String("domain_label"));
QVERIFY(excludeDomainLabel);
KLineEdit *excludeDomainLineEdit = qFindChild<KLineEdit *>(&widget, QLatin1String("domain_lineedit"));
QVERIFY(excludeDomainLineEdit);
QVERIFY(excludeDomainLineEdit->trapReturnKey());
QVERIFY(excludeDomainLineEdit->text().isEmpty());
QVERIFY(excludeDomainLineEdit->isClearButtonShown());
QVERIFY(!excludeDomainLineEdit->clickMessage().isEmpty());
}
void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
......
......@@ -81,6 +81,24 @@ BlackListBalooEmailCompletionWidget::BlackListBalooEmailCompletionWidget(QWidget
connect(mSearchLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSearchLineEditChanged(QString)));
QHBoxLayout *excludeDomainLayout = new QHBoxLayout;
excludeDomainLayout->setMargin(0);
mainLayout->addLayout(excludeDomainLayout);
//kf5 add i18n
QLabel *excludeDomainLabel = new QLabel(QLatin1String("Exclude domain name:"));
excludeDomainLabel->setObjectName(QLatin1String("domain_label"));
excludeDomainLayout->addWidget(excludeDomainLabel);
mExcludeDomainLineEdit = new KLineEdit;
excludeDomainLayout->addWidget(mExcludeDomainLineEdit);
mExcludeDomainLineEdit->setObjectName(QLatin1String("domain_lineedit"));
mExcludeDomainLineEdit->setClearButtonShown(true);
mExcludeDomainLineEdit->setTrapReturnKey(true);
//kf5 add i18n
mExcludeDomainLineEdit->setClickMessage(QLatin1String("Separate domain with \',\'"));
load();
}
BlackListBalooEmailCompletionWidget::~BlackListBalooEmailCompletionWidget()
......@@ -88,6 +106,14 @@ BlackListBalooEmailCompletionWidget::~BlackListBalooEmailCompletionWidget()
}
void BlackListBalooEmailCompletionWidget::load()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig( QLatin1String("kpimbalooblacklist") );
KConfigGroup group( config, "AddressLineEdit" );
const QStringList lst = group.readEntry("ExcludeDomain", QStringList());
mExcludeDomainLineEdit->setText(lst.join(QLatin1String(",")));
}
void BlackListBalooEmailCompletionWidget::slotUnselectEmails()
{
Q_FOREACH(QListWidgetItem *item, mEmailList->selectedItems()) {
......@@ -125,16 +151,17 @@ void BlackListBalooEmailCompletionWidget::setEmailBlackList(const QStringList &l
void BlackListBalooEmailCompletionWidget::save()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig( QLatin1String("kpimbalooblacklist") );
KConfigGroup group( config, "AddressLineEdit" );
const QHash<QString, bool> result = mEmailList->blackListItemChanged();
if (!result.isEmpty()) {
KSharedConfig::Ptr config = KSharedConfig::openConfig( QLatin1String("kpimbalooblacklist") );
KConfigGroup group( config, "AddressLineEdit" );
QStringList blackList = group.readEntry( "BalooBackList", QStringList() );
KPIM::BlackListBalooEmailUtil util;
util.initialBlackList(blackList);
util.newBlackList(result);
blackList = util.createNewBlackList();
group.writeEntry( "BalooBackList", blackList );
group.sync();
}
group.writeEntry("ExcludeDomain", mExcludeDomainLineEdit->text().split(QLatin1String(",")));
group.sync();
}
......@@ -41,7 +41,9 @@ private slots:
void slotSearchLineEditChanged(const QString &text);
void slotSearch();
private:
void load();
KLineEdit *mSearchLineEdit;
KLineEdit *mExcludeDomainLineEdit;
BlackListBalooEmailList *mEmailList;
KPushButton *mSearchButton;
};
......
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