Commit 92e5c833 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Search Diacritic support

parent fc3be546
Pipeline #142199 passed with stage
in 1 minute and 34 seconds
......@@ -9,6 +9,7 @@
#include "akregator_debug.h"
#include "article.h"
#include "types.h"
#include "utils/textutil.h"
#include <KConfig>
#include <KConfigGroup>
#include <QUrl>
......@@ -160,17 +161,17 @@ bool Criterion::satisfiedBy(const Article &article) const
switch (predicateType) {
case Contains:
satisfied = concreteSubject.toString().indexOf(m_object.toString(), 0, Qt::CaseInsensitive) != -1;
satisfied = TextUtil::normalize(concreteSubject.toString()).indexOf(m_object.toString(), 0, Qt::CaseInsensitive) != -1;
break;
case Equals:
if (subjectType == QLatin1String("int")) {
satisfied = concreteSubject.toInt() == m_object.toInt();
} else {
satisfied = concreteSubject.toString() == m_object.toString();
satisfied = TextUtil::normalize(concreteSubject.toString()) == m_object.toString();
}
break;
case Matches:
satisfied = concreteSubject.toString().contains(QRegularExpression(m_object.toString()));
satisfied = TextUtil::normalize(concreteSubject.toString()).contains(QRegularExpression(m_object.toString()));
break;
default:
qCDebug(AKREGATOR_LOG) << "Internal inconsistency; predicateType should never be Negation";
......
......@@ -10,6 +10,7 @@
#include "akregatorconfig.h"
#include "article.h"
#include "utils/textutil.h"
#include <KLineEdit>
#include <KLocalizedString>
......@@ -132,12 +133,13 @@ void SearchBar::slotActivateSearch()
QVector<Criterion> statusCriteria;
if (!m_searchText.isEmpty()) {
const QString searchTextDiacritic(TextUtil::normalize(m_searchText));
textCriteria.reserve(3);
Criterion subjCrit(Criterion::Title, Criterion::Contains, m_searchText);
Criterion subjCrit(Criterion::Title, Criterion::Contains, searchTextDiacritic);
textCriteria << subjCrit;
Criterion crit1(Criterion::Description, Criterion::Contains, m_searchText);
Criterion crit1(Criterion::Description, Criterion::Contains, searchTextDiacritic);
textCriteria << crit1;
Criterion authCrit(Criterion::Author, Criterion::Contains, m_searchText);
Criterion authCrit(Criterion::Author, Criterion::Contains, searchTextDiacritic);
textCriteria << authCrit;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment