summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-12-30 07:52:30 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-12-30 07:58:20 (GMT)
commit22daf9fbdfaa859db6414d39d9354e7d46f63005 (patch)
tree372a0d1d69fa82dd6aad44f09f239e1014bea750 /src
parent2de60ba30f86a9dd338359f7269b62ca5d0a2c46 (diff)
downloadQt-22daf9fbdfaa859db6414d39d9354e7d46f63005.zip
Qt-22daf9fbdfaa859db6414d39d9354e7d46f63005.tar.gz
Qt-22daf9fbdfaa859db6414d39d9354e7d46f63005.tar.bz2
Add convenience deselect() functions to TextInput and TextEdit
Task-number: QTBUG-16059 Reviewed-by: Christopher Ham
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp13
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h1
4 files changed, 26 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index f37fa62..c1314ff 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -996,6 +996,19 @@ void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus)
}
/*!
+ \qmlmethod void TextEdit::deselect()
+
+ Removes active text selection.
+*/
+void QDeclarativeTextEdit::deselect()
+{
+ Q_D(QDeclarativeTextEdit);
+ QTextCursor c = d->control->textCursor();
+ c.clearSelection();
+ d->control->setTextCursor(c);
+}
+
+/*!
\qmlmethod void TextEdit::selectAll()
Causes all text to be selected.
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 7f12c85..691d995 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -223,6 +223,7 @@ Q_SIGNALS:
void selectByMouseChanged(bool selectByMouse);
public Q_SLOTS:
+ void deselect();
void selectAll();
void selectWord();
void select(int start, int end);
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 4649be8..4e1c297 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -1166,6 +1166,17 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property)
}
/*!
+ \qmlmethod void TextInput::deselect()
+
+ Removes active text selection.
+*/
+void QDeclarativeTextInput::deselect()
+{
+ Q_D(QDeclarativeTextInput);
+ d->control->deselect();
+}
+
+/*!
\qmlmethod void TextInput::selectAll()
Causes all text to be selected.
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index 06f77e5..878f040 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -231,6 +231,7 @@ protected:
void focusInEvent(QFocusEvent *event);
public Q_SLOTS:
+ void deselect();
void selectAll();
void selectWord();
void select(int start, int end);