diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-09-17 06:37:15 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-09-17 06:37:15 (GMT) |
commit | 2f9017c7736b3f8db721f6605e6131ab376cb864 (patch) | |
tree | e2a5c7fdacdc19e2ebddcb6dcf628255d81d78f2 /src/declarative/fx | |
parent | 0c2e40683007c9405b8fc9f7efbd728ef519d78f (diff) | |
parent | 8caff8b4be02a2f28c9a2a50d3b5ef274138021e (diff) | |
download | Qt-2f9017c7736b3f8db721f6605e6131ab376cb864.zip Qt-2f9017c7736b3f8db721f6605e6131ab376cb864.tar.gz Qt-2f9017c7736b3f8db721f6605e6131ab376cb864.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r-- | src/declarative/fx/qfxborderimage.cpp | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 28 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.h | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem_p.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 10 | ||||
-rw-r--r-- | src/declarative/fx/qfxloader.cpp | 6 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.cpp | 11 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.h | 16 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect_p.h | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext.cpp | 14 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.cpp | 19 |
11 files changed, 75 insertions, 47 deletions
diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index d199d5d..ee505f2 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -386,11 +386,9 @@ void QFxBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge if (d->smooth) p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - QPixmap pix = d->pix; - QMargins margins(border()->top(), border()->left(), border()->bottom(), border()->right()); QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); - qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, pix, pix.rect(), margins, rules); + qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules); if (d->smooth) { p->setRenderHint(QPainter::Antialiasing, oldAA); p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 962fee2..dd51aa6 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2688,9 +2688,23 @@ void QFxItem::setWidth(qreal w) QRectF(x(), y(), oldWidth, height())); } +void QFxItem::resetWidth() +{ + Q_D(QFxItem); + d->widthValid = false; + setImplicitWidth(implicitWidth()); +} + +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 +2747,23 @@ void QFxItem::setHeight(qreal h) QRectF(x(), y(), width(), oldHeight)); } +void QFxItem::resetHeight() +{ + Q_D(QFxItem); + d->heightValid = false; + setImplicitHeight(implicitHeight()); +} + +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..b309cb3 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -75,8 +75,8 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false) Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) - Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) @@ -134,9 +134,13 @@ public: qreal width() const; void setWidth(qreal); + void resetWidth(); + qreal implicitWidth() const; qreal height() const; void setHeight(qreal); + void resetHeight(); + 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/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 015eacf..5de9bf3 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -831,8 +831,9 @@ void QFxListViewPrivate::fixupX() \inherits Flickable \brief The ListView item provides a list view of items provided by a model. - The model is typically provided by a QAbstractListModel "C++ model object", but can also be created directly in QML. - The items are laid out vertically or horizontally and may be flicked to scroll. + The model is typically provided by a QAbstractListModel "C++ model object", + but can also be created directly in QML. The items are laid out vertically + or horizontally and may be flicked to scroll. The below example creates a very simple vertical list, using a QML model. \image trivialListView.png @@ -871,9 +872,10 @@ QFxListView::~QFxListView() The model provides a set of data that is used to create the items for the view. For large or dynamic datasets the model is usually provided by a C++ model object. The C++ model object must be a \l - {QAbstractItemModel} subclass, a VisualModel, or a simple list. + {QAbstractItemModel} subclass or a simple list. - Models can also be created directly in QML, using a \l{ListModel} or \l{XmlListModel}. + Models can also be created directly in QML, using a \l{ListModel}, + \l{XmlListModel} or \l{VisualItemModel}. */ QVariant QFxListView::model() 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/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index fbd7ee8..7d6340f 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -69,14 +69,17 @@ void QFxPen::setColor(const QColor &c) { _color = c; _valid = _color.alpha() ? true : false; - emit updated(); + emit penChanged(); } void QFxPen::setWidth(int w) { + if (_width == w) + return; + _width = w; _valid = (_width < 1) ? false : true; - emit updated(); + emit penChanged(); } @@ -293,6 +296,7 @@ void QFxRect::setRadius(qreal radius) d->radius = radius; d->rectImage = QPixmap(); update(); + emit radiusChanged(); } /*! @@ -326,6 +330,7 @@ void QFxRect::setColor(const QColor &c) d->color = c; d->rectImage = QPixmap(); update(); + emit colorChanged(); } void QFxRect::generateRoundedRect() @@ -395,7 +400,7 @@ void QFxRect::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) void QFxRect::drawRect(QPainter &p) { Q_D(QFxRect); - if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) { + if (d->gradient && d->gradient->gradient()) { // XXX This path is still slower than the image path // Image path won't work for gradients though bool oldAA = p.testRenderHint(QPainter::Antialiasing); diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index 439cc65..e5bb8d3 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -55,8 +55,8 @@ class Q_DECLARATIVE_EXPORT QFxPen : public QObject { Q_OBJECT - Q_PROPERTY(int width READ width WRITE setWidth) - Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged) public: QFxPen(QObject *parent=0) : QObject(parent), _width(1), _color("#000000"), _valid(false) @@ -71,7 +71,7 @@ public: bool isValid() { return _valid; }; Q_SIGNALS: - void updated(); + void penChanged(); private: int _width; @@ -135,10 +135,10 @@ class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem { Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QFxGradient *gradient READ gradient WRITE setGradient) - Q_PROPERTY(QFxPen * border READ border) - Q_PROPERTY(qreal radius READ radius WRITE setRadius) + Q_PROPERTY(QFxPen * border READ border CONSTANT) + Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) public: QFxRect(QFxItem *parent=0); @@ -157,6 +157,10 @@ public: void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); +Q_SIGNALS: + void colorChanged(); + void radiusChanged(); + private Q_SLOTS: void doUpdate(); diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h index 8eb074a..c055b76 100644 --- a/src/declarative/fx/qfxrect_p.h +++ b/src/declarative/fx/qfxrect_p.h @@ -85,7 +85,7 @@ public: if (!pen) { Q_Q(QFxRect); pen = new QFxPen; - QObject::connect(pen, SIGNAL(updated()), q, SLOT(doUpdate())); + QObject::connect(pen, SIGNAL(penChanged()), q, SLOT(doUpdate())); } return pen; } 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 c106ee0..d1bafd6 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -1043,18 +1043,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; |