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

Improve unittest

parent e6204643
......@@ -39,4 +39,11 @@ void BlackListBalooEmailListTest::shouldHaveDefaultValue()
QVERIFY(blackList.count() == 0);
}
void BlackListBalooEmailListTest::shouldFillListEmail()
{
KPIM::BlackListBalooEmailList blackList;
blackList.slotEmailFound(QStringList() << QLatin1String("foo") << QLatin1String("bla") << QLatin1String("bli"));
QCOMPARE(blackList.count(), 3);
}
QTEST_KDEMAIN(BlackListBalooEmailListTest, GUI)
......@@ -31,6 +31,7 @@ public:
~BlackListBalooEmailListTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldFillListEmail();
};
#endif // BLACKLISTBALOOEMAILLISTTEST_H
......@@ -19,6 +19,7 @@
*/
#include "blacklistbalooemailcompletiondialog.h"
#include "blacklistbalooemailsearchjob.h"
#include "blacklistbalooemaillist.h"
#include <KLocalizedString>
#include <QHBoxLayout>
......@@ -105,5 +106,8 @@ void BlackListBalooEmailCompletionDialog::slotSave()
void BlackListBalooEmailCompletionDialog::slotSearch()
{
//TODO
const QString searchEmail = mSearchLineEdit->text().trimmed();
KPIM::BlackListBalooEmailSearchJob *job = new KPIM::BlackListBalooEmailSearchJob(this);
connect(job, SIGNAL(emailsFound(QStringList)), mEmailList, SLOT(slotEmailFound(QStringList)));
}
......@@ -19,8 +19,11 @@
*/
#include "blacklistbalooemaillist.h"
#include <QDebug>
using namespace KPIM;
BlackListBalooEmailList::BlackListBalooEmailList(QWidget *parent)
: QListWidget(parent)
{
......@@ -32,3 +35,40 @@ BlackListBalooEmailList::~BlackListBalooEmailList()
}
void BlackListBalooEmailList::setEmailBlackList(const QStringList &list)
{
mEmailBlackList = list;
}
void BlackListBalooEmailList::slotEmailFound(const QStringList &list)
{
clear();
Q_FOREACH(const QString & mail, list) {
BlackListBalooEmailListItem *item = new BlackListBalooEmailListItem(this);
item->setText(mail);
}
}
BlackListBalooEmailListItem::BlackListBalooEmailListItem(QListWidget *parent)
: QListWidgetItem(parent),
mInitializeStatus(false)
{
setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable);
}
BlackListBalooEmailListItem::~BlackListBalooEmailListItem()
{
}
bool BlackListBalooEmailListItem::initializeStatus() const
{
return mInitializeStatus;
}
void BlackListBalooEmailListItem::setInitializeStatus(bool initializeStatus)
{
mInitializeStatus = initializeStatus;
}
......@@ -22,15 +22,38 @@
#define BLACKLISTBALOOEMAILLIST_H
#include <QListWidget>
#include <QListWidgetItem>
#include "kdepim_export.h"
namespace KPIM {
class KDEPIM_EXPORT BlackListBalooEmailListItem : public QListWidgetItem
{
public:
explicit BlackListBalooEmailListItem(QListWidget *parent = 0);
~BlackListBalooEmailListItem();
bool initializeStatus() const;
void setInitializeStatus(bool initializeStatus);
private:
bool mInitializeStatus;
};
class KDEPIM_EXPORT BlackListBalooEmailList : public QListWidget
{
Q_OBJECT
public:
explicit BlackListBalooEmailList(QWidget *parent = 0);
~BlackListBalooEmailList();
void setEmailBlackList(const QStringList &list);
public Q_SLOTS:
void slotEmailFound(const QStringList &);
private:
QStringList mEmailBlackList;
};
}
......
......@@ -20,6 +20,8 @@
#include "blacklistbalooemailsearchjob.h"
#include <baloo/pim/contactcompleter.h>
#include <QStringList>
using namespace KPIM;
BlackListBalooEmailSearchJob::BlackListBalooEmailSearchJob(QObject *parent)
......@@ -35,11 +37,15 @@ BlackListBalooEmailSearchJob::~BlackListBalooEmailSearchJob()
bool BlackListBalooEmailSearchJob::start()
{
if (mSearchEmail.trimmed().isEmpty()) {
const QString trimmedString = mSearchEmail.trimmed();
if (trimmedString.isEmpty()) {
deleteLater();
return false;
}
//TODO
Baloo::PIM::ContactCompleter com(trimmedString, 500);
Q_EMIT emailsFound(com.complete());
deleteLater();
return true;
}
......
......@@ -36,6 +36,9 @@ public:
void setSearchEmail(const QString &searchEmail);
Q_SIGNALS:
void emailsFound(const QStringList &list);
private:
QString mSearchEmail;
};
......
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