if (d->url.isEmpty()) {
d->pix.clear(this);
d->status = Null;
- setImplicitWidth(0);
- setImplicitHeight(0);
+ setImplicitSize(0, 0);
emit statusChanged(d->status);
update();
} else {
d->pix.connectDownloadProgress(this, SLOT(requestProgress(qint64,qint64)));
} else {
QSize impsize = d->pix.implicitSize();
- setImplicitWidth(impsize.width());
- setImplicitHeight(impsize.height());
+ setImplicitSize(impsize.width(), impsize.height());
if (d->pix.isReady()) {
d->status = Ready;
} else {
QSize impsize = d->pix.implicitSize();
- setImplicitWidth(impsize.width());
- setImplicitHeight(impsize.height());
+ setImplicitSize(impsize.width(), impsize.height());
if (d->pix.isReady()) {
d->status = Ready;
d->status = Ready;
}
- setImplicitWidth(impsize.width());
- setImplicitHeight(impsize.height());
+ setImplicitSize(impsize.width(), impsize.height());
if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height())
emit sourceSizeChanged();
if (d->fillMode == PreserveAspectFit) {
if (!d->pix.width() || !d->pix.height()) {
- setImplicitWidth(0);
- setImplicitHeight(0);
+ setImplicitSize(0, 0);
return;
}
qreal w = widthValid() ? width() : d->pix.width();
d->paintedWidth = heightScale * qreal(d->pix.width());
d->paintedHeight = h;
}
- if (widthValid() && !heightValid()) {
- setImplicitHeight(d->paintedHeight);
- } else {
- setImplicitHeight(d->pix.height());
- }
- if (heightValid() && !widthValid()) {
- setImplicitWidth(d->paintedWidth);
- } else {
- setImplicitWidth(d->pix.width());
- }
+ qreal iHeight = (widthValid() && !heightValid()) ? d->paintedHeight : d->pix.height();
+ qreal iWidth = (heightValid() && !widthValid()) ? d->paintedWidth : d->pix.width();
+ setImplicitSize(iWidth, iHeight);
+
} else if (d->fillMode == PreserveAspectCrop) {
if (!d->pix.width() || !d->pix.height())
return;
void QQuickImageBase::pixmapChange()
{
Q_D(QQuickImageBase);
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
+ setImplicitSize(d->pix.width(), d->pix.height());
}
QT_END_NAMESPACE
d->implicitHeightChanged();
}
+void QQuickItem::setImplicitSize(qreal w, qreal h)
+{
+ Q_D(QQuickItem);
+ bool wChanged = w != d->implicitWidth;
+ bool hChanged = h != d->implicitHeight;
+
+ d->implicitWidth = w;
+ d->implicitHeight = h;
+
+ bool wDone = false;
+ bool hDone = false;
+ if (d->width == w || widthValid()) {
+ if (wChanged)
+ d->implicitWidthChanged();
+ wDone = true;
+ }
+ if (d->height == h || heightValid()) {
+ if (hChanged)
+ d->implicitHeightChanged();
+ hDone = true;
+ }
+ if (wDone && hDone)
+ return;
+
+ qreal oldWidth = d->width;
+ qreal oldHeight = d->height;
+ if (!wDone)
+ d->width = w;
+ if (!hDone)
+ d->height = h;
+
+ d->dirty(QQuickItemPrivate::Size);
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, oldHeight));
+
+ if (!wDone && wChanged)
+ d->implicitWidthChanged();
+ if (!hDone && hChanged)
+ d->implicitHeightChanged();
+}
+
/*!
Returns whether the height property has been set explicitly.
*/
bool widthValid() const; // ### better name?
void setImplicitHeight(qreal);
bool heightValid() const; // ### better name?
+ void setImplicitSize(qreal, qreal);
virtual void classBegin();
virtual void componentComplete();
updatingSize = true;
- if (!itemWidthValid)
- q->setImplicitWidth(item->implicitWidth());
- else
- q->setImplicitWidth(item->width());
+ qreal iWidth = !itemWidthValid ? item->implicitWidth() : item->width();
+ qreal iHeight = !itemHeightValid ? item->implicitHeight() : item->height();
+ q->setImplicitSize(iWidth, iHeight);
+
if (loaderGeometryChanged && q->widthValid())
item->setWidth(q->width());
-
- if (!itemHeightValid)
- q->setImplicitHeight(item->implicitHeight());
- else
- q->setImplicitHeight(item->height());
if (loaderGeometryChanged && q->heightValid())
item->setHeight(q->height());
finishApplyTransitions();
d->doingPositioning = false;
//Set implicit size to the size of its children
- setImplicitHeight(contentSize.height());
- setImplicitWidth(contentSize.width());
+ setImplicitSize(contentSize.width(), contentSize.height());
}
void QQuickBasePositioner::positionX(int x, const PositionedItem &target)
QFontMetrics fm(font);
if (text.isEmpty()) {
- q->setImplicitWidth(0);
- q->setImplicitHeight(fm.height());
+ q->setImplicitSize(0, fm.height());
paintedSize = QSize(0, fm.height());
emit q->paintedSizeChanged();
q->update();
//### need to comfirm cost of always setting these for richText
internalWidthUpdate = true;
+ qreal iWidth = -1;
if (!q->widthValid())
- q->setImplicitWidth(size.width());
+ iWidth = size.width();
else if (requireImplicitWidth)
- q->setImplicitWidth(naturalWidth);
+ iWidth = naturalWidth;
+ if (iWidth > -1)
+ q->setImplicitSize(iWidth, size.height());
internalWidthUpdate = false;
- q->setImplicitHeight(size.height());
+ if (iWidth == -1)
+ q->setImplicitHeight(size.height());
if (paintedSize != size) {
paintedSize = size;
emit q->paintedSizeChanged();
if (!widthValid() && d->document->textWidth() != newWidth)
d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug)
// ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
+ qreal iWidth = -1;
if (!widthValid())
- setImplicitWidth(newWidth);
+ iWidth = newWidth;
else if (d->requireImplicitWidth)
- setImplicitWidth(naturalWidth);
+ iWidth = naturalWidth;
qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height();
- setImplicitHeight(newHeight);
+ if (iWidth > -1)
+ setImplicitSize(iWidth, newHeight);
+ else
+ setImplicitHeight(newHeight);
d->paintedSize = QSize(newWidth, newHeight);
emit paintedSizeChanged();
Q_D(QQuickTextInput);
int w = width();
int h = height();
- setImplicitHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text.
- setImplicitWidth(d->calculateTextWidth());
+ setImplicitSize(d->calculateTextWidth(), d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text.
if (w==width() && h==height() && needsRedraw)
update();
}
QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QQuickView *view = new QQuickView;
view->setSource(source);