summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-08-03 06:53:26 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-08-03 06:53:26 (GMT)
commit14c57306bb0d9edd6c45cd142b49896f746fe9d1 (patch)
treeb7a8eb759e553979634d2506274484cb1a13c7e1
parent018bc2baa05320c41d124785064064cd03fe8a43 (diff)
downloadQt-14c57306bb0d9edd6c45cd142b49896f746fe9d1.zip
Qt-14c57306bb0d9edd6c45cd142b49896f746fe9d1.tar.gz
Qt-14c57306bb0d9edd6c45cd142b49896f746fe9d1.tar.bz2
Move the 'smooth' property to QFxItem
Items currently using it are QFxImage, QFxText, QFxLineEdit, QFxTextEdit and QFxPaintedItem.
-rw-r--r--src/declarative/fx/qfximage.cpp40
-rw-r--r--src/declarative/fx/qfximage.h4
-rw-r--r--src/declarative/fx/qfximage_p.h3
-rw-r--r--src/declarative/fx/qfxitem.cpp85
-rw-r--r--src/declarative/fx/qfxitem.h6
-rw-r--r--src/declarative/fx/qfxitem_p.h5
-rw-r--r--src/declarative/fx/qfxlineedit.cpp2
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp30
-rw-r--r--src/declarative/fx/qfxpainteditem.h4
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h3
-rw-r--r--src/declarative/fx/qfxtext.cpp15
-rw-r--r--src/declarative/fx/qfxtext.h10
-rw-r--r--src/declarative/fx/qfxtext_p.h3
-rw-r--r--src/declarative/fx/qfxtextedit.cpp2
14 files changed, 79 insertions, 133 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 5976cd5..ec3053c 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -61,7 +61,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage)
\inherits Item
The Image element supports untransformed, stretched, tiled, and grid-scaled images.
-
+
For an explanation of stretching and tiling, see the fillMode property description.
For an explanation of grid-scaling see the scaleGrid property description
@@ -271,44 +271,6 @@ void QFxImage::componentComplete()
\brief the 3x3 grid used to scale an image, excluding the corners.
*/
-/*!
- \qmlproperty bool Image::smooth
-
- Set this property if you want the image to be smoothly filtered when scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the Image is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the image is stationary on
- the screen. A common pattern when animating an image is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
- */
-
-/*!
- \property QFxImage::smooth
- \brief whether the image is smoothly transformed.
-
- This property is provided purely for the purpose of optimization. Turning
- smooth transforms off is faster, but looks worse; turning smooth
- transformations on is slower, but looks better.
-
- By default smooth transformations are off.
-*/
-bool QFxImage::smoothTransform() const
-{
- Q_D(const QFxImage);
- return d->smooth;
-}
-
-void QFxImage::setSmoothTransform(bool s)
-{
- Q_D(QFxImage);
- if (d->smooth == s)
- return;
- d->smooth = s;
- update();
-}
-
void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QFxImage);
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 9c2ef30..fc9cfe0 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -67,7 +67,6 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem
Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid)
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false)
- Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged);
public:
@@ -81,9 +80,6 @@ public:
QPixmap pixmap() const;
void setPixmap(const QPixmap &);
- bool smoothTransform() const;
- void setSmoothTransform(bool);
-
enum Status { Null, Ready, Loading, Error };
Status status() const;
qreal progress() const;
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index 41b628c..2ce41f8 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -71,7 +71,7 @@ class QFxImagePrivate : public QFxItemPrivate
public:
QFxImagePrivate()
- : scaleGrid(0), smooth(false),
+ : scaleGrid(0),
fillMode(QFxImage::Stretch),
status(QFxImage::Null), sciReply(0),
progress(0.0)
@@ -94,7 +94,6 @@ public:
QFxScaleGrid *scaleGrid;
QPixmap pix;
- bool smooth : 1;
QFxImage::FillMode fillMode;
QFxImage::Status status;
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 4479215..2d3fa8d 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -135,7 +135,7 @@ QFxContents::QFxContents() : m_height(0), m_width(0)
The contents properties allow an item access to the size of its
children. This property is useful if you have an item that needs to be
- sized to fit its children.
+ sized to fit its children.
*/
/*!
@@ -257,7 +257,7 @@ void QFxContents::setItem(QFxItem *item)
}
\endqml
\endqmltext
-
+
\ingroup group_coreitems
*/
@@ -458,10 +458,10 @@ QFxItem *QFxItem::parentItem() const
\qmlproperty list<Item> Item::children
\qmlproperty list<Object> Item::resources
- The children property contains the list of visual children of this item.
- The resources property contains non-visual resources that you want to
+ The children property contains the list of visual children of this item.
+ The resources property contains non-visual resources that you want to
reference by name.
-
+
Generally you can rely on Item's default property to handle all this for
you, but it can come in handy in some cases.
@@ -484,20 +484,20 @@ QFxItem *QFxItem::parentItem() const
/*!
\property QFxItem::children
- This property contains the list of visual children of this item.
+ This property contains the list of visual children of this item.
*/
/*!
\property QFxItem::resources
- This property contains non-visual resources that you want to
+ This property contains non-visual resources that you want to
reference by name.
*/
/*!
Returns true if construction of the QML component is complete; otherwise
returns false.
-
+
It is often desireable to delay some processing until the component is
completed.
@@ -691,7 +691,7 @@ void QFxItemPrivate::transform_clear()
}
\endqml
- data is a behind-the-scenes property: you should never need to explicitly
+ data is a behind-the-scenes property: you should never need to explicitly
specify it.
*/
@@ -790,12 +790,12 @@ void QFxItem::setClip(bool c)
\qmlproperty real Item::z
Sets the stacking order of the item. By default the stacking order is 0.
-
+
Items with a higher stacking value are drawn on top of items with a
lower stacking order. Items with the same stacking value are drawn
bottom up in the order they appear. Items with a negative stacking
value are drawn under their parent's content.
-
+
The following example shows the various effects of stacking order.
\table
@@ -869,7 +869,7 @@ void QFxItem::setClip(bool c)
geometry from \a oldGeometry to \a newGeometry. If the two
geometries are the same, it doesn't do anything.
*/
-void QFxItem::geometryChanged(const QRectF &newGeometry,
+void QFxItem::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QFxItem);
@@ -880,11 +880,11 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
if (transformOrigin() != QFxItem::TopLeft)
setTransformOriginPoint(d->computeTransformOrigin());
- if (newGeometry.x() != oldGeometry.x())
+ if (newGeometry.x() != oldGeometry.x())
emit xChanged();
if (newGeometry.width() != oldGeometry.width())
emit widthChanged();
- if (newGeometry.y() != oldGeometry.y())
+ if (newGeometry.y() != oldGeometry.y())
emit yChanged();
if (newGeometry.height() != oldGeometry.height())
emit heightChanged();
@@ -926,7 +926,7 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event)
/*!
\qmlproperty string Item::id
This property holds the identifier for the item.
-
+
The identifier can be used in bindings and other expressions to
refer to the item. For example:
@@ -1083,7 +1083,7 @@ QFxAnchorLine QFxItem::baseline() const
\qmlproperty real Item::anchors.horizontalCenterOffset
\qmlproperty real Item::anchors.verticalCenterOffset
\qmlproperty real Item::anchors.baselineOffset
-
+
Anchors provide a way to position an item by specifying its
relationship with other items.
@@ -1551,7 +1551,7 @@ void QFxItem::componentComplete()
if (d->_stateGroup)
d->_stateGroup->componentComplete();
if (d->_anchors) {
- d->_anchors->componentComplete();
+ d->_anchors->componentComplete();
d->_anchors->d_func()->updateOnComplete();
}
}
@@ -1625,7 +1625,7 @@ bool QFxItem::sceneEvent(QEvent *event)
return rv;
}
-QVariant QFxItem::itemChange(GraphicsItemChange change,
+QVariant QFxItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == ItemParentHasChanged) {
@@ -1682,6 +1682,45 @@ void QFxItem::setTransformOrigin(TransformOrigin origin)
}
}
+/*!
+ \qmlproperty bool Item::smooth
+
+ Set this property if you want the item to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+ Currently, only the \c Image, \c Text , \c TextEdit and \c LineEdit items implement smooth filtering.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+ */
+
+/*!
+ \property QFxItem::smooth
+ \brief whether the item is smoothly transformed.
+
+ This property is provided purely for the purpose of optimization. Turning
+ smooth transforms off is faster, but looks worse; turning smooth
+ transformations on is slower, but looks better.
+
+ By default smooth transformations are off.
+*/
+bool QFxItem::smoothTransform() const
+{
+ Q_D(const QFxItem);
+ return d->smooth;
+}
+
+void QFxItem::setSmoothTransform(bool s)
+{
+ Q_D(QFxItem);
+ if (d->smooth == s)
+ return;
+ d->smooth = s;
+ update();
+}
+
qreal QFxItem::width() const
{
Q_D(const QFxItem);
@@ -1701,7 +1740,7 @@ void QFxItem::setWidth(qreal w)
d->width = w;
update();
- geometryChanged(QRectF(x(), y(), width(), height()),
+ geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), oldWidth, height()));
}
@@ -1717,7 +1756,7 @@ void QFxItem::setImplicitWidth(qreal w)
d->width = w;
update();
- geometryChanged(QRectF(x(), y(), width(), height()),
+ geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), oldWidth, height()));
}
@@ -1746,7 +1785,7 @@ void QFxItem::setHeight(qreal h)
d->height = h;
update();
- geometryChanged(QRectF(x(), y(), width(), height()),
+ geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), width(), oldHeight));
}
@@ -1762,7 +1801,7 @@ void QFxItem::setImplicitHeight(qreal h)
d->height = h;
update();
- geometryChanged(QRectF(x(), y(), width(), height()),
+ geometryChanged(QRectF(x(), y(), width(), height()),
QRectF(x(), y(), width(), oldHeight));
}
@@ -1813,7 +1852,7 @@ void QFxItem::setFocus(bool focus)
if (current->focusProxy() && current->focusProxy() != this) {
QFxItem *currentItem = qobject_cast<QFxItem *>(current->focusProxy());
- if (currentItem)
+ if (currentItem)
currentItem->setFocus(false);
}
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index e832a67..b1676e4 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -147,6 +147,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin)
+ Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
@@ -197,6 +198,9 @@ public:
TransformOrigin transformOrigin() const;
void setTransformOrigin(TransformOrigin);
+ bool smoothTransform() const;
+ void setSmoothTransform(bool);
+
QRectF boundingRect() const;
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
@@ -235,7 +239,7 @@ protected:
virtual void activeFocusChanged(bool);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
- virtual void geometryChanged(const QRectF &newGeometry,
+ virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
private Q_SLOTS:
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 674eada..b11b812 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -78,9 +78,9 @@ public:
_componentComplete(true), _keepMouse(false),
_anchorLines(0),
_stateGroup(0), origin(QFxItem::TopLeft),
- widthValid(false), heightValid(false), width(0), height(0)
+ widthValid(false), heightValid(false), width(0), height(0), smooth(false)
{}
- ~QFxItemPrivate()
+ ~QFxItemPrivate()
{ delete _anchors; }
void init(QFxItem *parent)
@@ -181,6 +181,7 @@ public:
qreal width;
qreal height;
+ bool smooth;
QPointF computeTransformOrigin() const;
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
index bef77e7..13267f2 100644
--- a/src/declarative/fx/qfxlineedit.cpp
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -473,7 +473,7 @@ void QFxLineEditPrivate::init()
control->setCursorWidth(1);
control->setPasswordCharacter(QLatin1Char('*'));
control->setLayoutDirection(Qt::LeftToRight);
- q->setSmooth(true);
+ q->setSmoothTransform(true);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFlag(QGraphicsItem::ItemHasNoContents, false);
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 2bd17bc..8c04074 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -85,11 +85,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QFxPaintedItem::smooth
- \brief Setting for whether smooth scaling is enabled.
-*/
-
-/*!
Marks areas of the cache that intersect with the given \a rect as dirty and
in need of being refreshed.
@@ -120,17 +115,6 @@ void QFxPaintedItem::clearCache()
}
/*!
- Returns if smooth scaling of the cache contents is enabled.
-
- \sa setSmooth()
-*/
-bool QFxPaintedItem::isSmooth() const
-{
- Q_D(const QFxPaintedItem);
- return d->smooth;
-}
-
-/*!
Returns the size of the contents.
\sa setContentsSize()
@@ -142,20 +126,6 @@ QSize QFxPaintedItem::contentsSize() const
}
/*!
- If \a smooth is true sets the image item to enable smooth scaling of
- the cache contents.
-
- \sa isSmooth()
-*/
-void QFxPaintedItem::setSmooth(bool smooth)
-{
- Q_D(QFxPaintedItem);
- if (d->smooth == smooth) return;
- d->smooth = smooth;
- update();
-}
-
-/*!
Sets the size of the contents to the given \a size.
\sa contentsSize()
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index 51e155e..9c40458 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -58,7 +58,6 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem
Q_OBJECT
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize)
- Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth)
Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
@@ -66,10 +65,7 @@ public:
QFxPaintedItem(QFxItem *parent=0);
~QFxPaintedItem();
- bool isSmooth() const;
QSize contentsSize() const;
-
- void setSmooth(bool);
void setContentsSize(const QSize &);
int cacheSize() const;
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 06e80ff..f01936d 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -63,7 +63,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate
public:
QFxPaintedItemPrivate()
- : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent)
+ : max_imagecache_size(100000), fillColor(Qt::transparent)
{
}
@@ -78,7 +78,6 @@ public:
QList<ImageCacheItem*> imagecache;
int max_imagecache_size;
- bool smooth;
QSize contentsSize;
QColor fillColor;
};
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 1313dca..0c3f4e9 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -750,21 +750,6 @@ void QFxTextPrivate::checkImgCache()
imgDirty = false;
}
-bool QFxText::smoothTransform() const
-{
- Q_D(const QFxText);
- return d->smooth;
-}
-
-void QFxText::setSmoothTransform(bool s)
-{
- Q_D(QFxText);
- if (d->smooth == s)
- return;
- d->smooth = s;
- update();
-}
-
void QFxText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QFxText);
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index 41362ae..3665ac6 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -71,7 +71,6 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat)
Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode)
Q_PROPERTY(QString activeLink READ activeLink)
- Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
public:
QFxText(QFxItem *parent=0);
@@ -80,8 +79,8 @@ public:
enum HAlignment { AlignLeft = Qt::AlignLeft,
AlignRight = Qt::AlignRight,
AlignHCenter = Qt::AlignHCenter };
- enum VAlignment { AlignTop = Qt::AlignTop,
- AlignBottom = Qt::AlignBottom,
+ enum VAlignment { AlignTop = Qt::AlignTop,
+ AlignBottom = Qt::AlignBottom,
AlignVCenter = Qt::AlignVCenter };
enum TextStyle { Normal,
Outline,
@@ -122,9 +121,6 @@ public:
QString activeLink() const;
- bool smoothTransform() const;
- void setSmoothTransform(bool);
-
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual void componentComplete();
@@ -141,7 +137,7 @@ protected:
QFxText(QFxTextPrivate &dd, QFxItem *parent);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void geometryChanged(const QRectF &newGeometry,
+ virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
private:
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index 6692d9e..bbb54a3 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -71,7 +71,7 @@ public:
QFxTextPrivate()
: _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true),
hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone),
- dirty(false), wrap(false), smooth(false), richText(false), singleline(false), control(0), doc(0),
+ dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0),
format(QFxText::AutoText)
{
}
@@ -119,7 +119,6 @@ public:
Qt::TextElideMode elideMode;
bool dirty;
bool wrap;
- bool smooth;
bool richText;
bool singleline;
QTextControl *control;
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index b632268..e4001b2 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -1014,7 +1014,7 @@ void QFxTextEditPrivate::init()
{
Q_Q(QFxTextEdit);
- q->setSmooth(true);
+ q->setSmoothTransform(true);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFlag(QGraphicsItem::ItemHasNoContents, false);
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);