Commit 38bd3d84 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to QLineEdit

parent e3be514e
......@@ -20,7 +20,7 @@
#include "recentaddresswidgettest.h"
#include "../recentaddress/recentaddresswidget.h"
#include <KLineEdit>
#include <QLineEdit>
#include <QToolButton>
#include <QListWidget>
#include <QTest>
......@@ -38,10 +38,9 @@ RecentAddressWidgetTest::~RecentAddressWidgetTest()
void RecentAddressWidgetTest::shouldHaveDefaultValue()
{
KPIM::RecentAddressWidget w;
KLineEdit *lineedit = w.findChild<KLineEdit *>(QStringLiteral("line_edit"));
QLineEdit *lineedit = w.findChild<QLineEdit *>(QStringLiteral("line_edit"));
QVERIFY(lineedit);
QVERIFY(lineedit->isClearButtonEnabled());
QVERIFY(lineedit->trapReturnKey());
QVERIFY(lineedit->text().isEmpty());
QToolButton *newButton = w.findChild<QToolButton *>(QStringLiteral("new_button"));
......@@ -76,7 +75,7 @@ void RecentAddressWidgetTest::shouldInformThatItWasChanged()
{
KPIM::RecentAddressWidget w;
QVERIFY(!w.wasChanged());
KLineEdit *lineedit = w.findChild<KLineEdit *>(QStringLiteral("line_edit"));
QLineEdit *lineedit = w.findChild<QLineEdit *>(QStringLiteral("line_edit"));
lineedit->setText(QStringLiteral("foo"));
QToolButton *newButton = w.findChild<QToolButton *>(QStringLiteral("new_button"));
QVERIFY(newButton);
......@@ -90,7 +89,7 @@ void RecentAddressWidgetTest::shouldInformThatItWasChanged()
void RecentAddressWidgetTest::shouldNotAddMultiSameLine()
{
KPIM::RecentAddressWidget w;
KLineEdit *lineedit = w.findChild<KLineEdit *>(QStringLiteral("line_edit"));
QLineEdit *lineedit = w.findChild<QLineEdit *>(QStringLiteral("line_edit"));
QToolButton *newButton = w.findChild<QToolButton *>(QStringLiteral("new_button"));
QListWidget *listview = w.findChild<QListWidget *>(QStringLiteral("list_view"));
......@@ -108,7 +107,7 @@ void RecentAddressWidgetTest::shouldNotAddMultiSameLine()
void RecentAddressWidgetTest::shouldNotAddEmptyLine()
{
KPIM::RecentAddressWidget w;
KLineEdit *lineedit = w.findChild<KLineEdit *>(QStringLiteral("line_edit"));
QLineEdit *lineedit = w.findChild<QLineEdit *>(QStringLiteral("line_edit"));
QToolButton *newButton = w.findChild<QToolButton *>(QStringLiteral("new_button"));
QListWidget *listview = w.findChild<QListWidget *>(QStringLiteral("list_view"));
QCOMPARE(listview->count(), 0);
......@@ -129,7 +128,7 @@ void RecentAddressWidgetTest::shouldNotAddEmptyLine()
void RecentAddressWidgetTest::shouldDisableAddButton()
{
KPIM::RecentAddressWidget w;
KLineEdit *lineedit = w.findChild<KLineEdit *>(QStringLiteral("line_edit"));
QLineEdit *lineedit = w.findChild<QLineEdit *>(QStringLiteral("line_edit"));
QToolButton *newButton = w.findChild<QToolButton *>(QStringLiteral("new_button"));
lineedit->setText(QStringLiteral("foo"));
......
......@@ -20,9 +20,10 @@
#include "recentaddresswidget.h"
#include "recentaddresses.h"
#include "misc/lineeditcatchreturnkey.h"
#include <KConfig>
#include <KLineEdit>
#include <QLineEdit>
#include <QPushButton>
#include <KMessageBox>
#include <KLocalizedString>
......@@ -44,14 +45,14 @@ RecentAddressWidget::RecentAddressWidget(QWidget *parent)
QHBoxLayout *lineLayout = new QHBoxLayout;
layout->addLayout(lineLayout);
mLineEdit = new KLineEdit(this);
mLineEdit = new QLineEdit(this);
mLineEdit->setObjectName(QStringLiteral("line_edit"));
mLineEdit->setTrapReturnKey(true);
new LineEditCatchReturnKey(mLineEdit, this);
mLineEdit->installEventFilter(this);
mLineEdit->setClearButtonEnabled(true);
KPIM::EmailValidator *emailValidator = new KPIM::EmailValidator(this);
mLineEdit->setValidator(emailValidator);
connect(mLineEdit, &KLineEdit::returnPressed, this, &RecentAddressWidget::slotAddItem);
connect(mLineEdit, &QLineEdit::returnPressed, this, &RecentAddressWidget::slotAddItem);
lineLayout->addWidget(mLineEdit);
......@@ -61,7 +62,7 @@ RecentAddressWidget::RecentAddressWidget(QWidget *parent)
mNewButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
mNewButton->setEnabled(false);
connect(mNewButton, &QPushButton::clicked, this, &RecentAddressWidget::slotAddItem);
connect(mLineEdit, &KLineEdit::textChanged, this, &RecentAddressWidget::slotUpdateAddButton);
connect(mLineEdit, &QLineEdit::textChanged, this, &RecentAddressWidget::slotUpdateAddButton);
lineLayout->addWidget(mNewButton);
mRemoveButton = new QToolButton(this);
......
......@@ -26,7 +26,7 @@
#include <QStringList>
class KConfig;
class QListWidget;
class KLineEdit;
class QLineEdit;
class QToolButton;
namespace KPIM {
......@@ -56,7 +56,7 @@ private:
QToolButton *mNewButton = nullptr;
QToolButton *mRemoveButton = nullptr;
QListWidget *mListView = nullptr;
KLineEdit *mLineEdit = nullptr;
QLineEdit *mLineEdit = nullptr;
bool mDirty = false;
};
}
......
......@@ -23,7 +23,7 @@
#include "../blacklistbalooemaillist.h"
#include <KListWidgetSearchLine>
#include <QLabel>
#include <KLineEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QTest>
#include <addressline/blacklistbaloocompletion/blacklistbalooemailwarning.h>
......@@ -45,10 +45,9 @@ void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
QLabel *searchLabel = widget.findChild<QLabel *>(QStringLiteral("search_label"));
QVERIFY(searchLabel);
KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
QLineEdit *searchLineEdit = widget.findChild<QLineEdit *>(QStringLiteral("search_lineedit"));
QVERIFY(searchLineEdit);
QVERIFY(searchLineEdit->isClearButtonEnabled());
QVERIFY(searchLineEdit->trapReturnKey());
QVERIFY(searchLineEdit->text().isEmpty());
QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
......@@ -79,9 +78,8 @@ void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
QLabel *excludeDomainLabel = widget.findChild<QLabel *>(QStringLiteral("domain_label"));
QVERIFY(excludeDomainLabel);
KLineEdit *excludeDomainLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("domain_lineedit"));
QLineEdit *excludeDomainLineEdit = widget.findChild<QLineEdit *>(QStringLiteral("domain_lineedit"));
QVERIFY(excludeDomainLineEdit);
QVERIFY(excludeDomainLineEdit->trapReturnKey());
QVERIFY(excludeDomainLineEdit->text().isEmpty());
QVERIFY(excludeDomainLineEdit->isClearButtonEnabled());
QVERIFY(!excludeDomainLineEdit->placeholderText().isEmpty());
......@@ -99,7 +97,7 @@ void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
{
KPIM::BlackListBalooEmailCompletionWidget widget;
KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
QLineEdit *searchLineEdit = widget.findChild<QLineEdit *>(QStringLiteral("search_lineedit"));
QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QStringLiteral("fo"));
......
......@@ -23,9 +23,10 @@
#include "blacklistbalooemailsearchjob.h"
#include "blacklistbalooemailutil.h"
#include "blacklistbalooemailwarning.h"
#include "misc/lineeditcatchreturnkey.h"
#include <KLocalizedString>
#include <KLineEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
......@@ -49,13 +50,13 @@ BlackListBalooEmailCompletionWidget::BlackListBalooEmailCompletionWidget(QWidget
lab->setObjectName(QStringLiteral("search_label"));
searchLayout->addWidget(lab);
mSearchLineEdit = new KLineEdit(this);
mSearchLineEdit = new QLineEdit(this);
mSearchLineEdit->setPlaceholderText(i18n("Research is done from 3 characters"));
mSearchLineEdit->setFocus();
mSearchLineEdit->setClearButtonEnabled(true);
mSearchLineEdit->setTrapReturnKey(true);
new KPIM::LineEditCatchReturnKey(mSearchLineEdit, this);
mSearchLineEdit->setObjectName(QStringLiteral("search_lineedit"));
connect(mSearchLineEdit, &KLineEdit::returnPressed, this, &BlackListBalooEmailCompletionWidget::slotCheckIfUpdateBlackListIsNeeded);
connect(mSearchLineEdit, &QLineEdit::returnPressed, this, &BlackListBalooEmailCompletionWidget::slotCheckIfUpdateBlackListIsNeeded);
searchLayout->addWidget(mSearchLineEdit);
mSearchButton = new QPushButton(QIcon::fromTheme(QStringLiteral("edit-find")), i18n("Search"), this);
......@@ -126,11 +127,11 @@ BlackListBalooEmailCompletionWidget::BlackListBalooEmailCompletionWidget(QWidget
excludeDomainLabel->setObjectName(QStringLiteral("domain_label"));
excludeDomainLayout->addWidget(excludeDomainLabel);
mExcludeDomainLineEdit = new KLineEdit(this);
mExcludeDomainLineEdit = new QLineEdit(this);
excludeDomainLayout->addWidget(mExcludeDomainLineEdit);
mExcludeDomainLineEdit->setObjectName(QStringLiteral("domain_lineedit"));
mExcludeDomainLineEdit->setClearButtonEnabled(true);
mExcludeDomainLineEdit->setTrapReturnKey(true);
new KPIM::LineEditCatchReturnKey(mExcludeDomainLineEdit, this);
mExcludeDomainLineEdit->setPlaceholderText(i18n("Separate domain with \'%1\'", QLatin1Char(',')));
connect(mEmailList, &QListWidget::itemSelectionChanged, this, &BlackListBalooEmailCompletionWidget::slotSelectionChanged);
......
......@@ -24,7 +24,7 @@
#include <QWidget>
#include "libkdepimakonadi_private_export.h"
class QPushButton;
class KLineEdit;
class QLineEdit;
class QLabel;
class KListWidgetSearchLine;
namespace KPIM {
......@@ -54,8 +54,8 @@ private:
void hideMoreResultAndChangeLimit();
QStringList mOriginalExcludeDomain;
QLabel *mNumberOfEmailsFound = nullptr;
KLineEdit *mSearchLineEdit = nullptr;
KLineEdit *mExcludeDomainLineEdit = nullptr;
QLineEdit *mSearchLineEdit = nullptr;
QLineEdit *mExcludeDomainLineEdit = nullptr;
BlackListBalooEmailList *mEmailList = nullptr;
QPushButton *mSearchButton = nullptr;
QPushButton *mSelectButton = nullptr;
......
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