summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-16 06:26:46 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-16 06:26:46 (GMT)
commit633b4b0655bf47b6f5100ee9a6c2f692b0aeb081 (patch)
treed5deeb37b770f2fdff140c2f75a1f38a992da2be
parentd3b03a7d6c4ad023572d7099ee9f9ec3f0711d04 (diff)
downloadQt-633b4b0655bf47b6f5100ee9a6c2f692b0aeb081.zip
Qt-633b4b0655bf47b6f5100ee9a6c2f692b0aeb081.tar.gz
Qt-633b4b0655bf47b6f5100ee9a6c2f692b0aeb081.tar.bz2
Experiment with implicitWidth and implicitHeight functions.
-rw-r--r--src/declarative/fx/qfxitem.cpp14
-rw-r--r--src/declarative/fx/qfxitem.h2
-rw-r--r--src/declarative/fx/qfxitem_p.h4
-rw-r--r--src/declarative/fx/qfxloader.cpp6
-rw-r--r--src/declarative/fx/qfxtext.cpp14
-rw-r--r--src/declarative/fx/qfxtextedit.cpp19
6 files changed, 31 insertions, 28 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 962fee2..c7e807c 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -2688,9 +2688,16 @@ void QFxItem::setWidth(qreal w)
QRectF(x(), y(), oldWidth, height()));
}
+qreal QFxItem::implicitWidth() const
+{
+ Q_D(const QFxItem);
+ return d->implicitWidth;
+}
+
void QFxItem::setImplicitWidth(qreal w)
{
Q_D(QFxItem);
+ d->implicitWidth = w;
if (d->width == w || widthValid())
return;
@@ -2733,9 +2740,16 @@ void QFxItem::setHeight(qreal h)
QRectF(x(), y(), width(), oldHeight));
}
+qreal QFxItem::implicitHeight() const
+{
+ Q_D(const QFxItem);
+ return d->implicitHeight;
+}
+
void QFxItem::setImplicitHeight(qreal h)
{
Q_D(QFxItem);
+ d->implicitHeight = h;
if (d->height == h || heightValid())
return;
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 7ec1ab2..9d2113f 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -134,9 +134,11 @@ public:
qreal width() const;
void setWidth(qreal);
+ qreal implicitWidth() const;
qreal height() const;
void setHeight(qreal);
+ qreal implicitHeight() const;
TransformOrigin transformOrigin() const;
void setTransformOrigin(TransformOrigin);
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index b2560ee..df75148 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -108,7 +108,7 @@ public:
widthValid(false), heightValid(false),
_componentComplete(true), _keepMouse(false),
smooth(false), keyHandler(0),
- width(0), height(0)
+ width(0), height(0), implicitWidth(0), implicitHeight(0)
{}
~QFxItemPrivate()
{ delete _anchors; }
@@ -213,6 +213,8 @@ public:
qreal width;
qreal height;
+ qreal implicitWidth;
+ qreal implicitHeight;
QPointF computeTransformOrigin() const;
diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp
index 668faa4..d0c2690 100644
--- a/src/declarative/fx/qfxloader.cpp
+++ b/src/declarative/fx/qfxloader.cpp
@@ -361,10 +361,8 @@ void QFxLoaderPrivate::_q_updateSize()
return;
switch (resizeMode) {
case QFxLoader::SizeLoaderToItem:
- if (!q->widthValid())
- q->setImplicitWidth(item->width());
- if (!q->heightValid())
- q->setImplicitHeight(item->height());
+ q->setImplicitWidth(item->width());
+ q->setImplicitHeight(item->height());
break;
case QFxLoader::SizeItemToLoader:
item->setWidth(q->width());
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 5b10289..c4e534e 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -513,17 +513,9 @@ void QFxTextPrivate::updateSize()
}
q->setBaselineOffset(fm.ascent() + yoff);
- if (!q->widthValid()) {
- int newWidth = (richText ? (int)doc->idealWidth() : size.width());
- q->setImplicitWidth(newWidth);
- }
- if (!q->heightValid()) {
- if (richText) {
- q->setImplicitHeight((int)doc->size().height());
- } else {
- q->setImplicitHeight(size.height());
- }
- }
+ //### need to comfirm cost of always setting these for richText
+ q->setImplicitWidth(richText ? (int)doc->idealWidth() : size.width());
+ q->setImplicitHeight(richText ? (int)doc->size().height() : size.height());
} else {
dirty = true;
}
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 72f12cc..0185ce0 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -1044,18 +1044,13 @@ void QFxTextEdit::updateSize()
yoff = dy/2;
}
setBaselineOffset(fm.ascent() + yoff + d->textMargin);
- if (!widthValid()) {
- int newWidth = (int)d->document->idealWidth();
- d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set
- setImplicitWidth(newWidth);
- }
- if (!heightValid()) {
- if (d->text.isEmpty()) {
- setImplicitHeight(fm.height());
- } else {
- setImplicitHeight((int)d->document->size().height());
- }
- }
+
+ //### need to comfirm cost of always setting these
+ int newWidth = (int)d->document->idealWidth();
+ d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well?
+ setImplicitWidth(newWidth);
+ setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height());
+
setContentsSize(QSize(width(), height()));
} else {
d->dirty = true;