diff options
author | A-Team <ateam@pad.test.qt.nokia.com> | 2010-12-01 23:00:14 (GMT) |
---|---|---|
committer | A-Team <ateam@pad.test.qt.nokia.com> | 2010-12-01 23:00:14 (GMT) |
commit | aeecea2fe853f1b10e84ac004de8b3461b295925 (patch) | |
tree | b4b528634a0e4bd9fc7d09779e0aeac4bc89542e /src/declarative/graphicsitems | |
parent | f6ae1a0bdd10d7afe5631c2054e4adb7b4c6bff3 (diff) | |
parent | 49187bc691e67dca741d300e95d5fcde146d5118 (diff) | |
download | Qt-aeecea2fe853f1b10e84ac004de8b3461b295925.zip Qt-aeecea2fe853f1b10e84ac004de8b3461b295925.tar.gz Qt-aeecea2fe853f1b10e84ac004de8b3461b295925.tar.bz2 |
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'src/declarative/graphicsitems')
4 files changed, 52 insertions, 14 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 649c8fb..c0a7d72 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -509,7 +509,7 @@ void QDeclarativeBorderImage::doUpdate() void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeBorderImage); - if (d->pix.isNull()) + if (d->pix.isNull() || d->width() <= 0.0 || d->height() <= 0.0) return; bool oldAA = p->testRenderHint(QPainter::Antialiasing); @@ -518,7 +518,23 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); const QDeclarativeScaleGrid *border = d->getScaleGrid(); - QMargins margins(border->left(), border->top(), border->right(), border->bottom()); + int left = border->left(); + int right = border->right(); + qreal borderWidth = left + right; + if (borderWidth > 0.0 && d->width() < borderWidth) { + qreal diff = borderWidth - d->width() - 1; + left -= qRound(diff * qreal(left) / borderWidth); + right -= qRound(diff * qreal(right) / borderWidth); + } + int top = border->top(); + int bottom = border->bottom(); + qreal borderHeight = top + bottom; + if (borderHeight > 0.0 && d->height() < borderHeight) { + qreal diff = borderHeight - d->height() - 1; + top -= qRound(diff * qreal(top) / borderHeight); + bottom -= qRound(diff * qreal(bottom) / borderHeight); + } + QMargins margins(left, top, right, bottom); QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); qDrawBorderPixmap(p, QRect(0, 0, (int)d->width(), (int)d->height()), margins, d->pix, d->pix.rect(), margins, rules); if (d->smooth) { diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 4454284..1615b0f 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1769,8 +1769,10 @@ void QDeclarativeGridView::setFooter(QDeclarativeComponent *footer) d->footer = 0; } d->footerComponent = footer; - d->updateFooter(); - d->updateGrid(); + if (isComponentComplete()) { + d->updateFooter(); + d->updateGrid(); + } emit footerChanged(); } } @@ -1799,9 +1801,11 @@ void QDeclarativeGridView::setHeader(QDeclarativeComponent *header) d->header = 0; } d->headerComponent = header; - d->updateHeader(); - d->updateFooter(); - d->updateGrid(); + if (isComponentComplete()) { + d->updateHeader(); + d->updateFooter(); + d->updateGrid(); + } emit headerChanged(); } } @@ -2226,6 +2230,8 @@ void QDeclarativeGridView::componentComplete() { Q_D(QDeclarativeGridView); QDeclarativeFlickable::componentComplete(); + d->updateHeader(); + d->updateFooter(); d->updateGrid(); if (d->isValid()) { refill(); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index d1f52be..845da79 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -402,6 +402,8 @@ public: void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { Q_Q(QDeclarativeListView); QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); + if (!q->isComponentComplete()) + return; if (item != contentItem && (!highlight || item != highlight->item)) { if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height()) || (orient == QDeclarativeListView::Horizontal && newGeometry.width() != oldGeometry.width())) { @@ -1123,8 +1125,6 @@ void QDeclarativeListViewPrivate::updateHeader() QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); header = new FxListItem(item, q); - if (visibleItems.isEmpty()) - visiblePos = header->size(); } } if (header) { @@ -1137,6 +1137,8 @@ void QDeclarativeListViewPrivate::updateHeader() header->setPosition(startPos - header->size()); } } else { + if (itemCount == 0) + visiblePos = header->size(); header->setPosition(0); } } @@ -2215,8 +2217,10 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer) d->footerComponent = footer; d->minExtentDirty = true; d->maxExtentDirty = true; - d->updateFooter(); - d->updateViewport(); + if (isComponentComplete()) { + d->updateFooter(); + d->updateViewport(); + } emit footerChanged(); } } @@ -2247,9 +2251,11 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header) d->headerComponent = header; d->minExtentDirty = true; d->maxExtentDirty = true; - d->updateHeader(); - d->updateFooter(); - d->updateViewport(); + if (isComponentComplete()) { + d->updateHeader(); + d->updateFooter(); + d->updateViewport(); + } emit headerChanged(); } } @@ -2659,6 +2665,8 @@ void QDeclarativeListView::componentComplete() Q_D(QDeclarativeListView); QDeclarativeFlickable::componentComplete(); updateSections(); + d->updateHeader(); + d->updateFooter(); if (d->isValid()) { refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp index e8da367..14a1109 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp @@ -361,10 +361,18 @@ void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p) d->position = p; } + QPen oldPen = priv->state->pen; + QColor currentColor = oldPen.color(); for (int ii = 0; ii < itemCount; ++ii) { QStaticTextItem &item = d->items[ii]; + if (item.color.isValid() && currentColor != item.color) { + painter->setPen(item.color); + currentColor = item.color; + } priv->extended->drawStaticTextItem(&item); } + if (currentColor != oldPen.color()) + painter->setPen(oldPen); } QT_END_NAMESPACE |