summaryrefslogtreecommitdiffstats
path: root/src/gui/inputmethod
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-05-12 13:43:13 (GMT)
committeraxis <qt-info@nokia.com>2009-05-12 13:43:13 (GMT)
commite4cfb0ac1320a1832cedd69495151bc817075a23 (patch)
tree439ae8ae460c2b06be8d8d8e2324e1dd6878cc1e /src/gui/inputmethod
parent3749fcfdb5b6dcf538ceb909f1fec7971fe3a74b (diff)
downloadQt-e4cfb0ac1320a1832cedd69495151bc817075a23.zip
Qt-e4cfb0ac1320a1832cedd69495151bc817075a23.tar.gz
Qt-e4cfb0ac1320a1832cedd69495151bc817075a23.tar.bz2
Fixed the translation from S60 text format to Qt text format in FEP.
This was done by making sure that the format code is called from both start and update, because S60 will often return nothing in start, but then later on return something in update. In addition, we fall back on our own format if S60 does not give us anything. Currently it seems to give us a format only when using predictive text.
Diffstat (limited to 'src/gui/inputmethod')
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp51
2 files changed, 34 insertions, 18 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h
index 9ce9724..50f8a12 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_p.h
+++ b/src/gui/inputmethod/qcoefepinputcontext_p.h
@@ -65,6 +65,7 @@ private:
void commitCurrentString();
void updateHints();
void applyHints(Qt::InputMethodHints hints);
+ void applyFormat(QList<QInputMethodEvent::Attribute> *attributes);
// From MCoeFepAwareTextEditor
public:
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 1ae3d79..8612e55 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -465,6 +465,37 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints)
CCoeEnv::Static()->InputCapabilitiesChanged();
}
+void QCoeFepInputContext::applyFormat(QList<QInputMethodEvent::Attribute> *attributes)
+{
+ TCharFormat cFormat;
+ TInt numChars = 0;
+ TInt charPos = 0;
+ int oldSize = attributes->size();
+ while (m_formatRetriever) {
+ m_formatRetriever->GetFormatOfFepInlineText(cFormat, numChars, charPos);
+ if (numChars <= 0) {
+ // This shouldn't happen according to S60 docs, but apparently does sometimes.
+ break;
+ }
+ attributes->append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
+ charPos,
+ numChars,
+ QVariant(qt_TCharFormat2QTextCharFormat(cFormat))));
+ charPos += numChars;
+ if (charPos >= m_preeditString.size()) {
+ break;
+ }
+ }
+
+ if (attributes->size() == oldSize) {
+ // S60 didn't provide any format, so let's give our own instead.
+ attributes->append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
+ 0,
+ m_preeditString.size(),
+ standardFormat(PreeditFormat)));
+ }
+}
+
void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText,
TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* /*aCustomDraw*/,
MFepInlineTextFormatRetriever& aInlineTextFormatRetriever,
@@ -485,24 +516,7 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText,
m_formatRetriever = &aInlineTextFormatRetriever;
m_pointerHandler = &aPointerEventHandlerDuringInlineEdit;
- TCharFormat cFormat;
- TInt numChars = 0;
- TInt charPos = 0;
- while (m_formatRetriever) {
- m_formatRetriever->GetFormatOfFepInlineText(cFormat, numChars, charPos);
- if (numChars <= 0) {
- // This shouldn't happen according to S60 docs, but apparently does sometimes.
- break;
- }
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
- charPos,
- numChars,
- QVariant(qt_TCharFormat2QTextCharFormat(cFormat))));
- charPos += numChars;
- if (charPos >= m_preeditString.size()) {
- break;
- }
- }
+ applyFormat(&attributes);
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
m_inlinePosition,
@@ -522,6 +536,7 @@ void QCoeFepInputContext::UpdateFepInlineTextL(const TDesC& aNewInlineText,
m_inlinePosition = aPositionOfInsertionPointInInlineText;
QList<QInputMethodEvent::Attribute> attributes;
+ applyFormat(&attributes);
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
m_inlinePosition,
m_cursorVisibility,