diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-05-18 04:09:47 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-05-18 04:09:47 (GMT) |
commit | 183afaf48fdaeeacde009cd3f497152f89d8e0af (patch) | |
tree | e6fcc88a20e8af694c7c5020b2050c76add26de7 /src/imports | |
parent | cb03c8cad2a40272c9cc8d0998246fb74a49e671 (diff) | |
parent | 379b4dc81177b95c15de30c5925efca1136e4041 (diff) | |
download | Qt-183afaf48fdaeeacde009cd3f497152f89d8e0af.zip Qt-183afaf48fdaeeacde009cd3f497152f89d8e0af.tar.gz Qt-183afaf48fdaeeacde009cd3f497152f89d8e0af.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts:
configure.exe
src/imports/multimedia/qdeclarativeaudio.cpp
src/imports/multimedia/qdeclarativeaudio_p.h
src/multimedia/mediaservices/mediaservices.pro
src/plugins/mediaservices/mediaservices.pro
src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h
src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h
src/s60installs/s60installs.pro
src/src.pro
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/gestures/qdeclarativegesturearea.cpp | 2 | ||||
-rw-r--r-- | src/imports/imports.pro | 2 | ||||
-rw-r--r-- | src/imports/webkit/qdeclarativewebview.cpp | 277 | ||||
-rw-r--r-- | src/imports/webkit/qdeclarativewebview_p.h | 32 | ||||
-rw-r--r-- | src/imports/widgets/graphicslayouts.cpp | 366 | ||||
-rw-r--r-- | src/imports/widgets/graphicslayouts_p.h | 303 | ||||
-rw-r--r-- | src/imports/widgets/qmldir | 1 | ||||
-rw-r--r-- | src/imports/widgets/widgets.cpp | 71 | ||||
-rw-r--r-- | src/imports/widgets/widgets.pro | 30 |
9 files changed, 137 insertions, 947 deletions
diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp index 615c674..19afe0c 100644 --- a/src/imports/gestures/qdeclarativegesturearea.cpp +++ b/src/imports/gestures/qdeclarativegesturearea.cpp @@ -259,7 +259,7 @@ bool QDeclarativeGestureAreaPrivate::gestureEvent(QGestureEvent *event) bool accept = true; for (Bindings::Iterator it = bindings.begin(); it != bindings.end(); ++it) { if ((gesture = event->gesture(it.key()))) { - it.value()->value(); + it.value()->evaluate(); event->setAccepted(true); // XXX only if value returns true? } } diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 8562fb5..a45af95 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS += widgets particles +SUBDIRS += particles gestures contains(QT_CONFIG, webkit): SUBDIRS += webkit diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index 5db812c..36a25f6 100644 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -42,11 +42,9 @@ #include "qdeclarativewebview_p.h" #include "qdeclarativewebview_p_p.h" -#include <private/qdeclarativepainteditem_p_p.h> - #include <qdeclarative.h> #include <qdeclarativeengine.h> -#include <private/qdeclarativestate_p.h> +#include <qdeclarativecontext.h> #include <QDebug> #include <QPen> @@ -61,29 +59,29 @@ #include <QtWebKit/QWebFrame> #include <QtWebKit/QWebElement> #include <QtWebKit/QWebSettings> -#include <private/qlistmodelinterface_p.h> QT_BEGIN_NAMESPACE static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system -class QDeclarativeWebViewPrivate : public QDeclarativePaintedItemPrivate +class QDeclarativeWebViewPrivate { - Q_DECLARE_PUBLIC(QDeclarativeWebView) - public: - QDeclarativeWebViewPrivate() - : QDeclarativePaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0), + QDeclarativeWebViewPrivate(QDeclarativeWebView* qq) + : q(qq), page(0), preferredwidth(0), preferredheight(0), progress(1.0), status(QDeclarativeWebView::Null), pending(PendingNone), newWindowComponent(0), newWindowParent(0), pressTime(400), rendering(true) { + QObject::connect(q, SIGNAL(focusChanged(bool)), q, SLOT(propagateFocusToWebPage(bool))); } - void focusChanged(bool); + + QDeclarativeWebView *q; QUrl url; // page url might be different if it has not loaded yet QWebPage *page; + QGraphicsWebView* view; int preferredwidth, preferredheight; qreal progress; @@ -101,7 +99,6 @@ public: QPoint pressPoint; int pressTime; // milliseconds before it's a "hold" - static void windowObjects_append(QDeclarativeListProperty<QObject> *prop, QObject *o) { static_cast<QDeclarativeWebViewPrivate *>(prop->data)->windowObjects.append(o); static_cast<QDeclarativeWebViewPrivate *>(prop->data)->updateWindowObjects(); @@ -129,6 +126,9 @@ public: dynamically adjust to a size appropriate for the content. This width may be large for typical online web pages. + If the width or height is explictly set, the rendered website + will be clipped, not scaled, to fit into the set dimensions. + If the preferredWidth is set, the width will be this amount or larger, usually laying out the web content to fit the preferredWidth. @@ -137,8 +137,8 @@ public: WebView { url: "http://www.nokia.com" - width: 490 - height: 400 + preferredWidth: 490 + preferredHeight: 400 scale: 0.5 smooth: false smoothCache: true @@ -169,34 +169,39 @@ public: */ QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent) - : QDeclarativePaintedItem(*(new QDeclarativeWebViewPrivate), parent) + : QDeclarativeItem(parent) { init(); } QDeclarativeWebView::~QDeclarativeWebView() { - Q_D(QDeclarativeWebView); delete d->page; + delete d; } void QDeclarativeWebView::init() { - Q_D(QDeclarativeWebView); + d = new QDeclarativeWebViewPrivate(this); QWebSettings::enablePersistentStorage(); setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::LeftButton); - setFlag(QGraphicsItem::ItemHasNoContents, false); + setFlag(QGraphicsItem::ItemHasNoContents, true); + setClip(true); d->page = 0; + d->view = new QGraphicsWebView(this); + d->view->setResizesToContents(true); + d->view->setFlag(QGraphicsItem::ItemStacksBehindParent, true); + connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); + connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); } void QDeclarativeWebView::componentComplete() { - QDeclarativePaintedItem::componentComplete(); - Q_D(QDeclarativeWebView); + QDeclarativeItem::componentComplete(); switch (d->pending) { case QDeclarativeWebViewPrivate::PendingUrl: setUrl(d->pending_url); @@ -216,7 +221,6 @@ void QDeclarativeWebView::componentComplete() QDeclarativeWebView::Status QDeclarativeWebView::status() const { - Q_D(const QDeclarativeWebView); return d->status; } @@ -230,13 +234,11 @@ QDeclarativeWebView::Status QDeclarativeWebView::status() const */ qreal QDeclarativeWebView::progress() const { - Q_D(const QDeclarativeWebView); return d->progress; } void QDeclarativeWebView::doLoadStarted() { - Q_D(QDeclarativeWebView); if (!d->url.isEmpty()) { d->status = Loading; @@ -247,7 +249,6 @@ void QDeclarativeWebView::doLoadStarted() void QDeclarativeWebView::doLoadProgress(int p) { - Q_D(QDeclarativeWebView); if (d->progress == p/100.0) return; d->progress = p/100.0; @@ -256,12 +257,7 @@ void QDeclarativeWebView::doLoadProgress(int p) void QDeclarativeWebView::pageUrlChanged() { - Q_D(QDeclarativeWebView); - - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); - expandToWebPage(); + updateContentsSize(); if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank"))) || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())) @@ -275,7 +271,6 @@ void QDeclarativeWebView::pageUrlChanged() void QDeclarativeWebView::doLoadFinished(bool ok) { - Q_D(QDeclarativeWebView); if (title().isEmpty()) pageUrlChanged(); // XXX bug 232556 - pages with no title never get urlChanged() @@ -302,21 +297,17 @@ void QDeclarativeWebView::doLoadFinished(bool ok) */ QUrl QDeclarativeWebView::url() const { - Q_D(const QDeclarativeWebView); return d->url; } void QDeclarativeWebView::setUrl(const QUrl &url) { - Q_D(QDeclarativeWebView); if (url == d->url) return; if (isComponentComplete()) { d->url = url; - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); QUrl seturl = url; if (seturl.isEmpty()) seturl = QUrl(QLatin1String("about:blank")); @@ -338,16 +329,14 @@ void QDeclarativeWebView::setUrl(const QUrl &url) */ int QDeclarativeWebView::preferredWidth() const { - Q_D(const QDeclarativeWebView); return d->preferredwidth; } void QDeclarativeWebView::setPreferredWidth(int iw) { - Q_D(QDeclarativeWebView); if (d->preferredwidth == iw) return; d->preferredwidth = iw; - //expandToWebPage(); + updateContentsSize(); emit preferredWidthChanged(); } @@ -358,14 +347,14 @@ void QDeclarativeWebView::setPreferredWidth(int iw) */ int QDeclarativeWebView::preferredHeight() const { - Q_D(const QDeclarativeWebView); return d->preferredheight; } + void QDeclarativeWebView::setPreferredHeight(int ih) { - Q_D(QDeclarativeWebView); if (d->preferredheight == ih) return; d->preferredheight = ih; + updateContentsSize(); emit preferredHeightChanged(); } @@ -383,82 +372,86 @@ QVariant QDeclarativeWebView::evaluateJavaScript(const QString &scriptSource) return this->page()->mainFrame()->evaluateJavaScript(scriptSource); } -void QDeclarativeWebViewPrivate::focusChanged(bool hasFocus) +void QDeclarativeWebView::propagateFocusToWebPage(bool hasFocus) { - Q_Q(QDeclarativeWebView); QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut); - q->page()->event(&e); - QDeclarativeItemPrivate::focusChanged(hasFocus); + page()->event(&e); } -void QDeclarativeWebView::initialLayout() +void QDeclarativeWebView::updateDeclarativeWebViewSize() { - // nothing useful to do at this point + QSizeF size = d->view->geometry().size() * contentsScale(); + setImplicitWidth(size.width()); + setImplicitHeight(size.height()); } -void QDeclarativeWebView::noteContentsSizeChanged(const QSize&) +void QDeclarativeWebView::initialLayout() { - expandToWebPage(); + // nothing useful to do at this point } -void QDeclarativeWebView::expandToWebPage() +void QDeclarativeWebView::updateContentsSize() { - Q_D(QDeclarativeWebView); - QSize cs = page()->mainFrame()->contentsSize(); - if (cs.width() < d->preferredwidth) - cs.setWidth(d->preferredwidth); - if (cs.height() < d->preferredheight) - cs.setHeight(d->preferredheight); - if (widthValid()) - cs.setWidth(width()); - if (heightValid()) - cs.setHeight(height()); - if (cs != page()->viewportSize()) { - page()->setViewportSize(cs); - } - if (cs != contentsSize()) - setContentsSize(cs); + if (d->page) + d->page->setPreferredContentsSize(QSize( + d->preferredwidth>0 ? d->preferredwidth : width(), + d->preferredheight>0 ? d->preferredheight : height())); } void QDeclarativeWebView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - if (newGeometry.size() != oldGeometry.size()) - expandToWebPage(); - QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); -} - -void QDeclarativeWebView::paintPage(const QRect& r) -{ - dirtyCache(r); - update(); + if (newGeometry.size() != oldGeometry.size() && d->page) { + QSize cs = d->page->preferredContentsSize(); + if (widthValid()) + cs.setWidth(width()); + if (heightValid()) + cs.setHeight(height()); + if (cs != d->page->preferredContentsSize()) + d->page->setPreferredContentsSize(cs); + } + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } /*! \qmlproperty list<object> WebView::javaScriptWindowObjects - This property is a list of object that are available from within - the webview's JavaScript context. + A list of QML objects to expose to the web page. + + Each object will be added as a property of the web frame's window object. The + property name is controlled by the value of \c WebView.windowObjectName + attached property. + + Exposing QML objects to a web page allows JavaScript executing in the web + page itself to communicate with QML, by reading and writing properties and + by calling methods of the exposed QML objects. - The \a object will be inserted as a child of the frame's window - object, under the name given by the attached property \c WebView.windowObjectName. + This example shows how to call into a QML method using a window object. \qml WebView { - javaScriptWindowObjects: Object { - WebView.windowObjectName: "coordinates" + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + + function qmlCall() { + console.log("This call is in QML!"); + } } + + html: "<script>console.log(\"This is in WebKit!\"); window.qml.qmlCall();</script>" } \endqml - Properties of the object will be exposed as JavaScript properties and slots as - JavaScript methods. + The output of the example will be: + \code + This is in WebKit! + This call is in QML! + \endcode - If Javascript is not enabled for this page, then this property does nothing. + If Javascript is not enabled for the page, then this property does nothing. */ QDeclarativeListProperty<QObject> QDeclarativeWebView::javaScriptWindowObjects() { - Q_D(QDeclarativeWebView); return QDeclarativeListProperty<QObject>(this, d, &QDeclarativeWebViewPrivate::windowObjects_append); } @@ -469,8 +462,7 @@ QDeclarativeWebViewAttached *QDeclarativeWebView::qmlAttachedProperties(QObject void QDeclarativeWebViewPrivate::updateWindowObjects() { - Q_Q(QDeclarativeWebView); - if (!q->isComponentComplete() || !page) + if (!q->isComponentCompletePublic() || !page) return; for (int ii = 0; ii < windowObjects.count(); ++ii) { @@ -484,29 +476,17 @@ void QDeclarativeWebViewPrivate::updateWindowObjects() bool QDeclarativeWebView::renderingEnabled() const { - Q_D(const QDeclarativeWebView); return d->rendering; } void QDeclarativeWebView::setRenderingEnabled(bool enabled) { - Q_D(QDeclarativeWebView); if (d->rendering == enabled) return; d->rendering = enabled; emit renderingEnabledChanged(); - setCacheFrozen(!enabled); - if (enabled) - clearCache(); -} - - -void QDeclarativeWebView::drawContents(QPainter *p, const QRect &r) -{ - Q_D(QDeclarativeWebView); - if (d->rendering) - page()->mainFrame()->render(p,r); + d->view->setTiledBackingStoreFrozen(!enabled); } QMouseEvent *QDeclarativeWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) @@ -541,7 +521,6 @@ QMouseEvent *QDeclarativeWebView::sceneHoverMoveEventToMouseEvent(QGraphicsScene return me; } - /*! \qmlsignal WebView::onDoubleClick(clickx,clicky) @@ -573,7 +552,6 @@ void QDeclarativeWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) */ bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) { - Q_D(QDeclarativeWebView); if (contentsScale() >= maxzoom/zoomFactor()) return false; qreal ozf = contentsScale(); @@ -602,13 +580,11 @@ bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) */ int QDeclarativeWebView::pressGrabTime() const { - Q_D(const QDeclarativeWebView); return d->pressTime; } void QDeclarativeWebView::setPressGrabTime(int ms) { - Q_D(QDeclarativeWebView); if (d->pressTime == ms) return; d->pressTime = ms; @@ -617,8 +593,6 @@ void QDeclarativeWebView::setPressGrabTime(int ms) void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeWebView); - setFocus (true); QMouseEvent *me = sceneMouseEventToMouseEvent(event); @@ -646,14 +620,12 @@ void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) ); delete me; if (!event->isAccepted()) { - QDeclarativePaintedItem::mousePressEvent(event); + QDeclarativeItem::mousePressEvent(event); } } void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeWebView); - QMouseEvent *me = sceneMouseEventToMouseEvent(event); page()->event(me); d->pressTimer.stop(); @@ -670,7 +642,7 @@ void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ); delete me; if (!event->isAccepted()) { - QDeclarativePaintedItem::mouseReleaseEvent(event); + QDeclarativeItem::mouseReleaseEvent(event); } setKeepMouseGrab(false); ungrabMouse(); @@ -678,7 +650,6 @@ void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void QDeclarativeWebView::timerEvent(QTimerEvent *event) { - Q_D(QDeclarativeWebView); if (event->timerId() == d->pressTimer.timerId()) { d->pressTimer.stop(); grabMouse(); @@ -688,8 +659,6 @@ void QDeclarativeWebView::timerEvent(QTimerEvent *event) void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeWebView); - QMouseEvent *me = sceneMouseEventToMouseEvent(event); if (d->pressTimer.isActive()) { if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) { @@ -713,9 +682,9 @@ void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } delete me; if (!event->isAccepted()) - QDeclarativePaintedItem::mouseMoveEvent(event); - + QDeclarativeItem::mouseMoveEvent(event); } + void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event) { QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event); @@ -729,21 +698,7 @@ void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event) ); delete me; if (!event->isAccepted()) - QDeclarativePaintedItem::hoverMoveEvent(event); -} - -void QDeclarativeWebView::keyPressEvent(QKeyEvent* event) -{ - page()->event(event); - if (!event->isAccepted()) - QDeclarativePaintedItem::keyPressEvent(event); -} - -void QDeclarativeWebView::keyReleaseEvent(QKeyEvent* event) -{ - page()->event(event); - if (!event->isAccepted()) - QDeclarativePaintedItem::keyReleaseEvent(event); + QDeclarativeItem::hoverMoveEvent(event); } bool QDeclarativeWebView::sceneEvent(QEvent *event) @@ -758,7 +713,7 @@ bool QDeclarativeWebView::sceneEvent(QEvent *event) } } } - return QDeclarativePaintedItem::sceneEvent(event); + return QDeclarativeItem::sceneEvent(event); } @@ -827,15 +782,11 @@ QPixmap QDeclarativeWebView::icon() const */ void QDeclarativeWebView::setZoomFactor(qreal factor) { - Q_D(QDeclarativeWebView); if (factor == page()->mainFrame()->zoomFactor()) return; page()->mainFrame()->setZoomFactor(factor); - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth*factor : width()*factor, - d->preferredheight>0 ? d->preferredheight*factor : height()*factor)); - expandToWebPage(); + updateContentsSize(); emit zoomFactorChanged(); } @@ -853,37 +804,27 @@ qreal QDeclarativeWebView::zoomFactor() const */ void QDeclarativeWebView::setStatusText(const QString& s) { - Q_D(QDeclarativeWebView); d->statusText = s; emit statusTextChanged(); } void QDeclarativeWebView::windowObjectCleared() { - Q_D(QDeclarativeWebView); d->updateWindowObjects(); } QString QDeclarativeWebView::statusText() const { - Q_D(const QDeclarativeWebView); return d->statusText; } QWebPage *QDeclarativeWebView::page() const { - Q_D(const QDeclarativeWebView); if (!d->page) { QDeclarativeWebView *self = const_cast<QDeclarativeWebView*>(this); QWebPage *wp = new QDeclarativeWebPage(self); - // QML items don't default to having a background, - // even though most we pages will set one anyway. - QPalette pal = QApplication::palette(); - pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0)); - wp->setPalette(pal); - wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); self->setPage(wp); @@ -939,14 +880,12 @@ QWebPage *QDeclarativeWebView::page() const */ QDeclarativeWebSettings *QDeclarativeWebView::settingsObject() const { - Q_D(const QDeclarativeWebView); d->settings.s = page()->settings(); return &d->settings; } void QDeclarativeWebView::setPage(QWebPage *page) { - Q_D(QDeclarativeWebView); if (d->page == page) return; if (d->page) { @@ -957,18 +896,15 @@ void QDeclarativeWebView::setPage(QWebPage *page) } } d->page = page; - d->page->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); - connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect))); 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(titleChanged(QString)), this, SIGNAL(iconChanged())); connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); - connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize))); connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); + connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted())); connect(d->page,SIGNAL(loadProgress(int)),this,SLOT(doLoadProgress(int))); @@ -976,6 +912,10 @@ void QDeclarativeWebView::setPage(QWebPage *page) connect(d->page,SIGNAL(statusBarMessage(QString)),this,SLOT(setStatusText(QString))); connect(d->page->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(windowObjectCleared())); + + d->page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + + d->view->setPage(page); } /*! @@ -1030,10 +970,7 @@ QString QDeclarativeWebView::html() const */ void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl) { - Q_D(QDeclarativeWebView); - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); if (isComponentComplete()) page()->mainFrame()->setHtml(html, baseUrl); else { @@ -1046,10 +983,7 @@ void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl) void QDeclarativeWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) { - Q_D(QDeclarativeWebView); - page()->setViewportSize(QSize( - d->preferredwidth>0 ? d->preferredwidth : width(), - d->preferredheight>0 ? d->preferredheight : height())); + updateContentsSize(); if (isComponentComplete()) page()->mainFrame()->setContent(data,mimeType,qmlContext(this)->resolvedUrl(baseUrl)); @@ -1073,7 +1007,6 @@ QWebSettings *QDeclarativeWebView::settings() const QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType type) { - Q_D(QDeclarativeWebView); switch (type) { case QWebPage::WebBrowserWindow: { if (!d->newWindowComponent && d->newWindowParent) @@ -1127,13 +1060,11 @@ QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType t */ QDeclarativeComponent *QDeclarativeWebView::newWindowComponent() const { - Q_D(const QDeclarativeWebView); return d->newWindowComponent; } void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow) { - Q_D(QDeclarativeWebView); if (newWindow == d->newWindowComponent) return; d->newWindowComponent = newWindow; @@ -1150,13 +1081,11 @@ void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow */ QDeclarativeItem *QDeclarativeWebView::newWindowParent() const { - Q_D(const QDeclarativeWebView); return d->newWindowParent; } void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent) { - Q_D(QDeclarativeWebView); if (parent == d->newWindowParent) return; if (d->newWindowParent && parent) { @@ -1169,6 +1098,25 @@ void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent) emit newWindowParentChanged(); } +QSize QDeclarativeWebView::contentsSize() const +{ + return d->page->mainFrame()->contentsSize() * contentsScale(); +} + +qreal QDeclarativeWebView::contentsScale() const +{ + return d->view->scale(); +} + +void QDeclarativeWebView::setContentsScale(qreal scale) +{ + if (scale == d->view->scale()) + return; + d->view->setScale(scale); + updateDeclarativeWebViewSize(); + emit contentsScaleChanged(); +} + /*! Returns the area of the largest element at position (\a x,\a y) that is no larger than \a maxwidth by \a maxheight pixels. @@ -1265,3 +1213,4 @@ QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type) } QT_END_NAMESPACE + diff --git a/src/imports/webkit/qdeclarativewebview_p.h b/src/imports/webkit/qdeclarativewebview_p.h index 81581d8..87bd938 100644 --- a/src/imports/webkit/qdeclarativewebview_p.h +++ b/src/imports/webkit/qdeclarativewebview_p.h @@ -42,12 +42,13 @@ #ifndef QDECLARATIVEWEBVIEW_H #define QDECLARATIVEWEBVIEW_H -#include <private/qdeclarativepainteditem_p.h> +#include <qdeclarativeitem.h> #include <QtGui/QAction> #include <QtCore/QUrl> #include <QtNetwork/qnetworkaccessmanager.h> #include <QtWebKit/QWebPage> +#include <QtWebKit/QGraphicsWebView> QT_BEGIN_HEADER @@ -61,6 +62,7 @@ class QDeclarativeWebSettings; class QDeclarativeWebViewPrivate; class QNetworkRequest; class QDeclarativeWebView; +class QDeclarativeWebViewPrivate; class QDeclarativeWebPage : public QWebPage { @@ -85,7 +87,7 @@ class QDeclarativeWebViewAttached; //### TODO: browser plugins -class QDeclarativeWebView : public QDeclarativePaintedItem +class QDeclarativeWebView : public QDeclarativeItem { Q_OBJECT @@ -120,6 +122,9 @@ class QDeclarativeWebView : public QDeclarativePaintedItem Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged) + Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged) + Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) + public: QDeclarativeWebView(QDeclarativeItem *parent=0); ~QDeclarativeWebView(); @@ -182,6 +187,13 @@ public: QDeclarativeItem *newWindowParent() const; void setNewWindowParent(QDeclarativeItem *newWindow); + bool isComponentCompletePublic() const { return isComponentComplete(); } + + QSize contentsSize() const; + + void setContentsScale(qreal scale); + qreal contentsScale() const; + Q_SIGNALS: void preferredWidthChanged(); void preferredHeightChanged(); @@ -197,6 +209,8 @@ Q_SIGNALS: void newWindowComponentChanged(); void newWindowParentChanged(); void renderingEnabledChanged(); + void contentsSizeChanged(const QSize&); + void contentsScaleChanged(); void loadStarted(); void loadFinished(); @@ -212,38 +226,36 @@ public Q_SLOTS: QVariant evaluateJavaScript(const QString&); private Q_SLOTS: - void expandToWebPage(); - void paintPage(const QRect&); void doLoadStarted(); void doLoadProgress(int p); void doLoadFinished(bool ok); void setStatusText(const QString&); void windowObjectCleared(); void pageUrlChanged(); - void noteContentsSizeChanged(const QSize&); void initialLayout(); -protected: - void drawContents(QPainter *, const QRect &); + void propagateFocusToWebPage(bool); + void updateDeclarativeWebViewSize(); + +protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void timerEvent(QTimerEvent *event); void hoverMoveEvent (QGraphicsSceneHoverEvent * event); - void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent* event); virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); virtual bool sceneEvent(QEvent *event); QDeclarativeWebView *createWindow(QWebPage::WebWindowType type); private: + void updateContentsSize(); void init(); virtual void componentComplete(); Q_DISABLE_COPY(QDeclarativeWebView) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeWebView) + QDeclarativeWebViewPrivate* d; QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *); QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *); friend class QDeclarativeWebPage; diff --git a/src/imports/widgets/graphicslayouts.cpp b/src/imports/widgets/graphicslayouts.cpp deleted file mode 100644 index 25cf994..0000000 --- a/src/imports/widgets/graphicslayouts.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "graphicslayouts_p.h" - -#include <QtGui/qgraphicswidget.h> -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -LinearLayoutAttached::LinearLayoutAttached(QObject *parent) -: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter), _spacing(0) -{ -} - -void LinearLayoutAttached::setStretchFactor(int f) -{ - if (_stretch == f) - return; - - _stretch = f; - emit stretchChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _stretch); -} - -void LinearLayoutAttached::setSpacing(int s) -{ - if (_spacing == s) - return; - - _spacing = s; - emit spacingChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _spacing); -} - -void LinearLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _alignment); -} - -QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) - : QObject(parent) -{ -} - -QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ -Q_UNUSED(which); -Q_UNUSED(constraint); -return QSizeF(); -} - - -QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() -{ -} - -void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) -{ -insertItem(index, item); - -//connect attached properties -if (LinearLayoutAttached *obj = attachedProperties.value(item)) { - setStretchFactor(item, obj->stretchFactor()); - setAlignment(item, obj->alignment()); - updateSpacing(item, obj->spacing()); - QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - QObject::connect(obj, SIGNAL(spacingChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateSpacing(QGraphicsLayoutItem*,int))); - //### need to disconnect when widget is removed? -} -} - -//### is there a better way to do this? -void QGraphicsLinearLayoutObject::clearChildren() -{ -for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsLinearLayoutObject::contentsMargin() const -{ - qreal a,b,c,d; - getContentsMargins(&a, &b, &c, &d); - if(a==b && a==c && a==d) - return a; - return -1; -} - -void QGraphicsLinearLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m,m,m,m); -} - -void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) -{ -QGraphicsLinearLayout::setStretchFactor(item, stretch); -} - -void QGraphicsLinearLayoutObject::updateSpacing(QGraphicsLayoutItem* item, int spacing) -{ - for(int i=0; i < count(); i++){ - if(itemAt(i) == item){ //I do not see the reverse function, which is why we must loop over all items - QGraphicsLinearLayout::setItemSpacing(i, spacing); - return; - } - } -} - -void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ -QGraphicsLinearLayout::setAlignment(item, alignment); -} - -QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> QGraphicsLinearLayoutObject::attachedProperties; -LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) -{ -// ### This is not allowed - you must attach to any object -if (!qobject_cast<QGraphicsLayoutItem*>(obj)) - return 0; -LinearLayoutAttached *rv = new LinearLayoutAttached(obj); -attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv); -return rv; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////// -// QGraphicsGridLayout-related classes -////////////////////////////////////////////////////////////////////////////////////////////////////// -GridLayoutAttached::GridLayoutAttached(QObject *parent) -: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1), _rowstretch(-1), - _colstretch(-1), _rowspacing(-1), _colspacing(-1), _rowprefheight(-1), _rowmaxheight(-1), _rowminheight(-1), - _rowfixheight(-1), _colprefwidth(-1), _colmaxwidth(-1), _colminwidth(-1), _colfixwidth(-1) -{ -} - -void GridLayoutAttached::setRow(int r) -{ - if (_row == r) - return; - - _row = r; - //emit rowChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _row); -} - -void GridLayoutAttached::setColumn(int c) -{ - if (_column == c) - return; - - _column = c; - //emit columnChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _column); -} - -void GridLayoutAttached::setRowSpan(int rs) -{ - if (_rowspan == rs) - return; - - _rowspan = rs; - //emit rowSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _rowSpan); -} - -void GridLayoutAttached::setColumnSpan(int cs) -{ - if (_colspan == cs) - return; - - _colspan = cs; - //emit columnSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _columnSpan); -} - -void GridLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _alignment); -} - -void GridLayoutAttached::setRowStretchFactor(int f) -{ - _rowstretch = f; -} - -void GridLayoutAttached::setColumnStretchFactor(int f) -{ - _colstretch = f; -} - -void GridLayoutAttached::setRowSpacing(int s) -{ - _rowspacing = s; -} - -void GridLayoutAttached::setColumnSpacing(int s) -{ - _colspacing = s; -} - - -QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() -{ -} - -void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) -{ -//use attached properties -if (QObject *obj = attachedProperties.value(qobject_cast<QGraphicsLayoutItem*>(wid))) { - int row = static_cast<GridLayoutAttached *>(obj)->row(); - int column = static_cast<GridLayoutAttached *>(obj)->column(); - int rowSpan = static_cast<GridLayoutAttached *>(obj)->rowSpan(); - int columnSpan = static_cast<GridLayoutAttached *>(obj)->columnSpan(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - addItem(wid, row, column, rowSpan, columnSpan); -} -} - -void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) -{ -//use attached properties -if (GridLayoutAttached *obj = attachedProperties.value(item)) { - int row = obj->row(); - int column = obj->column(); - int rowSpan = obj->rowSpan(); - int columnSpan = obj->columnSpan(); - Qt::Alignment alignment = obj->alignment(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - if(obj->rowSpacing() != -1) - setRowSpacing(row, obj->rowSpacing()); - if(obj->columnSpacing() != -1) - setColumnSpacing(column, obj->columnSpacing()); - if(obj->rowStretchFactor() != -1) - setRowStretchFactor(row, obj->rowStretchFactor()); - if(obj->columnStretchFactor() != -1) - setColumnStretchFactor(column, obj->columnStretchFactor()); - if(obj->rowPreferredHeight() != -1) - setRowPreferredHeight(row, obj->rowPreferredHeight()); - if(obj->rowMaximumHeight() != -1) - setRowMaximumHeight(row, obj->rowMaximumHeight()); - if(obj->rowMinimumHeight() != -1) - setRowMinimumHeight(row, obj->rowMinimumHeight()); - if(obj->rowFixedHeight() != -1) - setRowFixedHeight(row, obj->rowFixedHeight()); - if(obj->columnPreferredWidth() != -1) - setColumnPreferredWidth(row, obj->columnPreferredWidth()); - if(obj->columnMaximumWidth() != -1) - setColumnMaximumWidth(row, obj->columnMaximumWidth()); - if(obj->columnMinimumWidth() != -1) - setColumnMinimumWidth(row, obj->columnMinimumWidth()); - if(obj->columnFixedWidth() != -1) - setColumnFixedWidth(row, obj->columnFixedWidth()); - addItem(item, row, column, rowSpan, columnSpan); - if (alignment != -1) - setAlignment(item,alignment); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - //### need to disconnect when widget is removed? -} -} - -//### is there a better way to do this? -void QGraphicsGridLayoutObject::clearChildren() -{ -for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsGridLayoutObject::spacing() const -{ -if (verticalSpacing() == horizontalSpacing()) - return verticalSpacing(); -return -1; //### -} - -qreal QGraphicsGridLayoutObject::contentsMargin() const -{ - qreal a,b,c,d; - getContentsMargins(&a, &b, &c, &d); - if(a==b && a==c && a==d) - return a; - return -1; -} - -void QGraphicsGridLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m,m,m,m); -} - - -void QGraphicsGridLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ -QGraphicsGridLayout::setAlignment(item, alignment); -} - -QHash<QGraphicsLayoutItem*, GridLayoutAttached*> QGraphicsGridLayoutObject::attachedProperties; -GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) -{ -// ### This is not allowed - you must attach to any object -if (!qobject_cast<QGraphicsLayoutItem*>(obj)) - return 0; -GridLayoutAttached *rv = new GridLayoutAttached(obj); -attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv); -return rv; -} - -QT_END_NAMESPACE diff --git a/src/imports/widgets/graphicslayouts_p.h b/src/imports/widgets/graphicslayouts_p.h deleted file mode 100644 index ea9c614..0000000 --- a/src/imports/widgets/graphicslayouts_p.h +++ /dev/null @@ -1,303 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRAPHICSLAYOUTS_H -#define GRAPHICSLAYOUTS_H - -#include <QtGui/QGraphicsLinearLayout> -#include <QtGui/QGraphicsGridLayout> -#include <qdeclarative.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) -public: - QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); - - virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; -}; - -class LinearLayoutAttached; -class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty<QGraphicsLayoutItem> children READ children) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsLinearLayoutObject(QObject * = 0); - ~QGraphicsLinearLayoutObject(); - - QDeclarativeListProperty<QGraphicsLayoutItem> children() { return QDeclarativeListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); } - - static LinearLayoutAttached *qmlAttachedProperties(QObject *); - - qreal contentsMargin() const; - void setContentsMargin(qreal); - -private Q_SLOTS: - void updateStretch(QGraphicsLayoutItem*,int); - void updateSpacing(QGraphicsLayoutItem*,int); - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class LinearLayoutAttached; - void clearChildren(); - void insertLayoutItem(int, QGraphicsLayoutItem *); - static QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> attachedProperties; - - static void children_append(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) { - static_cast<QGraphicsLinearLayoutObject*>(prop->object)->insertLayoutItem(-1, item); - } - - static void children_clear(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) { - static_cast<QGraphicsLinearLayoutObject*>(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) { - return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, int index) { - return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->itemAt(index); - } -}; - -class GridLayoutAttached; -class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty<QGraphicsLayoutItem> children READ children) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) - Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsGridLayoutObject(QObject * = 0); - ~QGraphicsGridLayoutObject(); - - QDeclarativeListProperty<QGraphicsLayoutItem> children() { return QDeclarativeListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); } - - qreal spacing() const; - qreal contentsMargin() const; - void setContentsMargin(qreal); - - static GridLayoutAttached *qmlAttachedProperties(QObject *); - -private Q_SLOTS: - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class GraphicsLayoutAttached; - void addWidget(QGraphicsWidget *); - void clearChildren(); - void addLayoutItem(QGraphicsLayoutItem *); - static QHash<QGraphicsLayoutItem*, GridLayoutAttached*> attachedProperties; - - static void children_append(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) { - static_cast<QGraphicsGridLayoutObject*>(prop->object)->addLayoutItem(item); - } - - static void children_clear(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) { - static_cast<QGraphicsGridLayoutObject*>(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) { - return static_cast<QGraphicsGridLayoutObject*>(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, int index) { - return static_cast<QGraphicsGridLayoutObject*>(prop->object)->itemAt(index); - } -}; - -class LinearLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) -public: - LinearLayoutAttached(QObject *parent); - - int stretchFactor() const { return _stretch; } - void setStretchFactor(int f); - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a); - int spacing() const { return _spacing; } - void setSpacing(int s); - -Q_SIGNALS: - void stretchChanged(QGraphicsLayoutItem*,int); - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - void spacingChanged(QGraphicsLayoutItem*,int); - -private: - int _stretch; - Qt::Alignment _alignment; - int _spacing; -}; - -class GridLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int row READ row WRITE setRow) - Q_PROPERTY(int column READ column WRITE setColumn) - Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) - Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) - Q_PROPERTY(int rowStretchFactor READ rowStretchFactor WRITE setRowStretchFactor) - Q_PROPERTY(int columnStretchFactor READ columnStretchFactor WRITE setColumnStretchFactor) - Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) - Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) - Q_PROPERTY(int rowPreferredHeight READ rowPreferredHeight WRITE setRowPreferredHeight) - Q_PROPERTY(int rowMinimumHeight READ rowMinimumHeight WRITE setRowMinimumHeight) - Q_PROPERTY(int rowMaximumHeight READ rowMaximumHeight WRITE setRowMaximumHeight) - Q_PROPERTY(int rowFixedHeight READ rowFixedHeight WRITE setRowFixedHeight) - Q_PROPERTY(int columnPreferredWidth READ columnPreferredWidth WRITE setColumnPreferredWidth) - Q_PROPERTY(int columnMaximumWidth READ columnMaximumWidth WRITE setColumnMaximumWidth) - Q_PROPERTY(int columnMinimumWidth READ columnMinimumWidth WRITE setColumnMinimumWidth) - Q_PROPERTY(int columnFixedWidth READ columnFixedWidth WRITE setColumnFixedWidth) - -public: - GridLayoutAttached(QObject *parent); - - int row() const { return _row; } - void setRow(int r); - - int column() const { return _column; } - void setColumn(int c); - - int rowSpan() const { return _rowspan; } - void setRowSpan(int rs); - - int columnSpan() const { return _colspan; } - void setColumnSpan(int cs); - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a); - - int rowStretchFactor() const { return _rowstretch; } - void setRowStretchFactor(int f); - int columnStretchFactor() const { return _colstretch; } - void setColumnStretchFactor(int f); - - int rowSpacing() const { return _rowspacing; } - void setRowSpacing(int s); - int columnSpacing() const { return _colspacing; } - void setColumnSpacing(int s); - - int rowPreferredHeight() const { return _rowprefheight; } - void setRowPreferredHeight(int s) { _rowprefheight = s; } - - int rowMaximumHeight() const { return _rowmaxheight; } - void setRowMaximumHeight(int s) { _rowmaxheight = s; } - - int rowMinimumHeight() const { return _rowminheight; } - void setRowMinimumHeight(int s) { _rowminheight = s; } - - int rowFixedHeight() const { return _rowfixheight; } - void setRowFixedHeight(int s) { _rowfixheight = s; } - - int columnPreferredWidth() const { return _colprefwidth; } - void setColumnPreferredWidth(int s) { _colprefwidth = s; } - - int columnMaximumWidth() const { return _colmaxwidth; } - void setColumnMaximumWidth(int s) { _colmaxwidth = s; } - - int columnMinimumWidth() const { return _colminwidth; } - void setColumnMinimumWidth(int s) { _colminwidth = s; } - - int columnFixedWidth() const { return _colfixwidth; } - void setColumnFixedWidth(int s) { _colfixwidth = s; } - -Q_SIGNALS: - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - -private: - int _row; - int _column; - int _rowspan; - int _colspan; - Qt::Alignment _alignment; - int _rowstretch; - int _colstretch; - int _rowspacing; - int _colspacing; - int _rowprefheight; - int _rowmaxheight; - int _rowminheight; - int _rowfixheight; - int _colprefwidth; - int _colmaxwidth; - int _colminwidth; - int _colfixwidth; -}; - -QT_END_NAMESPACE - -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) -QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) -QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QGraphicsGridLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // GRAPHICSLAYOUTS_H diff --git a/src/imports/widgets/qmldir b/src/imports/widgets/qmldir deleted file mode 100644 index 6f19878..0000000 --- a/src/imports/widgets/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin widgets diff --git a/src/imports/widgets/widgets.cpp b/src/imports/widgets/widgets.cpp deleted file mode 100644 index 20de1fe..0000000 --- a/src/imports/widgets/widgets.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> -#include <QGraphicsWidget> - -#include "graphicslayouts_p.h" -#include <private/qdeclarativegraphicswidget_p.h> -QT_BEGIN_NAMESPACE - -class QWidgetsQmlModule : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.widgets")); - - qmlRegisterInterface<QGraphicsLayoutItem>("QGraphicsLayoutItem"); - qmlRegisterInterface<QGraphicsLayout>("QGraphicsLayout"); - qmlRegisterType<QGraphicsLinearLayoutStretchItemObject>(uri,4,7,"QGraphicsLinearLayoutStretchItem"); - qmlRegisterType<QGraphicsLinearLayoutObject>(uri,4,7,"QGraphicsLinearLayout"); - qmlRegisterType<QGraphicsGridLayoutObject>(uri,4,7,"QGraphicsGridLayout"); - } -}; - -QT_END_NAMESPACE - -#include "widgets.moc" - -Q_EXPORT_PLUGIN2(qtwidgetsqmlmodule, QT_PREPEND_NAMESPACE(QWidgetsQmlModule)); - diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro deleted file mode 100644 index 234ff1e..0000000 --- a/src/imports/widgets/widgets.pro +++ /dev/null @@ -1,30 +0,0 @@ -TARGET = widgets -TARGETPATH = Qt/widgets -include(../qimportbase.pri) - -QT += declarative - -SOURCES += \ - graphicslayouts.cpp \ - widgets.cpp - -HEADERS += \ - graphicslayouts_p.h - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -symbian:{ - load(data_caging_paths) - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - - importFiles.sources = widgets.dll qmldir - importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH - - DEPLOYMENT = importFiles -} - -INSTALLS += target qmldir |