QTextEdit - Fix selectionChange emission bug
QTextEdit did not emit selectionChange signal if selection availability did not change, but the start or end of the selection did. This was causing unit test to fail. Change-Id: Iea0cb0bae767bc8d2dd36141362f9a084af97266 Reviewed-on: http://codereview.qt-project.org/6426 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>bb10
parent
76ca6642a9
commit
bd34df230d
|
|
@ -119,7 +119,8 @@ QWidgetTextControlPrivate::QWidgetTextControlPrivate()
|
|||
#ifndef QT_NO_DRAGANDDROP
|
||||
mousePressed(false), mightStartDrag(false),
|
||||
#endif
|
||||
lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false),
|
||||
lastSelectionPosition(0), lastSelectionAnchor(0),
|
||||
ignoreAutomaticScrollbarAdjustement(false),
|
||||
overwriteMode(false),
|
||||
acceptRichText(true),
|
||||
preeditCursor(0), hideCursor(false),
|
||||
|
|
@ -577,15 +578,25 @@ void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged
|
|||
if (forceEmitSelectionChanged)
|
||||
emit q->selectionChanged();
|
||||
|
||||
bool current = cursor.hasSelection();
|
||||
if (current == lastSelectionState)
|
||||
if (cursor.position() == lastSelectionPosition
|
||||
&& cursor.anchor() == lastSelectionAnchor)
|
||||
return;
|
||||
|
||||
lastSelectionState = current;
|
||||
emit q->copyAvailable(current);
|
||||
if (!forceEmitSelectionChanged)
|
||||
bool selectionStateChange = (cursor.hasSelection()
|
||||
!= (lastSelectionPosition != lastSelectionAnchor));
|
||||
if (selectionStateChange)
|
||||
emit q->copyAvailable(cursor.hasSelection());
|
||||
|
||||
if (!forceEmitSelectionChanged
|
||||
&& (selectionStateChange
|
||||
|| (cursor.hasSelection()
|
||||
&& (cursor.position() != lastSelectionPosition
|
||||
|| cursor.anchor() != lastSelectionAnchor))))
|
||||
emit q->selectionChanged();
|
||||
|
||||
emit q->microFocusChanged();
|
||||
lastSelectionPosition = cursor.position();
|
||||
lastSelectionAnchor = cursor.anchor();
|
||||
}
|
||||
|
||||
void QWidgetTextControlPrivate::_q_updateCurrentCharFormatAndSelection()
|
||||
|
|
|
|||
|
|
@ -193,7 +193,8 @@ public:
|
|||
QPoint dragStartPos;
|
||||
QPointer<QWidget> contextWidget;
|
||||
|
||||
bool lastSelectionState;
|
||||
int lastSelectionPosition;
|
||||
int lastSelectionAnchor;
|
||||
|
||||
bool ignoreAutomaticScrollbarAdjustement;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue