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

Add job. Improve dialog

parent 6545529a
......@@ -76,6 +76,7 @@ set(kdepim_addressline_LIB_SRCS
set(kdepim_addressline_blacklist_baloo_LIB_SRCS
addressline/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.cpp
addressline/blacklistbaloocompletion/blacklistbalooemaillist.cpp
addressline/blacklistbaloocompletion/blacklistbalooemailsearchjob.cpp
)
set(kdepim_LIB_SRCS
......
......@@ -13,3 +13,8 @@ set( libkdepim_blacklistbalooemaillisttest_SRCS blacklistbalooemaillisttest.cpp
kde4_add_unit_test( libkdepim_blacklistbalooemaillisttest ${libkdepim_blacklistbalooemaillisttest_SRCS})
target_link_libraries( libkdepim_blacklistbalooemaillisttest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} kdepim)
set( libkdepim_blacklistbalooemailsearchjobtest_SRCS blacklistbalooemailsearchjobtest.cpp )
kde4_add_unit_test( libkdepim_blacklistbalooemailsearchjobtest ${libkdepim_blacklistbalooemailsearchjobtest_SRCS})
target_link_libraries( libkdepim_blacklistbalooemailsearchjobtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} kdepim)
......@@ -20,8 +20,10 @@
#include "blacklistbalooemailcompletiondialogtest.h"
#include "../blacklistbalooemailcompletiondialog.h"
#include "../blacklistbalooemaillist.h"
#include <QLabel>
#include <klineedit.h>
#include <kpushbutton.h>
#include <qtest_kde.h>
BlackListBalooEmailCompletionDialogTest::BlackListBalooEmailCompletionDialogTest(QObject *parent)
: QObject(parent)
......@@ -44,6 +46,32 @@ void BlackListBalooEmailCompletionDialogTest::shouldHaveDefaultValue()
QVERIFY(searchLineEdit);
QVERIFY(searchLineEdit->isClearButtonShown());
QVERIFY(searchLineEdit->trapReturnKey());
QVERIFY(searchLineEdit->text().isEmpty());
KPushButton *seachButton = qFindChild<KPushButton *>(&dlg, QLatin1String("search_button"));
QVERIFY(seachButton);
QVERIFY(!seachButton->isEnabled());
KPIM::BlackListBalooEmailList *emailList = qFindChild<KPIM::BlackListBalooEmailList *>(&dlg, QLatin1String("email_list"));
QVERIFY(emailList);
}
void BlackListBalooEmailCompletionDialogTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
{
KPIM::BlackListBalooEmailCompletionDialog dlg;
KLineEdit *searchLineEdit = qFindChild<KLineEdit *>(&dlg, QLatin1String("search_lineedit"));
KPushButton *seachButton = qFindChild<KPushButton *>(&dlg, QLatin1String("search_button"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QLatin1String("fo"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QLatin1String("foo"));
QVERIFY(seachButton->isEnabled());
searchLineEdit->setText(QLatin1String("o "));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QLatin1String(" o "));
QVERIFY(!seachButton->isEnabled());
}
QTEST_KDEMAIN(BlackListBalooEmailCompletionDialogTest, GUI)
......@@ -30,6 +30,7 @@ public:
~BlackListBalooEmailCompletionDialogTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldEnablePushButtonWhenTestSizeSupperiorToTwo();
};
#endif // BLACKLISTBALOOEMAILCOMPLETIONDIALOGTEST_H
......@@ -19,6 +19,7 @@
*/
#include "blacklistbalooemaillisttest.h"
#include "../blacklistbalooemaillist.h"
#include <qtest_kde.h>
BlackListBalooEmailListTest::BlackListBalooEmailListTest(QObject *parent)
......@@ -32,4 +33,10 @@ BlackListBalooEmailListTest::~BlackListBalooEmailListTest()
}
void BlackListBalooEmailListTest::shouldHaveDefaultValue()
{
KPIM::BlackListBalooEmailList blackList;
QVERIFY(blackList.count() == 0);
}
QTEST_KDEMAIN(BlackListBalooEmailListTest, GUI)
......@@ -29,6 +29,8 @@ class BlackListBalooEmailListTest : public QObject
public:
explicit BlackListBalooEmailListTest(QObject *parent = 0);
~BlackListBalooEmailListTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // BLACKLISTBALOOEMAILLISTTEST_H
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "blacklistbalooemailsearchjobtest.h"
#include "../blacklistbalooemailsearchjob.h"
#include <qtest_kde.h>
BlackListBalooEmailSearchJobTest::BlackListBalooEmailSearchJobTest(QObject *parent)
: QObject(parent)
{
}
BlackListBalooEmailSearchJobTest::~BlackListBalooEmailSearchJobTest()
{
}
void BlackListBalooEmailSearchJobTest::shouldNotSearchWhenTextIsEmpty()
{
KPIM::BlackListBalooEmailSearchJob *job = new KPIM::BlackListBalooEmailSearchJob;
QVERIFY(!job->start());
}
QTEST_KDEMAIN(BlackListBalooEmailSearchJobTest, NoGUI)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef BLACKLISTBALOOEMAILSEARCHJOBTEST_H
#define BLACKLISTBALOOEMAILSEARCHJOBTEST_H
#include <QObject>
class BlackListBalooEmailSearchJobTest : public QObject
{
Q_OBJECT
public:
explicit BlackListBalooEmailSearchJobTest(QObject *parent = 0);
~BlackListBalooEmailSearchJobTest();
private Q_SLOTS:
void shouldNotSearchWhenTextIsEmpty();
};
#endif // BLACKLISTBALOOEMAILSEARCHJOBTEST_H
......@@ -25,6 +25,7 @@
#include <QVBoxLayout>
#include <QLabel>
#include <KLineEdit>
#include <KPushButton>
using namespace KPIM;
......@@ -57,11 +58,17 @@ BlackListBalooEmailCompletionDialog::BlackListBalooEmailCompletionDialog(QWidget
mSearchLineEdit->setObjectName(QLatin1String("search_lineedit"));
searchLayout->addWidget(mSearchLineEdit);
//Add i18n in kf5
mSearchButton = new KPushButton(QLatin1String("Search"));
mSearchButton->setObjectName(QLatin1String("search_button"));
mSearchButton->setEnabled(false);
searchLayout->addWidget(mSearchButton);
mEmailList = new BlackListBalooEmailList;
mEmailList->setObjectName(QLatin1String("email_list"));
mainLayout->addWidget(mEmailList);
connect(mSearchLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSearchLineEditChanged(QString)));
connect(this, SIGNAL(okClicked()), this, SLOT(slotSave()));
readConfig();
}
......@@ -71,6 +78,11 @@ BlackListBalooEmailCompletionDialog::~BlackListBalooEmailCompletionDialog()
writeConfig();
}
void BlackListBalooEmailCompletionDialog::slotSearchLineEditChanged(const QString &text)
{
mSearchButton->setEnabled(text.trimmed().count() > 2);
}
void BlackListBalooEmailCompletionDialog::readConfig()
{
KConfigGroup group( KGlobal::config(), "BlackListBalooEmailCompletionDialog" );
......@@ -90,3 +102,8 @@ void BlackListBalooEmailCompletionDialog::slotSave()
{
//TODO
}
void BlackListBalooEmailCompletionDialog::slotSearch()
{
//TODO
}
......@@ -24,6 +24,7 @@
#include <KDialog>
#include "kdepim_export.h"
class KLineEdit;
class KPushButton;
namespace KPIM {
class BlackListBalooEmailList;
class KDEPIM_EXPORT BlackListBalooEmailCompletionDialog : public KDialog
......@@ -35,12 +36,15 @@ public:
private slots:
void slotSave();
void slotSearch();
void slotSearchLineEditChanged(const QString &text);
private:
void writeConfig();
void readConfig();
KLineEdit *mSearchLineEdit;
BlackListBalooEmailList *mEmailList;
KPushButton *mSearchButton;
};
}
......
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "blacklistbalooemailsearchjob.h"
using namespace KPIM;
BlackListBalooEmailSearchJob::BlackListBalooEmailSearchJob(QObject *parent)
: QObject(parent)
{
}
BlackListBalooEmailSearchJob::~BlackListBalooEmailSearchJob()
{
}
bool BlackListBalooEmailSearchJob::start()
{
if (mSearchEmail.trimmed().isEmpty()) {
deleteLater();
return false;
}
//TODO
return true;
}
void BlackListBalooEmailSearchJob::setSearchEmail(const QString &searchEmail)
{
mSearchEmail = searchEmail;
}
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef BLACKLISTBALOOEMAILSEARCHJOB_H
#define BLACKLISTBALOOEMAILSEARCHJOB_H
#include <QObject>
#include "kdepim_export.h"
namespace KPIM {
class KDEPIM_EXPORT BlackListBalooEmailSearchJob : public QObject
{
Q_OBJECT
public:
explicit BlackListBalooEmailSearchJob(QObject *parent=0);
~BlackListBalooEmailSearchJob();
bool start();
void setSearchEmail(const QString &searchEmail);
private:
QString mSearchEmail;
};
}
#endif // BLACKLISTBALOOEMAILSEARCHJOB_H
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