aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit_p_p.h
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-05-04 16:07:32 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-14 00:51:15 +0200
commitbd5e23a00e97603c1cc73328c508a044f1528802 (patch)
tree8ffe4145ec6d62c5d9e0798af9d48c29d66ff176 /src/quick/items/qquicktextedit_p_p.h
parent6f9b3893c8c7bc0b6663acb34c17c120852ef7b7 (diff)
Defer construction of TextEdit/TextInput delegates.
Don't create instances of the delegate components until the item gains focus, or the cursorVisible property is set to true. Cursor delegates are typically small and relatively fast to create and so won't have a significant cost during a one off focus in event, but that cost can still add up when creating a number of TextInputs or TextEdits at once. If a delegate that is instantiated immeditately is required it is possible to instead create a child item and bind to the cursorRectangle and cursorVisible properties. Change-Id: I5ec2b5b6a30e534aee3dd5a58c6a5ac0686f5ce2 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/quick/items/qquicktextedit_p_p.h')
-rw-r--r--src/quick/items/qquicktextedit_p_p.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index e556367bcf..1fb82110ea 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -55,6 +55,7 @@
#include "qquicktextedit_p.h"
#include "qquickimplicitsizeitem_p_p.h"
+#include "qquicktextcontrol_p.h"
#include <QtQml/qqml.h>
@@ -64,19 +65,21 @@ class QQuickTextDocumentWithImageResources;
class QQuickTextControl;
class QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
{
+public:
Q_DECLARE_PUBLIC(QQuickTextEdit)
-public:
+ typedef QQuickTextEdit Public;
+
QQuickTextEditPrivate()
: color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
- , textMargin(0.0), yoff(0), font(sourceFont), cursorComponent(0), cursor(0), document(0), control(0)
+ , textMargin(0.0), yoff(0), font(sourceFont), cursorComponent(0), cursorItem(0), document(0), control(0)
, lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
, hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
, format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
, contentDirection(Qt::LayoutDirectionAuto)
, mouseSelectionMode(QQuickTextEdit::SelectCharacters), inputMethodHints(Qt::ImhNone)
, updateType(UpdatePaintNode)
- , documentDirty(true), dirty(false), richText(false), cursorVisible(false)
+ , documentDirty(true), dirty(false), richText(false), cursorVisible(false), cursorPending(false)
, focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
, selectByMouse(false), canPaste(false), canPasteValid(false), hAlignImplicit(true)
, textCached(false), inLayout(false)
@@ -96,6 +99,8 @@ public:
qreal getImplicitWidth() const;
Qt::LayoutDirection textDirection(const QString &text) const;
+ void setNativeCursorEnabled(bool enabled) { control->setCursorWidth(enabled ? 1 : 0); }
+
QColor color;
QColor selectionColor;
QColor selectedTextColor;
@@ -111,7 +116,7 @@ public:
QFont font;
QQmlComponent* cursorComponent;
- QQuickItem* cursor;
+ QQuickItem* cursorItem;
QQuickTextDocumentWithImageResources *document;
QQuickTextControl *control;
@@ -138,6 +143,7 @@ public:
bool dirty : 1;
bool richText : 1;
bool cursorVisible : 1;
+ bool cursorPending : 1;
bool focusOnPress : 1;
bool persistentSelection : 1;
bool requireImplicitWidth:1;