Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Messagelib
Commits
1ae374aa
Commit
1ae374aa
authored
Jun 20, 2021
by
Laurent Montel
😁
Browse files
Allow to define icon
parent
7023bd22
Changes
4
Hide whitespace changes
Inline
Side-by-side
messagelist/src/core/widgets/autotests/CMakeLists.txt
View file @
1ae374aa
...
...
@@ -3,7 +3,7 @@ macro(add_messagelist_widget_unittest _source)
ecm_add_test
(
${
_source
}
TEST_NAME
${
_name
}
NAME_PREFIX
"messagelist-"
LINK_LIBRARIES Qt::Test KF5::MessageCore KF5::MessageList KF5::PimCommon
LINK_LIBRARIES Qt::Test KF5::MessageCore KF5::MessageList KF5::PimCommon
KF5::IconThemes
)
endmacro
()
...
...
messagelist/src/core/widgets/autotests/filternamewidgettest.cpp
View file @
1ae374aa
...
...
@@ -6,6 +6,9 @@
#include "filternamewidgettest.h"
#include "core/widgets/filternamewidget.h"
#include <KIconButton>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QTest>
QTEST_MAIN
(
FilterNameWidgetTest
)
FilterNameWidgetTest
::
FilterNameWidgetTest
(
QObject
*
parent
)
...
...
@@ -16,5 +19,14 @@ FilterNameWidgetTest::FilterNameWidgetTest(QObject *parent)
void
FilterNameWidgetTest
::
shouldHaveDefaultValues
()
{
MessageList
::
Core
::
FilterNameWidget
w
;
// TODO
auto
mainLayout
=
w
.
findChild
<
QHBoxLayout
*>
(
QStringLiteral
(
"mainLayout"
));
QVERIFY
(
mainLayout
);
QCOMPARE
(
mainLayout
->
contentsMargins
(),
{});
auto
mName
=
w
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"mName"
));
QVERIFY
(
mName
);
QVERIFY
(
mName
->
text
().
isEmpty
());
auto
mIconButton
=
w
.
findChild
<
KIconButton
*>
(
QStringLiteral
(
"mIconButton"
));
QVERIFY
(
mIconButton
);
}
messagelist/src/core/widgets/filternamewidget.cpp
View file @
1ae374aa
...
...
@@ -5,7 +5,9 @@
*/
#include "filternamewidget.h"
#include <KIconButton>
#include <KLocalizedString>
#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
...
...
@@ -14,18 +16,21 @@ using namespace MessageList::Core;
FilterNameWidget
::
FilterNameWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
,
mName
(
new
QLineEdit
(
this
))
,
mIconButton
(
new
KIconButton
(
this
))
{
auto
mainLayout
=
new
QHBoxLayout
(
this
);
mainLayout
->
setObjectName
(
QStringLiteral
(
"mainLayout"
));
mainLayout
->
setContentsMargins
({});
mName
->
setObjectName
(
QStringLiteral
(
"mName"
));
mIconButton
->
setObjectName
(
QStringLiteral
(
"mIconButton"
));
auto
label
=
new
QLabel
(
i18n
(
"Name:"
),
this
);
label
->
setObjectName
(
QStringLiteral
(
"label"
));
mainLayout
->
addWidget
(
label
);
mainLayout
->
addWidget
(
mName
);
mainLayout
->
addWidget
(
mIconButton
);
connect
(
mName
,
&
QLineEdit
::
textChanged
,
this
,
[
this
](
const
QString
&
str
)
{
const
QString
trimmedStr
=
str
.
trimmed
();
Q_EMIT
updateOkButton
(
!
trimmedStr
.
isEmpty
()
&&
!
mFilterListNames
.
contains
(
trimmedStr
));
...
...
@@ -41,6 +46,11 @@ QString FilterNameWidget::filterName() const
return
mName
->
text
();
}
QString
FilterNameWidget
::
iconName
()
const
{
return
mIconButton
->
icon
();
}
void
FilterNameWidget
::
setExistingFilterNames
(
const
QStringList
&
lst
)
{
mFilterListNames
=
lst
;
...
...
messagelist/src/core/widgets/filternamewidget.h
View file @
1ae374aa
...
...
@@ -9,6 +9,7 @@
#include "messagelist_private_export.h"
#include <QWidget>
class
QLineEdit
;
class
KIconButton
;
namespace
MessageList
{
namespace
Core
...
...
@@ -23,12 +24,14 @@ public:
Q_REQUIRED_RESULT
QString
filterName
()
const
;
void
setExistingFilterNames
(
const
QStringList
&
lst
);
Q_REQUIRED_RESULT
QString
iconName
()
const
;
Q_SIGNALS:
void
updateOkButton
(
bool
enabled
);
private:
QStringList
mFilterListNames
;
QLineEdit
*
const
mName
;
KIconButton
*
const
mIconButton
;
};
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment