diff options
Diffstat (limited to 'src/declarative/graphicsitems')
15 files changed, 123 insertions, 108 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index fb1bdf6..b1ebec8 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -87,6 +87,32 @@ QT_BEGIN_NAMESPACE */ /*! + \qmlproperty url AnimatedImage::source + + This property holds the URL that refers to the source image. + + AnimatedImage can handle any image format supported by Qt, loaded from any + URL scheme supported by Qt. + + \sa QDeclarativeImageProvider +*/ + +/*! + \qmlproperty bool AnimatedImage::asynchronous + + Specifies that images on the local filesystem should be loaded + asynchronously in a separate thread. The default value is + false, causing the user interface thread to block while the + image is loaded. Setting \a asynchronous to true is useful where + maintaining a responsive user interface is more desirable + than having images immediately visible. + + Note that this property is only valid for images read from the + local filesystem. Images loaded via a network resource (e.g. HTTP) + are always loaded asynchonously. +*/ + +/*! \qmlproperty bool AnimatedImage::cache \since QtQuick 1.1 diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index bd6405c..4b4efb6 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -240,22 +240,20 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. - It can also handle .sci files, which are a QML-specific format. A .sci - file uses a simple text-based format that specifies the borders, the - image file and the tile rules. + This property can also be used to refer to .sci files, which are + written in a QML-specific, text-based format that specifies the + borders, the image file and the tile rules for a given border image. The following .sci file sets the borders to 10 on each side for the image \c picture.png: - \qml - BorderImage { - border.left: 10 - border.top: 10 - border.bottom: 10 - border.right: 10 - source: "picture.png" - } - \endqml + \code + border.left: 10 + border.top: 10 + border.bottom: 10 + border.right: 10 + source: "picture.png" + \endcode The URL may be absolute, or relative to the URL of the component. diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 474126d..fd2dc45 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -264,7 +264,7 @@ void QDeclarativeFlickablePrivate::flickY(qreal velocity) flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity); } -void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, +void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal, QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity) { Q_Q(QDeclarativeFlickable); @@ -1235,71 +1235,50 @@ void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject> } } -static inline int children_count_helper(QGraphicsObject *object) +int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty<QObject> *property) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object); - return d->children.count(); + QDeclarativeItem *contentItem= static_cast<QDeclarativeFlickablePrivate*>(property->data)->contentItem; + return contentItem->childItems().count() + contentItem->children().count(); } -static inline QObject *children_at_helper(QGraphicsObject *object, int index) +QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty<QObject> *property, int index) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object); - if (index >= 0 && index < d->children.count()) - return d->children.at(index)->toGraphicsObject(); - else + QDeclarativeItem *contentItem = static_cast<QDeclarativeFlickablePrivate*>(property->data)->contentItem; + + int childItemCount = contentItem->childItems().count(); + + if (index < 0) return 0; -} -static inline void children_clear_helper(QGraphicsObject *object) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object); - int childCount = d->children.count(); - if (static_cast<QDeclarativeItemPrivate*>(d)->componentComplete) { - for (int index = 0 ;index < childCount; index++) { - d->children.at(0)->setParentItem(0); - } + if (index < childItemCount) { + return contentItem->childItems().at(index)->toGraphicsObject(); } else { - for (int index = 0 ;index < childCount; index++) { - QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, /*newParentVariant=*/0, /*thisPointerVariant=*/0); - } + return contentItem->children().at(index - childItemCount); } + return 0; } -int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty<QObject> *prop) +void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty<QObject> *property) { - return QDeclarativeItemPrivate::resources_count(prop) + - children_count_helper(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem); -} + QDeclarativeItem *contentItem = static_cast<QDeclarativeFlickablePrivate*>(property->data)->contentItem; -QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty<QObject> *prop, int i) -{ - int resourcesCount = QDeclarativeItemPrivate::resources_count(prop); - if (i < resourcesCount) - return QDeclarativeItemPrivate::resources_at(prop, i); - const int j = i - resourcesCount; - QGraphicsObject *contentObject = static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem; - if (j < children_count_helper(contentObject)) - return children_at_helper(contentObject, j); - return 0; -} + const QList<QGraphicsItem*> graphicsItems = contentItem->childItems(); + for (int i = 0; i < graphicsItems.count(); i++) + contentItem->scene()->removeItem(graphicsItems[i]); -void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty<QObject> *prop) -{ - QDeclarativeItemPrivate::resources_clear(prop); - QGraphicsObject *contentObject = - static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem; - children_clear_helper(contentObject); + const QList<QObject*> objects = contentItem->children(); + for (int i = 0; i < objects.count(); i++) + objects[i]->setParent(0); } QDeclarativeListProperty<QObject> QDeclarativeFlickable::flickableData() { Q_D(QDeclarativeFlickable); return QDeclarativeListProperty<QObject>(this, (void *)d, QDeclarativeFlickablePrivate::data_append, - QDeclarativeFlickablePrivate::data_count, - QDeclarativeFlickablePrivate::data_at, - QDeclarativeFlickablePrivate::data_clear - ); + QDeclarativeFlickablePrivate::data_count, + QDeclarativeFlickablePrivate::data_at, + QDeclarativeFlickablePrivate::data_clear); } QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildren() diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 20410ab..e53472d 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -824,7 +824,9 @@ void QDeclarativeGridViewPrivate::createHighlight() if (highlight) { if (trackedItem == highlight) trackedItem = 0; - delete highlight->item; + if (highlight->item->scene()) + highlight->item->scene()->removeItem(highlight->item); + highlight->item->deleteLater(); delete highlight; highlight = 0; delete highlightXAnimator; @@ -1828,7 +1830,7 @@ void QDeclarativeGridView::setHighlightRangeMode(HighlightRangeMode mode) \o Qt.LeftToRight (default) - Items will be laid out starting in the top, left corner. The flow is dependent on the \l GridView::flow property. \o Qt.RightToLeft - Items will be laid out starting in the top, right corner. The flow is dependent - on the \l GridView:flow property. + on the \l GridView::flow property. \endlist When using the attached property \l {LayoutMirroring::enabled} for locale layouts, @@ -2282,6 +2284,7 @@ qreal QDeclarativeGridView::maxXExtent() const } else { highlightStart = d->highlightRangeStart; highlightEnd = d->highlightRangeEnd; + lastItemPosition = 0; if (d->model && d->model->count()) lastItemPosition = d->rowPosAt(d->model->count()-1); } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index ee2d19d..d36d163 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2604,6 +2604,17 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep) If \a item is a \c null value, this maps the point from the coordinate system of the root QML view. */ + +/*! + Maps the point (\a x, \a y), which is in \a item's coordinate system, to + this item's coordinate system, and returns a script value with \c x and \c y + properties matching the mapped cooordinate. + + If \a item is a \c null value, this maps the point from the coordinate + system of the root QML view. + + \sa Item::mapFromItem() +*/ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qreal y) const { QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject(); @@ -2630,6 +2641,17 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qr If \a item is a \c null value, this maps \a x and \a y to the coordinate system of the root QML view. */ + +/*! + Maps the point (\a x, \a y), which is in this item's coordinate system, to + \a item's coordinate system, and returns a script value with \c x and \c y + properties matching the mapped cooordinate. + + If \a item is a \c null value, this maps \a x and \a y to the coordinate + system of the root QML view. + + \sa Item::mapToItem() +*/ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qreal y) const { QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject(); @@ -2649,8 +2671,17 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea /*! \qmlmethod Item::forceActiveFocus() - Force active focus on the item. - This method sets focus on the item and makes sure that all the focus scopes higher in the object hierarchy are also given focus. + Forces active focus on the item. + + This method sets focus on the item and makes sure that all the focus scopes + higher in the object hierarchy are also given the focus. +*/ + +/*! + Forces active focus on the item. + + This method sets focus on the item and makes sure that all the focus scopes + higher in the object hierarchy are also given the focus. */ void QDeclarativeItem::forceActiveFocus() { @@ -2669,7 +2700,12 @@ void QDeclarativeItem::forceActiveFocus() Returns the visible child item at point (\a x, \a y), which is in this item's coordinate system, or \c null if there is no such item. - */ +*/ + +/*! + Returns the visible child item at point (\a x, \a y), which is in this + item's coordinate system, or 0 if there is no such item. +*/ QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const { const QList<QGraphicsItem *> children = childItems(); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index e75189c..f0fc96b 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -932,7 +932,9 @@ void QDeclarativeListViewPrivate::createHighlight() if (highlight) { if (trackedItem == highlight) trackedItem = 0; - delete highlight->item; + if (highlight->item->scene()) + highlight->item->scene()->removeItem(highlight->item); + highlight->item->deleteLater(); delete highlight; highlight = 0; delete highlightPosAnimator; @@ -2851,7 +2853,7 @@ void QDeclarativeListView::geometryChanged(const QRectF &newGeometry, Q_D(QDeclarativeListView); d->maxExtentDirty = true; d->minExtentDirty = true; - if (d->isRightToLeft() && d->orient == Qt::Horizontal) { + if (d->isRightToLeft() && d->orient == QDeclarativeListView::Horizontal) { // maintain position relative to the right edge int dx = newGeometry.width() - oldGeometry.width(); setContentX(contentX() - dx); diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 79e52cd..94f128d 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -203,7 +203,9 @@ void QDeclarativePathViewPrivate::createHighlight() bool changed = false; if (highlightItem) { - delete highlightItem; + if (highlightItem->scene()) + highlightItem->scene()->removeItem(highlightItem); + highlightItem->deleteLater(); highlightItem = 0; changed = true; } diff --git a/src/declarative/graphicsitems/qdeclarativepincharea.cpp b/src/declarative/graphicsitems/qdeclarativepincharea.cpp index a84d63e..0e14ff1 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea.cpp +++ b/src/declarative/graphicsitems/qdeclarativepincharea.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p.h index c6b0275..357c060 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea_p.h +++ b/src/declarative/graphicsitems/qdeclarativepincharea_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h index ce67623..a01859c 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 6d1b15d..20e4eef 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -41,7 +41,6 @@ #include "private/qdeclarativetext_p.h" #include "private/qdeclarativetext_p_p.h" -#include <private/qtextdocumentlayout_p.h> #include <qdeclarativestyledtext_p.h> #include <qdeclarativeinfo.h> #include <qdeclarativepixmapcache_p.h> @@ -83,14 +82,6 @@ private: static QSet<QUrl> errors; }; -class QDeclarativeTextDocumentLayout : public QTextDocumentLayout -{ - Q_OBJECT -public: - QDeclarativeTextDocumentLayout(QTextDocument *doc); - void setLineHeight(qreal lineHeight, QDeclarativeText::LineHeightMode mode); -}; - DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE); QString QDeclarativeTextPrivate::elideChar = QString(0x2026); @@ -185,15 +176,6 @@ void QTextDocumentWithImageResources::setText(const QString &text) QSet<QUrl> QTextDocumentWithImageResources::errors; -QDeclarativeTextDocumentLayout::QDeclarativeTextDocumentLayout(QTextDocument *doc) - : QTextDocumentLayout(doc) { -} - -void QDeclarativeTextDocumentLayout::setLineHeight(qreal lineHeight, QDeclarativeText::LineHeightMode mode = QDeclarativeText::ProportionalHeight) -{ - QTextDocumentLayout::setLineHeight(lineHeight, QTextDocumentLayout::LineHeightMode(mode)); -} - QDeclarativeTextPrivate::~QDeclarativeTextPrivate() { } @@ -243,11 +225,6 @@ void QDeclarativeTextPrivate::updateLayout() singleline = false; QDeclarativeStyledText::parse(text, layout); } - } else { - ensureDoc(); - QDeclarativeTextDocumentLayout *layout = new QDeclarativeTextDocumentLayout(doc); - layout->setLineHeight(lineHeight, lineHeightMode); - doc->setDocumentLayout(layout); } updateSize(); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 24d7f75..6a9cf19 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -273,7 +273,6 @@ void QDeclarativeTextEdit::setText(const QString &text) \o TextEdit.AutoText \o TextEdit.PlainText \o TextEdit.RichText - \o TextEdit.StyledText \endlist The default is TextEdit.AutoText. If the text format is TextEdit.AutoText the text edit diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 231bd37..c17a360 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -564,13 +564,11 @@ QRect QDeclarativeTextInput::cursorRectangle() const \qmlproperty int TextInput::selectionStart The cursor position before the first character in the current selection. - Setting this and selectionEnd allows you to specify a selection in the - text edit. - Note that if selectionStart == selectionEnd then there is no current - selection. + This property is read-only. To change the selection, use select(start,end), + selectAll(), or selectWord(). - \sa selectionEnd, cursorPosition, selectedText, select() + \sa selectionEnd, cursorPosition, selectedText */ int QDeclarativeTextInput::selectionStart() const { @@ -582,13 +580,11 @@ int QDeclarativeTextInput::selectionStart() const \qmlproperty int TextInput::selectionEnd The cursor position after the last character in the current selection. - Setting this and selectionStart allows you to specify a selection in the - text edit. - Note that if selectionStart == selectionEnd then there is no current - selection. + This property is read-only. To change the selection, use select(start,end), + selectAll(), or selectWord(). - \sa selectionStart, cursorPosition, selectedText, select() + \sa selectionStart, cursorPosition, selectedText */ int QDeclarativeTextInput::selectionEnd() const { @@ -1854,6 +1850,7 @@ bool QDeclarativeTextInput::isInputMethodComposing() const void QDeclarativeTextInputPrivate::init() { Q_Q(QDeclarativeTextInput); + control->setParent(q); control->setCursorWidth(1); control->setPasswordCharacter(QLatin1Char('*')); q->setSmooth(smooth); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 0ae984a..0325016 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -70,7 +70,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplic { Q_DECLARE_PUBLIC(QDeclarativeTextInput) public: - QDeclarativeTextInputPrivate() : control(new QLineControl(QString())), + QDeclarativeTextInputPrivate() : control(new QLineControl), color((QRgb)0), style(QDeclarativeText::Normal), styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft), mouseSelectionMode(QDeclarativeTextInput::SelectCharacters), inputMethodHints(Qt::ImhNone), @@ -89,7 +89,6 @@ public: ~QDeclarativeTextInputPrivate() { - delete control; } int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp index 9aef504..e7bcf1f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp @@ -63,9 +63,6 @@ public: QVector<QChar> chars; }; -Q_GUI_EXPORT extern int qt_defaultDpiX(); -Q_GUI_EXPORT extern int qt_defaultDpiY(); - namespace { class DrawTextItemRecorder: public QPaintEngine { |