diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-11-16 03:50:29 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-16 03:50:29 (GMT) |
commit | 86f89023b52e00d155d6b14762f1a99a70d67e60 (patch) | |
tree | 9693d5a3dd848efe61bd2d1574453b63d279f7ab /src/declarative | |
parent | efb25bac3131b4ca39a44a16526d88c814986d60 (diff) | |
parent | 66eb8e1a135f5ac54be2ea088bae9c82708c4258 (diff) | |
download | Qt-86f89023b52e00d155d6b14762f1a99a70d67e60.zip Qt-86f89023b52e00d155d6b14762f1a99a70d67e60.tar.gz Qt-86f89023b52e00d155d6b14762f1a99a70d67e60.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/declarative.pro | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/graphicsitems.pri | 1 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstext.cpp | 3 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview.cpp | 96 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview_p.h | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview_p_p.h | 150 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 30 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlenginedebug.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlxmlhttprequest.cpp | 243 | ||||
-rw-r--r-- | src/declarative/util/qmllistaccessor.cpp | 128 | ||||
-rw-r--r-- | src/declarative/util/qmllistaccessor_p.h | 5 |
12 files changed, 267 insertions, 396 deletions
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index e4901bf..da8434f 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -9,7 +9,7 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtXml -# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors # LIBS += -lgcov INCLUDEPATH += ../../include/QtDeclarative diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index ef10e51..da3a0d4 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -83,5 +83,6 @@ contains(QT_CONFIG, webkit) { QT+=webkit SOURCES += graphicsitems/qmlgraphicswebview.cpp HEADERS += graphicsitems/qmlgraphicswebview_p.h + HEADERS += graphicsitems/qmlgraphicswebview_p_p.h } diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index 504eb2a..d0aec8d 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -50,6 +50,7 @@ #include <QTextCursor> #include <QGraphicsSceneMouseEvent> #include <QPainter> +#include <qmath.h> QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(Qt,4,6,Text,QmlGraphicsText) @@ -600,7 +601,7 @@ QSize QmlGraphicsTextPrivate::setupTextLayout(QTextLayout *layout) line.setPosition(QPointF(0, height)); height += int(line.height()); } - return QSize((int)widthUsed, height); + return QSize(qCeil(widthUsed), height); } QPixmap QmlGraphicsTextPrivate::wrappedTextImage(bool drawStyle) diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index 6dbf053..00fdd6d 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -59,6 +59,7 @@ #include <private/qlistmodelinterface_p.h> #include "qmlgraphicswebview_p.h" +#include "qmlgraphicswebview_p_p.h" #include <private/qmlgraphicspainteditem_p_p.h> QT_BEGIN_NAMESPACE @@ -67,97 +68,6 @@ QML_DEFINE_NOCREATE_TYPE(QAction) static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system -class QmlGraphicsWebSettings : public QObject { - Q_OBJECT - - Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily) - Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily) - Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily) - Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily) - Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily) - Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily) - - Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize) - Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize) - Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize) - Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize) - - Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) - Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) - Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) - Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) - Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) - Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) - Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) - Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) - Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) - Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) - Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) - Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) - Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) - Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) - Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls) - -public: - QmlGraphicsWebSettings() {} - - QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); } - void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont,f); } - QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); } - void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont,f); } - QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); } - void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont,f); } - QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); } - void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont,f); } - QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); } - void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont,f); } - QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); } - void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont,f); } - - int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); } - void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize,size); } - int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); } - void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize,size); } - int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); } - void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize,size); } - int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); } - void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize,size); } - - bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } - void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } - bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } - void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } - bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } - void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } - bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } - void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } - bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } - void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } - bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } - void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } - bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } - void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } - bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } - void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } - bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } - void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } - bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } - void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } - bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } - void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } - bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } - void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } - bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } - void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } - bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } - void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } - bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); } - void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); } - - QWebSettings *s; -}; - -QML_DECLARE_TYPE(QmlGraphicsWebSettings) QML_DEFINE_NOCREATE_TYPE(QmlGraphicsWebSettings) class QmlGraphicsWebViewPrivate : public QmlGraphicsPaintedItemPrivate @@ -706,7 +616,7 @@ void QmlGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) \i includes (\a clickX, \a clickY) \i fits into the preferredWidth and preferredHeight \i zooms by no more than \a maxzoom - \i is more than 20% above the current zoom + \i is more than 10% above the current zoom \endlist If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise, @@ -722,7 +632,7 @@ bool QmlGraphicsWebView::heuristicZoom(int clickX, int clickY, qreal 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.2) { + if (z/ozf > 1.1) { QRectF r(showarea.left()/ozf*z, showarea.top()/ozf*z, showarea.width()/ozf*z, showarea.height()/ozf*z); emit zoomTo(z,r.x()+r.width()/2, r.y()+r.height()/2); return true; diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 7c9faf4..1d55830 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -128,6 +128,7 @@ public: qreal zoomFactor() const; void setZoomFactor(qreal); Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom); + QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; int preferredWidth() const; void setPreferredWidth(int); @@ -223,7 +224,6 @@ protected: virtual void focusChanged(bool); virtual bool sceneEvent(QEvent *event); QmlGraphicsWebView *createWindow(QWebPage::WebWindowType type); - QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; private: void init(); diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p_p.h new file mode 100644 index 0000000..5063669 --- /dev/null +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p_p.h @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** 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 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 QMLGRAPHICSWEBVIEW_P_H +#define QMLGRAPHICSWEBVIEW_P_H + +#include <qml.h> +#include <QtWebKit/QWebPage> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlGraphicsWebSettings : public QObject { + Q_OBJECT + + Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily) + Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily) + Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily) + Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily) + Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily) + Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily) + + Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize) + Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize) + Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize) + Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize) + + Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) + Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) + Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) + Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) + Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) + Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) + Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) + Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) + Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) + Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) + Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) + Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) + Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) + Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) + Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls) + +public: + QmlGraphicsWebSettings() {} + + QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); } + void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont,f); } + QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); } + void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont,f); } + QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); } + void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont,f); } + QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); } + void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont,f); } + QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); } + void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont,f); } + QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); } + void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont,f); } + + int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); } + void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize,size); } + int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); } + void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize,size); } + int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); } + void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize,size); } + int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); } + void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize,size); } + + bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } + void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } + bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } + void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } + bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } + void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } + bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } + void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } + bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } + void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } + bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } + void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } + bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } + void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } + bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } + void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } + bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } + void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } + bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } + void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } + bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } + void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } + bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } + void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } + bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } + void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } + bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } + void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } + bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); } + void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); } + + QWebSettings *s; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlGraphicsWebSettings) + +QT_END_HEADER + +#endif diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 6e3cf69..66d4990 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -88,6 +88,7 @@ #include <private/qmllistscriptclass_p.h> #include <qmlscriptstring.h> #include <private/qmlglobal_p.h> +#include <QtCore/qcryptographichash.h> #ifdef Q_OS_WIN // for %APPDATA% #include "qt_windows.h" @@ -150,6 +151,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("closestAngle"), scriptEngine.newFunction(QmlEnginePrivate::closestAngle, 2)); qtObject.setProperty(QLatin1String("playSound"), scriptEngine.newFunction(QmlEnginePrivate::playSound, 1)); qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1)); + qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1)); scriptEngine.globalObject().setProperty(QLatin1String("createQmlObject"), scriptEngine.newFunction(QmlEnginePrivate::createQmlObject, 1)); @@ -425,22 +427,16 @@ QmlContext *QmlEngine::contextForObject(const QObject *object) */ void QmlEngine::setContextForObject(QObject *object, QmlContext *context) { - QObjectPrivate *priv = QObjectPrivate::get(object); - - QmlDeclarativeData *data = - static_cast<QmlDeclarativeData *>(priv->declarativeData); + if (!object || !context) + return; - if (data && data->context) { + QmlDeclarativeData *data = QmlDeclarativeData::get(object, true); + if (data->context) { qWarning("QmlEngine::setContextForObject(): Object already has a QmlContext"); return; } - if (!data) { - priv->declarativeData = new QmlDeclarativeData(context); - } else { - data->context = context; - } - + data->context = context; context->d_func()->contextObjects.append(object); } @@ -816,6 +812,18 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin return e->newVariant(QVariant(ret)); } +QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e) +{ + QByteArray data; + + if (ctxt->argumentCount() >= 1) + data = ctxt->argument(0).toString().toUtf8(); + + QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); + + return QScriptValue(QLatin1String(result.toHex())); +} + QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 2) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index a3e2d52..2e880bb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -272,6 +272,7 @@ public: static QScriptValue closestAngle(QScriptContext*, QScriptEngine*); static QScriptValue playSound(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); + static QScriptValue md5(QScriptContext*, QScriptEngine*); static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); } diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 78b166e..6871236 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -358,7 +358,7 @@ void QmlEngineDebugServer::messageReceived(const QByteArray &message) QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_OBJECT_R") << queryId << objectId << ok; + rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; sendMessage(reply); } else if (type == "WATCH_PROPERTY") { diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp index e5ee2f5..642c6de 100644 --- a/src/declarative/qml/qmlxmlhttprequest.cpp +++ b/src/declarative/qml/qmlxmlhttprequest.cpp @@ -91,16 +91,16 @@ namespace { -class NodeImpl : public QmlRefCount +class DocumentImpl; +class NodeImpl { public: - NodeImpl() : type(Element), parent(0) {} + NodeImpl() : type(Element), document(0), parent(0) {} virtual ~NodeImpl() { - if (parent) D(parent); for (int ii = 0; ii < children.count(); ++ii) - D(children.at(ii)); + delete children.at(ii); for (int ii = 0; ii < attributes.count(); ++ii) - D(attributes.at(ii)); + delete attributes.at(ii); } // These numbers are copied from the Node IDL definition @@ -125,18 +125,22 @@ public: QString data; + void addref(); + void release(); + + DocumentImpl *document; NodeImpl *parent; QList<NodeImpl *> children; QList<NodeImpl *> attributes; }; -class DocumentImpl : public QmlRefCount +class DocumentImpl : public QmlRefCount, public NodeImpl { public: - DocumentImpl() : root(0) { } + DocumentImpl() : root(0) { type = Document; } virtual ~DocumentImpl() { - if (root) D(root); + if (root) delete root; } QString version; @@ -144,6 +148,9 @@ public: bool isStandalone; NodeImpl *root; + + void addref() { QmlRefCount::addref(); } + void release() { QmlRefCount::release(); } }; class NamedNodeMap @@ -158,12 +165,13 @@ public: NamedNodeMap(); NamedNodeMap(const NamedNodeMap &); - NamedNodeMap &operator=(const NamedNodeMap &); ~NamedNodeMap(); bool isNull(); NodeImpl *d; QList<NodeImpl *> *list; +private: + NamedNodeMap &operator=(const NamedNodeMap &); }; class NamedNodeMapClass : public QScriptClass @@ -180,7 +188,6 @@ class NodeList public: // JS API static QScriptValue length(QScriptContext *context, QScriptEngine *engine); - static QScriptValue item(QScriptContext *context, QScriptEngine *engine); // C++ API static QScriptValue prototype(QScriptEngine *); @@ -188,11 +195,12 @@ public: NodeList(); NodeList(const NodeList &); - NodeList &operator=(const NodeList &); ~NodeList(); bool isNull(); NodeImpl *d; +private: + NodeList &operator=(const NodeList &); }; class NodeListClass : public QScriptClass @@ -232,11 +240,13 @@ public: Node(); Node(const Node &o); - Node &operator=(const Node &); ~Node(); bool isNull() const; NodeImpl *d; + +private: + Node &operator=(const Node &); }; class Element : public Node @@ -301,31 +311,39 @@ public: // C++ API static QScriptValue prototype(QScriptEngine *); static QScriptValue load(QScriptEngine *engine, const QString &data); - - Document(); - Document(const Document &); - Document &operator=(const Document &); - ~Document(); - bool isNull() const; - - DocumentImpl *d; -private: - Document(DocumentImpl *); }; -}; +}; // namespace Q_DECLARE_METATYPE(Node); Q_DECLARE_METATYPE(NodeList); Q_DECLARE_METATYPE(NamedNodeMap); -Q_DECLARE_METATYPE(Document); + +void NodeImpl::addref() +{ + A(document); +} + +void NodeImpl::release() +{ + D(document); +} QScriptValue Node::nodeName(QScriptContext *context, QScriptEngine *engine) { Node node = qscriptvalue_cast<Node>(context->thisObject()); if (node.isNull()) return engine->undefinedValue(); - return QScriptValue(node.d->name); + switch (node.d->type) { + case NodeImpl::Document: + return QScriptValue(QLatin1String("#document")); + case NodeImpl::CDATA: + return QScriptValue(QLatin1String("#cdata-section")); + case NodeImpl::Text: + return QScriptValue(QLatin1String("#text")); + default: + return QScriptValue(node.d->name); + } } QScriptValue Node::nodeValue(QScriptContext *context, QScriptEngine *engine) @@ -465,12 +483,11 @@ QScriptValue Node::create(QScriptEngine *engine, NodeImpl *data) case NodeImpl::Entity: case NodeImpl::EntityReference: case NodeImpl::Notation: + case NodeImpl::ProcessingInstruction: + return QScriptValue(); case NodeImpl::CDATA: instance.setPrototype(CDATA::prototype(engine)); break; - case NodeImpl::ProcessingInstruction: - instance.setPrototype(Node::prototype(engine)); - break; case NodeImpl::Text: instance.setPrototype(Text::prototype(engine)); break; @@ -556,8 +573,7 @@ QScriptValue Text::isElementContentWhitespace(QScriptContext *context, QScriptEn Node node = qscriptvalue_cast<Node>(context->thisObject()); if (node.isNull()) return engine->undefinedValue(); - // ### implement - return QScriptValue(false); + return node.d->data.trimmed().isEmpty(); } QScriptValue Text::wholeText(QScriptContext *context, QScriptEngine *engine) @@ -565,8 +581,7 @@ QScriptValue Text::wholeText(QScriptContext *context, QScriptEngine *engine) Node node = qscriptvalue_cast<Node>(context->thisObject()); if (node.isNull()) return engine->undefinedValue(); - // ### implement - return QScriptValue(QString()); + return node.d->data; } QScriptValue Text::prototype(QScriptEngine *engine) @@ -618,6 +633,7 @@ QScriptValue Document::load(QScriptEngine *engine, const QString &data) case QXmlStreamReader::StartDocument: Q_ASSERT(!document); document = new DocumentImpl; + document->document = document; document->version = reader.documentVersion().toString(); document->encoding = reader.documentEncoding().toString(); document->isStandalone = reader.isStandaloneDocument(); @@ -628,19 +644,20 @@ QScriptValue Document::load(QScriptEngine *engine, const QString &data) { Q_ASSERT(document); NodeImpl *node = new NodeImpl; + node->document = document; node->namespaceUri = reader.namespaceUri().toString(); node->name = reader.name().toString(); if (nodeStack.isEmpty()) { document->root = node; } else { node->parent = nodeStack.top(); - A(node->parent); node->parent->children.append(node); } nodeStack.append(node); foreach (const QXmlStreamAttribute &a, reader.attributes()) { NodeImpl *attr = new NodeImpl; + attr->document = document; attr->type = NodeImpl::Attr; attr->namespaceUri = a.namespaceUri().toString(); attr->name = a.name().toString(); @@ -656,9 +673,9 @@ QScriptValue Document::load(QScriptEngine *engine, const QString &data) case QXmlStreamReader::Characters: { NodeImpl *node = new NodeImpl; + node->document = document; node->type = reader.isCDATA()?NodeImpl::CDATA:NodeImpl::Text; node->parent = nodeStack.top(); - A(node->parent); node->parent->children.append(node); node->data = reader.text().toString(); } @@ -681,7 +698,9 @@ QScriptValue Document::load(QScriptEngine *engine, const QString &data) QScriptValue instance = engine->newObject(); instance.setPrototype(Document::prototype(engine)); - return engine->newVariant(instance, qVariantFromValue(Document(document))); + Node documentNode; + documentNode.d = document; + return engine->newVariant(instance, qVariantFromValue(documentNode)); } Node::Node() @@ -695,14 +714,6 @@ Node::Node(const Node &o) if (d) A(d); } -Node &Node::operator=(const Node &o) -{ - if (o.d) A(o.d); - if (d) D(d); - d = o.d; - return *this; -} - Node::~Node() { if (d) D(d); @@ -761,15 +772,6 @@ NamedNodeMap::NamedNodeMap(const NamedNodeMap &o) if (d) A(d); } -NamedNodeMap &NamedNodeMap::operator=(const NamedNodeMap &o) -{ - if (o.d) A(o.d); - if (d) D(d); - d = o.d; - list = o.list; - return *this; -} - NamedNodeMap::~NamedNodeMap() { if (d) D(d); @@ -780,20 +782,6 @@ bool NamedNodeMap::isNull() return d == 0; } -QScriptValue NodeList::item(QScriptContext *context, QScriptEngine *engine) -{ - NodeList list = qscriptvalue_cast<NodeList>(context->thisObject().data()); - if (list.isNull() || context->argumentCount() != 1) - return engine->undefinedValue(); - - qint32 index = context->argument(0).toInt32(); - - if (index >= list.d->children.count()) - return engine->undefinedValue(); // ### Exception - else - return Node::create(engine, list.d->children.at(index)); -} - QScriptValue NodeList::length(QScriptContext *context, QScriptEngine *engine) { NodeList list = qscriptvalue_cast<NodeList>(context->thisObject().data()); @@ -807,7 +795,6 @@ QScriptValue NodeList::prototype(QScriptEngine *engine) QScriptValue proto = engine->newObject(); proto.setProperty(QLatin1String("length"), engine->newFunction(length), QScriptValue::ReadOnly | QScriptValue::PropertyGetter); - proto.setProperty(QLatin1String("item"), engine->newFunction(item, 1), QScriptValue::ReadOnly); return proto; } @@ -842,14 +829,6 @@ NodeList::NodeList(const NodeList &o) if (d) A(d); } -NodeList &NodeList::operator=(const NodeList &o) -{ - if (o.d) A(o.d); - if (d) D(d); - d = o.d; - return *this; -} - NodeList::~NodeList() { if (d) D(d); @@ -866,8 +845,7 @@ NamedNodeMapClass::QueryFlags NamedNodeMapClass::queryProperty(const QScriptValu return 0; NamedNodeMap map = qscriptvalue_cast<NamedNodeMap>(object.data()); - if (map.isNull()) - return 0; + Q_ASSERT(!map.isNull()); bool ok = false; QString nameString = name.toString(); @@ -920,81 +898,36 @@ QScriptValue NodeListClass::property(const QScriptValue &object, const QScriptSt return Node::create(engine(), list.d->children.at(id)); } -Document::Document() -: d(0) -{ -} - -Document::Document(DocumentImpl *data) -: d(data) -{ -} - -Document::Document(const Document &o) -: Node(o), d(o.d) -{ - if (d) A(d); -} - -Document &Document::operator=(const Document &o) -{ - if (o.d) A(o.d); - if (d) D(d); - d = o.d; - return *this; -} - -Document::~Document() -{ - if (d) D(d); -} - -bool Document::isNull() const -{ - return d == 0; -} - QScriptValue Document::documentElement(QScriptContext *context, QScriptEngine *engine) { - Document document = qscriptvalue_cast<Document>(context->thisObject()); - if (document.isNull()) return engine->undefinedValue(); + Node document = qscriptvalue_cast<Node>(context->thisObject()); + if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue(); - if (!document.d->root) return engine->nullValue(); - - return Node::create(engine, document.d->root); + return Node::create(engine, static_cast<DocumentImpl *>(document.d)->root); } QScriptValue Document::xmlStandalone(QScriptContext *context, QScriptEngine *engine) { - Document document = qscriptvalue_cast<Document>(context->thisObject()); - if (document.isNull()) return engine->undefinedValue(); - - if (context->argumentCount()) - document.d->isStandalone = context->argument(0).toBool(); + Node document = qscriptvalue_cast<Node>(context->thisObject()); + if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue(); - return QScriptValue(document.d->isStandalone); + return QScriptValue(static_cast<DocumentImpl *>(document.d)->isStandalone); } QScriptValue Document::xmlVersion(QScriptContext *context, QScriptEngine *engine) { - Document document = qscriptvalue_cast<Document>(context->thisObject()); - if (document.isNull()) return engine->undefinedValue(); - - if (context->argumentCount()) - document.d->version = context->argument(0).toString(); + Node document = qscriptvalue_cast<Node>(context->thisObject()); + if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue(); - return QScriptValue(document.d->version); + return QScriptValue(static_cast<DocumentImpl *>(document.d)->version); } QScriptValue Document::xmlEncoding(QScriptContext *context, QScriptEngine *engine) { - Document document = qscriptvalue_cast<Document>(context->thisObject()); - if (document.isNull()) return engine->undefinedValue(); + Node document = qscriptvalue_cast<Node>(context->thisObject()); + if (document.isNull() || document.d->type != NodeImpl::Document) return engine->undefinedValue(); - if (context->argumentCount()) - document.d->encoding = context->argument(0).toString(); - - return QScriptValue(document.d->encoding); + return QScriptValue(static_cast<DocumentImpl *>(document.d)->encoding); } class QmlXMLHttpRequest : public QObject @@ -1179,7 +1112,7 @@ void QmlXMLHttpRequest::send(const QByteArray &data) QVariant var = request.header(QNetworkRequest::ContentTypeHeader); if (var.isValid()) { QString str = var.toString(); - int charsetIdx = str.indexOf("charset="); + int charsetIdx = str.indexOf(QLatin1String("charset=")); if (charsetIdx == -1) { // No charset - append if (!str.isEmpty()) str.append(QLatin1Char(';')); @@ -1391,7 +1324,7 @@ static QScriptValue qmlxmlhttprequest_setRequestHeader(QScriptContext *context, THROW_REFERENCE("Not an XMLHttpRequest object"); if (context->argumentCount() != 2) - THROW_SYNTAX("Incorrect argument count"); + THROW_DOM(SYNTAX_ERR, "Incorrect argument count"); if (request->readyState() != QmlXMLHttpRequest::Opened || @@ -1472,7 +1405,7 @@ static QScriptValue qmlxmlhttprequest_getResponseHeader(QScriptContext *context, THROW_REFERENCE("Not an XMLHttpRequest object"); if (context->argumentCount() != 1) - THROW_SYNTAX("Incorrect argument count"); + THROW_DOM(SYNTAX_ERR, "Incorrect argument count"); if (request->readyState() != QmlXMLHttpRequest::Loading && request->readyState() != QmlXMLHttpRequest::Done && @@ -1492,7 +1425,7 @@ static QScriptValue qmlxmlhttprequest_getAllResponseHeaders(QScriptContext *cont THROW_REFERENCE("Not an XMLHttpRequest object"); if (context->argumentCount() != 0) - THROW_SYNTAX("Incorrect argument count"); + THROW_DOM(SYNTAX_ERR, "Incorrect argument count"); if (request->readyState() != QmlXMLHttpRequest::Loading && request->readyState() != QmlXMLHttpRequest::Done && @@ -1634,23 +1567,23 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine) // DOM Exception QScriptValue domExceptionPrototype = engine->newObject(); - domExceptionPrototype.setProperty("INDEX_SIZE_ERR", INDEX_SIZE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("DOMSTRING_SIZE_ERR", DOMSTRING_SIZE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("HIERARCHY_REQUEST_ERR", HIERARCHY_REQUEST_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("WRONG_DOCUMENT_ERR", WRONG_DOCUMENT_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("INVALID_CHARACTER_ERR", INVALID_CHARACTER_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("NO_DATA_ALLOWED_ERR", NO_DATA_ALLOWED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("NO_MODIFICATION_ALLOWED_ERR", NO_MODIFICATION_ALLOWED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("NOT_FOUND_ERR", NOT_FOUND_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("NOT_SUPPORTED_ERR", NOT_SUPPORTED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("INUSE_ATTRIBUTE_ERR", INUSE_ATTRIBUTE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("INVALID_STATE_ERR", INVALID_STATE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("SYNTAX_ERR", SYNTAX_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("INVALID_MODIFICATION_ERR", INVALID_MODIFICATION_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("NAMESPACE_ERR", NAMESPACE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("INVALID_ACCESS_ERR", INVALID_ACCESS_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("VALIDATION_ERR", VALIDATION_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - domExceptionPrototype.setProperty("TYPE_MISMATCH_ERR", TYPE_MISMATCH_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("INDEX_SIZE_ERR"), INDEX_SIZE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("DOMSTRING_SIZE_ERR"), DOMSTRING_SIZE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("HIERARCHY_REQUEST_ERR"), HIERARCHY_REQUEST_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("WRONG_DOCUMENT_ERR"), WRONG_DOCUMENT_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("INVALID_CHARACTER_ERR"), INVALID_CHARACTER_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("NO_DATA_ALLOWED_ERR"), NO_DATA_ALLOWED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("NO_MODIFICATION_ALLOWED_ERR"), NO_MODIFICATION_ALLOWED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("NOT_FOUND_ERR"), NOT_FOUND_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("NOT_SUPPORTED_ERR"), NOT_SUPPORTED_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("INUSE_ATTRIBUTE_ERR"), INUSE_ATTRIBUTE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("INVALID_STATE_ERR"), INVALID_STATE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("SYNTAX_ERR"), SYNTAX_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("INVALID_MODIFICATION_ERR"), INVALID_MODIFICATION_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("NAMESPACE_ERR"), NAMESPACE_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("INVALID_ACCESS_ERR"), INVALID_ACCESS_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("VALIDATION_ERR"), VALIDATION_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); + domExceptionPrototype.setProperty(QLatin1String("TYPE_MISMATCH_ERR"), TYPE_MISMATCH_ERR, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); engine->globalObject().setProperty(QLatin1String("DOMException"), domExceptionPrototype); } diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 910f2a5..2c01081 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -149,134 +149,6 @@ QVariant QmlListAccessor::at(int idx) const return QVariant(); } -void QmlListAccessor::append(const QVariant &value) -{ - switch(m_type) { - case Invalid: - break; - case StringList: - { - const QString &str = value.toString(); - qvariant_cast<QStringList>(d).append(str); - break; - } - case VariantList: - { - qvariant_cast<QVariantList>(d).append(value); - break; - } - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->append(const_cast<void *>(value.constData())); //XXX - break; - } - case QList: - QmlMetaType::append(d, value); - break; - case Instance: - case Integer: - //do nothing - break; - } -} - -void QmlListAccessor::insert(int index, const QVariant &value) -{ - switch(m_type) { - case Invalid: - break; - case StringList: - { - const QString &str = value.toString(); - qvariant_cast<QStringList>(d).insert(index, str); - break; - } - case VariantList: - { - qvariant_cast<QVariantList>(d).insert(index, value); - break; - } - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->insert(index, const_cast<void *>(value.constData())); //XXX - break; - } - case QList: - //XXX needs implementation - qWarning() << "insert function not yet implemented for QLists"; - break; - case Instance: - //XXX do nothing? - if (index == 0) - setList(value); - break; - case Integer: - break; - } -} - -void QmlListAccessor::removeAt(int index) -{ - switch(m_type) { - case Invalid: - break; - case StringList: - qvariant_cast<QStringList>(d).removeAt(index); - break; - case VariantList: - qvariant_cast<QVariantList>(d).removeAt(index); - break; - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->removeAt(index); - break; - } - case QList: - //XXX needs implementation - qWarning() << "removeAt function not yet implemented for QLists"; - break; - case Instance: - //XXX do nothing? - if (index == 0) - setList(QVariant()); - break; - case Integer: - break; - } -} - -void QmlListAccessor::clear() -{ - switch(m_type) { - case Invalid: - break; - case StringList: - qvariant_cast<QStringList>(d).clear(); - break; - case VariantList: - qvariant_cast<QVariantList>(d).clear(); - break; - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->clear(); - break; - } - case QList: - QmlMetaType::clear(d); - break; - case Instance: - //XXX what should we do here? - setList(QVariant()); - break; - case Integer: - d = 0; - } -} - bool QmlListAccessor::isValid() const { return m_type != Invalid; diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h index 2697606..7b34d75 100644 --- a/src/declarative/util/qmllistaccessor_p.h +++ b/src/declarative/util/qmllistaccessor_p.h @@ -65,11 +65,6 @@ public: int count() const; QVariant at(int) const; - virtual void append(const QVariant &); - virtual void insert(int, const QVariant &); - virtual void removeAt(int); - virtual void clear(); - enum Type { Invalid, StringList, VariantList, QmlList, QList, Instance, Integer }; Type type() const { return m_type; } |