diff options
Diffstat (limited to 'src/declarative/graphicsitems')
34 files changed, 152 insertions, 106 deletions
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index da3a0d4..5675130 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -85,4 +85,3 @@ contains(QT_CONFIG, webkit) { HEADERS += graphicsitems/qmlgraphicswebview_p.h HEADERS += graphicsitems/qmlgraphicswebview_p_p.h } - diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h b/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h index 79daa0f..a837702 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p.h @@ -42,7 +42,7 @@ #ifndef QMLGRAPHICSANIMATEDIMAGE_H #define QMLGRAPHICSANIMATEDIMAGE_H -#include <private/qmlgraphicsimage_p.h> +#include "qmlgraphicsimage_p.h" QT_BEGIN_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h index c24afa0..0d1c749 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage_p_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include <private/qmlgraphicsimage_p_p.h> +#include "qmlgraphicsimage_p_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h index 5ccdaad..104769d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h @@ -57,8 +57,8 @@ #include "qmlgraphicsflickable_p.h" #include "qmlgraphicsitem_p.h" #include "qml.h" -#include "private/qmltimeline_p_p.h" -#include "private/qmlanimation_p_p.h" +#include "qmltimeline_p_p.h" +#include "qmlanimation_p_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index b964e22..c271010 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qmlgraphicsflipable_p.h" -#include "private/qmlgraphicsitem_p.h" +#include "qmlgraphicsitem_p.h" #include "QtGui/qgraphicstransform.h" #include <qmlinfo.h> diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp index 294a374..bdad6ae 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp @@ -43,7 +43,7 @@ #include <QGraphicsObject> #include <QGraphicsWidget> #include <QGraphicsSceneResizeEvent> -#include <private/qmlgraphicsitem_p.h> +#include "qmlgraphicsitem_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 4e2a366..cb6e675 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -40,10 +40,10 @@ ****************************************************************************/ #include "qmlgraphicsgridview_p.h" -#include <private/qmlgraphicsvisualitemmodel_p.h> -#include <private/qlistmodelinterface_p.h> -#include <private/qmleasefollow_p.h> -#include <private/qmlgraphicsflickable_p_p.h> +#include "qmlgraphicsvisualitemmodel_p.h" +#include "qlistmodelinterface_p.h" +#include "qmleasefollow_p.h" +#include "qmlgraphicsflickable_p_p.h" #include <QKeyEvent> diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h index 99515a3..1615469 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h @@ -42,7 +42,7 @@ #ifndef QMLGRAPHICSGRIDVIEW_H #define QMLGRAPHICSGRIDVIEW_H -#include <private/qmlgraphicsflickable_p.h> +#include "qmlgraphicsflickable_p.h" QT_BEGIN_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp index 8374c9f..c6954fb 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp @@ -45,7 +45,7 @@ #include <QNetworkReply> #include <QFile> #include <qmlengine.h> -#include <private/qmlpixmapcache_p.h> +#include "qmlpixmapcache_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index db59cf2..3ca9fce 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -47,21 +47,21 @@ #include <QNetworkRequest> #include <QGraphicsSceneMouseEvent> #include <QtScript/qscriptengine.h> -#include <private/qfxperf_p_p.h> +#include "qfxperf_p_p.h" #include <QtGui/qgraphicstransform.h> #include <QtGui/qgraphicseffect.h> #include <qmlengine.h> -#include <private/qmlopenmetaobject_p.h> -#include <private/qmlstate_p.h> -#include <private/qlistmodelinterface_p.h> +#include "qmlopenmetaobject_p.h" +#include "qmlstate_p.h" +#include "qlistmodelinterface_p.h" #include "qmlview.h" -#include <private/qmlstategroup_p.h> +#include "qmlstategroup_p.h" #include "qmlgraphicsitem_p.h" #include "qmlgraphicsitem.h" -#include <private/qmlgraphicsevents_p_p.h> +#include "qmlgraphicsevents_p_p.h" #include <qmlcomponent.h> QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index 0c722ac..0c6960e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -54,10 +54,10 @@ // #include <qmlgraphicsitem.h> -#include <private/qmlstate_p.h> -#include <private/qmlgraphicsanchors_p.h> -#include <private/qmlnullablevalue_p_p.h> -#include <private/qmlgraphicsanchors_p_p.h> +#include "qmlstate_p.h" +#include "qmlgraphicsanchors_p.h" +#include "qmlnullablevalue_p_p.h" +#include "qmlgraphicsanchors_p_p.h" #include <qml.h> #include <qmlcontext.h> #include <QtCore/qlist.h> diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h b/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h index 35905b5..1acb5c1 100644 --- a/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslayoutitem_p.h @@ -42,7 +42,7 @@ #ifndef QMLGRAPHICSGRAPHICSLAYOUTITEM_H #define QMLGRAPHICSGRAPHICSLAYOUTITEM_H #include <QGraphicsLayoutItem> -#include <QmlGraphicsItem> +#include <qmlgraphicsitem.h> #include <QSizeF> QT_BEGIN_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index b1692fe..83fdf68 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "private/qmlgraphicsflickable_p_p.h" -#include <private/qmleasefollow_p.h> -#include <private/qlistmodelinterface_p.h> +#include "qmlgraphicsflickable_p_p.h" +#include "qmleasefollow_p.h" +#include "qlistmodelinterface_p.h" #include "qmlgraphicsvisualitemmodel_p.h" #include "qmlgraphicslistview_p.h" #include <qmlexpression.h> diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h index 241fb05..6dc131c 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h @@ -42,7 +42,7 @@ #ifndef QMLGRAPHICSLISTVIEW_H #define QMLGRAPHICSLISTVIEW_H -#include <private/qmlgraphicsflickable_p.h> +#include "qmlgraphicsflickable_p.h" QT_BEGIN_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index c841efe..7b2c542 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qmlgraphicsloader_p_p.h" -#include <private/qmlengine_p.h> +#include "qmlengine_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp index 948f69a..b4bb361 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp @@ -50,6 +50,7 @@ #include <QGraphicsSceneMouseEvent> #include <QPainter> #include <QPaintEngine> +#include <qmath.h> QT_BEGIN_NAMESPACE @@ -98,9 +99,13 @@ static int inpaint_clearcache=0; void QmlGraphicsPaintedItem::dirtyCache(const QRect& rect) { Q_D(QmlGraphicsPaintedItem); + QRect srect(qCeil(rect.x()*d->contentsScale), + qCeil(rect.y()*d->contentsScale), + qCeil(rect.width()*d->contentsScale), + qCeil(rect.height()*d->contentsScale)); for (int i=0; i < d->imagecache.count(); ) { QmlGraphicsPaintedItemPrivate::ImageCacheItem *c = d->imagecache[i]; - QRect isect = (c->area & rect) | c->dirty; + QRect isect = (c->area & srect) | c->dirty; if (isect == c->area && !inpaint) { delete d->imagecache.takeAt(i); } else { @@ -147,10 +152,32 @@ void QmlGraphicsPaintedItem::setContentsSize(const QSize &size) Q_D(QmlGraphicsPaintedItem); if (d->contentsSize == size) return; d->contentsSize = size; + setImplicitWidth(size.width()*d->contentsScale); + setImplicitHeight(size.height()*d->contentsScale); clearCache(); update(); + emit contentsSizeChanged(); } +qreal QmlGraphicsPaintedItem::contentsScale() const +{ + Q_D(const QmlGraphicsPaintedItem); + return d->contentsScale; +} + +void QmlGraphicsPaintedItem::setContentsScale(qreal scale) +{ + Q_D(QmlGraphicsPaintedItem); + if (d->contentsScale == scale) return; + d->contentsScale = scale; + setImplicitWidth(d->contentsSize.width()*scale); + setImplicitHeight(d->contentsSize.height()*scale); + clearCache(); + update(); + emit contentsScaleChanged(); +} + + /*! Constructs a new QmlGraphicsPaintedItem with the given \a parent. */ @@ -204,7 +231,8 @@ void QmlGraphicsPaintedItem::setCacheFrozen(bool frozen) void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QmlGraphicsPaintedItem); - const QRect content(QPoint(0,0),d->contentsSize); + const QRect content(0,0,qCeil(d->contentsSize.width()*d->contentsScale), + qCeil(d->contentsSize.height()*d->contentsScale)); if (content.width() <= 0 || content.height() <= 0) return; @@ -244,21 +272,27 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * if (!d->cachefrozen) { if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) { QPainter qp(&d->imagecache[i]->image); - qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); + qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-area.x(), -area.y()); + qp.scale(d->contentsScale,d->contentsScale); + QRect clip = d->imagecache[i]->dirty; + QRect sclip(qFloor(clip.x()/d->contentsScale), + qFloor(clip.y()/d->contentsScale), + qCeil(clip.width()/d->contentsScale+clip.x()/d->contentsScale-qFloor(clip.x()/d->contentsScale)), + qCeil(clip.height()/d->contentsScale+clip.y()/d->contentsScale-qFloor(clip.y()/d->contentsScale))); + qp.setClipRect(sclip); if (d->fillColor.isValid()){ if(d->fillColor.alpha() < 255){ // ### Might not work outside of raster paintengine QPainter::CompositionMode prev = qp.compositionMode(); qp.setCompositionMode(QPainter::CompositionMode_Source); - qp.fillRect(d->imagecache[i]->dirty,d->fillColor); + qp.fillRect(sclip,d->fillColor); qp.setCompositionMode(prev); }else{ - qp.fillRect(d->imagecache[i]->dirty,d->fillColor); + qp.fillRect(sclip,d->fillColor); } } - qp.setClipRect(d->imagecache[i]->dirty); - drawContents(&qp, d->imagecache[i]->dirty); + drawContents(&qp, sclip); d->imagecache[i]->dirty = QRect(); } } @@ -300,10 +334,15 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * img.fill(d->fillColor); { QPainter qp(&img); - qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); + qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-r.x(),-r.y()); - drawContents(&qp, r); + qp.scale(d->contentsScale,d->contentsScale); + QRect sclip(qFloor(r.x()/d->contentsScale), + qFloor(r.y()/d->contentsScale), + 1+qCeil(r.width()/d->contentsScale+r.x()/d->contentsScale-qFloor(r.x()/d->contentsScale)), + 1+qCeil(r.height()/d->contentsScale+r.y()/d->contentsScale-qFloor(r.y()/d->contentsScale))); + drawContents(&qp, sclip); } QmlGraphicsPaintedItemPrivate::ImageCacheItem *newitem = new QmlGraphicsPaintedItemPrivate::ImageCacheItem; newitem->area = r; diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h index f6bb078..d59f6d1 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h @@ -56,10 +56,11 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPaintedItem : public QmlGraphicsItem { Q_OBJECT - Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) + Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged) Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize) Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache) + Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) public: @@ -69,6 +70,9 @@ public: QSize contentsSize() const; void setContentsSize(const QSize &); + qreal contentsScale() const; + void setContentsScale(qreal); + int pixelCacheSize() const; void setPixelCacheSize(int pixels); @@ -89,6 +93,8 @@ protected: Q_SIGNALS: void fillColorChanged(); + void contentsSizeChanged(); + void contentsScaleChanged(); protected Q_SLOTS: void dirtyCache(const QRect &); diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h index a938ecf..6bcc51a 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include <private/qmlgraphicsitem_p.h> +#include "qmlgraphicsitem_p.h" QT_BEGIN_NAMESPACE @@ -63,7 +63,7 @@ class QmlGraphicsPaintedItemPrivate : public QmlGraphicsItemPrivate public: QmlGraphicsPaintedItemPrivate() - : max_imagecache_size(100000), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true) + : max_imagecache_size(100000), contentsScale(1.0), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true) { } @@ -80,6 +80,7 @@ public: int max_imagecache_size; QSize contentsSize; + qreal contentsScale; QColor fillColor; bool cachefrozen; bool smoothCache; diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp index f15d9f6..a1dbe14 100644 --- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "private/qmlgraphicsitem_p.h" +#include "qmlgraphicsitem_p.h" #include <stdlib.h> #include <math.h> @@ -50,9 +50,9 @@ #ifndef INT_MAX #define INT_MAX 2147483647 #endif -#include <private/qmlpixmapcache_p.h> -#include <private/qfxperf_p_p.h> -#include <private/qmlanimation_p_p.h> +#include "qmlpixmapcache_p.h" +#include "qfxperf_p_p.h" +#include "qmlanimation_p_p.h" #include <QNetworkReply> #include "qmlgraphicsparticles_p.h" diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp index 1791074..269552a 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp @@ -41,7 +41,7 @@ #include "qmlgraphicspath_p.h" #include "qmlgraphicspath_p_p.h" -#include <private/qfxperf_p_p.h> +#include "qfxperf_p_p.h" #include <private/qbezier_p.h> #include <QSet> diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 92751a0..3a77274 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -42,12 +42,12 @@ #include <math.h> #include <QDebug> #include <QEvent> -#include <private/qmlstate_p.h> -#include <private/qlistmodelinterface_p.h> -#include <private/qmlopenmetaobject_p.h> +#include "qmlstate_p.h" +#include "qlistmodelinterface_p.h" +#include "qmlopenmetaobject_p.h" -#include <private/qmlgraphicspathview_p.h> -#include <private/qmlgraphicspathview_p_p.h> +#include "qmlgraphicspathview_p.h" +#include "qmlgraphicspathview_p_p.h" #include <QGraphicsSceneEvent> static const int FlickThreshold = 5; diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p.h index 38f1cd8..fef0798 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspathview_p.h @@ -43,7 +43,7 @@ #define QMLGRAPHICSPATHVIEW_H #include <qmlgraphicsitem.h> -#include <private/qmlgraphicspath_p.h> +#include "qmlgraphicspath_p.h" QT_BEGIN_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h index a0f2a3d..a61968c 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h @@ -58,7 +58,7 @@ #include "qmlgraphicsitem_p.h" #include "qmlgraphicsvisualitemmodel_p.h" #include "qml.h" -#include "private/qmlanimation_p_p.h" +#include "qmlanimation_p_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index 65e63eb..56fd98e 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -42,12 +42,12 @@ #include <QDebug> #include <QCoreApplication> #include "qml.h" -#include <private/qmlstate_p.h> -#include <private/qmlstategroup_p.h> -#include <private/qmlstateoperations_p.h> -#include <private/qfxperf_p_p.h> -#include <private/qmlgraphicspositioners_p.h> -#include <private/qmlgraphicspositioners_p_p.h> +#include "qmlstate_p.h" +#include "qmlstategroup_p.h" +#include "qmlstateoperations_p.h" +#include "qfxperf_p_p.h" +#include "qmlgraphicspositioners_p.h" +#include "qmlgraphicspositioners_p_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h index a0665ae..001ad80 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h @@ -45,7 +45,7 @@ #include <QtCore/QObject> #include <QtCore/QString> #include <qmlgraphicsitem.h> -#include <private/qmlstate_p.h> +#include "qmlstate_p.h" QT_BEGIN_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h index d7a31a3..ced545e 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h @@ -53,13 +53,13 @@ // We mean it. // -#include <private/qmlgraphicsitem_p.h> +#include "qmlgraphicsitem_p.h" #include <QtCore/QObject> #include <QtCore/QString> -#include <private/qmlgraphicspositioners_p.h> -#include <private/qmlstate_p.h> -#include <private/qmltransitionmanager_p_p.h> -#include <private/qmlstateoperations_p.h> +#include "qmlgraphicspositioners_p.h" +#include "qmlstate_p.h" +#include "qmltransitionmanager_p_p.h" +#include "qmlstateoperations_p.h" #include <QtCore/QTimer> QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp index be10c24..967a29b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp @@ -41,9 +41,9 @@ #include "qmlgraphicsrepeater_p.h" #include "qmlgraphicsrepeater_p_p.h" -#include <private/qmllistaccessor_p.h> -#include <private/qmlgraphicsvisualitemmodel_p.h> -#include <private/qlistmodelinterface_p.h> +#include "qmllistaccessor_p.h" +#include "qmlgraphicsvisualitemmodel_p.h" +#include "qlistmodelinterface_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h index 82e0a94..4283c19 100644 --- a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h @@ -44,7 +44,7 @@ #include <QtCore/QString> #include <QtCore/QObject> -#include <private/qmlpixmapcache_p.h> +#include "qmlpixmapcache_p.h" #include <qml.h> #include "qmlgraphicsborderimage_p.h" diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index d0aec8d..2d2c523 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -43,7 +43,7 @@ #include "qmlgraphicstext_p_p.h" #include <private/qtextcontrol_p.h> -#include <private/qfxperf_p_p.h> +#include "qfxperf_p_p.h" #include <QTextLayout> #include <QTextLine> #include <QTextDocument> diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index 3521638..4fed035 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -42,8 +42,8 @@ #include "qmlgraphicstextedit_p.h" #include "qmlgraphicstextedit_p_p.h" #include <private/qtextcontrol_p.h> -#include <private/qfxperf_p_p.h> -#include <private/qmlgraphicsevents_p_p.h> +#include "qfxperf_p_p.h" +#include "qmlgraphicsevents_p_p.h" #include <QTextLayout> #include <QTextLine> #include <QTextDocument> diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h index 1ddfa6b..28d7d83 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h @@ -42,8 +42,8 @@ #ifndef QMLGRAPHICSTEXTEDIT_H #define QMLGRAPHICSTEXTEDIT_H -#include <private/qmlgraphicstext_p.h> -#include <private/qmlgraphicspainteditem_p.h> +#include "qmlgraphicstext_p.h" +#include "qmlgraphicspainteditem_p.h" #include <QtGui/qtextdocument.h> #include <QtGui/qtextoption.h> diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index e8ee196..cde1f8a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include <private/qlistmodelinterface_p.h> +#include "qlistmodelinterface_p.h" #include "qmlgraphicsitem.h" #include <qmlcontext.h> #include <qmlexpression.h> -#include <private/qmlpackage_p.h> +#include "qmlpackage_p.h" #include "qhash.h" #include "qlist.h" #include "private/qobject_p.h" -#include "private/qmetaobjectbuilder_p.h" -#include <private/qmlopenmetaobject_p.h> -#include <private/qmllistaccessor_p.h> +#include "qmetaobjectbuilder_p.h" +#include "qmlopenmetaobject_p.h" +#include "qmllistaccessor_p.h" #include "qmlinfo.h" #include "qmlgraphicsvisualitemmodel_p.h" #include "private/qguard_p.h" diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index e21bda3..35dd1f0 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -55,12 +55,12 @@ #include "qml.h" #include "qmlengine.h" -#include <private/qmlstate_p.h> -#include <private/qlistmodelinterface_p.h> +#include "qmlstate_p.h" +#include "qlistmodelinterface_p.h" #include "qmlgraphicswebview_p.h" #include "qmlgraphicswebview_p_p.h" -#include <private/qmlgraphicspainteditem_p_p.h> +#include "qmlgraphicspainteditem_p_p.h" QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(Qt,4,6,WebView,QmlGraphicsWebView) @@ -317,8 +317,6 @@ void QmlGraphicsWebView::setUrl(const QUrl &url) page()->setViewportSize(QSize( d->preferredwidth>0 ? d->preferredwidth : width(), d->preferredheight>0 ? d->preferredheight : height())); - if (d->preferredwidth > 0 && d->preferredheight > 0) - page()->setPreferredContentsSize(QSize(d->preferredwidth,d->preferredheight)); QUrl seturl = url; if (seturl.isEmpty()) seturl = QUrl(QLatin1String("about:blank")); @@ -349,7 +347,7 @@ void QmlGraphicsWebView::setPreferredWidth(int iw) Q_D(QmlGraphicsWebView); if (d->preferredwidth == iw) return; d->preferredwidth = iw; - expandToWebPage(); + //expandToWebPage(); emit preferredWidthChanged(); } @@ -397,7 +395,7 @@ void QmlGraphicsWebView::initialLayout() // nothing useful to do at this point } -void QmlGraphicsWebView::contentsSizeChanged(const QSize&) +void QmlGraphicsWebView::noteContentsSizeChanged(const QSize&) { expandToWebPage(); } @@ -416,10 +414,9 @@ void QmlGraphicsWebView::expandToWebPage() cs.setHeight(height()); if (cs != page()->viewportSize()) { page()->setViewportSize(cs); - clearCache(); - setImplicitWidth(cs.width()); - setImplicitHeight(cs.height()); } + if (cs != contentsSize()) + setContentsSize(cs); } void QmlGraphicsWebView::geometryChanged(const QRectF &newGeometry, @@ -432,9 +429,6 @@ void QmlGraphicsWebView::geometryChanged(const QRectF &newGeometry, void QmlGraphicsWebView::paintPage(const QRect& r) { - Q_D(QmlGraphicsWebView); - if (d->page->mainFrame()->contentsSize() != contentsSize()) - setContentsSize(d->page->mainFrame()->contentsSize()); dirtyCache(r); update(); } @@ -536,7 +530,7 @@ void QmlGraphicsWebView::drawContents(QPainter *p, const QRect &r) page()->mainFrame()->render(p,r); } -static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) +QMouseEvent *QmlGraphicsWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) { QEvent::Type t; switch(e->type()) { @@ -555,15 +549,15 @@ static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) break; } - QMouseEvent *me = new QMouseEvent(t, e->pos().toPoint(), e->button(), e->buttons(), 0); + QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), e->button(), e->buttons(), 0); return me; } -static QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e) +QMouseEvent *QmlGraphicsWebView::sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e) { QEvent::Type t = QEvent::MouseMove; - QMouseEvent *me = new QMouseEvent(t, e->pos().toPoint(), Qt::NoButton, Qt::NoButton, 0); + QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), Qt::NoButton, Qt::NoButton, 0); return me; } @@ -601,15 +595,15 @@ void QmlGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) bool QmlGraphicsWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) { Q_D(QmlGraphicsWebView); - qreal ozf = zoomFactor(); - if (ozf >= maxzoom) + if (contentsScale() >= maxzoom/zoomFactor()) return false; + qreal ozf = contentsScale(); QRect showarea = elementAreaAt(clickX, clickY, d->preferredwidth/maxzoom, d->preferredheight/maxzoom); - qreal z = qMin(qreal(d->preferredwidth)*ozf/showarea.width(),qreal(d->preferredheight)*ozf/showarea.height()); - if (z > maxzoom) - z = maxzoom; - if (z/ozf > 1.1) { - QRectF r(showarea.left()/ozf*z, showarea.top()/ozf*z, showarea.width()/ozf*z, showarea.height()/ozf*z); + qreal z = qMin(qreal(d->preferredwidth)/showarea.width(),qreal(d->preferredheight)/showarea.height()); + if (z > maxzoom/zoomFactor()) + z = maxzoom/zoomFactor(); + if (z/ozf > 1.2) { + QRectF r(showarea.left()*z, showarea.top()*z, showarea.width()*z, showarea.height()*z); emit zoomTo(z,r.x()+r.width()/2, r.y()+r.height()/2); return true; } else { @@ -963,7 +957,7 @@ void QmlGraphicsWebView::setPage(QWebPage *page) connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged())); connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(contentsSizeChanged(QSize))); + connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize))); connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted())); @@ -1204,6 +1198,7 @@ QString QmlGraphicsWebPage::chooseFile(QWebFrame *originatingFrame, const QStrin void QmlGraphicsWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QString& msg) { + Q_UNUSED(originatingFrame) emit viewItem()->alert(msg); } @@ -1218,6 +1213,10 @@ bool QmlGraphicsWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QS bool QmlGraphicsWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result) { // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) + Q_UNUSED(defaultValue) + Q_UNUSED(result) return false; } diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 7ff51f3..2280697 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -44,7 +44,7 @@ #include <QtGui/QAction> #include <QtCore/QUrl> -#include <private/qmlgraphicspainteditem_p.h> +#include "qmlgraphicspainteditem_p.h" #include <QtNetwork/qnetworkaccessmanager.h> #include <QtWebKit/QWebPage> @@ -210,7 +210,7 @@ private Q_SLOTS: void setStatusText(const QString&); void windowObjectCleared(); void pageUrlChanged(); - void contentsSizeChanged(const QSize&); + void noteContentsSizeChanged(const QSize&); void initialLayout(); protected: @@ -235,6 +235,8 @@ private: virtual void componentComplete(); Q_DISABLE_COPY(QmlGraphicsWebView) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsWebView) + QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *); + QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *); friend class QmlGraphicsWebPage; }; |