1 |
dilfridge 11/10/29 18:30:18 |
2 |
|
3 |
Added: kdelibs-4.7.2-nepomuk-unicode.patch |
4 |
Log: |
5 |
Add unicode nepomuk fix from packager list |
6 |
|
7 |
(Portage version: 2.1.10.31/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 kde-base/kdelibs/files/kdelibs-4.7.2-nepomuk-unicode.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/kde-base/kdelibs/files/kdelibs-4.7.2-nepomuk-unicode.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/kde-base/kdelibs/files/kdelibs-4.7.2-nepomuk-unicode.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: kdelibs-4.7.2-nepomuk-unicode.patch |
16 |
=================================================================== |
17 |
diff --git a/nepomuk/query/querybuilderdata_p.h b/nepomuk/query/querybuilderdata_p.h |
18 |
index 055482e..3880e13 100644 |
19 |
--- a/nepomuk/query/querybuilderdata_p.h |
20 |
+++ b/nepomuk/query/querybuilderdata_p.h |
21 |
@@ -32,6 +32,28 @@ |
22 |
#include "query_p.h" |
23 |
#include "groupterm_p.h" |
24 |
|
25 |
+namespace { |
26 |
+/// A hack to avoid passing extended chars to the bif:search_excerpts method which cannot handle |
27 |
+/// utf8 chars which use more than one char, ie. wide chars. |
28 |
+/// Thus, we simply truncate each term at the first wide char. |
29 |
+QStringList stripExtendedCharsHack(const QStringList& terms) { |
30 |
+ QStringList newTerms; |
31 |
+ foreach(const QString& term, terms) { |
32 |
+ int i = 0; |
33 |
+ while(i < term.length()) { |
34 |
+ if(term[i].unicode() > 0x7f) { |
35 |
+ break; |
36 |
+ } |
37 |
+ ++i; |
38 |
+ } |
39 |
+ if(i > 0) { |
40 |
+ newTerms.append(term.left(i)); |
41 |
+ } |
42 |
+ } |
43 |
+ return newTerms; |
44 |
+} |
45 |
+} |
46 |
+ |
47 |
namespace Nepomuk { |
48 |
namespace Query { |
49 |
class QueryBuilderData |
50 |
@@ -246,16 +268,23 @@ namespace Nepomuk { |
51 |
for( QHash<QString, QStringList>::const_iterator it = m_fullTextSearchTerms.constBegin(); |
52 |
it != m_fullTextSearchTerms.constEnd(); ++it ) { |
53 |
const QString& varName = it.key(); |
54 |
- const QStringList& terms = it.value(); |
55 |
- // bif:search_excerpt wants a vector of all search terms |
56 |
- excerptParts |
57 |
- << QString::fromLatin1("bif:search_excerpt(bif:vector(bif:charset_recode('%1', '_WIDE_', 'UTF-8')), %2)") |
58 |
- .arg( terms.join(QLatin1String("','")), |
59 |
- varName ); |
60 |
+ const QStringList terms = stripExtendedCharsHack(it.value()); |
61 |
+ if(terms.count()) { |
62 |
+ // bif:search_excerpt wants a vector of all search terms |
63 |
+ excerptParts |
64 |
+ << QString::fromLatin1("bif:search_excerpt(bif:vector('%1'), %2)") |
65 |
+ .arg( terms.join(QLatin1String("','")), |
66 |
+ varName ); |
67 |
+ } |
68 |
} |
69 |
|
70 |
- return QString::fromLatin1("(bif:concat(%1)) as ?_n_f_t_m_ex_") |
71 |
- .arg(excerptParts.join(QLatin1String(","))); |
72 |
+ if(excerptParts.count()) { |
73 |
+ return QString::fromLatin1("(bif:concat(%1)) as ?_n_f_t_m_ex_") |
74 |
+ .arg(excerptParts.join(QLatin1String(","))); |
75 |
+ } |
76 |
+ else { |
77 |
+ return QString(); |
78 |
+ } |
79 |
} |
80 |
else { |
81 |
return QString(); |