summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 7b00d2f..e34bb3d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -80,6 +80,14 @@ TextEdit {
\image declarative-textedit.gif
+ Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific
+ to a look-and-feel. For example, to add flickable scrolling that follows the cursor:
+
+ \snippet snippets/declarative/texteditor.qml 0
+
+ A particular look-and-feel might use smooth scrolling (eg. using SmoothedFollow), might have a visible
+ scrollbar, or a scrollbar that fades in to show location, etc.
+
\sa Text
*/
@@ -574,7 +582,7 @@ void QDeclarativeTextEdit::setCursorDelegate(QDeclarativeComponent* c)
disconnect(d->control, SIGNAL(cursorPositionChanged()),
this, SLOT(moveCursorDelegate()));
d->control->setCursorWidth(-1);
- dirtyCache(cursorRect());
+ dirtyCache(cursorRectangle());
delete d->cursor;
d->cursor = 0;
}
@@ -601,7 +609,7 @@ void QDeclarativeTextEdit::loadCursorDelegate()
connect(d->control, SIGNAL(cursorPositionChanged()),
this, SLOT(moveCursorDelegate()));
d->control->setCursorWidth(0);
- dirtyCache(cursorRect());
+ dirtyCache(cursorRectangle());
QDeclarative_setParent_noEvent(d->cursor, this);
d->cursor->setParentItem(this);
d->cursor->setHeight(QFontMetrics(d->font).height());
@@ -854,10 +862,12 @@ Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const
}
/*!
- Returns the rectangle where the text cursor is rendered
- within the text edit.
+ \qmlproperty rectangle TextEdit::cursorRectangle
+
+ The rectangle where the text cursor is rendered
+ within the text edit. Read-only.
*/
-QRect QDeclarativeTextEdit::cursorRect() const
+QRect QDeclarativeTextEdit::cursorRectangle() const
{
Q_D(const QDeclarativeTextEdit);
return d->control->cursorRect().toRect().translated(0,-d->yoff);
@@ -1076,6 +1086,7 @@ void QDeclarativeTextEditPrivate::init()
QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
+ QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorRectangleChanged()));
document = control->document();
document->setDefaultFont(font);
@@ -1170,7 +1181,7 @@ void QDeclarativeTextEdit::updateSize()
newWidth += 3;// ### Need a better way of accounting for space between char and cursor
// ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
setImplicitWidth(newWidth);
- setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height());
+ setImplicitHeight(d->document->isEmpty() ? fm.height() : (int)d->document->size().height());
setContentsSize(QSize(width(), height()));
} else {