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
Akonadi Search
Commits
437a98ed
Commit
437a98ed
authored
Mar 11, 2022
by
Laurent Montel
😁
Browse files
Add normalize string
parent
11bc34aa
Pipeline
#148084
passed with stage
in 1 minute and 52 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
agent/CMakeLists.txt
View file @
437a98ed
...
...
@@ -33,7 +33,11 @@ target_sources(akonadi_indexing_agent PRIVATE
scheduler.h
collectionindexingjob.h
index.h
collectionupdatejob.h
)
collectionupdatejob.h
stringutil.h
stringutil.cpp
)
ecm_qt_declare_logging_category
(
akonadi_indexing_agent HEADER akonadi_indexer_agent_debug.h IDENTIFIER AKONADI_INDEXER_AGENT_LOG CATEGORY_NAME org.kde.pim.akonadi_indexer_agent
DESCRIPTION
"akonadisearch (akonadi indexer agent)"
...
...
agent/stringutil.cpp
0 → 100644
View file @
437a98ed
/*
* SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*
*/
#include "stringutil.h"
// code from kitinerary/src/lib/stringutil.cpp
QString
StringUtil
::
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
;
}
agent/stringutil.h
0 → 100644
View file @
437a98ed
/*
* SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*
*/
#pragma once
#include <QString>
namespace
StringUtil
{
Q_REQUIRED_RESULT
QString
normalize
(
QStringView
str
);
};
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