summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2012-03-21 15:27:21 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-23 11:25:21 +0100
commite264fbffc54741d769037ad7f53439caa018d815 (patch)
tree27ee428796617b1edc7c5cd589123e92ae0a8672 /src
parenta7b68bf189fbae3a0add5660f8a95ed4359a67d5 (diff)
TextInput not to emit selection change signals if values do not change
Fixed also tests with QTBUG-24036 Test was assuming selectionStartChanged and selectionEndChanged to trigger even if their values did not change. Change-Id: I26e57cfb4ff06ec6c195ec2b0d997885c807670b Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index ce75617d..28e89fff 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -1920,16 +1920,15 @@ void QDeclarativeTextInput::selectionChanged()
updateRect();//TODO: Only update rect in selection
emit selectedTextChanged();
- if(d->lastSelectionStart != d->control->selectionStart()){
- d->lastSelectionStart = d->control->selectionStart();
- if(d->lastSelectionStart == -1)
- d->lastSelectionStart = d->control->cursor();
+ int newSelectionStart = d->control->hasSelectedText() ? d->control->selectionStart() : d->control->cursor();
+ int newSelectionEnd = d->control->hasSelectedText() ? d->control->selectionEnd() : d->control->cursor();
+
+ if (d->lastSelectionStart != newSelectionStart) {
+ d->lastSelectionStart = newSelectionStart;
emit selectionStartChanged();
}
- if(d->lastSelectionEnd != d->control->selectionEnd()){
- d->lastSelectionEnd = d->control->selectionEnd();
- if(d->lastSelectionEnd == -1)
- d->lastSelectionEnd = d->control->cursor();
+ if (d->lastSelectionEnd != newSelectionEnd) {
+ d->lastSelectionEnd = newSelectionEnd;
emit selectionEndChanged();
}
}