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
KPimTextEdit
Commits
f16f822f
Commit
f16f822f
authored
Feb 16, 2022
by
Laurent Montel
Browse files
Prepare to search diacritic word
parent
f238c06f
Pipeline
#138271
passed with stages
in 9 minutes and 28 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/texteditor/commonwidget/findutils.cpp
View file @
f16f822f
...
...
@@ -36,3 +36,30 @@ int FindUtils::replaceAll(QTextDocument *document, const TextFindWidget *findWid
c
.
endEditBlock
();
return
count
;
}
// code from kitinerary/src/lib/stringutil.cpp
QChar
FindUtils
::
normalize
(
QChar
c
)
{
// 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
)
{
return
n
.
decomposition
().
at
(
0
);
}
return
n
;
}
QString
FindUtils
::
normalize
(
QStringView
str
)
{
QString
out
;
out
.
reserve
(
str
.
size
());
for
(
const
auto
c
:
str
)
{
out
.
push_back
(
normalize
(
c
));
}
return
out
;
}
src/texteditor/commonwidget/findutils.h
View file @
f16f822f
...
...
@@ -6,8 +6,9 @@
#pragma once
#include
<QChar>
#include
<QStringView>
#include
<qglobal.h>
class
QTextDocument
;
namespace
KPIMTextEdit
...
...
@@ -24,6 +25,8 @@ namespace FindUtils
* @return number of replacements done
*/
Q_REQUIRED_RESULT
int
replaceAll
(
QTextDocument
*
document
,
const
TextFindWidget
*
findWidget
,
const
TextReplaceWidget
*
replaceWidget
);
Q_REQUIRED_RESULT
QString
normalize
(
QStringView
str
);
Q_REQUIRED_RESULT
QChar
normalize
(
QChar
c
);
}
}
// namespace KPIMTextEdit
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