summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-06-23 06:07:11 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-06-23 06:07:11 (GMT)
commit6d7120dc2081e10c46ffe8467b047affe81ed747 (patch)
treec454785971f36b8cab970f919d6a89c03685a260 /src/declarative
parentb418419f23cec0880b6b351d304b1a755f82ab73 (diff)
parentdd792c28d89fbdc23de0d40143f0ca900c6c4daa (diff)
downloadQt-6d7120dc2081e10c46ffe8467b047affe81ed747.zip
Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.tar.gz
Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp47
-rw-r--r--src/declarative/fx/qfxpainteditem.h12
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h4
-rw-r--r--src/declarative/fx/qfxwebview.cpp112
-rw-r--r--src/declarative/fx/qfxwebview.h10
-rw-r--r--src/declarative/qml/qmlcustomparser.cpp1
6 files changed, 94 insertions, 92 deletions
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 44adba7..29d11ff 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -337,4 +337,51 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
#endif
}
+/*!
+ \qmlproperty int PaintedItem::cacheSize
+
+ This property holds the maximum number of pixels of image cache to
+ allow. The default is 0.1 megapixels. The cache will not be larger
+ than the (unscaled) size of the item.
+*/
+
+/*!
+ \property QFxPaintedItem::cacheSize
+
+ The maximum number of pixels of image cache to allow. The default
+ is 0.1 megapixels. The cache will not be larger than the (unscaled)
+ size of the QFxPaintedItem.
+*/
+int QFxPaintedItem::cacheSize() const
+{
+ Q_D(const QFxPaintedItem);
+ return d->max_imagecache_size;
+}
+
+void QFxPaintedItem::setCacheSize(int pixels)
+{
+ Q_D(QFxPaintedItem);
+ if (pixels < d->max_imagecache_size) {
+ int cachesize=0;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ QRect area = d->imagecache[i]->area;
+ cachesize += area.width()*area.height();
+ }
+ while (d->imagecache.count() && cachesize > pixels) {
+ int oldest=-1;
+ int age=-1;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ int a = d->imagecache[i]->age;
+ if (a > age) {
+ oldest = i;
+ age = a;
+ }
+ }
+ cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
+ d->imagecache.removeAt(oldest);
+ }
+ }
+ d->max_imagecache_size = pixels;
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index e086894..b7db2d9 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -56,12 +56,14 @@ class QFxPaintedItemPrivate;
class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem
{
Q_OBJECT
-public:
- QFxPaintedItem(QFxItem *parent=0);
- ~QFxPaintedItem();
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize)
Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth)
+ Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
+
+public:
+ QFxPaintedItem(QFxItem *parent=0);
+ ~QFxPaintedItem();
#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
@@ -74,6 +76,10 @@ public:
void setSmooth(bool);
void setContentsSize(const QSize &);
+
+ int cacheSize() const;
+ void setCacheSize(int pixels);
+
protected:
QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent);
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index d8d1a2a..21ac556 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -68,7 +68,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate
public:
QFxPaintedItemPrivate()
- : max_imagecache_size(1000*1000), smooth(false)
+ : max_imagecache_size(100000), smooth(false)
{
}
@@ -86,7 +86,7 @@ public:
QList<ImageCacheItem*> imagecache;
- const int max_imagecache_size;
+ int max_imagecache_size;
bool smooth;
QSize contentsSize;
};
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index dc7f60e..adb33e8 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -48,6 +48,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QtWebKit/QWebPage>
#include <QtWebKit/QWebFrame>
+#include <QtWebKit/QWebElement>
#include "qml.h"
#include "qmlbindablevalue.h"
@@ -149,47 +150,17 @@ class QFxWebViewPrivate : public QFxPaintedItemPrivate
public:
QFxWebViewPrivate()
: QFxPaintedItemPrivate(), page(0), idealwidth(0), idealheight(0), interactive(true), lastPress(0), lastRelease(0), mouseX(0), mouseY(0),
- max_imagecache_size(100000), progress(1.0), pending(PendingNone)
+ progress(1.0), pending(PendingNone)
{
}
QWebPage *page;
- struct ImageCacheItem {
- ImageCacheItem() : age(0) {}
- ~ImageCacheItem() { }
- int age;
- QRect area;
-#if defined(QFX_RENDER_QPAINTER)
- QPixmap image;
-#else
- GLTexture image;
-#endif
- };
- QList<ImageCacheItem*> imagecache;
- void dirtyCache(const QRect& dirt)
- {
- for (int i=0; i<imagecache.count(); ) {
- if (imagecache[i]->area.intersects(dirt)) {
- imagecache.removeAt(i);
- } else {
- ++i;
- }
- }
- }
- void clearCache()
- {
- foreach (ImageCacheItem* i, imagecache)
- delete i;
- imagecache.clear();
- }
-
int idealwidth;
int idealheight;
bool interactive;
QMouseEvent *lastPress, *lastRelease;
int mouseX, mouseY;
- int max_imagecache_size;
qreal progress;
QBasicTimer dcTimer;
QString statusBarMessage;
@@ -459,9 +430,8 @@ void QFxWebView::setInteractive(bool i)
void QFxWebView::updateCacheForVisibility()
{
- Q_D(QFxWebView);
if (!isVisible())
- d->clearCache();
+ clearCache();
}
void QFxWebView::expandToWebPage()
@@ -478,7 +448,7 @@ void QFxWebView::expandToWebPage()
cs.setHeight(height());
if (cs != page()->viewportSize()) {
page()->setViewportSize(cs);
- d->clearCache();
+ clearCache();
setImplicitWidth(cs.width());
setImplicitHeight(cs.height());
}
@@ -501,53 +471,6 @@ void QFxWebView::paintPage(const QRect& r)
update();
}
-/*!
- \qmlproperty int WebView::cacheSize
-
- This property holds the maximum number of pixels of image cache to
- allow. The default is 0.1 megapixels. The cache will not be larger
- than the (unscaled) size of the WebView.
-*/
-
-/*!
- \property QFxWebView::cacheSize
-
- The maximum number of pixels of image cache to allow. The default
- is 0.1 megapixels. The cache will not be larger than the (unscaled)
- size of the QFxWebView.
-*/
-int QFxWebView::cacheSize() const
-{
- Q_D(const QFxWebView);
- return d->max_imagecache_size;
-}
-
-void QFxWebView::setCacheSize(int pixels)
-{
- Q_D(QFxWebView);
- if (pixels < d->max_imagecache_size) {
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- cachesize += area.width()*area.height();
- }
- while (d->imagecache.count() && cachesize > pixels) {
- int oldest=-1;
- int age=-1;
- for (int i=0; i<d->imagecache.count(); ++i) {
- int a = d->imagecache[i]->age;
- if (a > age) {
- oldest = i;
- age = a;
- }
- }
- cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
- d->imagecache.removeAt(oldest);
- }
- }
- d->max_imagecache_size = pixels;
-}
-
void QFxWebView::dump(int depth)
{
QByteArray ba(depth * 4, ' ');
@@ -787,7 +710,7 @@ QPixmap QFxWebView::icon() const
/*!
\qmlproperty real WebView::textSizeMultiplier
- This property holds multiplier used to scale the text in a Web page
+ This property holds the multiplier used to scale the text in a Web page
*/
/*!
Sets the value of the multiplier used to scale the text in a Web page to
@@ -806,6 +729,31 @@ qreal QFxWebView::textSizeMultiplier() const
return page()->mainFrame()->textSizeMultiplier();
}
+/*!
+ \qmlproperty real WebView::zoomFactor
+ This property holds the multiplier used to scale the contents of a Web page.
+*/
+void QFxWebView::setZoomFactor(qreal factor)
+{
+ Q_D(QFxWebView);
+ if (factor == page()->mainFrame()->zoomFactor())
+ return;
+
+ //reset viewport size so we resize correctly
+ page()->setViewportSize(QSize(
+ d->idealwidth>0 ? d->idealwidth : -1,
+ d->idealheight>0 ? d->idealheight : -1));
+
+ page()->mainFrame()->setZoomFactor(factor);
+ expandToWebPage();
+ emit zoomFactorChanged();
+}
+
+qreal QFxWebView::zoomFactor() const
+{
+ return page()->mainFrame()->zoomFactor();
+}
+
void QFxWebView::setStatusBarMessage(const QString& s)
{
Q_D(QFxWebView);
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index f30fd0d..c9a62cc 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -81,6 +81,7 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged)
Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
Q_PROPERTY(QString status READ status NOTIFY statusChanged)
Q_PROPERTY(int mouseX READ mouseX)
@@ -95,8 +96,6 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem
Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
- Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
-
Q_PROPERTY(QObject* reload READ reloadAction)
Q_PROPERTY(QObject* back READ backAction)
Q_PROPERTY(QObject* forward READ forwardAction)
@@ -118,12 +117,12 @@ public:
qreal textSizeMultiplier() const;
void setTextSizeMultiplier(qreal);
+ qreal zoomFactor() const;
+ void setZoomFactor(qreal);
+
bool interactive() const;
void setInteractive(bool);
- int cacheSize() const;
- void setCacheSize(int pixels);
-
int mouseX() const;
int mouseY() const;
@@ -170,6 +169,7 @@ Q_SIGNALS:
void titleChanged(const QString&);
void iconChanged();
void statusChanged();
+ void zoomFactorChanged();
void loadStarted();
void loadFinished();
diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp
index 2e8c8f6..c90ab47 100644
--- a/src/declarative/qml/qmlcustomparser.cpp
+++ b/src/declarative/qml/qmlcustomparser.cpp
@@ -136,6 +136,7 @@ QmlCustomParserNodePrivate::fromProperty(QmlParser::Property *p)
} else {
for(int ii = 0; ii < p->values.count(); ++ii) {
Value *v = p->values.at(ii);
+ v->type = QmlParser::Value::Literal;
if(v->object) {
QmlCustomParserNode node = fromObject(v->object);