summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-12-30 17:52:30 +1000
committerJoona Petrell <joona.t.petrell@nokia.com>2010-12-30 17:58:20 +1000
commit22daf9fbdfaa859db6414d39d9354e7d46f63005 (patch)
tree372a0d1d69fa82dd6aad44f09f239e1014bea750 /src
parent2de60ba30f86a9dd338359f7269b62ca5d0a2c46 (diff)
downloadqt4-tools-22daf9fbdfaa859db6414d39d9354e7d46f63005.tar.gz
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 f37fa62905..c1314ff45d 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 7f12c8562f..691d9953bf 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 4649be8521..4e1c29798b 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 06f77e5d8d..878f04050f 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);