rpms/ibus-qt/devel ibus-qt-HEAD.patch, NONE, 1.1 ibus-qt.spec, 1.14, 1.15
Takao Fujiwara
fujiwara at fedoraproject.org
Fri Jul 23 02:52:08 UTC 2010
Author: fujiwara
Update of /cvs/pkgs/rpms/ibus-qt/devel
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv17724
Modified Files:
ibus-qt.spec
Added Files:
ibus-qt-HEAD.patch
Log Message:
Fix Bug 616277 - hangul text color is not properly set in kwrite
ibus-qt-HEAD.patch:
ibus-input-context.cpp | 103 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 101 insertions(+), 2 deletions(-)
--- NEW FILE ibus-qt-HEAD.patch ---
>From b62d2643b3654af88f456443ff18b410cf2ff092 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1 at gmail.com>
Date: Fri, 23 Jul 2010 11:32:08 +0900
Subject: [PATCH] Fix background and foreground in preedit QTextCharFormat.
---
qtim/ibus-input-context.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 101 insertions(+), 1 deletions(-)
diff --git a/qtim/ibus-input-context.cpp b/qtim/ibus-input-context.cpp
index f7d4f7b..c47fce6 100644
--- a/qtim/ibus-input-context.cpp
+++ b/qtim/ibus-input-context.cpp
@@ -563,9 +563,82 @@ IBusInputContext::slotCommitText (const TextPointer &text)
update ();
}
+static bool
+sortSegments (const AttributePointer &attr_a, const AttributePointer &attr_b)
+{
+ return attr_a->start () < attr_b->start ();
+}
+
+/*
+ * KateViewInternal::inputMethodEvent() in kdelibs doesn't support the
+ * duplicated format ranges.
+ * This function separates each AttributePointer with the minimum size.
+ * E.g.
+ * attrs[i = 0]: [0 8]
+ * attrs[j = 1]: [6 10]
+ * attrs[j = 2]: [4 8]
+ * If i == 0, the default min_end == 8 == attr_i->start () + attr_i->length ()
+ * If j == 1, the min_end becomes 6 == attr_j->start ()
+ * but it's not the minimum min_end yet.
+ * If j == 2, the min_end becomes 4 == attr_j->start ()
+ * Now min_end gets the minimum min_end.
+ * After checks the min_end between j = 0 to attrs.size(),
+ * attr_i gets the minimum min_end.
+ * Let's split attr_i's range [0 8] with [0 4] and [4 8]
+ * and then
+ * attrs[i = 0]: [0 4]
+ * attrs[i = 1]: [4 8]
+ * attrs[j = 2]: [6 10]
+ * attrs[j = 3]: [4 8]
+ * increment i = i + 1 == 1 and apply the same split.
+ * after split all attrs with the minimum rages, sort the attrs with
+ * the attr->start() so that same range formats can be consolidated into
+ * one format in IBusInputContext::displayPreeditText().
+ */
+static inline void
+sortAttrs (QList <AttributePointer> &attrs)
+{
+ for (int i = 0; i < attrs.size (); i++) {
+ AttributePointer attr_i = attrs[i];
+ uint min_end = attr_i->start () + attr_i->length ();
+ for (int j = 0; j < attrs.size (); j++) {
+ if (i == j) {
+ continue;
+ }
+ AttributePointer attr_j = attrs[j];
+ if (attr_i->start () < attr_j->start () &&
+ attr_j->start () < min_end) {
+ min_end = attr_j->start ();
+ }
+ if (attr_i->start () < attr_j->start () + attr_j->length () &&
+ attr_j->start () + attr_j->length () < min_end) {
+ min_end = attr_j->start () + attr_j->length ();
+ }
+ }
+ if (min_end == attr_i->start () + attr_i->length ()) {
+ continue;
+ }
+ attrs.removeAt (i);
+ int n = i;
+ AttributePointer attr1 = new Attribute (attr_i->type (),
+ attr_i->value (),
+ attr_i->start (),
+ min_end);
+ attrs.insert (n++, attr1);
+ AttributePointer attr2 = new Attribute (attr_i->type (),
+ attr_i->value (),
+ min_end,
+ attr_i->end ());
+ attrs.insert (n++, attr2);
+ }
+
+ qSort (attrs.begin (), attrs.end (), sortSegments);
+}
+
void
IBusInputContext::displayPreeditText (const TextPointer &text, uint cursor_pos, bool visible)
{
+ QList <AttributePointer> attrs_sortable;
QList <QAttribute> qattrs;
QString string;
@@ -575,8 +648,26 @@ IBusInputContext::displayPreeditText (const TextPointer &text, uint cursor_pos,
AttrListPointer attrs = text->attrs ();
for (uint i = 0; i < attrs->size (); i++) {
- QTextCharFormat format;
AttributePointer attr = attrs->get (i);
+ attrs_sortable.append (attr);
+ }
+ sortAttrs (attrs_sortable);
+
+ for (int i = 0; i < attrs_sortable.size (); i++) {
+ QTextCharFormat format;
+ AttributePointer attr = attrs_sortable[i];
+ int size = qattrs.size ();
+ // The first index 0 is used by QInputMethodEvent::Cursor above.
+ const int first_index = 1;
+
+ if (size > first_index) {
+ QAttribute qattr = qattrs[size - 1];
+ if(qattr.start == (int) attr->start () &&
+ qattr.length == (int) attr->length ()) {
+ format = qvariant_cast<QTextFormat> (qattr.value).toCharFormat ();
+ }
+ }
+
switch (attr->type ()) {
case Attribute::TypeUnderline:
switch (attr->value ()) {
@@ -605,6 +696,15 @@ IBusInputContext::displayPreeditText (const TextPointer &text, uint cursor_pos,
<< "unknow Attribute type" << attr->type ();
continue;
}
+
+ if (size > first_index) {
+ QAttribute qattr = qattrs[size - 1];
+ if(qattr.start == (int) attr->start () &&
+ qattr.length == (int) attr->length()) {
+ qattrs.removeAt (size - 1);
+ }
+ }
+
qattrs.append (QAttribute (QInputMethodEvent::TextFormat,
attr->start (), attr->length (), QVariant (format)));
}
--
1.6.2.5
Index: ibus-qt.spec
===================================================================
RCS file: /cvs/pkgs/rpms/ibus-qt/devel/ibus-qt.spec,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -p -r1.14 -r1.15
--- ibus-qt.spec 16 Jul 2010 14:46:28 -0000 1.14
+++ ibus-qt.spec 23 Jul 2010 02:52:08 -0000 1.15
@@ -1,12 +1,12 @@
Name: ibus-qt
Version: 1.3.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Qt IBus library and Qt input method plugin
License: GPLv2+
Group: System Environment/Libraries
URL: http://code.google.com/p/ibus/
Source0: http://ibus.googlecode.com/files/%{name}-%{version}-Source.tar.gz
-
+Patch0: ibus-qt-HEAD.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: cmake
@@ -37,6 +37,7 @@ The ibus-qt-docs package contains develo
%prep
%setup -q -n %{name}-%{version}-Source
+%patch0 -p1
%build
%cmake \
@@ -78,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT
%doc docs/html
%changelog
+* Fri Jul 23 2010 Takao Fujiwara <tfujiwar at redhat.com> - 1.3.0-2
+- Fix Bug 616277 - hangul text color is not properly set in kwrite
+
* Fri Jul 16 2010 Takao Fujiwara <tfujiwar at redhat.com> - 1.3.0-1
- Update to 1.3.0.
More information about the scm-commits
mailing list