summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-03 07:57:19 +0200
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-03 07:57:19 +0200
commitb68a5d2cd6b08504b354b09465ab05593120fee8 (patch)
tree813f65cf0a9e9207e35611072b6927a3b0f7b97e /src
parentdaeb81493aef4fd8f632ba4ea7f8d12ed80fa7be (diff)
parent80de59a2f0289d3f7bbef405ed2175a64faabc96 (diff)
downloadqt4-tools-b68a5d2cd6b08504b354b09465ab05593120fee8.tar.gz
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Don't write to the logger widget while the application is closing down. Fix exponential behavior of QTextCursor::removeSelectedText Fix test for N900 (ARM-specific SVG results). docs - fix doc links, minor improvements Fix TextEdit bitmap tests testing the wrong element Make autotests work with qreal == float (in addition to double). Fix TextInput text getting improperly clipped fix doc links Fix docs to link to the new QML Viewer page instead of the Runtime page qmlviewer: Update the proxy factory when the user changes the proxy. Don't accept *files* that exist when *directory* is required.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp46
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h1
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp4
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp6
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp2
-rw-r--r--src/declarative/util/qdeclarativeview.cpp2
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp2
-rw-r--r--src/gui/text/qtextdocument_p.cpp7
-rw-r--r--src/gui/text/qtextdocument_p.h1
-rw-r--r--src/imports/gestures/qdeclarativegesturearea.cpp2
16 files changed, 78 insertions, 49 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 4abffc606a..bd935c9e51 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -2145,7 +2145,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const
\property QDeclarativeItem::baselineOffset
\brief The position of the item's baseline in local coordinates.
- The baseline of a Text item is the imaginary line on which the text
+ The baseline of a \l Text item is the imaginary line on which the text
sits. Controls containing text usually set their baseline to the
baseline of their text.
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index c8c9e44aa1..e745ca66b0 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -119,7 +119,7 @@ void QDeclarativeLoaderPrivate::initResize()
property, or loaded from a URL via the \l source property.
Loader can be used to delay the creation of a component until it is required.
- For example, this loads "Page1.qml" as a component into the \l Loader element
+ For example, this loads "Page1.qml" as a component into the Loader element
when the \l MouseArea is clicked:
\code
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 87da90466b..3be4014154 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -85,6 +85,19 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
The \l model of a Repeater can be any of the supported \l {qmlmodels}{Data Models}.
+ Items instantiated by the Repeater are inserted, in order, as
+ children of the Repeater's parent. The insertion starts immediately after
+ the repeater's position in its parent stacking list. This allows
+ a Repeater to be used inside a layout. For example, the following Repeater's
+ items are stacked between a red rectangle and a blue rectangle:
+
+ \snippet doc/src/snippets/declarative/repeater.qml layout
+
+ \image repeater.png
+
+
+ \section2 The \c index and \c modelData properties
+
The index of a delegate is exposed as an accessible \c index property in the delegate.
Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}.
@@ -105,25 +118,22 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
\o \image repeater-modeldata.png
\endtable
- Items instantiated by the Repeater are inserted, in order, as
- children of the Repeater's parent. The insertion starts immediately after
- the repeater's position in its parent stacking list. This allows
- a Repeater to be used inside a layout. For example, the following Repeater's
- items are stacked between a red rectangle and a blue rectangle:
-
- \snippet doc/src/snippets/declarative/repeater.qml layout
-
- \image repeater.png
A Repeater item owns all items it instantiates. Removing or dynamically destroying
an item created by a Repeater results in unpredictable behavior.
- Note that if a repeater is
- required to instantiate a large number of items, it may be more efficient to
- use other view elements such as ListView.
- \note Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects.
- For example, it cannot be used to repeat QtObjects.
+ \section2 Considerations when using Repeater
+
+ The Repeater element creates all of its delegate items when the repeater is first
+ created. This can be inefficient if there are a large number of delegate items and
+ not all of the items are required to be visible at the same time. If this is the case,
+ consider using other view elements like ListView (which only creates delegate items
+ when they are scrolled into view) or use the \l {Dynamic Object Creation} methods to
+ create items as they are required.
+
+ Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects.
+ For example, it cannot be used to repeat QtObjects:
\badcode
Item {
//XXX does not work! Can't repeat QtObject as it doesn't derive from Item.
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index c6566fff56..c066f11298 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -203,7 +203,7 @@ QString QDeclarativeTextEdit::text() const
Sets the font size in pixels.
Using this function makes the font device dependent.
- Use \l pointSize to set the size of the font in a device independent manner.
+ Use \l font.pointSize to set the size of the font in a device independent manner.
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index ed999a2c68..374f371316 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -100,8 +100,6 @@ void QDeclarativeTextInput::setText(const QString &s)
if(s == text())
return;
d->control->setText(s);
- d->updateHorizontalScroll();
- //emit textChanged();
}
/*!
@@ -550,9 +548,9 @@ void QDeclarativeTextInput::setAutoScroll(bool b)
return;
d->autoScroll = b;
- d->updateHorizontalScroll();
//We need to repaint so that the scrolling is taking into account.
updateSize(true);
+ d->updateHorizontalScroll();
emit autoScrollChanged(d->autoScroll);
}
@@ -1020,27 +1018,43 @@ bool QDeclarativeTextInput::event(QEvent* ev)
void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
- if (newGeometry.width() != oldGeometry.width())
+ Q_D(QDeclarativeTextInput);
+ if (newGeometry.width() != oldGeometry.width()) {
updateSize();
+ d->updateHorizontalScroll();
+ }
QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
}
+int QDeclarativeTextInputPrivate::calculateTextWidth()
+{
+ int cursorWidth = control->cursorWidth();
+ if(cursorItem)
+ cursorWidth = cursorItem->width();
+
+ QFontMetrics fm = QFontMetrics(font);
+ int leftBearing = 0;
+ int rightBearing = 0;
+ if (!control->text().isEmpty()) {
+ leftBearing = qMax(0, -fm.leftBearing(control->text().at(0)));
+ rightBearing = qMax(0, -fm.rightBearing(control->text().at(control->text().count()-1)));
+ }
+
+ return qRound(control->naturalTextWidth()) + qMax(cursorWidth, leftBearing) + rightBearing;
+}
+
void QDeclarativeTextInputPrivate::updateHorizontalScroll()
{
Q_Q(QDeclarativeTextInput);
- QFontMetrics fm = QFontMetrics(font);
int cix = qRound(control->cursorToX());
QRect br(q->boundingRect().toRect());
- //###Is this using bearing appropriately?
- int minLB = qMax(0, -fm.minLeftBearing());
- int minRB = qMax(0, -fm.minRightBearing());
- int widthUsed = qRound(control->naturalTextWidth()) + 1 + minRB;
+ int widthUsed = calculateTextWidth();
if (autoScroll) {
- if ((minLB + widthUsed) <= br.width()) {
+ if (widthUsed <= br.width()) {
// text fits in br; use hscroll for alignment
switch (hAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
case Qt::AlignRight:
- hscroll = widthUsed - br.width() + 1;
+ hscroll = widthUsed - br.width() - 1;
break;
case Qt::AlignHCenter:
hscroll = (widthUsed - br.width()) / 2;
@@ -1050,7 +1064,6 @@ void QDeclarativeTextInputPrivate::updateHorizontalScroll()
hscroll = 0;
break;
}
- hscroll -= minLB;
} else if (cix - hscroll >= br.width()) {
// text doesn't fit, cursor is to the right of br (scroll right)
hscroll = cix - br.width() + 1;
@@ -1070,7 +1083,6 @@ void QDeclarativeTextInputPrivate::updateHorizontalScroll()
} else {
hscroll = 0;
}
- hscroll -= minLB;
}
}
@@ -1095,7 +1107,6 @@ void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r)
offset = QPoint(d->hscroll, 0);
}
d->control->draw(p, offset, r, flags);
-
p->restore();
}
@@ -1448,8 +1459,8 @@ void QDeclarativeTextInput::selectionChanged()
void QDeclarativeTextInput::q_textChanged()
{
Q_D(QDeclarativeTextInput);
- d->updateHorizontalScroll();
updateSize();
+ d->updateHorizontalScroll();
updateMicroFocus();
emit textChanged();
emit displayTextChanged();
@@ -1475,10 +1486,7 @@ void QDeclarativeTextInput::updateSize(bool needsRedraw)
int w = width();
int h = height();
setImplicitHeight(d->control->height());
- int cursorWidth = d->control->cursorWidth();
- if(d->cursorItem)
- cursorWidth = d->cursorItem->width();
- setImplicitWidth(d->control->naturalTextWidth() + cursorWidth);
+ setImplicitWidth(d->calculateTextWidth());
setContentsSize(QSize(width(), height()));//Repaints if changed
if(w==width() && h==height() && needsRedraw){
clearCache();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 8b74bcc064..4ac5134f20 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -100,6 +100,7 @@ public:
void startCreatingCursor();
void focusChanged(bool hasFocus);
void updateHorizontalScroll();
+ int calculateTextWidth();
QLineControl* control;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 623e3df9e9..e3ce70e39b 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -228,10 +228,10 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
}
break;
case QMetaType::Float:
- if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected"));
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected"));
break;
case QVariant::Double:
- if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected"));
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected"));
break;
case QVariant::Color:
{
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index a3cddb5da0..5b30bde94f 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -493,7 +493,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const
return QMetaType::type("int");
case QDeclarativeParser::Object::DynamicProperty::Real:
- return QMetaType::type("double");
+ return sizeof(qreal) == sizeof(double) ? QMetaType::type("double") : QMetaType::type("float");
case QDeclarativeParser::Object::DynamicProperty::String:
return QMetaType::type("QString");
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 8b15ae96b9..8bf7450adc 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -151,6 +151,7 @@ void QDeclarativeEnginePrivate::defineModule()
}
/*!
+\keyword QmlGlobalQtObject
\qmlclass Qt QDeclarativeEnginePrivate
\brief The QML global Qt object provides useful enums and functions from Qt.
@@ -1077,7 +1078,7 @@ If you are certain the files will be local, you could simplify to:
\snippet doc/src/snippets/declarative/componentCreation.js 2
To create a QML object from an arbitrary string of QML (instead of a file),
-use \l{Qt::createQmlObject()}{Qt.createQmlObject()}.
+use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
*/
QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1124,7 +1125,7 @@ Each object in this array has the members \c lineNumber, \c columnNumber, \c fil
Note that this function returns immediately, and therefore may not work if
the \a qml string loads new components (that is, external QML files that have not yet been loaded).
-If this is the case, consider using \l{Qt::createComponent()}{Qt.createComponent()} instead.
+If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
*/
QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1728,8 +1729,7 @@ void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const
/*!
\qmlmethod Qt::quit()
This function causes the QDeclarativeEngine::quit() signal to be emitted.
-Within the \l {Qt Declarative UI Runtime}{qml} application this causes the
-launcher application to exit.
+Within the \l {QML Viewer}, this causes the launcher application to exit.
*/
QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e)
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index a2e3831623..fe05d20f3f 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -409,7 +409,8 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl);
if (!localFileOrQrc.isEmpty()) {
QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
- if (dir.isEmpty() || !QDir().exists(dir)) {
+ QFileInfo dirinfo(dir);
+ if (dir.isEmpty() || !dirinfo.exists() || !dirinfo.isDir()) {
if (errorString)
*errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg);
return false; // local import dirs must exist
@@ -425,7 +426,8 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
if (prefix.isEmpty()) {
// directory must at least exist for valid import
QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
- if (localFileOrQrc.isEmpty() || !QDir().exists(localFileOrQrc)) {
+ QFileInfo dirinfo(localFileOrQrc);
+ if (localFileOrQrc.isEmpty() || !dirinfo.exists() || !dirinfo.isDir()) {
if (errorString) {
if (localFileOrQrc.isEmpty())
*errorString = QDeclarativeImportDatabase::tr("import \"%1\" has no qmldir and no namespace").arg(uri);
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index c32cab6b13..153e2be4a6 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -1152,7 +1152,7 @@ bool QDeclarativeMetaType::copy(int type, void *data, const void *copy)
*static_cast<float *>(data) = float(0);
return true;
case QMetaType::Double:
- *static_cast<double *>(data) = double();
+ *static_cast<double *>(data) = double(0);
return true;
case QMetaType::QChar:
*static_cast<NS(QChar) *>(data) = NS(QChar)();
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 0414e65818..12a8d3a7eb 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -611,7 +611,7 @@ void QDeclarativeView::timerEvent(QTimerEvent* e)
}
}
-/*! \reimp */
+/*! \internal */
bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e)
{
Q_D(QDeclarativeView);
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 0692aaad8a..558300701b 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -589,7 +589,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
with a combined value of all key roles that is not already present in
the model.
- \sa {declarative/rssnews}{RSS News demo}
+ \sa {demos/declarative/rssnews}{RSS News demo}
*/
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index f3cd48157f..a55e5f364c 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -205,6 +205,7 @@ QTextDocumentPrivate::QTextDocumentPrivate()
undoEnabled = true;
inContentsChange = false;
+ inRemove = false;
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
@@ -669,7 +670,10 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati
{
if (length == 0)
return;
+ inRemove = true;
move(pos, -1, length, op);
+ inRemove = false;
+ adjustDocumentChangesAndCursors(pos, -length, op);
}
void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode)
@@ -1263,6 +1267,9 @@ void QTextDocumentPrivate::documentChange(int from, int length)
*/
void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op)
{
+ if (inRemove) // postpone, will be called again from QTextDocumentPrivate::remove()
+ return;
+
if (!editBlock)
++revision;
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index d1bd6987bc..06e0753415 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -346,6 +346,7 @@ public:
int maximumBlockCount;
uint needsEnsureMaximumBlockCount : 1;
uint inContentsChange : 1;
+ uint inRemove : 1;
QSizeF pageSize;
QString title;
QString url;
diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp
index e5647bdb50..243ba0f774 100644
--- a/src/imports/gestures/qdeclarativegesturearea.cpp
+++ b/src/imports/gestures/qdeclarativegesturearea.cpp
@@ -130,7 +130,7 @@ public:
GestureArea is an invisible item: it is never painted.
- \sa Gesture, MouseArea, {declarative/touchinteraction/gestures}{Gestures example}
+ \sa MouseArea, {declarative/touchinteraction/gestures}{Gestures example}
*/
/*!