summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2012-02-28 13:35:17 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-27 12:51:38 +0200
commit0ee1b4a1dea8b587a5d39bfeb7e18c97f13dd877 (patch)
tree72069427d47ad395a9b9a29ccbf5e5c69ebc0c93 /src/widgets
parent4f92f9b7251addef556b25e8ab88e00acfaf61b0 (diff)
Reverted use of tentative commit use in QWidget editors
Feature to be reimplemented simplified. Cases when input method needs to be reset with possibility to commit use QInputMethod::commit() again. Change-Id: Ibfe7aecc0799e7a76c7ac4f5d860971cfe6e97ca Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp7
-rw-r--r--src/widgets/kernel/qapplication.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp10
-rw-r--r--src/widgets/widgets/qlineedit.cpp3
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp29
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h10
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp19
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p_p.h1
8 files changed, 19 insertions, 62 deletions
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 8d1795c3c2..583e6da90a 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -815,20 +815,19 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
lastFocusItem = focusItem;
#ifndef QT_NO_IM
- if (lastFocusItem
- && (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
+ if (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod) {
// Close any external input method panel. This happens
// automatically by removing WA_InputMethodEnabled on
// the views, but if we are changing focus, we have to
// do it ourselves.
if (qApp)
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
}
+#endif //QT_NO_IM
focusItem = 0;
QFocusEvent event(QEvent::FocusOut, focusReason);
sendEvent(lastFocusItem, &event);
-#endif //QT_NO_IM
}
// This handles the case that the item has been removed from the
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 2615ac891d..a099faae3f 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2042,7 +2042,7 @@ void QApplication::setActiveWindow(QWidget* act)
if (QApplicationPrivate::focus_widget) {
if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason);
QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 9a32d952f9..cccde764ad 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -3090,7 +3090,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
qApp->inputMethod()->update(Qt::ImEnabled);
} else {
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
qApp->inputMethod()->update(Qt::ImEnabled);
}
}
@@ -5948,7 +5948,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
if (prev) {
if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
&& prev->testAttribute(Qt::WA_InputMethodEnabled)) {
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
}
if (reason != Qt::NoFocusReason) {
@@ -6057,7 +6057,7 @@ void QWidget::clearFocus()
{
if (hasFocus()) {
if (testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange);
QApplication::sendEvent(this, &focusAboutToChange);
@@ -10087,7 +10087,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
QWidget *focusWidget = d->effectiveFocusWidget();
if (on && !internalWinId() && hasFocus()
&& focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
qApp->inputMethod()->update(Qt::ImEnabled);
}
if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
@@ -10137,7 +10137,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
#ifndef QT_NO_IM
if (qApp->focusObject() == this) {
if (!on)
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
qApp->inputMethod()->update(Qt::ImEnabled);
}
#endif //QT_NO_IM
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 07843136ff..1ea636ffb2 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1669,7 +1669,7 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
case Qt::ImCursorPosition:
return QVariant(d->control->cursor());
case Qt::ImSurroundingText:
- return QVariant(d->control->realText());
+ return QVariant(d->control->text());
case Qt::ImCurrentSelection:
return QVariant(selectedText());
case Qt::ImMaximumTextLength:
@@ -1748,7 +1748,6 @@ void QLineEdit::focusOutEvent(QFocusEvent *e)
reason != Qt::PopupFocusReason)
deselect();
- d->control->commitPreedit();
d->setCursorVisible(false);
d->control->setCursorBlinkPeriod(0);
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index b4a7007190..20af574049 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -184,21 +184,15 @@ void QWidgetLineControl::paste(QClipboard::Mode clipboardMode)
/*!
\internal
-
- Exits preedit mode and commits parts marked as tentative commit
*/
void QWidgetLineControl::commitPreedit()
{
if (!composeMode())
return;
- qApp->inputMethod()->reset();
-
- if (!m_tentativeCommit.isEmpty()) {
- internalInsert(m_tentativeCommit);
- m_tentativeCommit.clear();
- finishChange(-1, true/*not used, not documented*/, false);
- }
+ qApp->inputMethod()->commit();
+ if (!composeMode())
+ return;
m_preeditCursor = 0;
setPreeditArea(-1, QString());
@@ -573,13 +567,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
else if (m_preeditCursor != oldPreeditCursor)
emit updateMicroFocus();
- bool tentativeCommitChanged = (m_tentativeCommit != event->tentativeCommitString());
- if (tentativeCommitChanged) {
- m_textDirty = true;
- m_tentativeCommit = event->tentativeCommitString();
- }
-
- if (isGettingInput || tentativeCommitChanged)
+ if (isGettingInput)
finishChange(priorState);
if (selectionChange)
@@ -687,15 +675,6 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e
return true;
}
m_cursor = cursorCopy;
-
- if (!m_tentativeCommit.isEmpty()) {
- textCopy.insert(m_cursor, m_tentativeCommit);
- bool validInput = (m_validator->validate(textCopy, cursorCopy) != QValidator::Invalid);
- if (!validInput)
- m_tentativeCommit.clear();
- }
- } else {
- m_tentativeCommit.clear();
}
}
#endif
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 62184a27bb..ebc5758d4f 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -217,22 +217,13 @@ public:
QString text() const
{
QString content = m_text;
- if (!m_tentativeCommit.isEmpty())
- content.insert(m_cursor, m_tentativeCommit);
QString res = m_maskData ? stripString(content) : content;
return (res.isNull() ? QString::fromLatin1("") : res);
}
- // like text() but doesn't include preedit
- QString realText() const
- {
- QString res = m_maskData ? stripString(m_text) : m_text;
- return (res.isNull() ? QString::fromLatin1("") : res);
- }
void setText(const QString &txt)
{
if (composeMode())
qApp->inputMethod()->reset();
- m_tentativeCommit.clear();
internalSetText(txt, -1, false);
}
void commitPreedit();
@@ -402,7 +393,6 @@ private:
int m_cursor;
int m_preeditCursor;
int m_cursorWidth;
- QString m_tentativeCommit;
Qt::LayoutDirection m_layoutDirection;
uint m_hideCursor : 1; // used to hide the m_cursor inside preedit areas
uint m_separator : 1;
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 86dfb30389..d602d6daa5 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -2000,7 +2000,6 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
layout->setAdditionalFormats(overrides);
- tentativeCommit = e->tentativeCommitString();
cursor.endEditBlock();
@@ -2057,7 +2056,6 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e)
}
#endif
} else {
- commitPreedit();
setBlinkingCursorEnabled(false);
if (cursorIsFocusIndicator
@@ -2758,14 +2756,12 @@ void QWidgetTextControlPrivate::commitPreedit()
if (!isPreediting())
return;
- cursor.beginEditBlock();
- qApp->inputMethod()->reset();
+ qApp->inputMethod()->commit();
- if (!tentativeCommit.isEmpty()) {
- cursor.insertText(tentativeCommit);
- tentativeCommit.clear();
- }
+ if (!isPreediting())
+ return;
+ cursor.beginEditBlock();
preeditCursor = 0;
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
@@ -2936,17 +2932,12 @@ bool QWidgetTextControl::find(const QString &exp, QTextDocument::FindFlags optio
QString QWidgetTextControl::toPlainText() const
{
- Q_D(const QWidgetTextControl);
- QString plainText = document()->toPlainText();
- if (!d->tentativeCommit.isEmpty())
- plainText.insert(textCursor().position(), d->tentativeCommit);
- return plainText;
+ return document()->toPlainText();
}
#ifndef QT_NO_TEXTHTMLPARSER
QString QWidgetTextControl::toHtml() const
{
- // note: currently not including tentative commit
return document()->toHtml();
}
#endif
diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h
index d0d940e521..4efb59152a 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h
@@ -209,7 +209,6 @@ public:
int preeditCursor;
bool hideCursor; // used to hide the cursor in the preedit area
- QString tentativeCommit;
QVector<QAbstractTextDocumentLayout::Selection> extraSelections;