summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-04-22 12:10:50 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2010-04-22 12:16:30 +0200
commitcc37d494c2c6ef5768e4bc30cad62f24fee033c3 (patch)
treedee88dbf9aa875b25ceda0d2e1e7a5282a3f7ba1 /src/gui/widgets
parent2f14520ce72f0798a751f796baf93dd3f77a276d (diff)
downloadqt4-tools-cc37d494c2c6ef5768e4bc30cad62f24fee033c3.tar.gz
Fix regression: auto completion text cursor problem in Q3FileDialog
This was another regression in QLineEdit introduced with the move to QLineControl setCursorPosition clear the selection, and setSelection move the cursor position. So the case where we want the position at the beginning of the selection need to be handled separately (by doing the selection reverse) This does not cover the case where the position is in the middle, or outside the selection, but it is not possible to do. Task-number: QTBUG-10019 Reviewed-by: jbache
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qlineedit.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 2d2df92278..f041a36d86 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -738,8 +738,14 @@ bool QLineEdit::validateAndSet(const QString &newText, int newPos,
setText(oldText);
return false;
}
- setCursorPosition(newPos);
- setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag));
+ int selstart = qMin(newMarkAnchor, newMarkDrag);
+ int sellength = qAbs(newMarkAnchor - newMarkDrag);
+ if (selstart == newPos) {
+ selstart = qMax(newMarkAnchor, newMarkDrag);
+ sellength = -sellength;
+ }
+ //setSelection also set the position
+ setSelection(selstart, sellength);
return true;
}
#endif //QT3_SUPPORT