QTextEdit to use tentative commit instead of QInputPanel::commit()
Latter to be deprecated. Change-Id: I2c302c73a7ab2f4201af6a3c6fb4a64a4760263e Reviewed-by: Lars Knoll <lars.knoll@nokia.com>bb10
parent
1dbfbf4c66
commit
b5c37d9e13
|
|
@ -1537,8 +1537,7 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto
|
|||
const QTextCursor oldSelection = cursor;
|
||||
const int oldCursorPos = cursor.position();
|
||||
|
||||
if (isPreediting())
|
||||
qApp->inputPanel()->commit();
|
||||
commitPreedit();
|
||||
|
||||
if (trippleClickTimer.isActive()
|
||||
&& ((pos - trippleClickPoint).toPoint().manhattanLength() < QApplication::startDragDistance())) {
|
||||
|
|
@ -1648,7 +1647,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button
|
|||
int selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit);
|
||||
|
||||
if (newCursorPos != selectionStartPos) {
|
||||
qApp->inputPanel()->commit();
|
||||
commitPreedit();
|
||||
// commit invalidates positions
|
||||
newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
|
||||
selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit);
|
||||
|
|
@ -1774,8 +1773,7 @@ void QWidgetTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton
|
|||
#ifndef QT_NO_DRAGANDDROP
|
||||
mightStartDrag = false;
|
||||
#endif
|
||||
if (isPreediting())
|
||||
qApp->inputPanel()->commit();
|
||||
commitPreedit();
|
||||
|
||||
const QTextCursor oldSelection = cursor;
|
||||
setCursorPosition(pos);
|
||||
|
|
@ -2752,6 +2750,27 @@ bool QWidgetTextControlPrivate::isPreediting() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void QWidgetTextControlPrivate::commitPreedit()
|
||||
{
|
||||
if (!isPreediting())
|
||||
return;
|
||||
|
||||
cursor.beginEditBlock();
|
||||
qApp->inputPanel()->reset();
|
||||
|
||||
if (!tentativeCommit.isEmpty()) {
|
||||
cursor.insertText(tentativeCommit);
|
||||
tentativeCommit.clear();
|
||||
}
|
||||
|
||||
preeditCursor = 0;
|
||||
QTextBlock block = cursor.block();
|
||||
QTextLayout *layout = block.layout();
|
||||
layout->setPreeditArea(-1, QString());
|
||||
layout->clearAdditionalFormats();
|
||||
cursor.endEditBlock();
|
||||
}
|
||||
|
||||
bool QWidgetTextControl::setFocusToNextOrPreviousAnchor(bool next)
|
||||
{
|
||||
Q_D(QWidgetTextControl);
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ public:
|
|||
#endif
|
||||
|
||||
bool isPreediting() const;
|
||||
void commitPreedit();
|
||||
|
||||
void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue