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
KPimTextEdit
Commits
bed0b06c
Commit
bed0b06c
authored
Mar 08, 2022
by
Laurent Montel
😁
Browse files
Synchronize normalize code
parent
f311412a
Pipeline
#146949
passed with stages
in 7 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/texteditor/commonwidget/findutils.cpp
View file @
bed0b06c
...
...
@@ -205,28 +205,28 @@ bool FindUtils::find(QTextEdit *view, const QString &searchText, QTextDocument::
}
// 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
));
// 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
;
}
src/texteditor/commonwidget/findutils.h
View file @
bed0b06c
...
...
@@ -34,7 +34,6 @@ replaceAll(QTextEdit *view, const QString &str, const QString &replaceWidget, Te
Q_REQUIRED_RESULT
KPIMTEXTEDIT_TESTS_EXPORT
int
replaceAll
(
QTextDocument
*
document
,
const
QRegularExpression
&
regExp
,
const
QString
&
replaceWidget
,
TextEditFindBarBase
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
QString
normalize
(
QStringView
str
);
Q_REQUIRED_RESULT
QChar
normalize
(
QChar
c
);
Q_REQUIRED_RESULT
bool
find
(
QPlainTextEdit
*
view
,
const
QString
&
searchText
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
bool
find
(
QTextEdit
*
view
,
const
QString
&
searchText
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
QTextDocument
::
FindFlags
convertTextEditFindFlags
(
TextEditFindBarBase
::
FindFlags
textEditFlags
);
...
...
Write
Preview
Supports
Markdown
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