Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KNotes
Commits
b9d5739b
Commit
b9d5739b
authored
Mar 11, 2022
by
Laurent Montel
Browse files
Improve search
parent
4f9e526a
Pipeline
#148081
passed with stage
in 1 minute and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/kontactplugin/knoteslistwidgetsearchline.cpp
View file @
b9d5739b
...
...
@@ -9,6 +9,32 @@
#include
<KLocalizedString>
static
QString
normalize
(
QStringView
str
)
{
QString
out
;
out
.
reserve
(
str
.
size
());
for
(
const
auto
c
:
str
)
{
// case folding
const
auto
n
=
c
.
toCaseFolded
();
// if the character has a canonical decomposition use that and skip the
// combining diacritic markers following it
// see https://en.wikipedia.org/wiki/Unicode_equivalence
// see https://en.wikipedia.org/wiki/Combining_character
if
(
n
.
decompositionTag
()
==
QChar
::
Canonical
)
{
out
.
push_back
(
n
.
decomposition
().
at
(
0
));
}
// handle compatibility compositions such as ligatures
// see https://en.wikipedia.org/wiki/Unicode_compatibility_characters
else
if
(
n
.
decompositionTag
()
==
QChar
::
Compat
&&
n
.
isLetter
()
&&
n
.
script
()
==
QChar
::
Script_Latin
)
{
out
.
append
(
n
.
decomposition
());
}
else
{
out
.
push_back
(
n
);
}
}
return
out
;
}
KNotesListWidgetSearchLine
::
KNotesListWidgetSearchLine
(
QWidget
*
parent
)
:
KListWidgetSearchLine
(
parent
)
{
...
...
@@ -31,10 +57,11 @@ bool KNotesListWidgetSearchLine::itemMatches(const QListWidgetItem *item, const
if
(
!
iconView
)
{
return
false
;
}
if
(
iconView
->
realName
().
contains
(
s
))
{
const
QString
strNormalize
{
normalize
(
s
)};
if
(
normalize
(
iconView
->
realName
()).
contains
(
strNormalize
))
{
return
true
;
}
if
(
iconView
->
description
().
contains
(
s
))
{
if
(
normalize
(
iconView
->
description
()
)
.
contains
(
s
trNormalize
))
{
return
true
;
}
return
KListWidgetSearchLine
::
itemMatches
(
item
,
s
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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