summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp23
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h4
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp8
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp17
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp10
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp2
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp2
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp4
9 files changed, 54 insertions, 20 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 {
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 8848d47..891b868 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -78,6 +78,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
@@ -180,13 +181,14 @@ public:
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
Qt::TextInteractionFlags textInteractionFlags() const;
- QRect cursorRect() const;
+ QRect cursorRectangle() const;
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
Q_SIGNALS:
void textChanged(const QString &);
void cursorPositionChanged();
+ void cursorRectangleChanged();
void selectionStartChanged();
void selectionEndChanged();
void selectionChanged();
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 8230941..882e981 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -191,7 +191,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
data->error.setUrl(url);
data->error.setLine(line);
data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(data->property.propertyType())));
+ data->error.setDescription(QLatin1String("Unable to assign [undefined] to ")
+ + QLatin1String(QMetaType::typeName(data->property.propertyType()))
+ + QLatin1String(" ") + data->property.name());
} else if (!scriptValue.isRegExp() && scriptValue.isFunction()) {
@@ -353,8 +355,6 @@ void QDeclarativeAbstractBinding::removeFromObject()
if (m_prevBinding) {
int index = propertyIndex();
- Q_ASSERT(m_object);
-
*m_prevBinding = m_nextBinding;
if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
m_prevBinding = 0;
@@ -363,7 +363,7 @@ void QDeclarativeAbstractBinding::removeFromObject()
if (index & 0xFF000000) {
// Value type - we don't remove the proxy from the object. It will sit their happily
// doing nothing for ever more.
- } else {
+ } else if (m_object) {
QDeclarativeData *data = QDeclarativeData::get(m_object, false);
if (data) data->clearBindingBit(index);
}
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index b5bf972..d27aced 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -1089,6 +1089,23 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
fetch.line = prop->location.start.line;
output->bytecode << fetch;
+ if (!prop->value->metadata.isEmpty()) {
+ QDeclarativeInstruction meta;
+ meta.type = QDeclarativeInstruction::StoreMetaObject;
+ meta.line = 0;
+ meta.storeMeta.data = output->indexForByteArray(prop->value->metadata);
+ meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata);
+ meta.storeMeta.propertyCache = output->propertyCaches.count();
+ // ### Surely the creation of this property cache could be more efficient
+ QDeclarativePropertyCache *propertyCache =
+ enginePrivate->cache(prop->value->metaObject()->superClass())->copy();
+ propertyCache->append(engine, prop->value->metaObject(), QDeclarativePropertyCache::Data::NoFlags,
+ QDeclarativePropertyCache::Data::IsVMEFunction);
+
+ output->propertyCaches << propertyCache;
+ output->bytecode << meta;
+ }
+
genObjectBody(prop->value);
QDeclarativeInstruction pop;
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 3b782e7..7aa17e8 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -549,15 +549,19 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
Returns an object instance from this component, or null if object creation fails.
The object will be created in the same context as the one in which the component
- was created.
+ was created. This function will always return null when called on components
+ which were not created in QML.
Note that if the returned object is to be displayed, its \c parent must be set to
- an existing item in a scene, or else the object will not be visible.
+ an existing item in a scene, or else the object will not be visible. The parent
+ argument is required to help you avoid this, you must explicitly pass in null if
+ you wish to create an object without setting a parent.
*/
/*!
\internal
- A version of create which returns a scriptObject, for use in script
+ A version of create which returns a scriptObject, for use in script.
+ This function will only work on components created in QML.
Sets graphics object parent because forgetting to do this is a frequent
and serious problem.
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index df9aa59..a7384a9 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1049,9 +1049,9 @@ If you are certain the files will be local, you could simplify to:
\snippet doc/src/snippets/declarative/componentCreation.js 2
-The methods and properties of the Component element are defined in its own
+The methods and properties of the \l {Component} element are defined in its own
page, but when using it dynamically only two methods are usually used.
-\c Component.createObject() returns the created object or \c null if there is an error.
+ \l {Component::createObject()}{Component.createObject()} returns the created object or \c null if there is an error.
If there is an error, \l {Component::errorString()}{Component.errorString()} describes
the error that occurred. Note that createObject() takes exactly one argument, which is set
to the parent of the created object. Graphical objects without a parent will not appear
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 8b64e0e..aca01b2 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -623,7 +623,7 @@ private:
inline void cleanup();
- void *data[4];
+ char data[4 * sizeof(void *)];
int type;
};
}
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
index 13e9c26..7aea7cb 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -381,7 +381,7 @@ QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj,
const QMetaObject *other,
const QDeclarativeVMEMetaData *meta,
QDeclarativeCompiledData *cdata)
-: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj)->outerContext),
+: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj, true)->outerContext),
metaData(meta), data(0), methods(0), parent(0)
{
compiledData->addref();
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 80ae5f5..99f163e 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -1128,8 +1128,8 @@ void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target)
\qml
AnchorChanges {
target: myItem
- left: undefined //remove myItem's left anchor
- right: otherItem.right
+ anchors.left: undefined //remove myItem's left anchor
+ anchors.right: otherItem.right
}
\endqml
*/