summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-10 13:40:34 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-10 13:40:34 (GMT)
commit2c4bbeecd084bf4565643d4cd42de3be1aed5681 (patch)
treedc40f7bba6c74248c9a0359b05b39bce0e6decb2 /src
parentd1c5585faa066a6693c24600cf8a1c42a285fe3b (diff)
parent7b15c669c336a1d76e3ac001fadde38a294e3e80 (diff)
downloadQt-2c4bbeecd084bf4565643d4cd42de3be1aed5681.zip
Qt-2c4bbeecd084bf4565643d4cd42de3be1aed5681.tar.gz
Qt-2c4bbeecd084bf4565643d4cd42de3be1aed5681.tar.bz2
Merge remote branch 'mainline/4.6' into 4.6
Conflicts: tools/configure/configureapp.cpp
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/ce-compat/ce_time.c (renamed from src/3rdparty/ce-compat/ce_time.cpp)0
-rw-r--r--src/3rdparty/ce-compat/ce_time.h13
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri3
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h6
-rw-r--r--src/3rdparty/phonon/mmf/videooutput.cpp2
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri3
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h6
-rw-r--r--src/3rdparty/webkit/VERSION2
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog18
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp17
-rw-r--r--src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp190
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h34
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h71
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp6
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp24
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h1
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp7
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h1
-rw-r--r--src/3rdparty/webkit/WebKit/qt/ChangeLog252
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp6
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp33
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp121
-rw-r--r--src/corelib/io/qfsfileengine.cpp168
-rw-r--r--src/corelib/tools/qregexp.cpp18
-rw-r--r--src/corelib/tools/qregexp.h3
-rw-r--r--src/corelib/tools/qscopedpointer.h32
-rw-r--r--src/corelib/tools/qscopedpointer_p.h20
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.cpp6
-rw-r--r--src/gui/effects/qgraphicseffect.cpp233
-rw-r--r--src/gui/effects/qgraphicseffect.h90
-rw-r--r--src/gui/effects/qgraphicseffect_p.h41
-rw-r--r--src/gui/embedded/qscreen_qws.cpp18
-rw-r--r--src/gui/embedded/qscreen_qws.h3
-rw-r--r--src/gui/embedded/qwscursor_qws.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp586
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h172
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp15
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h1
-rw-r--r--src/gui/image/qbmphandler.cpp22
-rw-r--r--src/gui/image/qimage.cpp134
-rw-r--r--src/gui/image/qimage.h9
-rw-r--r--src/gui/image/qpixmap.cpp7
-rw-r--r--src/gui/image/qpixmap.h3
-rw-r--r--src/gui/image/qpixmap_mac.cpp14
-rw-r--r--src/gui/image/qpixmap_qws.cpp7
-rw-r--r--src/gui/image/qpixmap_raster.cpp2
-rw-r--r--src/gui/image/qpixmap_s60.cpp8
-rw-r--r--src/gui/image/qpixmap_x11.cpp22
-rw-r--r--src/gui/image/qpixmapdata.cpp2
-rw-r--r--src/gui/image/qpixmapdata_p.h3
-rw-r--r--src/gui/image/qpixmapfilter.cpp22
-rw-r--r--src/gui/image/qpixmapfilter_p.h4
-rw-r--r--src/gui/image/qpnghandler.cpp12
-rw-r--r--src/gui/image/qppmhandler.cpp6
-rw-r--r--src/gui/image/qxbmhandler.cpp2
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp2
-rw-r--r--src/gui/kernel/qaction.cpp2
-rw-r--r--src/gui/kernel/qapplication_win.cpp2
-rw-r--r--src/gui/kernel/qcursor_win.cpp8
-rw-r--r--src/gui/kernel/qgesturemanager.cpp4
-rw-r--r--src/gui/kernel/qlayout.cpp32
-rw-r--r--src/gui/kernel/qlayout.h3
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp4
-rw-r--r--src/gui/kernel/qstandardgestures.cpp3
-rw-r--r--src/gui/kernel/qwidget.cpp12
-rw-r--r--src/gui/kernel/qwidget_p.h2
-rw-r--r--src/gui/kernel/qwidget_win.cpp33
-rw-r--r--src/gui/kernel/qwidget_x11.cpp2
-rw-r--r--src/gui/kernel/qwinnativepangesturerecognizer_win.cpp4
-rw-r--r--src/gui/kernel/qwinnativepangesturerecognizer_win_p.h4
-rw-r--r--src/gui/painting/qbrush.cpp2
-rw-r--r--src/gui/painting/qcolormap_qws.cpp2
-rw-r--r--src/gui/painting/qmatrix.cpp18
-rw-r--r--src/gui/painting/qmatrix.h3
-rw-r--r--src/gui/painting/qpaintdevice.h3
-rw-r--r--src/gui/painting/qpaintengine_mac.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
-rw-r--r--src/gui/painting/qpaintengineex.cpp2
-rw-r--r--src/gui/painting/qregion.cpp20
-rw-r--r--src/gui/painting/qregion.h3
-rw-r--r--src/gui/painting/qtransform.cpp2
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp6
-rw-r--r--src/gui/styles/qs60style.cpp2
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp21
-rw-r--r--src/gui/styles/qwindowsmobilestyle_p.h4
-rw-r--r--src/gui/text/qfontengine_qpf.cpp4
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp19
-rw-r--r--src/gui/widgets/qabstractscrollarea.h2
-rw-r--r--src/gui/widgets/qlcdnumber.cpp41
-rw-r--r--src/gui/widgets/qlcdnumber.h7
-rw-r--r--src/gui/widgets/qlineedit.cpp23
-rw-r--r--src/gui/widgets/qlineedit.h3
-rw-r--r--src/gui/widgets/qplaintextedit.cpp2
-rw-r--r--src/gui/widgets/qprintpreviewwidget.cpp12
-rw-r--r--src/gui/widgets/qprintpreviewwidget.h3
-rw-r--r--src/multimedia/audio/qaudio.cpp24
-rw-r--r--src/multimedia/audio/qaudio.h2
-rw-r--r--src/multimedia/audio/qaudiodevicefactory.cpp22
-rw-r--r--src/multimedia/audio/qaudiodevicefactory_p.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo.cpp8
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp6
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_mac_p.h2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp3
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.h2
-rw-r--r--src/multimedia/audio/qaudioengine.cpp8
-rw-r--r--src/multimedia/audio/qaudioengine.h8
-rw-r--r--src/multimedia/audio/qaudioengineplugin.h4
-rw-r--r--src/multimedia/audio/qaudioformat.cpp13
-rw-r--r--src/multimedia/audio/qaudioformat.h2
-rw-r--r--src/multimedia/audio/qaudioinput.cpp63
-rw-r--r--src/multimedia/audio/qaudioinput.h8
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp28
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.h4
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.cpp24
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.h4
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp39
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.h4
-rw-r--r--src/multimedia/audio/qaudiooutput.cpp52
-rw-r--r--src/multimedia/audio/qaudiooutput.h8
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp32
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.h4
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.cpp26
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.h4
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp26
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.h4
-rw-r--r--src/multimedia/video/qimagevideobuffer.cpp2
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp4
-rw-r--r--src/network/access/qnetworkcookie.cpp8
-rw-r--r--src/network/access/qnetworkcookiejar.cpp7
-rw-r--r--src/network/kernel/qhostinfo_p.h6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp2
-rw-r--r--src/opengl/qgl.cpp2
-rw-r--r--src/opengl/qglpixmapfilter.cpp46
-rw-r--r--src/opengl/qgraphicsshadereffect.cpp10
-rw-r--r--src/opengl/qgraphicsshadereffect_p.h2
-rw-r--r--src/opengl/qpixmapdata_gl.cpp2
-rw-r--r--src/openvg/qpaintengine_vg.cpp16
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp14
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp2
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp2
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp4
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp4
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp6
-rw-r--r--src/qt3support/painting/q3paintdevicemetrics.h2
-rw-r--r--src/script/api/qscriptengine.cpp30
-rw-r--r--src/script/api/qscriptengine.h2
-rw-r--r--src/script/api/qscriptengine_p.h2
-rw-r--r--src/script/api/qscriptvalue.cpp5
-rw-r--r--src/script/bridge/bridge.pri8
-rw-r--r--src/script/bridge/qscriptdeclarativeclass.cpp356
-rw-r--r--src/script/bridge/qscriptdeclarativeclass_p.h129
-rw-r--r--src/script/bridge/qscriptdeclarativeobject.cpp192
-rw-r--r--src/script/bridge/qscriptdeclarativeobject_p.h125
-rw-r--r--src/script/bridge/qscriptobject_p.h3
-rw-r--r--src/sql/models/qsqlquerymodel.cpp9
-rw-r--r--src/src.pro35
-rw-r--r--src/testlib/qbenchmarkvalgrind.cpp2
-rw-r--r--src/tools/tools.pro72
-rw-r--r--src/tools/uic3/embed.cpp4
-rw-r--r--src/xmlpatterns/functions/qpatternmatchingfns.cpp2
-rw-r--r--src/xmlpatterns/functions/qpatternplatform_p.h2
173 files changed, 3218 insertions, 1197 deletions
diff --git a/src/3rdparty/ce-compat/ce_time.cpp b/src/3rdparty/ce-compat/ce_time.c
index 92efae0..92efae0 100644
--- a/src/3rdparty/ce-compat/ce_time.cpp
+++ b/src/3rdparty/ce-compat/ce_time.c
diff --git a/src/3rdparty/ce-compat/ce_time.h b/src/3rdparty/ce-compat/ce_time.h
index 9d946e8..07ca094 100644
--- a/src/3rdparty/ce-compat/ce_time.h
+++ b/src/3rdparty/ce-compat/ce_time.h
@@ -2,15 +2,24 @@
#define __CE_TIME_H__
#if defined(_WIN32_WCE) && _WIN32_WCE >= 0x600
-// we need to prototype the time functions for Windows CE >= 6.0
+/* we need to prototype the time functions for Windows CE >= 6.0 */
#include <crtdefs.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct tm;
time_t time(time_t* timer);
time_t mktime(struct tm *t);
size_t strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t);
struct tm *localtime(const time_t *timer);
-#endif
+#ifdef __cplusplus
+} /* closing brace for extern "C" */
#endif
+
+#endif /* defined(_WIN32_WCE) && _WIN32_WCE >= 0x600 */
+
+#endif /* !defined(__CE_TIME_H__) */
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
index 2330de1..ea6e5ab 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
@@ -59,7 +59,8 @@ win32-* {
}
wince* {
- SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.cpp
+ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/ce-compat
+ SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.c
DEFINES += WINCEBASIC
}
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
index 73212db..2a407d4 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
@@ -367,6 +367,10 @@
# endif
#endif
+#if PLATFORM(WINCE) && PLATFORM(QT)
+# include <ce_time.h>
+#endif
+
/* Compiler */
/* COMPILER(MSVC) */
@@ -561,7 +565,7 @@
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMEB_H 1
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE)
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) && !PLATFORM(QT)
#define HAVE_MADV_FREE_REUSE 1
#define HAVE_MADV_FREE 1
#define HAVE_PTHREAD_SETNAME_NP 1
diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp
index 5288b4d..1b338a2 100644
--- a/src/3rdparty/phonon/mmf/videooutput.cpp
+++ b/src/3rdparty/phonon/mmf/videooutput.cpp
@@ -136,7 +136,7 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event)
TRACE("rect %d %d - %d %d",
event->rect().left(), event->rect().top(),
event->rect().right(), event->rect().bottom());
- TRACE("regions %d", event->region().numRects());
+ TRACE("regions %d", event->region().rectCount());
TRACE("type %d", event->type());
// Do nothing
diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri
index eb26664..8bd4225 100644
--- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri
+++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri
@@ -61,7 +61,8 @@ win32-* {
}
wince* {
- SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.cpp
+ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/ce-compat
+ SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.c
DEFINES += WINCEBASIC
}
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h
index 7632435..7bfde5b 100644
--- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h
@@ -372,6 +372,10 @@
# endif
#endif
+#if PLATFORM(WINCE) && PLATFORM(QT)
+# include <ce_time.h>
+#endif
+
/* Compiler */
/* COMPILER(MSVC) */
@@ -556,7 +560,7 @@
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMEB_H 1
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE)
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) && !PLATFORM(QT)
#define HAVE_MADV_FREE_REUSE 1
#define HAVE_MADV_FREE 1
#define HAVE_PTHREAD_SETNAME_NP 1
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index 810781f..ae1c3b6 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
and has the sha1 checksum
- 16aab1b39e14195abdc2100265da2e45b96b739f
+ 363898ca378e2198b855ca2f8921c5e4f898c5e2
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index 1dfc2f9..be07193 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2009-11-09 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Pass credentials provided by XMLHTTPRequest to the network request.
+ https://bugs.webkit.org/show_bug.cgi?id=31208
+
+ After r42483, the credentials are no longer passed to the network request
+ in the URL of the request.
+ Pass the credentials from XMLHTTPRequest to the network request, the same
+ way that other ports do.
+
+ After this patch LayoutTests/http/xmlhttprequest/basic-auth.html passes.
+
+ * platform/network/qt/ResourceHandleQt.cpp:
+ (WebCore::ResourceHandle::start):
+ (WebCore::ResourceHandle::loadResourceSynchronously):
+
2009-11-03 Simon Hausmann <hausmann@webkit.org>
Unreviewed build fix for WebInspector with Qt build.
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp
index f4c30c9..b3844bf 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp
@@ -131,6 +131,15 @@ bool ResourceHandle::start(Frame* frame)
if (!page)
return false;
+ if (!(d->m_user.isEmpty() || d->m_pass.isEmpty())) {
+ // If credentials were specified for this request, add them to the url,
+ // so that they will be passed to QNetworkRequest.
+ KURL urlWithCredentials(d->m_request.url());
+ urlWithCredentials.setUser(d->m_user);
+ urlWithCredentials.setPass(d->m_pass);
+ d->m_request.setURL(urlWithCredentials);
+ }
+
getInternal()->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame();
#if QT_VERSION < 0x040400
return QWebNetworkManager::self()->add(this, getInternal()->m_frame->page()->d->networkInterface);
@@ -204,6 +213,14 @@ void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, S
}
#else
ResourceHandleInternal *d = handle.getInternal();
+ if (!(d->m_user.isEmpty() || d->m_pass.isEmpty())) {
+ // If credentials were specified for this request, add them to the url,
+ // so that they will be passed to QNetworkRequest.
+ KURL urlWithCredentials(d->m_request.url());
+ urlWithCredentials.setUser(d->m_user);
+ urlWithCredentials.setPass(d->m_pass);
+ d->m_request.setURL(urlWithCredentials);
+ }
d->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame();
d->m_job = new QNetworkReplyHandler(&handle, QNetworkReplyHandler::LoadNormal);
#endif
diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp
index 8221760..442ffa3 100644
--- a/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/qt/PlatformScreenQt.cpp
@@ -72,7 +72,7 @@ int screenDepthPerComponent(Widget* w)
bool screenIsMonochrome(Widget* w)
{
- return QApplication::desktop()->screen(screenNumber(w))->numColors() < 2;
+ return QApplication::desktop()->screen(screenNumber(w))->colorCount() < 2;
}
FloatRect screenRect(Widget* w)
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
index b22109b..38d8c47 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
@@ -39,8 +39,6 @@ public:
QGraphicsWebViewPrivate(QGraphicsWebView* parent)
: q(parent)
, page(0)
- , interactive(true)
- , progress(1.0)
{}
virtual void scroll(int dx, int dy, const QRect&);
@@ -61,28 +59,12 @@ public:
virtual QObject* pluginParent() const;
- void _q_doLoadProgress(int progress);
void _q_doLoadFinished(bool success);
- void _q_setStatusBarMessage(const QString& message);
QGraphicsWebView* q;
QWebPage* page;
-
- QString statusBarMessage;
- bool interactive;
- qreal progress;
};
-void QGraphicsWebViewPrivate::_q_doLoadProgress(int progress)
-{
- if (qFuzzyCompare(this->progress, qreal(progress / 100.)))
- return;
-
- this->progress = progress / 100.;
-
- emit q->progressChanged(this->progress);
-}
-
void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success)
{
// If the page had no title, still make sure it gets the signal
@@ -105,8 +87,11 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect)
void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable)
{
- q->setAttribute(Qt::WA_InputMethodEnabled, enable);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable);
+#endif
}
+
#if QT_VERSION >= 0x040600
void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable)
{
@@ -156,12 +141,6 @@ QObject* QGraphicsWebViewPrivate::pluginParent() const
return q;
}
-void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s)
-{
- statusBarMessage = s;
- emit q->statusChanged();
-}
-
/*!
\class QGraphicsWebView
\brief The QGraphicsWebView class allows Web content to be added to a GraphicsView.
@@ -356,6 +335,24 @@ QVariant QGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant&
/*! \reimp
*/
+QSizeF QGraphicsWebView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const
+{
+ if (which == Qt::PreferredSize)
+ return QSizeF(800, 600); // ###
+ return QGraphicsWidget::sizeHint(which, constraint);
+}
+
+/*! \reimp
+*/
+QVariant QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ if (d->page)
+ return d->page->inputMethodQuery(query);
+ return QVariant();
+}
+
+/*! \reimp
+*/
bool QGraphicsWebView::event(QEvent* event)
{
// Re-implemented in order to allows fixing event-related bugs in patch releases.
@@ -438,11 +435,13 @@ void QGraphicsWebView::setPage(QWebPage* page)
connect(d->page, SIGNAL(loadStarted()),
this, SIGNAL(loadStarted()));
connect(d->page, SIGNAL(loadProgress(int)),
- this, SLOT(_q_doLoadProgress(int)));
+ this, SIGNAL(loadProgress(int)));
connect(d->page, SIGNAL(loadFinished(bool)),
this, SLOT(_q_doLoadFinished(bool)));
connect(d->page, SIGNAL(statusBarMessage(const QString&)),
- this, SLOT(_q_setStatusBarMessage(const QString&)));
+ this, SIGNAL(statusBarMessage(const QString&)));
+ connect(d->page, SIGNAL(linkClicked(const QUrl &)),
+ this, SIGNAL(linkClicked(const QUrl &)));
}
/*!
@@ -513,7 +512,6 @@ void QGraphicsWebView::setZoomFactor(qreal factor)
return;
page()->mainFrame()->setZoomFactor(factor);
- emit zoomFactorChanged();
}
qreal QGraphicsWebView::zoomFactor() const
@@ -550,21 +548,6 @@ void QGraphicsWebView::setGeometry(const QRectF& rect)
}
/*!
- \property QGraphicsWebView::status
- \brief the load status message.
-
- Provides the latest status message set during the load of a URL.
- Commonly shown by Status Bar widgets.
-
- \sa statusChanged()
-*/
-
-QString QGraphicsWebView::status() const
-{
- return d->statusBarMessage;
-}
-
-/*!
Convenience slot that stops loading the document.
\sa reload(), loadFinished()
@@ -611,15 +594,6 @@ void QGraphicsWebView::reload()
}
/*!
- \property QGraphicsWebView::progress
- \brief the progress of loading the current URL, from 0 to 1.
-*/
-qreal QGraphicsWebView::progress() const
-{
- return d->progress;
-}
-
-/*!
Loads the specified \a url and displays it.
\note The view remains the same until enough data has arrived to display the new \a url.
@@ -651,15 +625,14 @@ void QGraphicsWebView::load(const QNetworkRequest& request,
}
/*!
- \property QGraphicsWebView::html
- This property provides an HTML interface to the text in the webview.
+ Sets the content of the web view to the specified \a html.
- When setting this property, external objects such as stylesheets or images
- referenced in the HTML document are located relative to \a baseUrl.
+ External objects such as stylesheets or images referenced in the HTML
+ document are located relative to \a baseUrl.
The \a html is loaded immediately; external objects are loaded asynchronously.
- When using these methods, WebKit assumes that external resources such as
+ When using this method, WebKit assumes that external resources such as
JavaScript programs or style sheets are encoded in UTF-8 unless otherwise
specified. For example, the encoding of an external script can be specified
through the charset attribute of the HTML script tag. Alternatively, the
@@ -672,11 +645,6 @@ void QGraphicsWebView::setHtml(const QString& html, const QUrl& baseUrl)
page()->mainFrame()->setHtml(html, baseUrl);
}
-QString QGraphicsWebView::toHtml() const
-{
- return page()->mainFrame()->toHtml();
-}
-
/*!
Sets the content of the web graphicsitem to the specified content \a data. If the \a mimeType argument
is empty it is currently assumed that the content is HTML but in future versions we may introduce
@@ -706,22 +674,19 @@ QWebHistory* QGraphicsWebView::history() const
}
/*!
- \property QGraphicsWebView::interactive
- \brief controls whether the item responds to mouse and key events.
-*/
+ \property QGraphicsWebView::modified
+ \brief whether the document was modified by the user
-bool QGraphicsWebView::isInteractive() const
-{
- return d->interactive;
-}
+ Parts of HTML documents can be editable for example through the
+ \c{contenteditable} attribute on HTML elements.
-void QGraphicsWebView::setInteractive(bool allowed)
+ By default, this property is false.
+*/
+bool QGraphicsWebView::isModified() const
{
- if (d->interactive == allowed)
- return;
-
- d->interactive = allowed;
- emit interactivityChanged();
+ if (d->page)
+ return d->page->isModified();
+ return false;
}
/*!
@@ -738,11 +703,53 @@ QWebSettings* QGraphicsWebView::settings() const
return page()->settings();
}
+/*!
+ Returns a pointer to a QAction that encapsulates the specified web action \a action.
+*/
+QAction *QGraphicsWebView::pageAction(QWebPage::WebAction action) const
+{
+ return page()->action(action);
+}
+
+/*!
+ Triggers the specified \a action. If it is a checkable action the specified
+ \a checked state is assumed.
+
+ \sa pageAction()
+*/
+void QGraphicsWebView::triggerPageAction(QWebPage::WebAction action, bool checked)
+{
+ page()->triggerAction(action, checked);
+}
+
+/*!
+ Finds the specified string, \a subString, in the page, using the given \a options.
+
+ If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences
+ that exist in the page. All subsequent calls will extend the highlight, rather than
+ replace it, with occurrences of the new string.
+
+ If the HighlightAllOccurrences flag is not passed, the function will select an occurrence
+ and all subsequent calls will replace the current occurrence with the next one.
+
+ To clear the selection, just pass an empty string.
+
+ Returns true if \a subString was found; otherwise returns false.
+
+ \sa selectedText(), selectionChanged()
+*/
+bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags options)
+{
+ if (d->page)
+ return d->page->findText(subString, options);
+ return false;
+}
+
/*! \reimp
*/
void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev)
{
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
QMouseEvent me = QMouseEvent(QEvent::MouseMove,
ev->pos().toPoint(), Qt::NoButton,
@@ -766,7 +773,7 @@ void QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev)
*/
void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev)
{
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -780,7 +787,7 @@ void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev)
*/
void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev)
{
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -794,7 +801,7 @@ void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev)
*/
void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
{
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -808,7 +815,7 @@ void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
*/
void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
{
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -822,7 +829,7 @@ void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
*/
void QGraphicsWebView::keyPressEvent(QKeyEvent* ev)
{
- if (d->interactive && d->page)
+ if (d->page)
d->page->event(ev);
if (!ev->isAccepted())
@@ -833,7 +840,7 @@ void QGraphicsWebView::keyPressEvent(QKeyEvent* ev)
*/
void QGraphicsWebView::keyReleaseEvent(QKeyEvent* ev)
{
- if (d->interactive && d->page)
+ if (d->page)
d->page->event(ev);
if (!ev->isAccepted())
@@ -889,7 +896,7 @@ void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev)
void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev)
{
#ifndef QT_NO_DRAGANDDROP
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -907,7 +914,7 @@ void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev)
void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev)
{
#ifndef QT_NO_DRAGANDDROP
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -925,7 +932,7 @@ void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev)
void QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* ev)
{
#ifndef QT_NO_DRAGANDDROP
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -956,7 +963,7 @@ void QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev)
*/
void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev)
{
- if (d->interactive && d->page) {
+ if (d->page) {
const bool accepted = ev->isAccepted();
d->page->event(ev);
ev->setAccepted(accepted);
@@ -971,11 +978,20 @@ void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev)
*/
void QGraphicsWebView::inputMethodEvent(QInputMethodEvent* ev)
{
- if (d->interactive && d->page)
+ if (d->page)
d->page->event(ev);
if (!ev->isAccepted())
QGraphicsItem::inputMethodEvent(ev);
}
+/*!
+ \fn void QGraphicsWebView::linkClicked(const QUrl &url)
+
+ This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy
+ property is set to delegate the link handling for the specified \a url.
+
+ \sa QWebPage::linkDelegationPolicy()
+*/
+
#include "moc_qgraphicswebview.cpp"
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
index 43cf59a..f3afb4c 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h
@@ -21,6 +21,7 @@
#define QGraphicsWebView_h
#include "qwebkitglobal.h"
+#include "qwebpage.h"
#include <QtCore/qurl.h>
#include <QtGui/qevent.h>
#include <QtGui/qgraphicswidget.h>
@@ -39,17 +40,14 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget {
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
- Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
- Q_PROPERTY(QString status READ status NOTIFY statusChanged)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
- Q_PROPERTY(QString html READ toHtml WRITE setHtml)
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactivityChanged)
+ Q_PROPERTY(bool modified READ isModified)
public:
- QGraphicsWebView(QGraphicsItem* parent = 0);
+ explicit QGraphicsWebView(QGraphicsItem* parent = 0);
~QGraphicsWebView();
QWebPage* page() const;
@@ -64,15 +62,11 @@ public:
qreal zoomFactor() const;
void setZoomFactor(qreal);
- bool isInteractive() const;
- void setInteractive(bool);
-
- qreal progress() const;
+ bool isModified() const;
void load(const QUrl &url);
void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray());
- QString toHtml() const;
void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
// FIXME: Consider rename to setHtml?
void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());
@@ -80,7 +74,10 @@ public:
QWebHistory* history() const;
QWebSettings* settings() const;
- QString status() const;
+ QAction* pageAction(QWebPage::WebAction action) const;
+ void triggerPageAction(QWebPage::WebAction action, bool checked = false);
+
+ bool findText(const QString& subString, QWebPage::FindFlags options = 0);
virtual void setGeometry(const QRectF& rect);
virtual void updateGeometry();
@@ -88,6 +85,10 @@ public:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
virtual bool event(QEvent*);
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const;
+
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+
public Q_SLOTS:
void stop();
void back();
@@ -98,13 +99,12 @@ Q_SIGNALS:
void loadStarted();
void loadFinished(bool);
- void progressChanged(qreal);
- void interactivityChanged();
+ void loadProgress(int progress);
void urlChanged(const QUrl&);
void titleChanged(const QString&);
void iconChanged();
- void statusChanged();
- void zoomFactorChanged();
+ void statusBarMessage(const QString& message);
+ void linkClicked(const QUrl&);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
@@ -133,9 +133,7 @@ protected:
virtual bool sceneEvent(QEvent*);
private:
- Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress))
Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
- Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message))
QGraphicsWebViewPrivate* const d;
friend class QGraphicsWebViewPrivate;
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
index a18d262..9cb1ea1 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
@@ -177,6 +177,7 @@ public:
int count() const;
QWebElement at(int i) const;
+ inline QWebElement operator[](int i) const { return at(i); }
inline QWebElement first() const { return at(0); }
inline QWebElement last() const { return at(count() - 1); }
@@ -185,39 +186,69 @@ public:
class const_iterator {
public:
- int i;
- const QWebElementCollection *s;
-
- inline const_iterator(const QWebElementCollection *collection, int index) : i(index), s(collection) {}
- inline const_iterator(const const_iterator &o) : i(o.i), s(o.s) {}
+ inline const_iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {}
+ inline const_iterator(const const_iterator& o) : i(o.i), collection(o.collection) {}
- inline const QWebElement operator*() const { return s->at(i); }
+ inline const QWebElement operator*() const { return collection->at(i); }
- inline bool operator==(const const_iterator& o) const { return i == o.i && s == o.s; }
- inline bool operator!=(const const_iterator& o) const { return i != o.i || s != o.s; }
+ inline bool operator==(const const_iterator& o) const { return i == o.i && collection == o.collection; }
+ inline bool operator!=(const const_iterator& o) const { return i != o.i || collection != o.collection; }
inline bool operator<(const const_iterator& o) const { return i < o.i; }
inline bool operator<=(const const_iterator& o) const { return i <= o.i; }
inline bool operator>(const const_iterator& o) const { return i > o.i; }
inline bool operator>=(const const_iterator& o) const { return i >= o.i; }
- inline const_iterator &operator++() { ++i; return *this; }
- inline const_iterator operator++(int) { const_iterator n(s, i); ++i; return n; }
- inline const_iterator &operator--() { i--; return *this; }
- inline const_iterator operator--(int) { const_iterator n(s, i); i--; return n; }
- inline const_iterator &operator+=(int j) { i += j; return *this; }
- inline const_iterator &operator-=(int j) { i -= j; return *this; }
- inline const_iterator operator+(int j) const { return const_iterator(s, i + j); }
- inline const_iterator operator-(int j) const { return const_iterator(s, i - j); }
+ inline const_iterator& operator++() { ++i; return *this; }
+ inline const_iterator operator++(int) { const_iterator n(collection, i); ++i; return n; }
+ inline const_iterator& operator--() { i--; return *this; }
+ inline const_iterator operator--(int) { const_iterator n(collection, i); i--; return n; }
+ inline const_iterator& operator+=(int j) { i += j; return *this; }
+ inline const_iterator& operator-=(int j) { i -= j; return *this; }
+ inline const_iterator operator+(int j) const { return const_iterator(collection, i + j); }
+ inline const_iterator operator-(int j) const { return const_iterator(collection, i - j); }
inline int operator-(const_iterator j) const { return i - j.i; }
private:
- inline const_iterator() : i(0), s(0) {}
+ int i;
+ const QWebElementCollection* const collection;
};
friend class const_iterator;
- inline const_iterator begin() const { return const_iterator(this, 0); }
- inline const_iterator end() const { return const_iterator(this, count()); }
- inline QWebElement operator[](int i) const { return at(i); }
+ inline const_iterator begin() const { return constBegin(); }
+ inline const_iterator end() const { return constEnd(); }
+ inline const_iterator constBegin() const { return const_iterator(this, 0); }
+ inline const_iterator constEnd() const { return const_iterator(this, count()); };
+
+ class iterator {
+ public:
+ inline iterator(const QWebElementCollection* collection, int index) : i(index), collection(collection) {}
+ inline iterator(const iterator& o) : i(o.i), collection(o.collection) {}
+
+ inline QWebElement operator*() const { return collection->at(i); }
+
+ inline bool operator==(const iterator& o) const { return i == o.i && collection == o.collection; }
+ inline bool operator!=(const iterator& o) const { return i != o.i || collection != o.collection; }
+ inline bool operator<(const iterator& o) const { return i < o.i; }
+ inline bool operator<=(const iterator& o) const { return i <= o.i; }
+ inline bool operator>(const iterator& o) const { return i > o.i; }
+ inline bool operator>=(const iterator& o) const { return i >= o.i; }
+
+ inline iterator& operator++() { ++i; return *this; }
+ inline iterator operator++(int) { iterator n(collection, i); ++i; return n; }
+ inline iterator& operator--() { i--; return *this; }
+ inline iterator operator--(int) { iterator n(collection, i); i--; return n; }
+ inline iterator& operator+=(int j) { i += j; return *this; }
+ inline iterator& operator-=(int j) { i -= j; return *this; }
+ inline iterator operator+(int j) const { return iterator(collection, i + j); }
+ inline iterator operator-(int j) const { return iterator(collection, i - j); }
+ inline int operator-(iterator j) const { return i - j.i; }
+ private:
+ int i;
+ const QWebElementCollection* const collection;
+ };
+ friend class iterator;
+ inline iterator begin() { return iterator(this, 0); }
+ inline iterator end() { return iterator(this, count()); }
private:
QExplicitlySharedDataPointer<QWebElementCollectionPrivate> d;
};
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
index 409e1a0..f43cbbf 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
@@ -50,6 +50,7 @@
\section1 Resources
+ This class acts mostly as a container and a controller for the inspector.
Most of the resources needed by the inspector are owned by the associated
QWebPage and are allocated the first time that:
\list
@@ -57,11 +58,6 @@
\o the QWebInspector is shown.
\endlist
- This class acts mostly as a container and a controller for the inspector.
- You can defer the creation and association of the QWebInspector until
- the first emission of QWebPage::webInspectorTriggered() to save additional
- resources.
-
\section1 Inspector configuration persistence
The inspector allows the user to configure some options through its
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index a1e131a..d4a491b 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -1471,8 +1471,6 @@ QWebInspector* QWebPagePrivate::getOrCreateInspector()
if (!inspector) {
QWebInspector* insp = new QWebInspector;
insp->setPage(q);
- insp->connect(q, SIGNAL(webInspectorTriggered(const QWebElement&)), SLOT(show()));
- insp->show(); // The inspector is expected to be shown on inspection
inspectorIsInternalOnly = true;
Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q)
@@ -2018,11 +2016,9 @@ void QWebPage::triggerAction(WebAction action, bool)
editor->setBaseWritingDirection(RightToLeftWritingDirection);
break;
case InspectElement: {
- QWebElement inspectedElement(QWebElement::enclosingElement(d->hitTestResult.d->innerNonSharedNode.get()));
- emit webInspectorTriggered(inspectedElement);
-
if (!d->hitTestResult.isNull()) {
d->getOrCreateInspector(); // Make sure the inspector is created
+ d->inspector->show(); // The inspector is expected to be shown on inspection
d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get());
}
break;
@@ -3440,24 +3436,6 @@ quint64 QWebPage::bytesReceived() const
*/
/*!
- \fn void QWebPage::webInspectorTriggered(const QWebElement& inspectedElement);
- \since 4.6
-
- This signal is emitted when the user triggered an inspection through the
- context menu. If a QWebInspector is associated to this page, it should be
- visible to the user after this signal has been emitted.
-
- If still no QWebInspector is associated to this QWebPage after the emission
- of this signal, a privately owned inspector will be shown to the user.
-
- \note \a inspectedElement contains the QWebElement under the context menu.
- It is not garanteed to be the same as the focused element in the web
- inspector.
-
- \sa QWebInspector
-*/
-
-/*!
\fn void QWebPage::toolBarVisibilityChangeRequested(bool visible)
This signal is emitted whenever the visibility of the toolbar in a web browser
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h
index f39209c..8c455b1 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h
@@ -329,7 +329,6 @@ Q_SIGNALS:
void windowCloseRequested();
void printRequested(QWebFrame *frame);
void linkClicked(const QUrl &url);
- void webInspectorTriggered(const QWebElement& inspectedElement);
void toolBarVisibilityChangeRequested(bool visible);
void statusBarVisibilityChangeRequested(bool visible);
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp
index 3052056..ff86e1f 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp
@@ -206,10 +206,6 @@ void QWebSettingsPrivate::apply()
value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls,
global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls));
settings->setAllowUniversalAccessFromFileURLs(value);
-
- value = attributes.value(QWebSettings::SessionStorageEnabled,
- global->attributes.value(QWebSettings::SessionStorageEnabled));
- settings->setSessionStorageEnabled(value);
} else {
QList<QWebSettingsPrivate*> settings = *::allSettings();
for (int i = 0; i < settings.count(); ++i)
@@ -351,8 +347,6 @@ QWebSettings* QWebSettings::globalSettings()
\value LocalStorageEnabled Specifies whether support for the HTML 5
local storage feature is enabled or not. Disabled by default.
\value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls.
- \value SessionStorageEnabled Specifies whether support for the HTML 5
- session storage feature is enabled or not. Enabled by default.
*/
/*!
@@ -383,7 +377,6 @@ QWebSettings::QWebSettings()
d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false);
d->attributes.insert(QWebSettings::LocalStorageEnabled, false);
d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false);
- d->attributes.insert(QWebSettings::SessionStorageEnabled, true);
d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
d->defaultTextEncoding = QLatin1String("iso-8859-1");
d->printingMinimumShrinkFactor = 0.0f;
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h
index c958ae7..3b6d1a7 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h
@@ -67,7 +67,6 @@ public:
LocalStorageDatabaseEnabled = LocalStorageEnabled,
#endif
LocalContentCanAccessRemoteUrls,
- SessionStorageEnabled,
DnsPrefetchEnabled
};
enum WebGraphic {
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index 84c5d43..296e06c 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,255 @@
+2009-11-09 Benjamin Poulain <benjamin.poulain@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ https://bugs.webkit.org/show_bug.cgi?id=30772
+ Add a non-const iterator to QWebElementCollection.
+ Move the two attributes of the iterator to private.
+
+ * Api/qwebelement.h:
+ (const_iterator::begin):
+ (const_iterator::end):
+ (const_iterator::constBegin):
+ (const_iterator::constEnd):
+ (const_iterator::iterator::iterator):
+ (const_iterator::iterator::operator*):
+ (const_iterator::iterator::operator==):
+ (const_iterator::iterator::operator!=):
+ (const_iterator::iterator::operator<):
+ (const_iterator::iterator::operator<=):
+ (const_iterator::iterator::operator>):
+ (const_iterator::iterator::operator>=):
+ (const_iterator::iterator::operator++):
+ (const_iterator::iterator::operator--):
+ (const_iterator::iterator::operator+=):
+ (const_iterator::iterator::operator-=):
+ (const_iterator::iterator::operator+):
+ (const_iterator::iterator::operator-):
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::nonConstIterator):
+ (tst_QWebElement::constIterator):
+
+2009-11-09 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Kenneth Christiansen.
+
+ [Qt] Remove the sessionStorage setting (per Page)
+ https://bugs.webkit.org/show_bug.cgi?id=31249
+
+ This setting allows to run sessionStorage on/off on a per page
+ basis. Remove this prematurely exposed API.
+
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+ (QWebSettings::QWebSettings):
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::database):
+ (tst_QWebPage::testOptionalJSObjects):
+
+2009-11-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Remove the QWebPage:webInspectorTriggered signal.
+ User customization of the communication between QWebPage
+ and QWebInspector will be properly designed in the next version.
+ https://bugs.webkit.org/show_bug.cgi?id=30773
+
+ * Api/qwebinspector.cpp:
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::getOrCreateInspector):
+ (QWebPage::triggerAction):
+ * Api/qwebpage.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2009-11-05 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Added a missing re-implementation of QGraphicsItem::inputMethodQuery().
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebView::inputMethodQuery):
+ * Api/qgraphicswebview.h:
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Provide a dummy re-implementation of QGraphicsLayoutItem::sizeHint(),
+ similar to QWebView.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebView::sizeHint):
+ * Api/qgraphicswebview.h:
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Removed zoomFactoryChanged() signal and added
+ linkClicked() to QGraphicsWebView, for consistency with
+ QWebView.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebView::setPage):
+ (QGraphicsWebView::setZoomFactor):
+ * Api/qgraphicswebview.h:
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Added QGraphicsWebView::findText() for convenience and consistency
+ with QWebView.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebView::findText):
+ * Api/qgraphicswebview.h:
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Added QGraphicsWebView::pageAction() and triggerPageAction(), for
+ consistency with QWebView.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebView::pageAction):
+ (QGraphicsWebView::triggerPageAction):
+ * Api/qgraphicswebview.h:
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Removed QGraphicsWebView::toHtml() after API review.
+
+ That's consistent with QWebView and also based on the assumption that
+ toHtml() is called less frequently than setHtml().
+
+ * Api/qgraphicswebview.cpp:
+ * Api/qgraphicswebview.h:
+ * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+ (tst_QGraphicsWebView::qgraphicswebview):
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Removed the interactive property of QGraphicsWebView.
+
+ There are clearly use-cases for this feature, but it will require
+ more work to make this fully work with an enum to have fine-grained
+ control over the interactivity levels. For now it is easy to achieve
+ in user-code what the boolean property did.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
+ (QGraphicsWebView::hoverMoveEvent):
+ (QGraphicsWebView::mouseMoveEvent):
+ (QGraphicsWebView::mousePressEvent):
+ (QGraphicsWebView::mouseReleaseEvent):
+ (QGraphicsWebView::mouseDoubleClickEvent):
+ (QGraphicsWebView::keyPressEvent):
+ (QGraphicsWebView::keyReleaseEvent):
+ (QGraphicsWebView::dragLeaveEvent):
+ (QGraphicsWebView::dragMoveEvent):
+ (QGraphicsWebView::dropEvent):
+ (QGraphicsWebView::wheelEvent):
+ (QGraphicsWebView::inputMethodEvent):
+ * Api/qgraphicswebview.h:
+ * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+ (tst_QGraphicsWebView::qgraphicswebview):
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Make the QGraphicsWebView constructor explicit.
+
+ * Api/qgraphicswebview.h:
+
+2009-11-05 Simon Hausmann <hausmann@webkit.org>
+
+ Last Qt 4.5 build fix (*sigh*)
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (inputMethodHints): inputMethodHints() is only used for
+ Qt 4.6, so guard the whole function.
+
+2009-11-05 Simon Hausmann <hausmann@webkit.org>
+
+ Another prospective build fix against Qt 4.5 (build bot)
+
+ Don't compile & run the QGraphicsWebView portion of the
+ input methods auto test with Qt 4.5.
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::inputMethods_data):
+ (inputMethodHints):
+ (inputMethodEnabled):
+ (tst_QWebPage::inputMethods):
+
+2009-11-05 Simon Hausmann <hausmann@webkit.org>
+
+ Prospective build fix against Qt 4.5 (build bot)
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebViewPrivate::setInputMethodEnabled): Guard the
+ use of Qt 4.6 specific API with #ifdefs.
+
+2009-11-01 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Kenneth Christiansen.
+
+ [Qt] Fix enabling of input method support on QGraphicsWebView.
+ https://bugs.webkit.org/show_bug.cgi?id=30605
+
+ Instead of setting the unsupported widget attribute on the
+ QGraphicsWidget in setInputMethodEnabled() set the
+ ItemAcceptsInputMethod GraphicsItem flag directly.
+
+ Changed the existing input method auto test to run once
+ on a QWebView and once on a QGraphicsWebView.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebViewPrivate::setInputMethodEnabled):
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::inputMethods_data):
+ (inputMethodHints):
+ (inputMethodEnabled):
+ (tst_QWebPage::inputMethods):
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Kenneth Christiansen.
+
+ Added QGraphicsWebView::modified property, for consistency
+ with QWebView.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebView::isModified):
+ * Api/qgraphicswebview.h:
+ * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+ (tst_QGraphicsWebView::qgraphicswebview):
+
+2009-11-04 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Kenneth Christiansen.
+
+ Removed status and progress properties of QGraphicsWebView.
+ Added loadProgress and statusBarMessage signals instead,
+ after API review.
+
+ * Api/qgraphicswebview.cpp:
+ (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
+ (QGraphicsWebView::setPage):
+ * Api/qgraphicswebview.h:
+ * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+ (tst_QGraphicsWebView::qgraphicswebview):
+
2009-11-04 Yael Aharon <yael.aharon@nokia.com>
Reviewed by Simon Hausmann.
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
index 4bdb7f5..a52e167 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
@@ -63,21 +63,17 @@ void tst_QGraphicsWebView::qgraphicswebview()
item.title();
item.icon();
item.zoomFactor();
- item.isInteractive();
- item.progress();
- item.toHtml();
item.history();
item.settings();
- item.status();
item.page();
item.setPage(0);
item.page();
item.setUrl(QUrl());
item.setZoomFactor(0);
- item.setInteractive(true);
item.load(QUrl());
item.setHtml(QString());
item.setContent(QByteArray());
+ item.isModified();
}
class WebPage : public QWebPage
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
index cf83fe8..117393a 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -71,6 +71,8 @@ private slots:
void classes();
void namespaceURI();
void iteration();
+ void nonConstIterator();
+ void constIterator();
void foreachManipulation();
void emptyCollection();
void appendCollection();
@@ -305,6 +307,37 @@ void tst_QWebElement::iteration()
QCOMPARE(paras.at(1), paras.last());
}
+void tst_QWebElement::nonConstIterator()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+ QWebElementCollection paras = body.findAll("p");
+
+ QWebElementCollection::iterator it = paras.begin();
+ QCOMPARE(*it, paras.at(0));
+ ++it;
+ (*it).encloseWith("<div>");
+ QCOMPARE(*it, paras.at(1));
+ ++it;
+ QCOMPARE(it, paras.end());
+}
+
+void tst_QWebElement::constIterator()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+ const QWebElementCollection paras = body.findAll("p");
+
+ QWebElementCollection::const_iterator it = paras.begin();
+ QCOMPARE(*it, paras.at(0));
+ ++it;
+ QCOMPARE(*it, paras.at(1));
+ ++it;
+ QCOMPARE(it, paras.end());
+}
+
void tst_QWebElement::foreachManipulation()
{
QString html = "<body><p>first para</p><p>second para</p></body>";
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 3eead92..93a1784 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -21,6 +21,9 @@
#include <QtTest/QtTest>
+#include <qgraphicsscene.h>
+#include <qgraphicsview.h>
+#include <qgraphicswebview.h>
#include <qwebelement.h>
#include <qwebpage.h>
#include <qwidget.h>
@@ -124,6 +127,7 @@ private slots:
void testOptionalJSObjects();
void testEnablePersistentStorage();
void consoleOutput();
+ void inputMethods_data();
void inputMethods();
void defaultTextEncoding();
void errorPageExtension();
@@ -456,7 +460,6 @@ void tst_QWebPage::database()
QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024);
m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
- m_page->settings()->setAttribute(QWebSettings::SessionStorageEnabled, true);
m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
QString dbFileName = path + "Databases.db";
@@ -1268,28 +1271,87 @@ void tst_QWebPage::frameAt()
frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos());
}
+void tst_QWebPage::inputMethods_data()
+{
+ QTest::addColumn<QString>("viewType");
+ QTest::newRow("QWebView") << "QWebView";
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QTest::newRow("QGraphicsWebView") << "QGraphicsWebView";
+#endif
+}
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+static Qt::InputMethodHints inputMethodHints(QObject* object)
+{
+ if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object))
+ return o->inputMethodHints();
+ if (QWidget* w = qobject_cast<QWidget*>(object))
+ return w->inputMethodHints();
+ return Qt::InputMethodHints();
+}
+#endif
+
+static bool inputMethodEnabled(QObject* object)
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object))
+ return o->flags() & QGraphicsItem::ItemAcceptsInputMethod;
+#endif
+ if (QWidget* w = qobject_cast<QWidget*>(object))
+ return w->testAttribute(Qt::WA_InputMethodEnabled);
+ return false;
+}
+
void tst_QWebPage::inputMethods()
{
- m_view->page()->mainFrame()->setHtml("<html><body>" \
+ QFETCH(QString, viewType);
+ QWebPage* page = new QWebPage;
+ QObject* view = 0;
+ QObject* container = 0;
+ if (viewType == "QWebView") {
+ QWebView* wv = new QWebView;
+ wv->setPage(page);
+ view = wv;
+ container = view;
+ }
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ else if (viewType == "QGraphicsWebView") {
+ QGraphicsWebView* wv = new QGraphicsWebView;
+ wv->setPage(page);
+ view = wv;
+
+ QGraphicsView* gv = new QGraphicsView;
+ QGraphicsScene* scene = new QGraphicsScene(gv);
+ gv->setScene(scene);
+ scene->addItem(wv);
+ wv->setGeometry(QRect(0, 0, 500, 500));
+
+ container = gv;
+ }
+#endif
+ else
+ QVERIFY2(false, "Unknown view type");
+
+ page->mainFrame()->setHtml("<html><body>" \
"<input type='text' id='input1' style='font-family: serif' value='' maxlength='20'/><br>" \
"<input type='password'/>" \
"</body></html>");
- m_view->page()->mainFrame()->setFocus();
+ page->mainFrame()->setFocus();
- QWebElementCollection inputs = m_view->page()->mainFrame()->documentElement().findAll("input");
+ QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input");
QMouseEvent evpres(QEvent::MouseButtonPress, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evpres);
+ page->event(&evpres);
QMouseEvent evrel(QEvent::MouseButtonRelease, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evrel);
+ page->event(&evrel);
//ImMicroFocus
- QVariant variant = m_view->page()->inputMethodQuery(Qt::ImMicroFocus);
+ QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus);
QRect focusRect = variant.toRect();
QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft()));
//ImFont
- variant = m_view->page()->inputMethodQuery(Qt::ImFont);
+ variant = page->inputMethodQuery(Qt::ImFont);
QFont font = variant.value<QFont>();
QCOMPARE(QString("-webkit-serif"), font.family());
@@ -1298,45 +1360,45 @@ void tst_QWebPage::inputMethods()
//Insert text.
{
QInputMethodEvent eventText("QtWebKit", inputAttributes);
- QSignalSpy signalSpy(m_view->page(), SIGNAL(microFocusChanged()));
- m_view->page()->event(&eventText);
+ QSignalSpy signalSpy(page, SIGNAL(microFocusChanged()));
+ page->event(&eventText);
QCOMPARE(signalSpy.count(), 0);
}
{
QInputMethodEvent eventText("", inputAttributes);
eventText.setCommitString(QString("QtWebKit"), 0, 0);
- m_view->page()->event(&eventText);
+ page->event(&eventText);
}
#if QT_VERSION >= 0x040600
//ImMaximumTextLength
- variant = m_view->page()->inputMethodQuery(Qt::ImMaximumTextLength);
+ variant = page->inputMethodQuery(Qt::ImMaximumTextLength);
QCOMPARE(20, variant.toInt());
//Set selection
inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant());
QInputMethodEvent eventSelection("",inputAttributes);
- m_view->page()->event(&eventSelection);
+ page->event(&eventSelection);
//ImAnchorPosition
- variant = m_view->page()->inputMethodQuery(Qt::ImAnchorPosition);
+ variant = page->inputMethodQuery(Qt::ImAnchorPosition);
int anchorPosition = variant.toInt();
QCOMPARE(anchorPosition, 3);
//ImCursorPosition
- variant = m_view->page()->inputMethodQuery(Qt::ImCursorPosition);
+ variant = page->inputMethodQuery(Qt::ImCursorPosition);
int cursorPosition = variant.toInt();
QCOMPARE(cursorPosition, 5);
//ImCurrentSelection
- variant = m_view->page()->inputMethodQuery(Qt::ImCurrentSelection);
+ variant = page->inputMethodQuery(Qt::ImCurrentSelection);
QString selectionValue = variant.value<QString>();
QCOMPARE(selectionValue, QString("eb"));
#endif
//ImSurroundingText
- variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText);
+ variant = page->inputMethodQuery(Qt::ImSurroundingText);
QString value = variant.value<QString>();
QCOMPARE(value, QString("QtWebKit"));
@@ -1347,29 +1409,31 @@ void tst_QWebPage::inputMethods()
QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant());
attributes.append(newSelection);
QInputMethodEvent event("composition", attributes);
- m_view->page()->event(&event);
+ page->event(&event);
}
// A ongoing composition should not change the surrounding text before it is committed.
- variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText);
+ variant = page->inputMethodQuery(Qt::ImSurroundingText);
value = variant.value<QString>();
QCOMPARE(value, QString("QtWebKit"));
#endif
//ImhHiddenText
QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evpresPassword);
+ page->event(&evpresPassword);
QMouseEvent evrelPassword(QEvent::MouseButtonRelease, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evrelPassword);
+ page->event(&evrelPassword);
- QVERIFY(m_view->testAttribute(Qt::WA_InputMethodEnabled));
+ QVERIFY(inputMethodEnabled(view));
#if QT_VERSION >= 0x040600
- QVERIFY(m_view->inputMethodHints() & Qt::ImhHiddenText);
+ QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText);
- m_view->page()->event(&evpres);
- m_view->page()->event(&evrel);
- QVERIFY(!(m_view->inputMethodHints() & Qt::ImhHiddenText));
+ page->event(&evpres);
+ page->event(&evrel);
+ QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText));
#endif
+
+ delete container;
}
// import a little DRT helper function to trigger the garbage collector
@@ -1444,11 +1508,6 @@ void tst_QWebPage::testOptionalJSObjects()
QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true), true);
QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false);
QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true);
-
- QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false);
- QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", true), true);
- QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false);
- QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", false), true);
}
void tst_QWebPage::testEnablePersistentStorage()
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index d376dc7..9ab831f 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -76,17 +76,6 @@ QT_BEGIN_NAMESPACE
# endif
#endif
-#ifdef Q_OS_SYMBIAN
- // Using default 4k block in symbian is highly inefficient due to
- // the fact that each file operation requires slow IPC calls, so
- // use somewhat larger block size.
-# define FDFH_BLOCK_SIZE 16384
-#else
- // Read/write in blocks of 4k to avoid platform limitations (Windows
- // commonly bails out if you read or write too large blocks at once).
-# define FDFH_BLOCK_SIZE 4096
-#endif
-
/*! \class QFSFileEngine
\brief The QFSFileEngine class implements Qt's default file engine.
\since 4.1
@@ -633,67 +622,55 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
{
Q_Q(QFSFileEngine);
- // Buffered stdlib mode.
+ if (len < 0 || len != qint64(size_t(len))) {
+ q->setError(QFile::ReadError, qt_error_string(EINVAL));
+ return -1;
+ }
+
+ qint64 readBytes = 0;
+ bool eof = false;
+
if (fh) {
- qint64 readBytes = 0;
- qint64 read = 0;
- int retry = 0;
+ // Buffered stdlib mode.
- qint64 bytesToRead;
+ size_t result;
+ bool retry = true;
do {
- if (retry == 1)
- retry = 2;
-
- bytesToRead = qMin<qint64>(FDFH_BLOCK_SIZE, len - read);
- do {
- readBytes = fread(data + read, 1, size_t(bytesToRead), fh);
- } while (readBytes == 0 && !feof(fh) && errno == EINTR);
-
- if (readBytes > 0) {
- read += readBytes;
- } else if (!retry && feof(fh)) {
- // Synchronize and try again (just once though).
- if (++retry == 1)
- QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET);
+ result = fread(data + readBytes, 1, size_t(len - readBytes), fh);
+ eof = feof(fh);
+ if (retry && eof && result == 0) {
+ // On Mac OS, this is needed, e.g., if a file was written to
+ // through another stream since our last read. See test
+ // tst_QFile::appendAndRead
+ QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); // re-sync stream.
+ retry = false;
+ continue;
}
- } while (retry == 1 || (readBytes == bytesToRead && read < len));
+ readBytes += result;
+ } while (!eof && (result == 0 ? errno == EINTR : readBytes < len));
- // Return the number of bytes read, or if nothing was read, return -1
- // if an error occurred, or 0 if we detected EOF.
- if (read == 0) {
- q->setError(QFile::ReadError, qt_error_string(int(errno)));
- if (!feof(fh))
- read = -1;
- }
- return read;
- }
+ } else if (fd != -1) {
+ // Unbuffered stdio mode.
- // Unbuffered stdio mode.
- qint64 ret = 0;
- if (len) {
+#ifdef Q_OS_WIN
int result;
- qint64 read = 0;
- errno = 0;
-
+#else
+ ssize_t result;
+#endif
do {
- qint64 bytesToRead = qMin<qint64>(FDFH_BLOCK_SIZE, len - read);
- do {
- result = QT_READ(fd, data + read, int(bytesToRead));
- } while (result == -1 && errno == EINTR);
- if (result > 0)
- read += result;
- } while (result > 0 && read < len);
-
- // Return the number of bytes read, or if nothing was read, return -1
- // if an error occurred.
- if (read > 0) {
- ret += read;
- } else if (read == 0 && result < 0) {
- ret = -1;
- q->setError(QFile::ReadError, qt_error_string(errno));
- }
+ result = QT_READ(fd, data + readBytes, size_t(len - readBytes));
+ } while ((result == -1 && errno == EINTR)
+ || (result > 0 && (readBytes += result) < len));
+
+ eof = !(result == -1);
}
- return ret;
+
+ if (!eof && readBytes == 0) {
+ readBytes = -1;
+ q->setError(QFile::ReadError, qt_error_string(errno));
+ }
+
+ return readBytes;
}
/*!
@@ -773,34 +750,45 @@ qint64 QFSFileEngine::write(const char *data, qint64 len)
qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len)
{
Q_Q(QFSFileEngine);
- qint64 result;
- qint64 written = 0;
- do {
- qint64 bytesToWrite = qMin<qint64>(FDFH_BLOCK_SIZE, len - written);
- if (fh) {
- do {
- // Buffered stdlib mode.
- result = qint64(fwrite(data + written, 1, size_t(bytesToWrite), fh));
- } while (result == 0 && errno == EINTR);
- if (bytesToWrite > 0 && result == 0)
- result = -1;
- } else {
- do {
- // Unbuffered stdio mode.
- result = QT_WRITE(fd, data + written, bytesToWrite);
- } while (result == -1 && errno == EINTR);
- }
- if (result > 0)
- written += qint64(result);
- } while (written < len && result > 0);
-
- // If we read anything, return that with success. Otherwise, set an error,
- // and return the last return value.
- if (result > 0)
- return written;
- q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno));
- return result;
+ if (len < 0 || len != qint64(size_t(len))) {
+ q->setError(QFile::WriteError, qt_error_string(EINVAL));
+ return -1;
+ }
+
+ qint64 writtenBytes = 0;
+
+ if (fh) {
+ // Buffered stdlib mode.
+
+ size_t result;
+ bool eof;
+ do {
+ result = fwrite(data + writtenBytes, 1, size_t(len - writtenBytes), fh);
+ writtenBytes += result;
+ eof = feof(fh);
+ } while (!eof && (result == 0 ? errno == EINTR : writtenBytes < len));
+
+ } else if (fd != -1) {
+ // Unbuffered stdio mode.
+
+#ifdef Q_OS_WIN
+ int result;
+#else
+ ssize_t result;
+#endif
+ do {
+ result = QT_WRITE(fd, data + writtenBytes, size_t(len - writtenBytes));
+ } while ((result == -1 && errno == EINTR)
+ || (result > 0 && (writtenBytes += result) < len));
+ }
+
+ if (writtenBytes == 0) {
+ writtenBytes = -1;
+ q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno));
+ }
+
+ return writtenBytes;
}
/*!
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 1f23211..3ca8ab9 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1083,7 +1083,7 @@ public:
bool isValid() const { return valid; }
const QString &errorString() const { return yyError; }
- int numCaptures() const { return officialncap; }
+ int captureCount() const { return officialncap; }
int createState(QChar ch);
int createState(const QRegExpCharClass &cc);
@@ -1378,7 +1378,7 @@ void QRegExpMatchState::prepareForMatch(QRegExpEngine *eng)
#else
int newSlideTabSize = 0;
#endif
- int numCaptures = eng->numCaptures();
+ int numCaptures = eng->captureCount();
int newCapturedSize = 2 + 2 * numCaptures;
bigArray = q_check_ptr((int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int)));
@@ -4168,12 +4168,24 @@ int QRegExp::matchedLength() const
#ifndef QT_NO_REGEXP_CAPTURE
/*!
+ \obsolete
Returns the number of captures contained in the regular expression.
+
+ \sa captureCount()
*/
int QRegExp::numCaptures() const
{
+ return captureCount();
+}
+
+/*!
+ \since 4.6
+ Returns the number of captures contained in the regular expression.
+ */
+int QRegExp::captureCount() const
+{
prepareEngine(priv);
- return priv->eng->numCaptures();
+ return priv->eng->captureCount();
}
/*!
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 1a7cf53..2bad40e 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -119,7 +119,8 @@ public:
#endif
int matchedLength() const;
#ifndef QT_NO_REGEXP_CAPTURE
- int numCaptures() const;
+ QT_DEPRECATED int numCaptures() const;
+ int captureCount() const;
QStringList capturedTexts() const;
QStringList capturedTexts();
QString cap(int nth = 0) const;
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 2dedcc5..c40b3cf 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -113,16 +113,6 @@ public:
return d;
}
- inline bool operator==(const QScopedPointer<T, Cleanup> &other) const
- {
- return d == other.d;
- }
-
- inline bool operator!=(const QScopedPointer<T, Cleanup> &other) const
- {
- return d != other.d;
- }
-
inline bool operator!() const
{
return !d;
@@ -181,6 +171,18 @@ private:
};
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+{
+ return lhs.data() == rhs.data();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+{
+ return lhs.data() != rhs.data();
+}
+
+template <class T, class Cleanup>
Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2)
{ p1.swap(p2); }
@@ -203,16 +205,6 @@ public:
return this->d[i];
}
- inline bool operator==(const QScopedArrayPointer<T, Cleanup> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QScopedArrayPointer<T, Cleanup> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QScopedArrayPointer)
};
diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h
index fb627a4..b1636d5 100644
--- a/src/corelib/tools/qscopedpointer_p.h
+++ b/src/corelib/tools/qscopedpointer_p.h
@@ -76,16 +76,6 @@ public:
return this->d;
}
- inline bool operator==(const QCustomScopedPointer<T, Cleanup> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QCustomScopedPointer<T, Cleanup> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QCustomScopedPointer)
};
@@ -130,16 +120,6 @@ public:
QScopedPointerSharedDeleter<T>::cleanup(oldD);
}
- inline bool operator==(const QScopedSharedPointer<T> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QScopedSharedPointer<T> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QScopedSharedPointer)
};
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 1bca983..3b358a2 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -2681,7 +2681,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
realloc();
int index = 0;
- int numCaptures = rx2.numCaptures();
+ int numCaptures = rx2.captureCount();
int al = after.length();
QRegExp::CaretMode caretMode = QRegExp::CaretAtZero;
diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp
index 4cb0c93..1f0b51d 100644
--- a/src/gui/dialogs/qprintpreviewdialog.cpp
+++ b/src/gui/dialogs/qprintpreviewdialog.cpp
@@ -446,7 +446,7 @@ void QPrintPreviewDialogPrivate::setFitting(bool on)
void QPrintPreviewDialogPrivate::updateNavActions()
{
int curPage = preview->currentPage();
- int numPages = preview->numPages();
+ int numPages = preview->pageCount();
nextPageAction->setEnabled(curPage < numPages);
prevPageAction->setEnabled(curPage > 1);
firstPageAction->setEnabled(curPage > 1);
@@ -458,7 +458,7 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel()
{
Q_Q(QPrintPreviewDialog);
- int numPages = preview->numPages();
+ int numPages = preview->pageCount();
int maxChars = QString::number(numPages).length();
pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars));
@@ -515,7 +515,7 @@ void QPrintPreviewDialogPrivate::_q_navigate(QAction* action)
else if (action == firstPageAction)
preview->setCurrentPage(1);
else if (action == lastPageAction)
- preview->setCurrentPage(preview->numPages());
+ preview->setCurrentPage(preview->pageCount());
updateNavActions();
}
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 568ff73..13f42c5 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -76,24 +76,21 @@
To create your own custom effect, create a subclass of QGraphicsEffect (or
any other existing effects) and reimplement the virtual function draw().
This function is called whenever the effect needs to redraw. The draw()
- function accepts two arguments: the painter and a pointer to the source
- (QGraphicsEffectSource). The source provides extra context information,
- such as a pointer to the item that is rendering the effect, any cached
- pixmap data, or the device rectangle bounds. For more information, refer to
- the documenation for draw(). To obtain a pointer to the current source,
- simply call source().
+ function takes the painter with which to draw as an argument. For more
+ information, refer to the documenation for draw(). In the draw() function
+ you can call sourcePixmap() to get a pixmap of the graphics effect source
+ which you can then process.
If your effect changes, use update() to request for a redraw. If your
custom effect changes the bounding rectangle of the source, e.g., a radial
glow effect may need to apply an extra margin, you can reimplement the
- virtual boundingRectFor() function, and call updateBoundingRect() to notify
- the framework whenever this rectangle changes. The virtual
- sourceBoundingRectChanged() function is called to notify the effects that
- the source's bounding rectangle has changed - e.g., if the source is a
+ virtual boundingRectFor() function, and call updateBoundingRect()
+ to notify the framework whenever this rectangle changes. The virtual
+ sourceChanged() function is called to notify the effects that
+ the source has changed in some way - e.g., if the source is a
QGraphicsRectItem and its rectangle parameters have changed.
- \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect(),
- QGraphicsEffectSource
+ \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect()
*/
#include "qgraphicseffect_p.h"
@@ -112,10 +109,10 @@
QT_BEGIN_NAMESPACE
/*!
+ \internal
\class QGraphicsEffectSource
\brief The QGraphicsEffectSource class represents the source on which a
QGraphicsEffect is installed on.
- \since 4.6
When a QGraphicsEffect is installed on a QGraphicsItem, for example, this
class will act as a wrapper around QGraphicsItem. Then, calling update() is
@@ -154,20 +151,13 @@ QGraphicsEffectSource::~QGraphicsEffectSource()
{}
/*!
- Returns the bounds of the current painter's device.
-
- This function is useful when you want to draw something in device
- coordinates and ensure the size of the pixmap is not bigger than the size
- of the device.
-
- Calling QGraphicsEffectSource::pixmap(Qt::DeviceCoordinates) always returns
- a pixmap which is bound to the device's size.
+ Returns the bounding rectangle of the source mapped to the given \a system.
- \sa pixmap()
+ \sa draw()
*/
-QRect QGraphicsEffectSource::deviceRect() const
+QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const
{
- return d_func()->deviceRect();
+ return d_func()->boundingRect(system);
}
/*!
@@ -175,9 +165,12 @@ QRect QGraphicsEffectSource::deviceRect() const
\sa draw()
*/
-QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const
+QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const
{
- return d_func()->boundingRect(system);
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ return d->source->boundingRect(system);
+ return QRectF();
}
/*!
@@ -218,10 +211,6 @@ const QStyleOption *QGraphicsEffectSource::styleOption() const
This function should only be called from QGraphicsEffect::draw().
- For example:
-
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0
-
\sa QGraphicsEffect::draw()
*/
void QGraphicsEffectSource::draw(QPainter *painter)
@@ -246,6 +235,24 @@ void QGraphicsEffectSource::draw(QPainter *painter)
}
/*!
+ Draws the source directly using the given \a painter.
+
+ This function should only be called from QGraphicsEffect::draw().
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0
+
+ \sa QGraphicsEffect::draw()
+*/
+void QGraphicsEffect::drawSource(QPainter *painter)
+{
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ d->source->draw(painter);
+}
+
+/*!
Schedules a redraw of the source. Call this function whenever the source
needs to be redrawn.
@@ -271,6 +278,19 @@ bool QGraphicsEffectSource::isPixmap() const
}
/*!
+ Returns true if the source effectively is a pixmap, e.g., a
+ QGraphicsPixmapItem.
+
+ This function is useful for optimization purposes. For instance, there's no
+ point in drawing the source in device coordinates to avoid pixmap scaling
+ if this function returns true - the source pixmap will be scaled anyways.
+*/
+bool QGraphicsEffect::sourceIsPixmap() const
+{
+ return source() ? source()->isPixmap() : false;
+}
+
+/*!
Returns a pixmap with the source painted into it.
The \a system specifies which coordinate system to be used for the source.
@@ -283,15 +303,15 @@ bool QGraphicsEffectSource::isPixmap() const
The returned pixmap is bound to the current painter's device rectangle when
\a system is Qt::DeviceCoordinates.
- \sa QGraphicsEffect::draw(), boundingRect(), deviceRect()
+ \sa QGraphicsEffect::draw(), boundingRect()
*/
-QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, PixmapPadMode mode) const
+QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const
{
Q_D(const QGraphicsEffectSource);
// Shortcut, no cache for childless pixmap items...
const QGraphicsItem *item = graphicsItem();
- if (system == Qt::LogicalCoordinates && mode == NoExpandPadMode && item && isPixmap()) {
+ if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) {
return ((QGraphicsPixmapItem *) item)->pixmap();
}
@@ -320,6 +340,27 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse
return pm;
}
+/*!
+ Returns a pixmap with the source painted into it.
+
+ The \a system specifies which coordinate system to be used for the source.
+ The optional \a offset parameter returns the offset where the pixmap should
+ be painted at using the current painter. For control on how the pixmap is
+ padded use the \a mode parameter.
+
+ The returned pixmap is clipped to the current painter's device rectangle when
+ \a system is Qt::DeviceCoordinates.
+
+ \sa draw(), boundingRect()
+*/
+QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const
+{
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ return d->source->pixmap(system, offset, mode);
+ return QPixmap();
+}
+
QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate()
{
invalidateCache();
@@ -327,7 +368,7 @@ QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate()
void QGraphicsEffectSourcePrivate::invalidateCache(bool effectRectChanged) const
{
- if (effectRectChanged && m_cachedMode != QGraphicsEffectSource::ExpandToEffectRectPadMode)
+ if (effectRectChanged && m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect)
return;
QPixmapCache::remove(m_cacheKey);
}
@@ -359,9 +400,9 @@ QGraphicsEffect::~QGraphicsEffect()
}
/*!
- Returns the bounding rectangle for this effect, i.e., the bounding
- rectangle of the source, adjusted by any margins applied by the effect
- itself.
+ Returns the effective bounding rectangle for this effect, i.e., the
+ bounding rectangle of the source, adjusted by any margins applied by
+ the effect itself.
\sa boundingRectFor(), updateBoundingRect()
*/
@@ -374,12 +415,13 @@ QRectF QGraphicsEffect::boundingRect() const
}
/*!
- Returns the bounding rectangle for this effect, given the provided source
- \a rect. When writing you own custom effect, you must call
- updateBoundingRect() whenever any parameters are changed that may cause
- this this function to return a different value.
+ Returns the effective bounding rectangle for this effect, given the
+ provided \a rect in the source's coordinate space. When writing
+ you own custom effect, you must call updateBoundingRect() whenever any
+ parameters are changed that may cause this this function to return a
+ different value.
- \sa boundingRect()
+ \sa sourceBoundingRect()
*/
QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const
{
@@ -445,6 +487,8 @@ void QGraphicsEffect::update()
}
/*!
+ \internal
+
Returns a pointer to the source, which provides extra context information
that can be useful for the effect.
@@ -464,7 +508,7 @@ QGraphicsEffectSource *QGraphicsEffect::source() const
This function will call update() if this is necessary.
- \sa boundingRectFor(), boundingRect()
+ \sa boundingRectFor(), boundingRect(), sourceBoundingRect()
*/
void QGraphicsEffect::updateBoundingRect()
{
@@ -476,15 +520,13 @@ void QGraphicsEffect::updateBoundingRect()
}
/*!
- \fn virtual void QGraphicsEffect::draw(QPainter *painter,
- QGraphicsEffectSource *source) = 0
+ \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0
This pure virtual function draws the effect and is called whenever the
- source() needs to be drawn.
+ source needs to be drawn.
Reimplement this function in a QGraphicsEffect subclass to provide the
- effect's drawing implementation, using \a painter. The \a source parameter
- is provided for convenience; its value is the same as source().
+ effect's drawing implementation, using \a painter.
For example:
@@ -492,8 +534,6 @@ void QGraphicsEffect::updateBoundingRect()
This function should not be called explicitly by the user, since it is
meant for reimplementation purposes only.
-
- \sa QGraphicsEffectSource
*/
/*!
@@ -509,6 +549,20 @@ void QGraphicsEffect::updateBoundingRect()
*/
/*!
+ \enum QGraphicsEffect::PixmapPadMode
+
+ This enum describes how the pixmap returned from sourcePixmap should be
+ padded.
+
+ \value NoPad The pixmap should not receive any additional
+ padding.
+ \value PadToTransparentBorder The pixmap should be padded
+ to ensure it has a completely transparent border.
+ \value PadToEffectiveBoundingRect The pixmap should be padded to
+ match the effective bounding rectangle of the effect.
+*/
+
+/*!
This virtual function is called by QGraphicsEffect to notify the effect
that the source has changed. If the effect applies any cache, then this
cache must be purged in order to reflect the new appearance of the source.
@@ -615,26 +669,25 @@ void QGraphicsColorizeEffect::setStrength(qreal strength)
/*!
\reimp
*/
-void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
+void QGraphicsColorizeEffect::draw(QPainter *painter)
{
Q_D(QGraphicsColorizeEffect);
if (!d->opaque) {
- source->draw(painter);
+ drawSource(painter);
return;
}
QPoint offset;
- if (source->isPixmap()) {
+ if (sourceIsPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
- const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset,
- QGraphicsEffectSource::NoExpandPadMode);
+ const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad);
d->filter->draw(painter, offset, pixmap);
return;
}
// Draw pixmap in deviceCoordinates to avoid pixmap scaling.
- const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
d->filter->draw(painter, offset, pixmap);
@@ -649,7 +702,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou
A blur effect blurs the source. This effect is useful for reducing details,
such as when the source loses focus and you want to draw attention to other
elements. The level of detail can be modified using the setBlurRadius()
- function. Use setBlurHint() to choose the quality or performance blur hints.
+ function. Use setBlurHints() to choose the blur hints.
By default, the blur radius is 5 pixels.
@@ -666,15 +719,17 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou
blur effects are applied. The hints might not have an effect in all the
paint engines.
- \value QualityHint Indicates that rendering quality is the most important factor,
- at the potential cost of lower performance.
-
\value PerformanceHint Indicates that rendering performance is the most important factor,
at the potential cost of lower quality.
+ \value QualityHint Indicates that rendering quality is the most important factor,
+ at the potential cost of lower performance.
+
\value AnimationHint Indicates that the blur radius is going to be animated, hinting
- that the implementation can keep a cache of blurred verisons of the source pixmap.
- Do not use this hint if the source item is going to be dynamically changing.
+ that the implementation can keep a cache of blurred verisons of the source.
+ Do not use this hint if the source is going to be dynamically changing.
+
+ \sa blurHints(), setBlurHints()
*/
@@ -686,7 +741,7 @@ QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent)
: QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent)
{
Q_D(QGraphicsBlurEffect);
- d->filter->setBlurHint(QGraphicsBlurEffect::PerformanceHint);
+ d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint);
}
/*!
@@ -730,7 +785,7 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius)
*/
/*!
- \property QGraphicsBlurEffect::blurHint
+ \property QGraphicsBlurEffect::blurHints
\brief the blur hint of the effect.
Use the PerformanceHint hint to say that you want a faster blur,
@@ -739,27 +794,27 @@ void QGraphicsBlurEffect::setBlurRadius(qreal radius)
By default, the blur hint is PerformanceHint.
*/
-QGraphicsBlurEffect::BlurHint QGraphicsBlurEffect::blurHint() const
+QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const
{
Q_D(const QGraphicsBlurEffect);
- return d->filter->blurHint();
+ return d->filter->blurHints();
}
-void QGraphicsBlurEffect::setBlurHint(QGraphicsBlurEffect::BlurHint hint)
+void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
{
Q_D(QGraphicsBlurEffect);
- if (d->filter->blurHint() == hint)
+ if (d->filter->blurHints() == hints)
return;
- d->filter->setBlurHint(hint);
- emit blurHintChanged(hint);
+ d->filter->setBlurHints(hints);
+ emit blurHintsChanged(hints);
}
/*!
- \fn void QGraphicsBlurEffect::blurHintChanged(QGraphicsBlurEffect::BlurHint hint)
+ \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints)
- This signal is emitted whenever the effect's blur hint changes.
- The \a hint parameter holds the effect's new blur hint.
+ This signal is emitted whenever the effect's blur hints changes.
+ The \a hints parameter holds the effect's new blur hints.
*/
/*!
@@ -774,21 +829,21 @@ QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const
/*!
\reimp
*/
-void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
+void QGraphicsBlurEffect::draw(QPainter *painter)
{
Q_D(QGraphicsBlurEffect);
if (d->filter->radius() <= 0) {
- source->draw(painter);
+ drawSource(painter);
return;
}
- QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode;
+ PixmapPadMode mode = PadToEffectiveBoundingRect;
if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
- mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode;
+ mode = PadToTransparentBorder;
// Draw pixmap in device coordinates to avoid pixmap scaling.
QPoint offset;
- const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode);
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
d->filter->draw(painter, offset, pixmap);
@@ -963,21 +1018,21 @@ QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const
/*!
\reimp
*/
-void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
+void QGraphicsDropShadowEffect::draw(QPainter *painter)
{
Q_D(QGraphicsDropShadowEffect);
if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) {
- source->draw(painter);
+ drawSource(painter);
return;
}
- QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToEffectRectPadMode;
+ PixmapPadMode mode = PadToEffectiveBoundingRect;
if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
- mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode;
+ mode = PadToTransparentBorder;
// Draw pixmap in device coordinates to avoid pixmap scaling.
QPoint offset;
- const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset, mode);
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
d->filter->draw(painter, offset, pixmap);
@@ -1100,7 +1155,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask)
/*!
\reimp
*/
-void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
+void QGraphicsOpacityEffect::draw(QPainter *painter)
{
Q_D(QGraphicsOpacityEffect);
@@ -1110,18 +1165,16 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour
// Opaque; draw directly without going through a pixmap.
if (d->isFullyOpaque && !d->hasOpacityMask) {
- source->draw(painter);
+ drawSource(painter);
return;
}
-
QPoint offset;
- Qt::CoordinateSystem system = source->isPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
- QPixmap pixmap = source->pixmap(system, &offset, QGraphicsEffectSource::NoExpandPadMode);
+ Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
+ QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad);
if (pixmap.isNull())
return;
-
painter->save();
painter->setOpacity(d->opacity);
@@ -1133,7 +1186,7 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour
QTransform worldTransform = painter->worldTransform();
worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y());
pixmapPainter.setWorldTransform(worldTransform);
- pixmapPainter.fillRect(source->boundingRect(), d->opacityMask);
+ pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask);
} else {
pixmapPainter.translate(-offset);
pixmapPainter.fillRect(pixmap.rect(), d->opacityMask);
diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h
index 5c73f4b..2257f01 100644
--- a/src/gui/effects/qgraphicseffect.h
+++ b/src/gui/effects/qgraphicseffect.h
@@ -60,46 +60,7 @@ class QStyleOption;
class QPainter;
class QPixmap;
-class QGraphicsEffectSourcePrivate;
-class Q_GUI_EXPORT QGraphicsEffectSource : public QObject
-{
- Q_OBJECT
-public:
- enum PixmapPadMode {
- NoExpandPadMode,
- ExpandToTransparentBorderPadMode,
- ExpandToEffectRectPadMode
- };
-
- ~QGraphicsEffectSource();
- const QGraphicsItem *graphicsItem() const;
- const QWidget *widget() const;
- const QStyleOption *styleOption() const;
-
- bool isPixmap() const;
- void draw(QPainter *painter);
- void update();
-
- QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const;
- QRect deviceRect() const;
- QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
- QPoint *offset = 0,
- PixmapPadMode mode = ExpandToEffectRectPadMode) const;
-
-protected:
- QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0);
-
-private:
- Q_DECLARE_PRIVATE(QGraphicsEffectSource)
- Q_DISABLE_COPY(QGraphicsEffectSource)
- friend class QGraphicsEffect;
- friend class QGraphicsEffectPrivate;
- friend class QGraphicsScenePrivate;
- friend class QGraphicsItem;
- friend class QGraphicsItemPrivate;
- friend class QWidget;
- friend class QWidgetPrivate;
-};
+class QGraphicsEffectSource;
class QGraphicsEffectPrivate;
class Q_GUI_EXPORT QGraphicsEffect : public QObject
@@ -116,14 +77,18 @@ public:
};
Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
+ enum PixmapPadMode {
+ NoPad,
+ PadToTransparentBorder,
+ PadToEffectiveBoundingRect
+ };
+
QGraphicsEffect(QObject *parent = 0);
virtual ~QGraphicsEffect();
- virtual QRectF boundingRectFor(const QRectF &rect) const;
+ virtual QRectF boundingRectFor(const QRectF &sourceRect) const;
QRectF boundingRect() const;
- QGraphicsEffectSource *source() const;
-
bool isEnabled() const;
public Q_SLOTS:
@@ -135,10 +100,17 @@ Q_SIGNALS:
protected:
QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0);
- virtual void draw(QPainter *painter, QGraphicsEffectSource *source) = 0;
+ virtual void draw(QPainter *painter) = 0;
virtual void sourceChanged(ChangeFlags flags);
void updateBoundingRect();
+ bool sourceIsPixmap() const;
+ QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const;
+ void drawSource(QPainter *painter);
+ QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
+ QPoint *offset = 0,
+ PixmapPadMode mode = PadToEffectiveBoundingRect) const;
+
private:
Q_DECLARE_PRIVATE(QGraphicsEffect)
Q_DISABLE_COPY(QGraphicsEffect)
@@ -147,6 +119,10 @@ private:
friend class QGraphicsScenePrivate;
friend class QWidget;
friend class QWidgetPrivate;
+
+public:
+ QGraphicsEffectSource *source() const; // internal
+
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags)
@@ -172,7 +148,7 @@ Q_SIGNALS:
void strengthChanged(qreal strength);
protected:
- void draw(QPainter *painter, QGraphicsEffectSource *source);
+ void draw(QPainter *painter);
private:
Q_DECLARE_PRIVATE(QGraphicsColorizeEffect)
@@ -183,38 +159,42 @@ class QGraphicsBlurEffectPrivate;
class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect
{
Q_OBJECT
+ Q_FLAGS(BlurHint BlurHints)
Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
- Q_PROPERTY(BlurHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged)
+ Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged)
public:
enum BlurHint {
- QualityHint,
- PerformanceHint,
- AnimationHint
+ PerformanceHint = 0x00,
+ QualityHint = 0x01,
+ AnimationHint = 0x02
};
+ Q_DECLARE_FLAGS(BlurHints, BlurHint)
QGraphicsBlurEffect(QObject *parent = 0);
~QGraphicsBlurEffect();
QRectF boundingRectFor(const QRectF &rect) const;
qreal blurRadius() const;
- BlurHint blurHint() const;
+ BlurHints blurHints() const;
public Q_SLOTS:
void setBlurRadius(qreal blurRadius);
- void setBlurHint(BlurHint hint);
+ void setBlurHints(BlurHints hints);
Q_SIGNALS:
void blurRadiusChanged(qreal blurRadius);
- void blurHintChanged(BlurHint hint);
+ void blurHintsChanged(BlurHints hints);
protected:
- void draw(QPainter *painter, QGraphicsEffectSource *source);
+ void draw(QPainter *painter);
private:
Q_DECLARE_PRIVATE(QGraphicsBlurEffect)
Q_DISABLE_COPY(QGraphicsBlurEffect)
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints)
+
class QGraphicsDropShadowEffectPrivate;
class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
{
@@ -264,7 +244,7 @@ Q_SIGNALS:
void colorChanged(const QColor &color);
protected:
- void draw(QPainter *painter, QGraphicsEffectSource *source);
+ void draw(QPainter *painter);
private:
Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect)
@@ -293,7 +273,7 @@ Q_SIGNALS:
void opacityMaskChanged(const QBrush &mask);
protected:
- void draw(QPainter *painter, QGraphicsEffectSource *source);
+ void draw(QPainter *painter);
private:
Q_DECLARE_PRIVATE(QGraphicsOpacityEffect)
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h
index d94d08d..c67052e 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/gui/effects/qgraphicseffect_p.h
@@ -63,6 +63,41 @@
#ifndef QT_NO_GRAPHICSEFFECT
QT_BEGIN_NAMESPACE
+class QGraphicsEffectSourcePrivate;
+class Q_AUTOTEST_EXPORT QGraphicsEffectSource : public QObject
+{
+ Q_OBJECT
+public:
+ ~QGraphicsEffectSource();
+ const QGraphicsItem *graphicsItem() const;
+ const QWidget *widget() const;
+ const QStyleOption *styleOption() const;
+
+ bool isPixmap() const;
+ void draw(QPainter *painter);
+ void update();
+
+ QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const;
+ QRect deviceRect() const;
+ QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
+ QPoint *offset = 0,
+ QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const;
+
+protected:
+ QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QGraphicsEffectSource)
+ Q_DISABLE_COPY(QGraphicsEffectSource)
+ friend class QGraphicsEffect;
+ friend class QGraphicsEffectPrivate;
+ friend class QGraphicsScenePrivate;
+ friend class QGraphicsItem;
+ friend class QGraphicsItemPrivate;
+ friend class QWidget;
+ friend class QWidgetPrivate;
+};
+
class QGraphicsEffectSourcePrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QGraphicsEffectSource)
@@ -70,7 +105,7 @@ public:
QGraphicsEffectSourcePrivate()
: QObjectPrivate()
, m_cachedSystem(Qt::DeviceCoordinates)
- , m_cachedMode(QGraphicsEffectSource::ExpandToTransparentBorderPadMode)
+ , m_cachedMode(QGraphicsEffect::PadToTransparentBorder)
{}
virtual ~QGraphicsEffectSourcePrivate();
@@ -84,7 +119,7 @@ public:
virtual void update() = 0;
virtual bool isPixmap() const = 0;
virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0,
- QGraphicsEffectSource::PixmapPadMode mode = QGraphicsEffectSource::ExpandToTransparentBorderPadMode) const = 0;
+ QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0;
virtual void effectBoundingRectChanged() = 0;
void invalidateCache(bool effectRectChanged = false) const;
@@ -94,7 +129,7 @@ public:
private:
mutable Qt::CoordinateSystem m_cachedSystem;
- mutable QGraphicsEffectSource::PixmapPadMode m_cachedMode;
+ mutable QGraphicsEffect::PixmapPadMode m_cachedMode;
mutable QPoint m_cachedOffset;
mutable QPixmapCache::Key m_cacheKey;
};
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index 911a77e..ae5570f 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -600,7 +600,7 @@ static void blit_template(QScreen *screen, const QImage &image,
const int screenStride = screen->linestep();
const int imageStride = image.bytesPerLine();
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
const QRect r = region.boundingRect();
const SRC *src = reinterpret_cast<const SRC*>(image.scanLine(r.y()))
+ r.x();
@@ -1385,7 +1385,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const
QScreen provides several functions to retrieve information about
the color palette: The clut() function returns a pointer to the
- color lookup table (i.e. its color palette). Use the numCols()
+ color lookup table (i.e. its color palette). Use the colorCount()
function to determine the number of entries in this table, and the
alloc() function to retrieve the palette index of the color that
is the closest match to a given RGB value.
@@ -1998,12 +1998,20 @@ QImage::Format QScreenPrivate::preferredImageFormat() const
i.e. in modes where only the palette indexes (and not the actual
color values) are stored in memory.
- \sa alloc(), depth(), numCols()
+ \sa alloc(), depth(), colorCount()
*/
/*!
+ \obsolete
\fn int QScreen::numCols()
+ \sa colorCount()
+*/
+
+/*!
+ \since 4.6
+ \fn int QScreen::colorCount()
+
Returns the number of entries in the screen's color lookup table
(i.e. its color palette). A pointer to the color table can be
retrieved using the clut() function.
@@ -2103,7 +2111,7 @@ void QScreen::setPixelFormat(QImage::Format format)
i.e. in modes where only the palette indexes (and not the actual
color values) are stored in memory.
- \sa clut(), numCols()
+ \sa clut(), colorCount()
*/
int QScreen::alloc(unsigned int r,unsigned int g,unsigned int b)
@@ -2455,7 +2463,7 @@ void QScreen::exposeRegion(QRegion r, int windowIndex)
delete blendBuffer;
}
- if (r.numRects() == 1) {
+ if (r.rectCount() == 1) {
setDirty(r.boundingRect());
} else {
const QVector<QRect> rects = r.rects();
diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h
index d20d709..b3246f9 100644
--- a/src/gui/embedded/qscreen_qws.h
+++ b/src/gui/embedded/qscreen_qws.h
@@ -243,7 +243,8 @@ public:
int totalSize() const { return mapsize; }
QRgb * clut() { return screenclut; }
- int numCols() { return screencols; }
+ QT_DEPRECATED int numCols() { return screencols; }
+ int colorCount() { return screencols; }
virtual QSize mapToDevice(const QSize &) const;
virtual QSize mapFromDevice(const QSize &) const;
diff --git a/src/gui/embedded/qwscursor_qws.cpp b/src/gui/embedded/qwscursor_qws.cpp
index 07271e1..7d5a3d1 100644
--- a/src/gui/embedded/qwscursor_qws.cpp
+++ b/src/gui/embedded/qwscursor_qws.cpp
@@ -534,7 +534,7 @@ void QWSCursor::set(const uchar *data, const uchar *mask,
if (!width || !height || !data || !mask || cursor.isNull())
return;
- cursor.setNumColors(3);
+ cursor.setColorCount(3);
cursor.setColor(0, 0xff000000);
cursor.setColor(1, 0xffffffff);
cursor.setColor(2, 0x00000000);
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 96f8930..182594e 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -61,6 +61,8 @@ QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)
QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()
{
+ // ###
+ layoutPrivate->restoreSimplifiedGraph(QGraphicsAnchorLayoutPrivate::Orientation(data->orientation));
layoutPrivate->removeAnchor(data->from, data->to);
}
@@ -218,9 +220,20 @@ bool AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
void ParallelAnchorData::updateChildrenSizes()
{
- firstEdge->sizeAtMinimum = secondEdge->sizeAtMinimum = sizeAtMinimum;
- firstEdge->sizeAtPreferred = secondEdge->sizeAtPreferred = sizeAtPreferred;
- firstEdge->sizeAtMaximum = secondEdge->sizeAtMaximum = sizeAtMaximum;
+ firstEdge->sizeAtMinimum = sizeAtMinimum;
+ firstEdge->sizeAtPreferred = sizeAtPreferred;
+ firstEdge->sizeAtMaximum = sizeAtMaximum;
+
+ const bool secondFwd = (secondEdge->from == from);
+ if (secondFwd) {
+ secondEdge->sizeAtMinimum = sizeAtMinimum;
+ secondEdge->sizeAtPreferred = sizeAtPreferred;
+ secondEdge->sizeAtMaximum = sizeAtMaximum;
+ } else {
+ secondEdge->sizeAtMinimum = -sizeAtMinimum;
+ secondEdge->sizeAtPreferred = -sizeAtPreferred;
+ secondEdge->sizeAtMaximum = -sizeAtMaximum;
+ }
firstEdge->updateChildrenSizes();
secondEdge->updateChildrenSizes();
@@ -239,8 +252,16 @@ bool ParallelAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleIn
return false;
}
- minSize = qMax(firstEdge->minSize, secondEdge->minSize);
- maxSize = qMin(firstEdge->maxSize, secondEdge->maxSize);
+ // Account for parallel anchors where the second edge is backwards.
+ // We rely on the fact that a forward anchor of sizes min, pref, max is equivalent
+ // to a backwards anchor of size (-max, -pref, -min)
+ const bool secondFwd = (secondEdge->from == from);
+ const qreal secondMin = secondFwd ? secondEdge->minSize : -secondEdge->maxSize;
+ const qreal secondPref = secondFwd ? secondEdge->prefSize : -secondEdge->prefSize;
+ const qreal secondMax = secondFwd ? secondEdge->maxSize : -secondEdge->minSize;
+
+ minSize = qMax(firstEdge->minSize, secondMin);
+ maxSize = qMin(firstEdge->maxSize, secondMax);
// This condition means that the maximum size of one anchor being simplified is smaller than
// the minimum size of the other anchor. The consequence is that there won't be a valid size
@@ -249,7 +270,22 @@ bool ParallelAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleIn
return false;
}
- prefSize = qMax(firstEdge->prefSize, secondEdge->prefSize);
+ // The equivalent preferred Size of a parallel anchor is calculated as to
+ // reduce the deviation from the original preferred sizes _and_ to avoid shrinking
+ // items below their preferred sizes, unless strictly needed.
+
+ // ### This logic only holds if all anchors in the layout are "well-behaved" in the
+ // following terms:
+ //
+ // - There are no negative-sized anchors
+ // - All sequential anchors are composed of children in the same direction as the
+ // sequential anchor itself
+ //
+ // With these assumptions we can grow a child knowing that no hidden items will
+ // have to shrink as the result of that.
+ // If any of these does not hold, we have a situation where the ParallelAnchor
+ // does not have enough information to calculate its equivalent prefSize.
+ prefSize = qMax(firstEdge->prefSize, secondPref);
prefSize = qMin(prefSize, maxSize);
// See comment in AnchorData::refreshSizeHints() about sizeAt* values
@@ -502,34 +538,67 @@ inline static qreal checkAdd(qreal a, qreal b)
/*!
\internal
- Adds \a newAnchor to the graph \a g.
+ Adds \a newAnchor to the graph.
Returns the newAnchor itself if it could be added without further changes to the graph. If a
new parallel anchor had to be created, then returns the new parallel anchor. If a parallel anchor
had to be created and it results in an unfeasible setup, \a feasible is set to false, otherwise
true.
+
+ Note that in the case a new parallel anchor is created, it might also take over some constraints
+ from its children anchors.
*/
-static AnchorData *addAnchorMaybeParallel(Graph<AnchorVertex, AnchorData> *g,
- AnchorData *newAnchor, bool *feasible)
+AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible)
{
+ Orientation orientation = Orientation(newAnchor->orientation);
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
*feasible = true;
// If already exists one anchor where newAnchor is supposed to be, we create a parallel
// anchor.
- if (AnchorData *oldAnchor = g->takeEdge(newAnchor->from, newAnchor->to)) {
+ if (AnchorData *oldAnchor = g.takeEdge(newAnchor->from, newAnchor->to)) {
ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor);
+ // The parallel anchor will "replace" its children anchors in
+ // every center constraint that they appear.
+
+ // ### If the dependent (center) anchors had reference(s) to their constraints, we
+ // could avoid traversing all the itemCenterConstraints.
+ QList<QSimplexConstraint *> &constraints = itemCenterConstraints[orientation];
+
+ AnchorData *children[2] = { oldAnchor, newAnchor };
+ QList<QSimplexConstraint *> *childrenConstraints[2] = { &parallel->m_firstConstraints,
+ &parallel->m_secondConstraints };
+
+ for (int i = 0; i < 2; ++i) {
+ AnchorData *child = children[i];
+ QList<QSimplexConstraint *> *childConstraints = childrenConstraints[i];
+
+ if (!child->isCenterAnchor)
+ continue;
+
+ parallel->isCenterAnchor = true;
+
+ for (int i = 0; i < constraints.count(); ++i) {
+ QSimplexConstraint *c = constraints[i];
+ if (c->variables.contains(child)) {
+ childConstraints->append(c);
+ qreal v = c->variables.take(child);
+ c->variables.insert(parallel, v);
+ }
+ }
+ }
+
// At this point we can identify that the parallel anchor is not feasible, e.g. one
// anchor minimum size is bigger than the other anchor maximum size.
*feasible = parallel->refreshSizeHints_helper(0, false);
newAnchor = parallel;
}
- g->createEdge(newAnchor->from, newAnchor->to, newAnchor);
+ g.createEdge(newAnchor->from, newAnchor->to, newAnchor);
return newAnchor;
}
-
/*!
\internal
@@ -633,30 +702,185 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation)
if (graphSimplified[orientation])
return true;
- graphSimplified[orientation] = true;
#if 0
qDebug("Simplifying Graph for %s",
orientation == Horizontal ? "Horizontal" : "Vertical");
#endif
- if (!layoutFirstVertex[orientation])
- return true;
+ // Vertex simplification
+ if (!simplifyVertices(orientation)) {
+ restoreVertices(orientation);
+ return false;
+ }
+ // Anchor simplification
bool dirty;
bool feasible = true;
do {
dirty = simplifyGraphIteration(orientation, &feasible);
} while (dirty && feasible);
- if (!feasible)
- graphSimplified[orientation] = false;
+ // Note that if we are not feasible, we fallback and make sure that the graph is fully restored
+ if (!feasible) {
+ graphSimplified[orientation] = true;
+ restoreSimplifiedGraph(orientation);
+ restoreVertices(orientation);
+ return false;
+ }
+
+ graphSimplified[orientation] = true;
+ return true;
+}
+
+static AnchorVertex *replaceVertex_helper(AnchorData *data, AnchorVertex *oldV, AnchorVertex *newV)
+{
+ AnchorVertex *other;
+ if (data->from == oldV) {
+ data->from = newV;
+ other = data->to;
+ } else {
+ data->to = newV;
+ other = data->from;
+ }
+ return other;
+}
+
+bool QGraphicsAnchorLayoutPrivate::replaceVertex(Orientation orientation, AnchorVertex *oldV,
+ AnchorVertex *newV, const QList<AnchorData *> &edges)
+{
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ bool feasible = true;
+
+ for (int i = 0; i < edges.count(); ++i) {
+ AnchorData *ad = edges[i];
+ AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV);
+
+#if defined(QT_DEBUG)
+ ad->name = QString::fromAscii("%1 --to--> %2").arg(ad->from->toString()).arg(ad->to->toString());
+#endif
+
+ bool newFeasible;
+ AnchorData *newAnchor = addAnchorMaybeParallel(ad, &newFeasible);
+ feasible &= newFeasible;
+
+ if (newAnchor != ad) {
+ // A parallel was created, we mark that in the list of anchors created by vertex
+ // simplification. This is needed because we want to restore them in a separate step
+ // from the restoration of anchor simplification.
+ anchorsFromSimplifiedVertices[orientation].append(newAnchor);
+ }
+
+ g.takeEdge(oldV, otherV);
+ }
return feasible;
}
/*!
\internal
+*/
+bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation)
+{
+ Q_Q(QGraphicsAnchorLayout);
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+
+ // We'll walk through vertices
+ QStack<AnchorVertex *> stack;
+ stack.push(layoutFirstVertex[orientation]);
+ QSet<AnchorVertex *> visited;
+
+ while (!stack.isEmpty()) {
+ AnchorVertex *v = stack.pop();
+ visited.insert(v);
+
+ // Each adjacent of 'v' is a possible vertex to be merged. So we traverse all of
+ // them. Since once a merge is made, we might add new adjacents, and we don't want to
+ // pass two times through one adjacent. The 'index' is used to track our position.
+ QList<AnchorVertex *> adjacents = g.adjacentVertices(v);
+ int index = 0;
+
+ while (index < adjacents.count()) {
+ AnchorVertex *next = adjacents.at(index);
+ index++;
+
+ AnchorData *data = g.edgeData(v, next);
+ const bool bothLayoutVertices = v->m_item == q && next->m_item == q;
+ const bool zeroSized = !data->minSize && !data->maxSize;
+
+ if (!bothLayoutVertices && zeroSized) {
+
+ // Create a new vertex pair, note that we keep a list of those vertices so we can
+ // easily process them when restoring the graph.
+ AnchorVertexPair *newV = new AnchorVertexPair(v, next, data);
+ simplifiedVertices[orientation].append(newV);
+
+ // Collect the anchors of both vertices, the new vertex pair will take their place
+ // in those anchors
+ const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v);
+ const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next);
+
+ for (int i = 0; i < vAdjacents.count(); ++i) {
+ AnchorVertex *adjacent = vAdjacents.at(i);
+ if (adjacent != next) {
+ AnchorData *ad = g.edgeData(v, adjacent);
+ newV->m_firstAnchors.append(ad);
+ }
+ }
+
+ for (int i = 0; i < nextAdjacents.count(); ++i) {
+ AnchorVertex *adjacent = nextAdjacents.at(i);
+ if (adjacent != v) {
+ AnchorData *ad = g.edgeData(next, adjacent);
+ newV->m_secondAnchors.append(ad);
+
+ // We'll also add new vertices to the adjacent list of the new 'v', to be
+ // created as a vertex pair and replace the current one.
+ if (!adjacents.contains(adjacent))
+ adjacents.append(adjacent);
+ }
+ }
+
+ // ### merge this loop into the ones that calculated m_firstAnchors/m_secondAnchors?
+ // Make newV take the place of v and next
+ bool feasible = replaceVertex(orientation, v, newV, newV->m_firstAnchors);
+ feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors);
+
+ // Update the layout vertex information if one of the vertices is a layout vertex.
+ AnchorVertex *layoutVertex = 0;
+ if (v->m_item == q)
+ layoutVertex = v;
+ else if (next->m_item == q)
+ layoutVertex = next;
+
+ if (layoutVertex) {
+ // Layout vertices always have m_item == q...
+ newV->m_item = q;
+ changeLayoutVertex(orientation, layoutVertex, newV);
+ }
+
+ g.takeEdge(v, next);
+
+ // If a non-feasibility is found, we leave early and cancel the simplification
+ if (!feasible)
+ return false;
+
+ v = newV;
+ visited.insert(newV);
+
+ } else if (!visited.contains(next) && !stack.contains(next)) {
+ // If the adjacent is not fit for merge and it wasn't visited by the outermost
+ // loop, we add it to the stack.
+ stack.push(next);
+ }
+ }
+ }
+
+ return true;
+}
+
+/*!
+ \internal
One iteration of the simplification algorithm. Returns true if another iteration is needed.
@@ -696,7 +920,8 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
// (a) it is a layout vertex, we don't simplify away the layout vertices;
// (b) it does not have exactly 2 adjacents;
// (c) it will change the direction of the sequence;
- // (d) its next adjacent is already visited (a cycle in the graph).
+ // (d) its next adjacent is already visited (a cycle in the graph);
+ // (e) the next anchor is a center anchor.
const QList<AnchorVertex *> &adjacents = g.adjacentVertices(v);
const bool isLayoutVertex = v->m_item == q;
@@ -719,13 +944,14 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
candidatesForward = (beforeSequence == data->from);
}
- // This is a tricky part. We peek at the next vertex to find out
+ // This is a tricky part. We peek at the next vertex to find out whether
//
- // - whether the edge from this vertex to the next vertex has the same direction;
- // - whether we already visited the next vertex.
+ // - the edge from this vertex to the next vertex has the same direction;
+ // - we already visited the next vertex;
+ // - the next anchor is a center.
//
- // Those are needed to identify (c) and (d). Note that unlike (a) and (b), we preempt
- // the end of sequence by looking into the next vertex.
+ // Those are needed to identify the remaining end of sequence cases. Note that unlike
+ // (a) and (b), we preempt the end of sequence by looking into the next vertex.
// Peek at the next vertex
AnchorVertex *after;
@@ -743,8 +969,8 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
const bool willChangeDirection = (candidatesForward != (v == data->from));
const bool cycleFound = visited.contains(after);
- // Now cases (c) and (d)...
- endOfSequence = willChangeDirection || cycleFound;
+ // Now cases (c), (d) and (e)...
+ endOfSequence = willChangeDirection || cycleFound || data->isCenterAnchor;
if (endOfSequence) {
if (!willChangeDirection) {
@@ -812,19 +1038,12 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
// Add the sequence to the graph.
//
- // ### At this point we assume that if some parallel anchor will be created because
- // of the new sequence, the other anchor will not be a center anchor (since we
- // not deal with that case yet). This assumption will break once we start simplifying
- // vertices.
- AnchorData *possibleParallel = g.edgeData(beforeSequence, afterSequence);
- Q_ASSERT(!possibleParallel || !possibleParallel->isCenterAnchor);
-
AnchorData *sequence = createSequence(&g, beforeSequence, candidates, afterSequence);
// If 'beforeSequence' and 'afterSequence' already had an anchor between them, we'll
// create a parallel anchor between the new sequence and the old anchor.
bool newFeasible;
- AnchorData *newAnchor = addAnchorMaybeParallel(&g, sequence, &newFeasible);
+ AnchorData *newAnchor = addAnchorMaybeParallel(sequence, &newFeasible);
if (!newFeasible) {
*feasible = false;
@@ -846,48 +1065,70 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
return false;
}
-static void restoreSimplifiedAnchor(Graph<AnchorVertex, AnchorData> &g,
- AnchorData *edge,
- AnchorVertex *before,
- AnchorVertex *after)
+void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)
{
- Q_ASSERT(edge->type != AnchorData::Normal);
#if 0
static const char *anchortypes[] = {"Normal",
"Sequential",
"Parallel"};
qDebug("Restoring %s edge.", anchortypes[int(edge->type)]);
#endif
- if (edge->type == AnchorData::Sequential) {
- SequentialAnchorData* seqEdge = static_cast<SequentialAnchorData*>(edge);
- // restore the sequential anchor
- AnchorVertex *prev = before;
- AnchorVertex *last = after;
- if (edge->from != prev)
- qSwap(last, prev);
-
- for (int i = 0; i < seqEdge->m_edges.count(); ++i) {
- AnchorVertex *v1 = (i < seqEdge->m_children.count()) ? seqEdge->m_children.at(i) : last;
- AnchorData *data = seqEdge->m_edges.at(i);
- if (data->type != AnchorData::Normal) {
- restoreSimplifiedAnchor(g, data, prev, v1);
- } else {
- g.createEdge(prev, v1, data);
- }
- prev = v1;
+
+ Graph<AnchorVertex, AnchorData> &g = graph[edge->orientation];
+
+ if (edge->type == AnchorData::Normal) {
+ g.createEdge(edge->from, edge->to, edge);
+
+ } else if (edge->type == AnchorData::Sequential) {
+ SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge);
+
+ for (int i = 0; i < sequence->m_edges.count(); ++i) {
+ AnchorData *data = sequence->m_edges.at(i);
+ restoreSimplifiedAnchor(data);
}
+
+ delete sequence;
+
} else if (edge->type == AnchorData::Parallel) {
- ParallelAnchorData* parallelEdge = static_cast<ParallelAnchorData*>(edge);
- AnchorData *parallelEdges[2] = {parallelEdge->firstEdge,
- parallelEdge->secondEdge};
- for (int i = 0; i < 2; ++i) {
- AnchorData *data = parallelEdges[i];
- if (data->type == AnchorData::Normal) {
- g.createEdge(before, after, data);
- } else {
- restoreSimplifiedAnchor(g, data, before, after);
- }
- }
+
+ // Skip parallel anchors that were created by vertex simplification, they will be processed
+ // later, when restoring vertex simplification.
+ // ### we could improve this check bit having a bit inside 'edge'
+ if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge))
+ return;
+
+ ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge);
+ restoreSimplifiedConstraints(parallel);
+
+ // ### Because of the way parallel anchors are created in the anchor simplification
+ // algorithm, we know that one of these will be a sequence, so it'll be safe if the other
+ // anchor create an edge between the same vertices as the parallel.
+ Q_ASSERT(parallel->firstEdge->type == AnchorData::Sequential
+ || parallel->secondEdge->type == AnchorData::Sequential);
+ restoreSimplifiedAnchor(parallel->firstEdge);
+ restoreSimplifiedAnchor(parallel->secondEdge);
+
+ delete parallel;
+ }
+}
+
+void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorData *parallel)
+{
+ if (!parallel->isCenterAnchor)
+ return;
+
+ for (int i = 0; i < parallel->m_firstConstraints.count(); ++i) {
+ QSimplexConstraint *c = parallel->m_firstConstraints.at(i);
+ qreal v = c->variables[parallel];
+ c->variables.remove(parallel);
+ c->variables.insert(parallel->firstEdge, v);
+ }
+
+ for (int i = 0; i < parallel->m_secondConstraints.count(); ++i) {
+ QSimplexConstraint *c = parallel->m_secondConstraints.at(i);
+ qreal v = c->variables[parallel];
+ c->variables.remove(parallel);
+ c->variables.insert(parallel->secondEdge, v);
}
}
@@ -902,19 +1143,93 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientatio
orientation == Horizontal ? "Horizontal" : "Vertical");
#endif
+ // Restore anchor simplification
Graph<AnchorVertex, AnchorData> &g = graph[orientation];
-
QList<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections();
for (int i = 0; i < connections.count(); ++i) {
AnchorVertex *v1 = connections.at(i).first;
AnchorVertex *v2 = connections.at(i).second;
AnchorData *edge = g.edgeData(v1, v2);
- if (edge->type != AnchorData::Normal) {
- AnchorData *oldEdge = g.takeEdge(v1, v2);
- restoreSimplifiedAnchor(g, edge, v1, v2);
- delete oldEdge;
+
+ // We restore only sequential anchors and parallels that were not created by
+ // vertex simplification.
+ if (edge->type == AnchorData::Sequential
+ || (edge->type == AnchorData::Parallel &&
+ !anchorsFromSimplifiedVertices[orientation].contains(edge))) {
+
+ g.takeEdge(v1, v2);
+ restoreSimplifiedAnchor(edge);
}
}
+
+ restoreVertices(orientation);
+}
+
+void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ QList<AnchorVertexPair *> &toRestore = simplifiedVertices[orientation];
+
+ // We will restore the vertices in the inverse order of creation, this way we ensure that
+ // the vertex being restored was not wrapped by another simplification.
+ for (int i = toRestore.count() - 1; i >= 0; --i) {
+ AnchorVertexPair *pair = toRestore.at(i);
+ QList<AnchorVertex *> adjacents = g.adjacentVertices(pair);
+
+ // Restore the removed edge, this will also restore both vertices 'first' and 'second' to
+ // the graph structure.
+ AnchorVertex *first = pair->m_first;
+ AnchorVertex *second = pair->m_second;
+ g.createEdge(first, second, pair->m_removedAnchor);
+
+ // Restore the anchors for the first child vertex
+ for (int j = 0; j < pair->m_firstAnchors.count(); ++j) {
+ AnchorData *ad = pair->m_firstAnchors.at(j);
+ Q_ASSERT(ad->from == pair || ad->to == pair);
+
+ replaceVertex_helper(ad, pair, first);
+ g.createEdge(ad->from, ad->to, ad);
+ }
+
+ // Restore the anchors for the second child vertex
+ for (int j = 0; j < pair->m_secondAnchors.count(); ++j) {
+ AnchorData *ad = pair->m_secondAnchors.at(j);
+ Q_ASSERT(ad->from == pair || ad->to == pair);
+
+ replaceVertex_helper(ad, pair, second);
+ g.createEdge(ad->from, ad->to, ad);
+ }
+
+ for (int j = 0; j < adjacents.count(); ++j) {
+ g.takeEdge(pair, adjacents.at(j));
+ }
+
+ // The pair simplified a layout vertex, so place back the correct vertex in the variable
+ // that track layout vertices
+ if (pair->m_item == q) {
+ AnchorVertex *layoutVertex = first->m_item == q ? first : second;
+ Q_ASSERT(layoutVertex->m_item == q);
+ changeLayoutVertex(orientation, pair, layoutVertex);
+ }
+
+ delete pair;
+ }
+ toRestore.clear();
+
+ // The restoration process for vertex simplification also restored the effect of the
+ // parallel anchors created during vertex simplification, so we just need to restore
+ // the constraints in case of parallels that contain center anchors. For the same
+ // reason as above, order matters here.
+ QList<AnchorData *> &parallelAnchors = anchorsFromSimplifiedVertices[orientation];
+
+ for (int i = parallelAnchors.count() - 1; i >= 0; --i) {
+ ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i));
+ restoreSimplifiedConstraints(parallel);
+ delete parallel;
+ }
+ parallelAnchors.clear();
}
QGraphicsAnchorLayoutPrivate::Orientation
@@ -1068,7 +1383,6 @@ void QGraphicsAnchorLayoutPrivate::createCenterAnchors(
if (item == q) {
layoutCentralVertex[orientation] = internalVertex(q, centerEdge);
}
-
}
void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
@@ -1118,7 +1432,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
AnchorData *oldData = g.edgeData(first, center);
// Remove center constraint
for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0; --i) {
- if (itemCenterConstraints[orientation][i]->variables.contains(oldData)) {
+ if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)) {
delete itemCenterConstraints[orientation].takeAt(i);
break;
}
@@ -1182,7 +1496,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *
// Look for our anchor in all item center constraints, then remove it
for (int i = 0; i < itemCenterConstraints[orientation].size(); ++i) {
- if (itemCenterConstraints[orientation][i]->variables.contains(internalAnchor)) {
+ if (itemCenterConstraints[orientation].at(i)->variables.contains(internalAnchor)) {
delete itemCenterConstraints[orientation].takeAt(i);
break;
}
@@ -1692,7 +2006,7 @@ QList<AnchorData *> getVariables(QList<QSimplexConstraint *> constraints)
{
QSet<AnchorData *> variableSet;
for (int i = 0; i < constraints.count(); ++i) {
- const QSimplexConstraint *c = constraints[i];
+ const QSimplexConstraint *c = constraints.at(i);
foreach (QSimplexVariable *var, c->variables.keys()) {
variableSet += static_cast<AnchorData *>(var);
}
@@ -1730,6 +2044,15 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
lastCalculationUsedSimplex[orientation] = false;
#endif
+ // ### This is necessary because now we do vertex simplification, we still don't know
+ // differentiate between invalidate()s that doesn't need resimplification and those which
+ // need. For example, when size hint of an item changes, this may cause an anchor to reach 0 or to
+ // leave 0 and get a size. In both cases we need resimplify.
+ //
+ // ### one possible solution would be tracking all the 0-sized anchors, if this set change, we need
+ // resimplify.
+ restoreSimplifiedGraph(orientation);
+
// Reset the nominal sizes of each anchor based on the current item sizes. This function
// works with both simplified and non-simplified graphs, so it'll work when the
// simplification is going to be reused.
@@ -1768,7 +2091,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
// Now run the simplex solver to calculate Minimum, Preferred and Maximum sizes
// of the "trunk" set of constraints and variables.
// ### does trunk always exist? empty = trunk is the layout left->center->right
- QList<QSimplexConstraint *> trunkConstraints = parts[0];
+ QList<QSimplexConstraint *> trunkConstraints = parts.at(0);
QList<AnchorData *> trunkVariables = getVariables(trunkConstraints);
// For minimum and maximum, use the path between the two layout sides as the
@@ -1787,7 +2110,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
if (!feasible)
break;
- QList<QSimplexConstraint *> partConstraints = parts[i];
+ QList<QSimplexConstraint *> partConstraints = parts.at(i);
QList<AnchorData *> partVariables = getVariables(partConstraints);
Q_ASSERT(!partVariables.isEmpty());
feasible &= calculateNonTrunk(partConstraints, partVariables);
@@ -1889,7 +2212,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstra
// Propagate size at preferred to other sizes. Semi-floats always will be
// in their sizeAtPreferred.
for (int j = 0; j < variables.count(); ++j) {
- AnchorData *ad = variables[j];
+ AnchorData *ad = variables.at(j);
Q_ASSERT(ad);
ad->sizeAtMinimum = ad->sizeAtPreferred;
ad->sizeAtMaximum = ad->sizeAtPreferred;
@@ -2002,7 +2325,7 @@ void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation)
QList<GraphPath> pathsToVertex = graphPaths[orientation].values(vertex);
for (int i = 1; i < valueCount; ++i) {
constraints[orientation] += \
- pathsToVertex[0].constraint(pathsToVertex[i]);
+ pathsToVertex[0].constraint(pathsToVertex.at(i));
}
}
}
@@ -2054,7 +2377,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin
QList<QSimplexConstraint *> anchorConstraints;
bool unboundedProblem = true;
for (int i = 0; i < anchors.size(); ++i) {
- AnchorData *ad = anchors[i];
+ AnchorData *ad = anchors.at(i);
// Anchors that have their size directly linked to another one don't need constraints
// For exammple, the second half of an item has exactly the same size as the first half
@@ -2125,10 +2448,10 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
QLinkedList<QSimplexConstraint *> remainingConstraints;
for (int i = 0; i < constraints[orientation].count(); ++i) {
- remainingConstraints += constraints[orientation][i];
+ remainingConstraints += constraints[orientation].at(i);
}
for (int i = 0; i < itemCenterConstraints[orientation].count(); ++i) {
- remainingConstraints += itemCenterConstraints[orientation][i];
+ remainingConstraints += itemCenterConstraints[orientation].at(i);
}
QList<QSimplexConstraint *> trunkConstraints;
@@ -2298,6 +2621,21 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom)
}
/*!
+ \internal
+
+ Fill the distance in the vertex and in the sub-vertices if its a combined vertex.
+*/
+static void setVertexDistance(AnchorVertex *v, qreal distance)
+{
+ v->distance = distance;
+ if (v->m_type == AnchorVertex::Pair) {
+ AnchorVertexPair *pair = static_cast<AnchorVertexPair *>(v);
+ setVertexDistance(pair->m_first, distance);
+ setVertexDistance(pair->m_second, distance);
+ }
+}
+
+/*!
\internal
Calculate the position of each vertex based on the paths to each of
@@ -2312,7 +2650,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(
// Get root vertex
AnchorVertex *root = layoutFirstVertex[orientation];
- root->distance = 0;
+ setVertexDistance(root, 0);
visited.insert(root);
// Add initial edges to the queue
@@ -2336,7 +2674,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(
continue;
visited.insert(pair.second);
- interpolateEdge(pair.first, edge, orientation);
+ interpolateEdge(pair.first, edge);
QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second);
for (int i = 0; i < adjacents.count(); ++i) {
@@ -2390,10 +2728,9 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
vertices to be initalized, so it calls specialized functions that
will recurse back to interpolateEdge().
*/
-void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base,
- AnchorData *edge,
- Orientation orientation)
+void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge)
{
+ const Orientation orientation = Orientation(edge->orientation);
const QPair<Interval, qreal> factor(interpolationInterval[orientation],
interpolationProgress[orientation]);
@@ -2402,24 +2739,21 @@ void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base,
Q_ASSERT(edge->from == base || edge->to == base);
- if (edge->from == base)
- edge->to->distance = base->distance + edgeDistance;
- else
- edge->from->distance = base->distance - edgeDistance;
+ // Calculate the distance for the vertex opposite to the base
+ if (edge->from == base) {
+ setVertexDistance(edge->to, base->distance + edgeDistance);
+ } else {
+ setVertexDistance(edge->from, base->distance - edgeDistance);
+ }
// Process child anchors
if (edge->type == AnchorData::Sequential)
- interpolateSequentialEdges(edge->from,
- static_cast<SequentialAnchorData *>(edge),
- orientation);
+ interpolateSequentialEdges(static_cast<SequentialAnchorData *>(edge));
else if (edge->type == AnchorData::Parallel)
- interpolateParallelEdges(edge->from,
- static_cast<ParallelAnchorData *>(edge),
- orientation);
+ interpolateParallelEdges(static_cast<ParallelAnchorData *>(edge));
}
-void QGraphicsAnchorLayoutPrivate::interpolateParallelEdges(
- AnchorVertex *base, ParallelAnchorData *data, Orientation orientation)
+void QGraphicsAnchorLayoutPrivate::interpolateParallelEdges(ParallelAnchorData *data)
{
// In parallels the boundary vertices are already calculate, we
// just need to look for sequential groups inside, because only
@@ -2427,46 +2761,44 @@ void QGraphicsAnchorLayoutPrivate::interpolateParallelEdges(
// First edge
if (data->firstEdge->type == AnchorData::Sequential)
- interpolateSequentialEdges(base,
- static_cast<SequentialAnchorData *>(data->firstEdge),
- orientation);
+ interpolateSequentialEdges(static_cast<SequentialAnchorData *>(data->firstEdge));
else if (data->firstEdge->type == AnchorData::Parallel)
- interpolateParallelEdges(base,
- static_cast<ParallelAnchorData *>(data->firstEdge),
- orientation);
+ interpolateParallelEdges(static_cast<ParallelAnchorData *>(data->firstEdge));
// Second edge
if (data->secondEdge->type == AnchorData::Sequential)
- interpolateSequentialEdges(base,
- static_cast<SequentialAnchorData *>(data->secondEdge),
- orientation);
+ interpolateSequentialEdges(static_cast<SequentialAnchorData *>(data->secondEdge));
else if (data->secondEdge->type == AnchorData::Parallel)
- interpolateParallelEdges(base,
- static_cast<ParallelAnchorData *>(data->secondEdge),
- orientation);
+ interpolateParallelEdges(static_cast<ParallelAnchorData *>(data->secondEdge));
}
-void QGraphicsAnchorLayoutPrivate::interpolateSequentialEdges(
- AnchorVertex *base, SequentialAnchorData *data, Orientation orientation)
+void QGraphicsAnchorLayoutPrivate::interpolateSequentialEdges(SequentialAnchorData *data)
{
- AnchorVertex *prev = base;
+ // This method is supposed to handle any sequential anchor, even out-of-order
+ // ones. However, in the current QGAL implementation we should get only the
+ // well behaved ones.
+ Q_ASSERT(data->m_edges.first()->from == data->from);
+ Q_ASSERT(data->m_edges.last()->to == data->to);
- // ### I'm not sure whether this assumption is safe. If not,
- // consider that m_edges.last() could be used instead (so
- // at(0) would be the one to be treated specially).
- Q_ASSERT(base == data->m_edges.at(0)->to || base == data->m_edges.at(0)->from);
+ // At this point, the two outter vertices already have their distance
+ // calculated.
+ // We use the first as the base to calculate the internal ones
+
+ AnchorVertex *prev = data->from;
- // Skip the last
for (int i = 0; i < data->m_edges.count() - 1; ++i) {
- AnchorData *child = data->m_edges.at(i);
- interpolateEdge(prev, child, orientation);
- prev = child->to;
+ AnchorData *edge = data->m_edges.at(i);
+ interpolateEdge(prev, edge);
+
+ // Use the recently calculated vertex as the base for the next one
+ const bool edgeIsForward = (edge->from == prev);
+ prev = edgeIsForward ? edge->to : edge->from;
}
// Treat the last specially, since we already calculated it's end
// vertex, so it's only interesting if it's a complex one
if (data->m_edges.last()->type != AnchorData::Normal)
- interpolateEdge(prev, data->m_edges.last(), orientation);
+ interpolateEdge(prev, data->m_edges.last());
}
bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *> &constraints,
@@ -2492,7 +2824,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *>
// Save sizeAtMinimum results
QList<AnchorData *> variables = getVariables(constraints);
for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = static_cast<AnchorData *>(variables[i]);
+ AnchorData *ad = static_cast<AnchorData *>(variables.at(i));
ad->sizeAtMinimum = ad->result;
Q_ASSERT(ad->sizeAtMinimum >= ad->minSize ||
qAbs(ad->sizeAtMinimum - ad->minSize) < 0.00000001);
@@ -2503,7 +2835,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *>
// Save sizeAtMaximum results
for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = static_cast<AnchorData *>(variables[i]);
+ AnchorData *ad = static_cast<AnchorData *>(variables.at(i));
ad->sizeAtMaximum = ad->result;
// Q_ASSERT(ad->sizeAtMaximum <= ad->maxSize ||
// qAbs(ad->sizeAtMaximum - ad->maxSize) < 0.00000001);
@@ -2537,7 +2869,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint
// A + A_shrinker - A_grower = A_pref
//
for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = variables[i];
+ AnchorData *ad = variables.at(i);
if (ad->skipInPreferred)
continue;
@@ -2568,7 +2900,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint
// Save sizeAtPreferred results
for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = variables[i];
+ AnchorData *ad = variables.at(i);
ad->sizeAtPreferred = ad->result;
}
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 1e11ee2..5f50c85 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -78,66 +78,30 @@ QT_BEGIN_NAMESPACE
Represents a vertex (anchorage point) in the internal graph
*/
struct AnchorVertex {
+ enum Type {
+ Normal = 0,
+ Pair
+ };
+
AnchorVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
- : m_item(item), m_edge(edge) {}
+ : m_item(item), m_edge(edge), m_type(Normal) {}
AnchorVertex()
- : m_item(0), m_edge(Qt::AnchorPoint(0)) {}
+ : m_item(0), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {}
#ifdef QT_DEBUG
inline QString toString() const;
#endif
+
QGraphicsLayoutItem *m_item;
Qt::AnchorPoint m_edge;
+ uint m_type : 1;
// Current distance from this vertex to the layout edge (Left or Top)
// Value is calculated from the current anchors sizes.
qreal distance;
};
-#ifdef QT_DEBUG
-inline QString AnchorVertex::toString() const
-{
- if (!this || !m_item) {
- return QLatin1String("NULL");
- }
- QString edge;
- switch (m_edge) {
- case Qt::AnchorLeft:
- edge = QLatin1String("Left");
- break;
- case Qt::AnchorHorizontalCenter:
- edge = QLatin1String("HorizontalCenter");
- break;
- case Qt::AnchorRight:
- edge = QLatin1String("Right");
- break;
- case Qt::AnchorTop:
- edge = QLatin1String("Top");
- break;
- case Qt::AnchorVerticalCenter:
- edge = QLatin1String("VerticalCenter");
- break;
- case Qt::AnchorBottom:
- edge = QLatin1String("Bottom");
- break;
- default:
- edge = QLatin1String("None");
- break;
- }
- QString itemName;
- if (m_item->isLayout()) {
- itemName = QLatin1String("layout");
- } else {
- if (QGraphicsItem *item = m_item->graphicsItem()) {
- itemName = item->data(0).toString();
- }
- }
- edge.insert(0, QLatin1String("%1_"));
- return edge.arg(itemName);
-}
-#endif
-
/*!
\internal
@@ -256,10 +220,11 @@ struct ParallelAnchorData : public AnchorData
type = AnchorData::Parallel;
orientation = first->orientation;
- // ### Those asserts force that both child anchors have the same direction,
- // but can't we simplify a pair of anchors in opposite directions?
- Q_ASSERT(first->from == second->from);
- Q_ASSERT(first->to == second->to);
+ // This assert whether the child anchors share their vertices
+ Q_ASSERT(((first->from == second->from) && (first->to == second->to)) ||
+ ((first->from == second->to) && (first->to == second->from)));
+
+ // We arbitrarily choose the direction of the first child as "our" direction
from = first->from;
to = first->to;
#ifdef QT_DEBUG
@@ -274,8 +239,73 @@ struct ParallelAnchorData : public AnchorData
AnchorData* firstEdge;
AnchorData* secondEdge;
+
+ QList<QSimplexConstraint *> m_firstConstraints;
+ QList<QSimplexConstraint *> m_secondConstraints;
};
+struct AnchorVertexPair : public AnchorVertex {
+ AnchorVertexPair(AnchorVertex *v1, AnchorVertex *v2, AnchorData *data)
+ : AnchorVertex(), m_first(v1), m_second(v2), m_removedAnchor(data) {
+ m_type = AnchorVertex::Pair;
+ }
+
+ AnchorVertex *m_first;
+ AnchorVertex *m_second;
+
+ AnchorData *m_removedAnchor;
+ QList<AnchorData *> m_firstAnchors;
+ QList<AnchorData *> m_secondAnchors;
+};
+
+#ifdef QT_DEBUG
+inline QString AnchorVertex::toString() const
+{
+ if (!this) {
+ return QLatin1String("NULL");
+ } else if (m_type == Pair) {
+ const AnchorVertexPair *vp = static_cast<const AnchorVertexPair *>(this);
+ return QString::fromAscii("(%1, %2)").arg(vp->m_first->toString()).arg(vp->m_second->toString());
+ } else if (!m_item) {
+ return QString::fromAscii("NULL_%1").arg(quintptr(this));
+ }
+ QString edge;
+ switch (m_edge) {
+ case Qt::AnchorLeft:
+ edge = QLatin1String("Left");
+ break;
+ case Qt::AnchorHorizontalCenter:
+ edge = QLatin1String("HorizontalCenter");
+ break;
+ case Qt::AnchorRight:
+ edge = QLatin1String("Right");
+ break;
+ case Qt::AnchorTop:
+ edge = QLatin1String("Top");
+ break;
+ case Qt::AnchorVerticalCenter:
+ edge = QLatin1String("VerticalCenter");
+ break;
+ case Qt::AnchorBottom:
+ edge = QLatin1String("Bottom");
+ break;
+ default:
+ edge = QLatin1String("None");
+ break;
+ }
+ QString itemName;
+ if (m_item->isLayout()) {
+ itemName = QLatin1String("layout");
+ } else {
+ if (QGraphicsItem *item = m_item->graphicsItem()) {
+ itemName = item->data(0).toString();
+ }
+ }
+ edge.insert(0, QLatin1String("%1_"));
+ return edge.arg(itemName);
+}
+#endif
+
/*!
\internal
@@ -432,20 +462,33 @@ public:
QLayoutStyleInfo &styleInfo() const;
- // Activation methods
- bool simplifyGraph(Orientation orientation);
- bool simplifyGraphIteration(Orientation orientation, bool *feasible);
- void restoreSimplifiedGraph(Orientation orientation);
+ AnchorData *addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible);
+ // Activation
void calculateGraphs();
void calculateGraphs(Orientation orientation);
+ // Simplification
+ bool simplifyGraph(Orientation orientation);
+ bool simplifyVertices(Orientation orientation);
+ bool simplifyGraphIteration(Orientation orientation, bool *feasible);
+
+ bool replaceVertex(Orientation orientation, AnchorVertex *oldV,
+ AnchorVertex *newV, const QList<AnchorData *> &edges);
+
+
+ void restoreSimplifiedGraph(Orientation orientation);
+ void restoreSimplifiedAnchor(AnchorData *edge);
+ void restoreSimplifiedConstraints(ParallelAnchorData *parallel);
+ void restoreVertices(Orientation orientation);
+
bool calculateTrunk(Orientation orientation, const GraphPath &trunkPath,
const QList<QSimplexConstraint *> &constraints,
const QList<AnchorData *> &variables);
bool calculateNonTrunk(const QList<QSimplexConstraint *> &constraints,
const QList<AnchorData *> &variables);
+ // Support functions for calculateGraph()
bool refreshAllSizeHints(Orientation orientation);
void findPaths(Orientation orientation);
void constraintsFromPaths(Orientation orientation);
@@ -465,6 +508,17 @@ public:
return internalVertex(qMakePair(const_cast<QGraphicsLayoutItem *>(item), edge));
}
+ inline void changeLayoutVertex(Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV)
+ {
+ if (layoutFirstVertex[orientation] == oldV)
+ layoutFirstVertex[orientation] = newV;
+ else if (layoutCentralVertex[orientation] == oldV)
+ layoutCentralVertex[orientation] = newV;
+ else if (layoutLastVertex[orientation] == oldV)
+ layoutLastVertex[orientation] = newV;
+ }
+
+
AnchorVertex *addInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge);
void removeInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge);
@@ -473,11 +527,9 @@ public:
void calculateVertexPositions(Orientation orientation);
void setupEdgesInterpolation(Orientation orientation);
- void interpolateEdge(AnchorVertex *base, AnchorData *edge, Orientation orientation);
- void interpolateSequentialEdges(AnchorVertex *base, SequentialAnchorData *edge,
- Orientation orientation);
- void interpolateParallelEdges(AnchorVertex *base, ParallelAnchorData *edge,
- Orientation orientation);
+ void interpolateEdge(AnchorVertex *base, AnchorData *edge);
+ void interpolateSequentialEdges(SequentialAnchorData *edge);
+ void interpolateParallelEdges(ParallelAnchorData *edge);
// Linear Programming solver methods
bool solveMinMax(const QList<QSimplexConstraint *> &constraints,
@@ -510,6 +562,10 @@ public:
AnchorVertex *layoutCentralVertex[2];
AnchorVertex *layoutLastVertex[2];
+ // Combined anchors in order of creation
+ QList<AnchorVertexPair *> simplifiedVertices[2];
+ QList<AnchorData *> anchorsFromSimplifiedVertices[2];
+
// Graph paths and constraints, for both orientations
QMultiHash<AnchorVertex *, GraphPath> graphPaths[2];
QList<QSimplexConstraint *> constraints[2];
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index a236b14..9d495e9 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3349,6 +3349,9 @@ QPointF QGraphicsItem::pos() const
*/
void QGraphicsItem::setX(qreal x)
{
+ if (d_ptr->inDestructor)
+ return;
+
d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y()));
}
@@ -3370,6 +3373,9 @@ void QGraphicsItem::setX(qreal x)
*/
void QGraphicsItem::setY(qreal y)
{
+ if (d_ptr->inDestructor)
+ return;
+
d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y));
}
@@ -3435,6 +3441,9 @@ void QGraphicsItem::setPos(const QPointF &pos)
if (d_ptr->pos == pos)
return;
+ if (d_ptr->inDestructor)
+ return;
+
// Update and repositition.
if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
d_ptr->setPosHelper(pos);
@@ -10803,7 +10812,7 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
}
QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffectSource::PixmapPadMode mode) const
+ QGraphicsEffect::PixmapPadMode mode) const
{
const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
if (!info && deviceCoordinates) {
@@ -10819,9 +10828,9 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
const QRectF sourceRect = boundingRect(system);
QRect effectRect;
- if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) {
+ if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
- } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) {
+ } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
// adjust by 1.5 to account for cosmetic pens
effectRect = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5).toAlignedRect();
} else {
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index afc2198..75c8246 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -633,7 +633,7 @@ public:
void draw(QPainter *);
QPixmap pixmap(Qt::CoordinateSystem system,
QPoint *offset,
- QGraphicsEffectSource::PixmapPadMode mode) const;
+ QGraphicsEffect::PixmapPadMode mode) const;
QGraphicsItem *item;
QGraphicsItemPaintInfo *info;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index d1845c2..13f31b8 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4208,7 +4208,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &
QRect br = pixmapExposed.boundingRect();
// Don't use subpixmap if we get a full update.
- if (pixmapExposed.isEmpty() || (pixmapExposed.numRects() == 1 && br.contains(pix->rect()))) {
+ if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) {
pix->fill(Qt::transparent);
pixmapPainter.begin(pix);
} else {
@@ -4656,7 +4656,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
sourced->lastEffectTransform = painter->worldTransform();
sourced->invalidateCache();
}
- item->d_ptr->graphicsEffect->draw(painter, source);
+ item->d_ptr->graphicsEffect->draw(painter);
painter->setWorldTransform(restoreTransform);
sourced->info = 0;
} else
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 87585a2..27fd09e 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -978,7 +978,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg
// Step 2) If the expose region is a simple rect and the view is only
// translated or scaled, search for items using
// QGraphicsScene::items(QRectF).
- bool simpleRectLookup = exposedRegion.numRects() == 1 && matrix.type() <= QTransform::TxScale;
+ bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale;
if (simpleRectLookup) {
return scene->items(exposedRegionSceneBounds,
Qt::IntersectsItemBoundingRect,
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 6f910c7..d9c65bb 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -318,6 +318,12 @@ void QGraphicsWidget::resize(const QSizeF &size)
*/
/*!
+ \property QGraphicsWidget::sizePolicy
+ \brief the size policy for the widget
+ \sa sizePolicy(), setSizePolicy(), QWidget::sizePolicy()
+*/
+
+/*!
\property QGraphicsWidget::geometry
\brief the geometry of the widget
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index 38f72f0..05d3a49 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -77,6 +77,7 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay
Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize)
Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize)
Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize)
+ Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 4b6fcba..f3eb7c3 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE
static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels
{
int i;
- if (image->depth() == 1 && image->numColors() == 2) {
+ if (image->depth() == 1 && image->colorCount() == 2) {
register uint *p = (uint *)image->bits();
- int nbytes = image->numBytes();
+ int nbytes = image->byteCount();
for (i=0; i<nbytes/4; i++) {
*p = ~*p;
p++;
@@ -246,7 +246,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
if (depth != 32) {
ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
- image.setNumColors(ncols);
+ image.setColorCount(ncols);
}
image.setDotsPerMeterX(bi.biXPelsPerMeter);
@@ -526,7 +526,7 @@ bool qt_write_dib(QDataStream &s, QImage image)
if (!d->isWritable())
return false;
- if (image.depth() == 8 && image.numColors() <= 16) {
+ if (image.depth() == 8 && image.colorCount() <= 16) {
bpl_bmp = (((bpl+1)/2+3)/4)*4;
nbits = 4;
} else if (image.depth() == 32) {
@@ -554,23 +554,23 @@ bool qt_write_dib(QDataStream &s, QImage image)
bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX()
: 2834; // 72 dpi default
bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834;
- bi.biClrUsed = image.numColors();
- bi.biClrImportant = image.numColors();
+ bi.biClrUsed = image.colorCount();
+ bi.biClrImportant = image.colorCount();
s << bi; // write info header
if (s.status() != QDataStream::Ok)
return false;
if (image.depth() != 32) { // write color table
- uchar *color_table = new uchar[4*image.numColors()];
+ uchar *color_table = new uchar[4*image.colorCount()];
uchar *rgb = color_table;
QVector<QRgb> c = image.colorTable();
- for (int i=0; i<image.numColors(); i++) {
+ for (int i=0; i<image.colorCount(); i++) {
*rgb++ = qBlue (c[i]);
*rgb++ = qGreen(c[i]);
*rgb++ = qRed (c[i]);
*rgb++ = 0;
}
- if (d->write((char *)color_table, 4*image.numColors()) == -1) {
+ if (d->write((char *)color_table, 4*image.colorCount()) == -1) {
delete [] color_table;
return false;
}
@@ -754,7 +754,7 @@ bool QBmpHandler::write(const QImage &img)
int bpl = image.bytesPerLine();
// Code partially repeated in qt_write_dib
- if (image.depth() == 8 && image.numColors() <= 16) {
+ if (image.depth() == 8 && image.colorCount() <= 16) {
bpl_bmp = (((bpl+1)/2+3)/4)*4;
} else if (image.depth() == 32) {
bpl_bmp = ((image.width()*24+31)/32)*4;
@@ -771,7 +771,7 @@ bool QBmpHandler::write(const QImage &img)
// write file header
bf.bfReserved1 = 0;
bf.bfReserved2 = 0;
- bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.numColors() * 4;
+ bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4;
bf.bfSize = bf.bfOffBits + bpl_bmp*image.height();
s << bf;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 21ca1e3..6d96d7a 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -449,7 +449,7 @@ bool QImageData::checkForAlphaPixels() const
to the pixel() function. The pixel() function returns the color
as a QRgb value indepedent of the image's format.
- In case of monochrome and 8-bit images, the numColors() and
+ In case of monochrome and 8-bit images, the colorCount() and
colorTable() functions provide information about the color
components used to store the image data: The colorTable() function
returns the image's entire color table. To obtain a single entry,
@@ -484,7 +484,7 @@ bool QImageData::checkForAlphaPixels() const
depths are 1 (monochrome), 8 and 32 (for more information see the
\l {QImage#Image Formats}{Image Formats} section).
- The format(), bytesPerLine(), and numBytes() functions provide
+ The format(), bytesPerLine(), and byteCount() functions provide
low-level information about the data stored in the image.
The cacheKey() function returns a number that uniquely
@@ -623,7 +623,7 @@ bool QImageData::checkForAlphaPixels() const
\o Sets the color table used to translate color indexes. Only
monochrome and 8-bit formats.
\row
- \o setNumColors()
+ \o setColorCount()
\o Resizes the color table. Only monochrome and 8-bit formats.
\endtable
@@ -906,7 +906,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
*/
QImage::QImage(uchar* data, int width, int height, Format format)
: QPaintDevice()
@@ -928,7 +928,7 @@ QImage::QImage(uchar* data, int width, int height, Format format)
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
Unlike the similar QImage constructor that takes a non-const data buffer,
this version will never alter the contents of the buffer. For example,
@@ -954,7 +954,7 @@ QImage::QImage(const uchar* data, int width, int height, Format format)
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
*/
QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format)
:QPaintDevice()
@@ -974,7 +974,7 @@ QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format form
If \a format is an indexed color format, the image color table is
initially empty and must be sufficiently expanded with
- setNumColors() or setColorTable() before the image is used.
+ setColorCount() or setColorTable() before the image is used.
Unlike the similar QImage constructor that takes a non-const data buffer,
this version will never alter the contents of the buffer. For example,
@@ -1126,7 +1126,7 @@ QImage::QImage(const QImage &image)
Use the constructor that accepts a width, a height and a format
(i.e. specifying the depth and bit order), in combination with the
- setNumColors() function, instead.
+ setColorCount() function, instead.
\oldcode
QImage image(width, height, depth, numColors);
@@ -1135,15 +1135,15 @@ QImage::QImage(const QImage &image)
// For 8 bit images the default number of colors is 256. If
// another number of colors is required it can be specified
- // using the setNumColors() function.
- image.setNumColors(numColors);
+ // using the setColorCount() function.
+ image.setColorCount(numColors);
\endcode
*/
-QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
+QImage::QImage(int w, int h, int depth, int colorCount, Endian bitOrder)
: QPaintDevice()
{
- d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), numColors);
+ d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), colorCount);
}
/*!
@@ -1152,7 +1152,7 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
Use the constructor that accepts a size and a format
(i.e. specifying the depth and bit order), in combination with the
- setNumColors() function, instead.
+ setColorCount() function, instead.
\oldcode
QSize mySize(width, height);
@@ -1163,8 +1163,8 @@ QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
// For 8 bit images the default number of colors is 256. If
// another number of colors is required it can be specified
- // using the setNumColors() function.
- image.setNumColors(numColors);
+ // using the setColorCount() function.
+ image.setColorCount(numColors);
\endcode
*/
QImage::QImage(const QSize& size, int depth, int numColors, Endian bitOrder)
@@ -1232,7 +1232,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, const QRgb* colortable, int
for (int i = 0; i < numColors; ++i)
d->colortable[i] = colortable[i];
} else if (numColors) {
- setNumColors(numColors);
+ setColorCount(numColors);
}
}
@@ -1283,7 +1283,7 @@ QImage::QImage(uchar* data, int w, int h, int depth, int bpl, const QRgb* colort
for (int i = 0; i < numColors; ++i)
d->colortable[i] = colortable[i];
} else if (numColors) {
- setNumColors(numColors);
+ setColorCount(numColors);
}
}
#endif // Q_WS_QWS
@@ -1592,17 +1592,31 @@ int QImage::depth() const
}
/*!
+ \obsolete
\fn int QImage::numColors() const
Returns the size of the color table for the image.
- Notice that numColors() returns 0 for 32-bpp images because these
+ \sa setColorCount()
+*/
+int QImage::numColors() const
+{
+ return d ? d->colortable.size() : 0;
+}
+
+/*!
+ \since 4.6
+ \fn int QImage::colorCount() const
+
+ Returns the size of the color table for the image.
+
+ Notice that colorCount() returns 0 for 32-bpp images because these
images do not use color tables, but instead encode pixel values as
ARGB quadruplets.
- \sa setNumColors(), {QImage#Image Information}{Image Information}
+ \sa setColorCount(), {QImage#Image Information}{Image Information}
*/
-int QImage::numColors() const
+int QImage::colorCount() const
{
return d ? d->colortable.size() : 0;
}
@@ -1711,7 +1725,7 @@ void QImage::setColorTable(const QVector<QRgb> colors)
Returns a list of the colors contained in the image's color table,
or an empty list if the image does not have a color table
- \sa setColorTable(), numColors(), color()
+ \sa setColorTable(), colorCount(), color()
*/
QVector<QRgb> QImage::colorTable() const
{
@@ -1720,12 +1734,24 @@ QVector<QRgb> QImage::colorTable() const
/*!
+ \obsolete
+ Returns the number of bytes occupied by the image data.
+
+ \sa byteCount()
+*/
+int QImage::numBytes() const
+{
+ return d ? d->nbytes : 0;
+}
+
+/*!
+ \since 4.6
Returns the number of bytes occupied by the image data.
\sa bytesPerLine(), bits(), {QImage#Image Information}{Image
Information}
*/
-int QImage::numBytes() const
+int QImage::byteCount() const
{
return d ? d->nbytes : 0;
}
@@ -1733,7 +1759,7 @@ int QImage::numBytes() const
/*!
Returns the number of bytes per image scanline.
- This is equivalent to numBytes()/ height().
+ This is equivalent to byteCount() / height().
\sa scanLine()
*/
@@ -1756,7 +1782,7 @@ int QImage::bytesPerLine() const
*/
QRgb QImage::color(int i) const
{
- Q_ASSERT(i < numColors());
+ Q_ASSERT(i < colorCount());
return d ? d->colortable.at(i) : QRgb(uint(-1));
}
@@ -1767,9 +1793,9 @@ QRgb QImage::color(int i) const
given to \a colorValue. The color value is an ARGB quadruplet.
If \a index is outside the current size of the color table, it is
- expanded with setNumColors().
+ expanded with setColorCount().
- \sa color(), numColors(), setColorTable(), {QImage#Pixel Manipulation}{Pixel
+ \sa color(), colorCount(), setColorTable(), {QImage#Pixel Manipulation}{Pixel
Manipulation}
*/
void QImage::setColor(int i, QRgb c)
@@ -1787,7 +1813,7 @@ void QImage::setColor(int i, QRgb c)
return;
if (i >= d->colortable.size())
- setNumColors(i+1);
+ setColorCount(i+1);
d->colortable[i] = c;
d->has_alpha_clut |= (qAlpha(c) != 255);
}
@@ -1844,7 +1870,7 @@ const uchar *QImage::scanLine(int i) const
data, thus ensuring that this QImage is the only one using the
current return value.
- \sa scanLine(), numBytes()
+ \sa scanLine(), byteCount()
*/
uchar *QImage::bits()
{
@@ -2025,8 +2051,21 @@ void QImage::invertPixels(InvertMode mode)
#endif
/*!
+ \obsolete
Resizes the color table to contain \a numColors entries.
+ \sa setColorCount()
+*/
+
+void QImage::setNumColors(int numColors)
+{
+ setColorCount(numColors);
+}
+
+/*!
+ \since 4.6
+ Resizes the color table to contain \a colorCount entries.
+
If the color table is expanded, all the extra colors will be set to
transparent (i.e qRgba(0, 0, 0, 0)).
@@ -2034,14 +2073,14 @@ void QImage::invertPixels(InvertMode mode)
have entries for all the pixel/index values present in the image,
otherwise the results are undefined.
- \sa numColors(), colorTable(), setColor(), {QImage#Image
+ \sa colorsCount(), colorTable(), setColor(), {QImage#Image
Transformations}{Image Transformations}
*/
-void QImage::setNumColors(int numColors)
+void QImage::setColorCount(int colorCount)
{
if (!d) {
- qWarning("QImage::setNumColors: null image");
+ qWarning("QImage::setColorCount: null image");
return;
}
@@ -2051,17 +2090,16 @@ void QImage::setNumColors(int numColors)
if (!d)
return;
- if (numColors == d->colortable.size())
+ if (colorCount == d->colortable.size())
return;
- if (numColors <= 0) { // use no color table
+ if (colorCount <= 0) { // use no color table
d->colortable = QVector<QRgb>();
return;
}
int nc = d->colortable.size();
- d->colortable.resize(numColors);
- for (int i = nc; i < numColors; ++i)
+ d->colortable.resize(colorCount);
+ for (int i = nc; i < colorCount; ++i)
d->colortable[i] = 0;
-
}
/*!
@@ -3674,7 +3712,7 @@ QRgb QImage::pixel(int x, int y) const
otherwise the parameter must be a QRgb value.
If \a position is not a valid coordinate pair in the image, or if
- \a index_or_rgb >= numColors() in the case of monochrome and
+ \a index_or_rgb >= colorCount() in the case of monochrome and
8-bit images, the result is undefined.
\warning This function is expensive due to the call of the internal
@@ -3835,7 +3873,7 @@ bool QImage::allGray() const
} else {
if (d->colortable.isEmpty())
return true;
- for (int i = 0; i < numColors(); i++)
+ for (int i = 0; i < colorCount(); i++)
if (!qIsGray(d->colortable.at(i)))
return false;
}
@@ -3862,7 +3900,7 @@ bool QImage::isGrayscale() const
case 16:
return allGray();
case 8: {
- for (int i = 0; i < numColors(); i++)
+ for (int i = 0; i < colorCount(); i++)
if (d->colortable.at(i) != qRgb(i,i,i))
return false;
return true;
@@ -4128,7 +4166,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const
int w = width();
int h = height();
QImage m(w, h, Format_MonoLSB);
- m.setNumColors(2);
+ m.setColorCount(2);
m.setColor(0, QColor(Qt::color0).rgba());
m.setColor(1, QColor(Qt::color1).rgba());
m.fill(0xff);
@@ -5703,7 +5741,7 @@ QImage QImage::alphaChannel() const
int h = d->height;
QImage image(w, h, Format_Indexed8);
- image.setNumColors(256);
+ image.setColorCount(256);
// set up gray scale table.
for (int i=0; i<256; ++i)
@@ -5833,7 +5871,7 @@ static QImage smoothScaled(const QImage &source, int w, int h) {
static QImage rotated90(const QImage &image) {
QImage out(image.height(), image.width(), image.format());
- if (image.numColors() > 0)
+ if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
int h = image.height();
@@ -5872,7 +5910,7 @@ static QImage rotated90(const QImage &image) {
break;
default:
for (int y=0; y<h; ++y) {
- if (image.numColors())
+ if (image.colorCount())
for (int x=0; x<w; ++x)
out.setPixel(h-y-1, x, image.pixelIndex(x, y));
else
@@ -5892,7 +5930,7 @@ static QImage rotated180(const QImage &image) {
static QImage rotated270(const QImage &image) {
QImage out(image.height(), image.width(), image.format());
- if (image.numColors() > 0)
+ if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
int h = image.height();
@@ -5931,7 +5969,7 @@ static QImage rotated270(const QImage &image) {
break;
default:
for (int y=0; y<h; ++y) {
- if (image.numColors())
+ if (image.colorCount())
for (int x=0; x<w; ++x)
out.setPixel(y, w-x-1, image.pixelIndex(x, y));
else
@@ -6071,16 +6109,16 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
if (dImage.d->colortable.size() < 256) {
// colors are left in the color table, so pick that one as transparent
dImage.d->colortable.append(0x0);
- memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.numBytes());
+ memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount());
} else {
- memset(dImage.bits(), 0, dImage.numBytes());
+ memset(dImage.bits(), 0, dImage.byteCount());
}
break;
case 1:
case 16:
case 24:
case 32:
- memset(dImage.bits(), 0x00, dImage.numBytes());
+ memset(dImage.bits(), 0x00, dImage.byteCount());
break;
}
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 1ac56a7..d8809ef 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -165,18 +165,21 @@ public:
QRect rect() const;
int depth() const;
- int numColors() const;
+ QT_DEPRECATED int numColors() const;
+ int colorCount() const;
QRgb color(int i) const;
void setColor(int i, QRgb c);
- void setNumColors(int);
+ QT_DEPRECATED void setNumColors(int);
+ void setColorCount(int);
bool allGray() const;
bool isGrayscale() const;
uchar *bits();
const uchar *bits() const;
- int numBytes() const;
+ QT_DEPRECATED int numBytes() const;
+ int byteCount() const;
uchar *scanLine(int);
const uchar *scanLine(int) const;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index dfeea76..985a20b 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -2150,6 +2150,13 @@ QPixmapData* QPixmap::pixmapData() const
*/
/*! \fn int QPixmap::numCols() const
+ \obsolete
+ \internal
+ \sa colorCount()
+*/
+
+/*! \fn int QPixmap::colorCount() const
+ \since 4.6
\internal
*/
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index d11bd03..d95b4ee 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -185,7 +185,8 @@ public:
const uchar *qwsBits() const;
int qwsBytesPerLine() const;
QRgb *clut() const;
- int numCols() const;
+ QT_DEPRECATED int numCols() const;
+ int colorCount() const;
#elif defined(Q_WS_MAC)
Qt::HANDLE macQDHandle() const;
Qt::HANDLE macQDAlphaHandle() const;
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 9209d45..6175931 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -248,7 +248,7 @@ void QMacPixmapData::fromImage(const QImage &img,
} else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) {
conv8 = d == 1; // native depth wanted
} else if (d == 1) {
- if (image.numColors() == 2) {
+ if (image.colorCount() == 2) {
QRgb c0 = image.color(0); // Auto: convert to best
QRgb c1 = image.color(1);
conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255);
@@ -339,7 +339,7 @@ void QMacPixmapData::fromImage(const QImage &img,
bool alphamap = image.depth() == 32;
if (sfmt == QImage::Format_Indexed8) {
const QVector<QRgb> rgb = image.colorTable();
- for (int i = 0, count = image.numColors(); i < count; ++i) {
+ for (int i = 0, count = image.colorCount(); i < count; ++i) {
const int alpha = qAlpha(rgb[i]);
if (alpha != 0xff) {
alphamap = true;
@@ -355,13 +355,13 @@ void QMacPixmapData::fromImage(const QImage &img,
int get_index(QImage * qi,QRgb mycol)
{
int loopc;
- for(loopc=0;loopc<qi->numColors();loopc++) {
+ for(loopc=0;loopc<qi->colorCount();loopc++) {
if(qi->color(loopc)==mycol)
return loopc;
}
- qi->setNumColors(qi->numColors()+1);
- qi->setColor(qi->numColors(),mycol);
- return qi->numColors();
+ qi->setColorCount(qi->colorCount()+1);
+ qi->setColor(qi->colorCount(),mycol);
+ return qi->colorCount();
}
QImage QMacPixmapData::toImage() const
@@ -376,7 +376,7 @@ QImage QMacPixmapData::toImage() const
const uint sbpr = bytesPerRow;
if (format == QImage::Format_MonoLSB) {
image.fill(0);
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
for (int y = 0; y < h; ++y) {
diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp
index a8516a5..69626ed 100644
--- a/src/gui/image/qpixmap_qws.cpp
+++ b/src/gui/image/qpixmap_qws.cpp
@@ -124,9 +124,14 @@ QRgb* QPixmap::clut() const
int QPixmap::numCols() const
{
+ return colorCount();
+}
+
+int QPixmap::colorCount() const
+{
if (data && data->classId() == QPixmapData::RasterClass) {
const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
- return d->image.numColors();
+ return d->image.colorCount();
}
return 0;
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index fc76dc3..1b01e6f 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -119,7 +119,7 @@ void QRasterPixmapData::resize(int width, int height)
is_null = (w <= 0 || h <= 0);
if (pixelType() == BitmapType && !image.isNull()) {
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
}
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
index cd8a4d4..f7a880c 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -443,7 +443,7 @@ void QS60PixmapData::fromSymbianBitmap(CFbsBitmap* bitmap)
// Create default palette if needed
if (cfbsBitmap->DisplayMode() == EGray2) {
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
@@ -526,13 +526,13 @@ void QS60PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags
const uchar *sptr = const_cast<const QImage &>(sourceImage).bits();
symbianBitmapDataAccess->beginDataAccess(cfbsBitmap);
uchar *dptr = (uchar*)cfbsBitmap->DataAddress();
- Mem::Copy(dptr, sptr, sourceImage.numBytes());
+ Mem::Copy(dptr, sptr, sourceImage.byteCount());
symbianBitmapDataAccess->endDataAccess(cfbsBitmap);
UPDATE_BUFFER();
if (destFormat == QImage::Format_MonoLSB) {
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
} else {
@@ -835,7 +835,7 @@ void* QS60PixmapData::toNativeType(NativeType type)
symbianBitmapDataAccess->beginDataAccess(newBitmap);
uchar *dptr = (uchar*)newBitmap->DataAddress();
- Mem::Copy(dptr, sptr, source.numBytes());
+ Mem::Copy(dptr, sptr, source.byteCount());
symbianBitmapDataAccess->endDataAccess(newBitmap);
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index c735031..3f297df 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -464,7 +464,7 @@ void QX11PixmapData::fromImage(const QImage &img,
} else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) {
conv8 = (d == 1); // native depth wanted
} else if (d == 1) {
- if (image.numColors() == 2) {
+ if (image.colorCount() == 2) {
QRgb c0 = image.color(0); // Auto: convert to best
QRgb c1 = image.color(1);
conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255);
@@ -489,7 +489,7 @@ void QX11PixmapData::fromImage(const QImage &img,
Visual *visual = (Visual *)xinfo.visual();
XImage *xi = 0;
bool trucol = (visual->c_class >= TrueColor);
- int nbytes = image.numBytes();
+ int nbytes = image.byteCount();
uchar *newbits= 0;
#ifndef QT_NO_XRENDER
@@ -631,7 +631,7 @@ void QX11PixmapData::fromImage(const QImage &img,
if (d8) { // setup pixel translation
QVector<QRgb> ctable = cimage.colorTable();
- for (int i=0; i < cimage.numColors(); i++) {
+ for (int i=0; i < cimage.colorCount(); i++) {
int r = qRed (ctable[i]);
int g = qGreen(ctable[i]);
int b = qBlue (ctable[i]);
@@ -957,8 +957,8 @@ void QX11PixmapData::fromImage(const QImage &img,
if (d == 8 && !trucol) { // 8 bit pixmap
int pop[256]; // pixel popularity
- if (image.numColors() == 0)
- image.setNumColors(1);
+ if (image.colorCount() == 0)
+ image.setColorCount(1);
const QImage &cimage = image;
memset(pop, 0, sizeof(int)*256); // reset popularity array
@@ -988,11 +988,11 @@ void QX11PixmapData::fromImage(const QImage &img,
int mindist;
};
int ncols = 0;
- for (int i=0; i< cimage.numColors(); i++) { // compute number of colors
+ for (int i=0; i< cimage.colorCount(); i++) { // compute number of colors
if (pop[i] > 0)
ncols++;
}
- for (int i = cimage.numColors(); i < 256; i++) // ignore out-of-range pixels
+ for (int i = cimage.colorCount(); i < 256; i++) // ignore out-of-range pixels
pop[i] = 0;
// works since we make sure above to have at least
@@ -1651,7 +1651,7 @@ QImage QX11PixmapData::toImage() const
}
if (d == 1) { // bitmap
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(0, qRgb(255,255,255));
image.setColor(1, qRgb(0,0,0));
} else if (!trucol) { // pixmap with colormap
@@ -1707,10 +1707,10 @@ QImage QX11PixmapData::toImage() const
int trans;
if (ncols < 256) {
trans = ncols++;
- image.setNumColors(ncols); // create color table
+ image.setColorCount(ncols); // create color table
image.setColor(trans, 0x00000000);
} else {
- image.setNumColors(ncols); // create color table
+ image.setColorCount(ncols); // create color table
// oh dear... no spare "transparent" pixel.
// use first pixel in image (as good as any).
trans = image.scanLine(0)[0];
@@ -1733,7 +1733,7 @@ QImage QX11PixmapData::toImage() const
}
}
} else {
- image.setNumColors(ncols); // create color table
+ image.setColorCount(ncols); // create color table
}
QVector<QColor> colors = QColormap::instance(xinfo.screen()).colormap();
int j = 0;
diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp
index 10194e4..38f6b5d 100644
--- a/src/gui/image/qpixmapdata.cpp
+++ b/src/gui/image/qpixmapdata.cpp
@@ -201,7 +201,7 @@ QBitmap QPixmapData::mask() const
if (mask.isNull()) // allocation failed
return QBitmap();
- mask.setNumColors(2);
+ mask.setColorCount(2);
mask.setColor(0, QColor(Qt::color0).rgba());
mask.setColor(1, QColor(Qt::color1).rgba());
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index d1bb92a..41e2923 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -113,7 +113,8 @@ public:
inline int width() const { return w; }
inline int height() const { return h; }
- inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
+ QT_DEPRECATED inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
+ inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); }
inline int depth() const { return d; }
inline bool isNull() const { return is_null; }
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index d83ef2c..c0b840a 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -490,7 +490,7 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q
which is applied when \l{QPixmapFilter::}{draw()} is called.
The filter lets you specialize the radius of the blur as well
- as hint as to whether to prefer performance or quality.
+ as hints as to whether to prefer performance or quality.
By default, the blur effect is produced by applying an exponential
filter generated from the specified blurRadius(). Paint engines
@@ -505,10 +505,10 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q
class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate
{
public:
- QPixmapBlurFilterPrivate() : radius(5), hint(QGraphicsBlurEffect::PerformanceHint) {}
+ QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {}
qreal radius;
- QGraphicsBlurEffect::BlurHint hint;
+ QGraphicsBlurEffect::BlurHints hints;
};
@@ -554,9 +554,9 @@ qreal QPixmapBlurFilter::radius() const
}
/*!
- Setting the blur hint to PerformanceHint causes the implementation
+ Setting the blur hints to PerformanceHint causes the implementation
to trade off visual quality to blur the image faster. Setting the
- blur hint to QualityHint causes the implementation to improve
+ blur hints to QualityHint causes the implementation to improve
visual quality at the expense of speed.
AnimationHint causes the implementation to optimize for animating
@@ -568,21 +568,21 @@ qreal QPixmapBlurFilter::radius() const
\internal
*/
-void QPixmapBlurFilter::setBlurHint(QGraphicsBlurEffect::BlurHint hint)
+void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
{
Q_D(QPixmapBlurFilter);
- d->hint = hint;
+ d->hints = hints;
}
/*!
- Gets the blur hint of the blur filter.
+ Gets the blur hints of the blur filter.
\internal
*/
-QGraphicsBlurEffect::BlurHint QPixmapBlurFilter::blurHint() const
+QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const
{
Q_D(const QPixmapBlurFilter);
- return d->hint;
+ return d->hints;
}
/*!
@@ -685,7 +685,7 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap
QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter);
if (blurFilter) {
blurFilter->setRadius(d->radius);
- blurFilter->setBlurHint(d->hint);
+ blurFilter->setBlurHints(d->hints);
blurFilter->draw(painter, p, src, srcRect);
return;
}
diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h
index 2573fc7..46e744e 100644
--- a/src/gui/image/qpixmapfilter_p.h
+++ b/src/gui/image/qpixmapfilter_p.h
@@ -132,10 +132,10 @@ public:
~QPixmapBlurFilter();
void setRadius(qreal radius);
- void setBlurHint(QGraphicsBlurEffect::BlurHint hint);
+ void setBlurHints(QGraphicsBlurEffect::BlurHints hints);
qreal radius() const;
- QGraphicsBlurEffect::BlurHint blurHint() const;
+ QGraphicsBlurEffect::BlurHints blurHints() const;
QRectF boundingRectFor(const QRectF &rect) const;
void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 44d689d..14c863b 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -171,7 +171,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
if (image.isNull())
return;
}
- image.setNumColors(2);
+ image.setColorCount(2);
image.setColor(1, qRgb(0,0,0));
image.setColor(0, qRgb(255,255,255));
} else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
@@ -199,7 +199,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
if (image.isNull())
return;
}
- image.setNumColors(ncols);
+ image.setColorCount(ncols);
for (int i=0; i<ncols; i++) {
int c = i*255/(ncols-1);
image.setColor(i, qRgba(c,c,c,0xff));
@@ -230,7 +230,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
if (image.isNull())
return;
}
- image.setNumColors(info_ptr->num_palette);
+ image.setColorCount(info_ptr->num_palette);
int i = 0;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
while (i < info_ptr->num_trans) {
@@ -508,7 +508,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
// sanity check palette entries
if (color_type == PNG_COLOR_TYPE_PALETTE
&& outImage->format() == QImage::Format_Indexed8) {
- int color_table_size = outImage->numColors();
+ int color_table_size = outImage->colorCount();
for (int y=0; y<(int)height; ++y) {
uchar *p = outImage->scanLine(y);
uchar *end = p + width;
@@ -762,9 +762,9 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image_in,
png_colorp palette = 0;
png_bytep copy_trans = 0;
- if (image.numColors()) {
+ if (image.colorCount()) {
// Paletted
- int num_palette = image.numColors();
+ int num_palette = image.colorCount();
palette = new png_color[num_palette];
png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
int* trans = new int[num_palette];
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 28e4a2a..8ec9efb 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -242,11 +242,11 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
}
if (nbits == 1) { // bitmap
- outImage->setNumColors(2);
+ outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
} else if (nbits == 8) { // graymap
- outImage->setNumColors(maxc+1);
+ outImage->setColorCount(maxc+1);
for (int i=0; i<=maxc; i++)
outImage->setColor(i, qRgb(i*255/maxc,i*255/maxc,i*255/maxc));
}
@@ -287,7 +287,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
}
}
- if (image.depth() == 1 && image.numColors() == 2) {
+ if (image.depth() == 1 && image.colorCount() == 2) {
if (qGray(image.color(0)) < qGray(image.color(1))) {
// 0=dark/black, 1=light/white - invert
image.detach();
diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp
index 1c74351..0d76ea0 100644
--- a/src/gui/image/qxbmhandler.cpp
+++ b/src/gui/image/qxbmhandler.cpp
@@ -135,7 +135,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage)
return false;
}
- outImage->setNumColors(2);
+ outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index 4bdd16e..ac4711a 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -895,7 +895,7 @@ static bool read_xpm_body(
if (image.isNull())
return false;
}
- image.setNumColors(ncols);
+ image.setColorCount(ncols);
}
QMap<quint64, int> colorMap;
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 3b3036d..3e00dba 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -1059,7 +1059,7 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette,
painter.end();
QPixmap selected = QPixmap(QPixmap::fromImage(img));
- int n = (img.numBytes() >> 10) + 1;
+ int n = (img.byteCount() >> 10) + 1;
if (QPixmapCache::cacheLimit() < n)
QPixmapCache::setCacheLimit(n);
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index 5f5650f..6f3cbaf 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -286,7 +286,7 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
Actions with a softkey role defined are only visible in the softkey bar when the widget containing
the action has focus. If no widget currently has focus, the softkey framework will traverse up the
- widget parent heirarchy looking for a widget containing softkey actions.
+ widget parent hierarchy looking for a widget containing softkey actions.
*/
/*!
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 387c29b..05e75a2 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -832,6 +832,7 @@ void qt_init(QApplicationPrivate *priv, int)
priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo;
priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments;
#elif !defined(Q_WS_WINCE)
+ #if !defined(QT_NO_NATIVE_GESTURES)
priv->GetGestureInfo =
(PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
"GetGestureInfo");
@@ -847,6 +848,7 @@ void qt_init(QApplicationPrivate *priv, int)
priv->GetGestureConfig =
(PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
"GetGestureConfig");
+ #endif // QT_NO_NATIVE_GESTURES
priv->BeginPanningFeedback =
(PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
"BeginPanningFeedback");
diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp
index 26cde1a..a4e7b1f 100644
--- a/src/gui/kernel/qcursor_win.cpp
+++ b/src/gui/kernel/qcursor_win.cpp
@@ -153,8 +153,8 @@ static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy)
bool invb, invm;
bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
- invb = bbits.numColors() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
- invm = mbits.numColors() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
+ invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
+ invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
int sysW = GetSystemMetrics(SM_CXCURSOR);
int sysH = GetSystemMetrics(SM_CYCURSOR);
@@ -396,8 +396,8 @@ void QCursorData::update()
} else {
bbits = bm->toImage().convertToFormat(QImage::Format_Mono);
mbits = bmm->toImage().convertToFormat(QImage::Format_Mono);
- invb = bbits.numColors() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
- invm = mbits.numColors() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
+ invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
+ invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
}
int n = qMax(1, bbits.width() / 8);
int h = bbits.height();
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index abd2128..3d4bb8c 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -52,7 +52,7 @@
#ifdef Q_WS_MAC
#include "qmacgesturerecognizer_mac_p.h"
#endif
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES)
#include "qwinnativepangesturerecognizer_win_p.h"
#endif
@@ -94,7 +94,9 @@ QGestureManager::QGestureManager(QObject *parent)
registerGestureRecognizer(new QTapGestureRecognizer);
#endif
#if defined(Q_OS_WIN)
+ #if !defined(QT_NO_NATIVE_GESTURES)
registerGestureRecognizer(new QWinNativePanGestureRecognizer);
+ #endif
#else
registerGestureRecognizer(new QTapAndHoldGestureRecognizer);
#endif
diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp
index 70cd5a5..5d44b3d 100644
--- a/src/gui/kernel/qlayout.cpp
+++ b/src/gui/kernel/qlayout.cpp
@@ -496,6 +496,21 @@ void QLayout::setContentsMargins(int left, int top, int right, int bottom)
}
/*!
+ \since 4.6
+
+ Sets the \a margins to use around the layout.
+
+ By default, QLayout uses the values provided by the style. On
+ most platforms, the margin is 11 pixels in all directions.
+
+ \sa contentsMargins()
+*/
+void QLayout::setContentsMargins(const QMargins &margins)
+{
+ setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
+}
+
+/*!
\since 4.3
Extracts the left, top, right, and bottom margins used around the
@@ -521,6 +536,23 @@ void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) c
}
/*!
+ \since 4.6
+
+ Returns the margins used around the layout.
+
+ By default, QLayout uses the values provided by the style. On
+ most platforms, the margin is 11 pixels in all directions.
+
+ \sa setContentsMargins()
+*/
+QMargins QLayout::contentsMargins() const
+{
+ int left, top, right, bottom;
+ getContentsMargins(&left, &top, &right, &bottom);
+ return QMargins(left, top, right, bottom);
+}
+
+/*!
\since 4.3
Returns the layout's geometry() rectangle, but taking into account the
diff --git a/src/gui/kernel/qlayout.h b/src/gui/kernel/qlayout.h
index 83cbab6..2f30294 100644
--- a/src/gui/kernel/qlayout.h
+++ b/src/gui/kernel/qlayout.h
@@ -46,6 +46,7 @@
#include <QtGui/qlayoutitem.h>
#include <QtGui/qsizepolicy.h>
#include <QtCore/qrect.h>
+#include <QtCore/qmargins.h>
#include <limits.h>
@@ -122,7 +123,9 @@ public:
void setSpacing(int);
void setContentsMargins(int left, int top, int right, int bottom);
+ void setContentsMargins(const QMargins &margins);
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
+ QMargins contentsMargins() const;
QRect contentsRect() const;
bool setAlignment(QWidget *w, Qt::Alignment alignment);
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index a914220..ecad72f 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -137,12 +137,14 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act
*/
QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget)
{
+#ifndef QT_NO_ACTION
QScopedPointer<QAction> action(createAction(standardKey, actionWidget));
connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent()));
connect(action.data(), SIGNAL(destroyed(QObject*)), QSoftKeyManager::instance(), SLOT(cleanupHash(QObject*)));
QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key);
return action.take();
+#endif //QT_NO_ACTION
}
void QSoftKeyManager::cleanupHash(QObject* obj)
@@ -175,6 +177,7 @@ void QSoftKeyManager::updateSoftKeys()
bool QSoftKeyManager::event(QEvent *e)
{
+#ifndef QT_NO_ACTION
if (e->type() == QEvent::UpdateSoftKeys) {
QList<QAction*> softKeys;
QWidget *source = QApplication::focusWidget();
@@ -200,6 +203,7 @@ bool QSoftKeyManager::event(QEvent *e)
QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys);
return true;
}
+#endif //QT_NO_ACTION
return false;
}
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 0ea4764..6b0441b 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -56,7 +56,7 @@ QPanGestureRecognizer::QPanGestureRecognizer()
QGesture *QPanGestureRecognizer::create(QObject *target)
{
if (target && target->isWidgetType()) {
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN) && !defined(QT_NO_NATIVE_GESTURES)
// for scroll areas on Windows we want to use native gestures instead
if (!qobject_cast<QAbstractScrollArea *>(target->parent()))
static_cast<QWidget *>(target)->setAttribute(Qt::WA_AcceptTouchEvents);
@@ -77,7 +77,6 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
QGestureRecognizer::Result result;
-
switch (event->type()) {
case QEvent::TouchBegin: {
result = QGestureRecognizer::MayBeGesture;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 2d2aa2e..c776c36 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -900,7 +900,7 @@ void QWidget::setAutoFillBackground(bool enabled)
passing a \c QAction with a softkey role set on it. When the widget
containing the softkey actions has focus, its softkeys should appear in
the user interface. Softkeys are discovered by traversing the widget
- heirarchy so it is possible to define a single set of softkeys that are
+ hierarchy so it is possible to define a single set of softkeys that are
present at all times by calling addAction() for a given top level widget.
On some platforms, this concept overlaps with \c QMenuBar such that if no
@@ -5238,7 +5238,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
QPainter p(pdev);
p.translate(offset);
context.painter = &p;
- graphicsEffect->draw(&p, source);
+ graphicsEffect->draw(&p);
paintEngine->d_func()->systemClip = QRegion();
} else {
context.painter = sharedPainter;
@@ -5248,7 +5248,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
}
sharedPainter->save();
sharedPainter->translate(offset);
- graphicsEffect->draw(sharedPainter, source);
+ graphicsEffect->draw(sharedPainter);
sharedPainter->restore();
}
sourced->context = 0;
@@ -5470,7 +5470,7 @@ void QWidgetEffectSourcePrivate::draw(QPainter *painter)
}
QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffectSource::PixmapPadMode mode) const
+ QGraphicsEffect::PixmapPadMode mode) const
{
const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
if (!context && deviceCoordinates) {
@@ -5491,10 +5491,10 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *
QRect effectRect;
- if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) {
+ if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
- } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) {
+ } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect();
} else {
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 151b90a..df28bac 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -824,7 +824,7 @@ public:
QRectF boundingRect(Qt::CoordinateSystem system) const;
void draw(QPainter *p);
QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffectSource::PixmapPadMode mode) const;
+ QGraphicsEffect::PixmapPadMode mode) const;
QWidget *m_widget;
QWidgetPaintContext *context;
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 22a94b9..fde0d45 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -677,7 +677,11 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
QWidget *parentWindow = window();
QWExtra *extra = parentWindow->d_func()->extra;
if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId()
- || (extra && extra->proxyWidget)) {
+ || (extra
+#ifndef QT_NO_GRAPHICSVIEW
+ && extra->proxyWidget
+#endif //QT_NO_GRAPHICSVIEW
+ )) {
if (extra && extra->topextra && extra->topextra->embedded) {
QPoint pt = mapTo(parentWindow, pos);
POINT p = {pt.x(), pt.y()};
@@ -704,7 +708,11 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
QWidget *parentWindow = window();
QWExtra *extra = parentWindow->d_func()->extra;
if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId()
- || (extra && extra->proxyWidget)) {
+ || (extra
+#ifndef QT_NO_GRAPHICSVIEW
+ && extra->proxyWidget
+#endif //QT_NO_GRAPHICSVIEW
+ )) {
if (extra && extra->topextra && extra->topextra->embedded) {
POINT p = {pos.x(), pos.y()};
ScreenToClient(parentWindow->effectiveWinId(), &p);
@@ -1331,8 +1339,15 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
if (isResize && !q->testAttribute(Qt::WA_StaticContents) && q->internalWinId())
ValidateRgn(q->internalWinId(), 0);
+#ifdef Q_WS_WINCE
+ // On Windows CE we can't just fiddle around with the window state.
+ // Too much magic in setWindowState.
+ if (isResize && q->isMaximized())
+ q->setWindowState(q->windowState() & ~Qt::WindowMaximized);
+#else
if (isResize)
data.window_state &= ~Qt::WindowMaximized;
+#endif
if (data.window_state & Qt::WindowFullScreen) {
QTLWExtra *top = topData();
@@ -2032,16 +2047,21 @@ void QWidgetPrivate::registerTouchWindow()
void QWidgetPrivate::winSetupGestures()
{
+#if !defined(QT_NO_NATIVE_GESTURES)
Q_Q(QWidget);
- if (!q || !q->isVisible())
+ if (!q || !q->isVisible() || !nativeGesturePanEnabled)
return;
+
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ if (!qAppPriv->SetGestureConfig)
+ return;
WId winid = q->internalWinId();
bool needh = false;
bool needv = false;
bool singleFingerPanEnabled = false;
+#ifndef QT_NO_SCROLLAREA
if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q->parent())) {
QScrollBar *hbar = asa->horizontalScrollBar();
QScrollBar *vbar = asa->verticalScrollBar();
@@ -2052,10 +2072,12 @@ void QWidgetPrivate::winSetupGestures()
needv = (vbarpolicy == Qt::ScrollBarAlwaysOn ||
(vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
- if (!winid)
+ if (!winid) {
winid = q->winId(); // enforces the native winid on the viewport
+ }
}
- if (winid && qAppPriv->SetGestureConfig) {
+#endif //QT_NO_SCROLLAREA
+ if (winid) {
GESTURECONFIG gc[1];
memset(gc, 0, sizeof(gc));
gc[0].dwID = GID_PAN;
@@ -2075,6 +2097,7 @@ void QWidgetPrivate::winSetupGestures()
qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
}
+#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 28676da..7461637 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1445,7 +1445,7 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
icon_data[pos++] = image.width();
icon_data[pos++] = image.height();
if (sizeof(long) == sizeof(quint32)) {
- memcpy(icon_data.data() + pos, image.scanLine(0), image.numBytes());
+ memcpy(icon_data.data() + pos, image.scanLine(0), image.byteCount());
} else {
for (int y = 0; y < image.height(); ++y) {
uint *scanLine = reinterpret_cast<uint *>(image.scanLine(y));
diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp
index 5fceb13..7dff543 100644
--- a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp
+++ b/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+#if !defined(QT_NO_NATIVE_GESTURES)
+
QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer()
{
}
@@ -122,4 +124,6 @@ void QWinNativePanGestureRecognizer::reset(QGesture *state)
QGestureRecognizer::reset(state);
}
+#endif // QT_NO_NATIVE_GESTURES
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
index 8fb0d50..7d53ed2 100644
--- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
+++ b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
@@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE
+#if !defined(QT_NO_NATIVE_GESTURES)
+
class QWinNativePanGestureRecognizer : public QGestureRecognizer
{
public:
@@ -67,6 +69,8 @@ public:
void reset(QGesture *state);
};
+#endif // QT_NO_NATIVE_GESTURES
+
QT_END_NAMESPACE
#endif // QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 6f5d892..afe9986 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -970,7 +970,7 @@ bool QBrush::operator==(const QBrush &b) const
QDebug operator<<(QDebug dbg, const QBrush &b)
{
#ifndef Q_BROKEN_DEBUG_STREAM
- char *BRUSH_STYLES[] = {
+ const char *BRUSH_STYLES[] = {
"NoBrush",
"SolidPattern",
"Dense1Pattern",
diff --git a/src/gui/painting/qcolormap_qws.cpp b/src/gui/painting/qcolormap_qws.cpp
index ce4cd09..bc97b08 100644
--- a/src/gui/painting/qcolormap_qws.cpp
+++ b/src/gui/painting/qcolormap_qws.cpp
@@ -170,7 +170,7 @@ const QColor QColormap::colorAt(uint pixel) const
(pixel & green_mask) >> green_shift,
(pixel & blue_mask));
}
- Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette");
+ Q_ASSERT_X(int(pixel) < qt_screen->colorCount(), "QColormap::colorAt", "pixel out of bounds of palette");
return QColor(qt_screen->clut()[pixel]);
}
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 88b2b7a..17b7241 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE
which returns true if the matrix is non-singular (i.e. AB = BA =
I). The inverted() function returns an inverted copy of \e this
matrix if it is invertible (otherwise it returns the identity
- matrix). In addition, QMatrix provides the det() function
+ matrix). In addition, QMatrix provides the determinant() function
returning the matrix's determinant.
Finally, the QMatrix class supports matrix multiplication, and
@@ -959,9 +959,19 @@ QMatrix &QMatrix::rotate(qreal a)
*/
/*!
+ \obsolete
\fn qreal QMatrix::det() const
Returns the matrix's determinant.
+
+ \sa determinant()
+*/
+
+/*!
+ \since 4.6
+ \fn qreal QMatrix::determinant() const
+
+ Returns the matrix's determinant.
*/
/*!
@@ -985,8 +995,8 @@ QMatrix &QMatrix::rotate(qreal a)
QMatrix QMatrix::inverted(bool *invertible) const
{
- qreal determinant = det();
- if (determinant == 0.0) {
+ qreal dtr = determinant();
+ if (dtr == 0.0) {
if (invertible)
*invertible = false; // singular matrix
return QMatrix(true);
@@ -994,7 +1004,7 @@ QMatrix QMatrix::inverted(bool *invertible) const
else { // invertible matrix
if (invertible)
*invertible = true;
- qreal dinv = 1.0/determinant;
+ qreal dinv = 1.0/dtr;
return QMatrix((_m22*dinv), (-_m12*dinv),
(-_m21*dinv), (_m11*dinv),
((_m21*_dy - _m22*_dx)*dinv),
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 8887f0e..152b3c9 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -101,7 +101,8 @@ public:
QMatrix &rotate(qreal a);
bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); }
- qreal det() const { return _m11*_m22 - _m12*_m21; }
+ qreal determinant() const { return _m11*_m22 - _m12*_m21; }
+ QT_DEPRECATED qreal det() const { return _m11*_m22 - _m12*_m21; }
QMatrix inverted(bool *invertible = 0) const;
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index c8e86b8..9148e4b 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -96,7 +96,8 @@ public:
int logicalDpiY() const { return metric(PdmDpiY); }
int physicalDpiX() const { return metric(PdmPhysicalDpiX); }
int physicalDpiY() const { return metric(PdmPhysicalDpiY); }
- int numColors() const { return metric(PdmNumColors); }
+ QT_DEPRECATED int numColors() const { return metric(PdmNumColors); }
+ int colorCount() const { return metric(PdmNumColors); }
int depth() const { return metric(PdmDepth); }
protected:
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
index e686373..c1b887c 100644
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ b/src/gui/painting/qpaintengine_mac.cpp
@@ -1023,7 +1023,7 @@ CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imag
#endif
QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(image,
static_cast<const QImage *>(image)->bits(),
- image->numBytes(),
+ image->byteCount(),
drawImageReleaseData);
if (imagePtr)
*imagePtr = image;
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 8d0b961..3f33319 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1362,7 +1362,7 @@ void QRasterPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
Q_D(QRasterPaintEngine);
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
clip(region.boundingRect(), op);
return;
}
@@ -4536,7 +4536,7 @@ void QClipData::setClipRect(const QRect &rect)
*/
void QClipData::setClipRegion(const QRegion &region)
{
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
setClipRect(region.rects().at(0));
return;
}
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 1fb8aab..7d1c109 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -602,7 +602,7 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op)
void QPaintEngineEx::clip(const QRegion &region, Qt::ClipOperation op)
{
- if (region.numRects() == 1)
+ if (region.rectCount() == 1)
clip(region.boundingRect(), op);
QVector<QRect> rects = region.rects();
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index b48b024..9d1d965 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -690,7 +690,7 @@ bool QRegion::intersects(const QRegion &region) const
if (!rect_intersects(boundingRect(), region.boundingRect()))
return false;
- if (numRects() == 1 && region.numRects() == 1)
+ if (rectCount() == 1 && region.rectCount() == 1)
return true;
const QVector<QRect> myRects = rects();
@@ -717,7 +717,7 @@ bool QRegion::intersects(const QRect &rect) const
const QRect r = rect.normalized();
if (!rect_intersects(boundingRect(), r))
return false;
- if (numRects() == 1)
+ if (rectCount() == 1)
return true;
const QVector<QRect> myRects = rects();
@@ -739,6 +739,7 @@ QRegion QRegion::intersect(const QRect &r) const
#endif
/*!
+ \obsolete
\fn int QRegion::numRects() const
\since 4.4
@@ -746,6 +747,13 @@ QRegion QRegion::intersect(const QRect &r) const
*/
/*!
+ \fn int QRegion::rectCount() const
+ \since 4.6
+
+ Returns the number of rectangles that will be returned in rects().
+*/
+
+/*!
\fn bool QRegion::isEmpty() const
Returns true if the region is empty; otherwise returns false. An
@@ -1027,7 +1035,7 @@ void addSegmentsToPath(Segment *segment, QPainterPath &path)
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion &region)
{
QPainterPath result;
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
result.addRect(region.boundingRect());
return result;
}
@@ -4317,6 +4325,12 @@ int QRegion::numRects() const
return (d->qt_rgn ? d->qt_rgn->numRects : 0);
}
+int QRegion::rectCount() const
+{
+ return (d->qt_rgn ? d->qt_rgn->numRects : 0);
+}
+
+
bool QRegion::operator==(const QRegion &r) const
{
if (!d->qt_rgn)
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index 7e459ed..2a1be86 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -116,7 +116,8 @@ public:
QRect boundingRect() const;
QVector<QRect> rects() const;
void setRects(const QRect *rect, int num);
- int numRects() const;
+ QT_DEPRECATED int numRects() const;
+ int rectCount() const;
const QRegion operator|(const QRegion &r) const;
const QRegion operator+(const QRegion &r) const;
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 1bd5842..45db80a 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1421,7 +1421,7 @@ QRegion QTransform::map(const QRegion &r) const
return copy;
}
- if (t == TxScale && r.numRects() == 1)
+ if (t == TxScale && r.rectCount() == 1)
return QRegion(mapRect(r.boundingRect()));
QPainterPath p = map(qt_regionToPath(r));
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index d412040..5060f95 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -140,7 +140,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
// Not ready for painting yet, bail out. This can happen in
// QWidget::create_sys()
- if (!d->image || rgn.numRects() == 0)
+ if (!d->image || rgn.rectCount() == 0)
return;
#ifdef Q_WS_WIN
@@ -203,7 +203,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
wrgn.translate(-wOffset);
QRect wbr = wrgn.boundingRect();
- if (wrgn.numRects() != 1) {
+ if (wrgn.rectCount() != 1) {
int num;
XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
@@ -242,7 +242,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
}
}
- if (wrgn.numRects() != 1)
+ if (wrgn.rectCount() != 1)
XSetClipMask(X11->display, d_ptr->gc, XNone);
#endif // FALCON
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index e0fcb92..b5e92c7 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -433,7 +433,7 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const
return Qt::black;
const QRgb *pixelRgb = (const QRgb*)frameImage.bits();
- const int pixels = frameImage.numBytes()/sizeof(QRgb);
+ const int pixels = frameImage.byteCount()/sizeof(QRgb);
int estimatedRed = 0;
int estimatedGreen = 0;
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index 7ed187f..86ba947 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -4121,6 +4121,7 @@ void QWindowsMobileStylePrivate::setupWindowsMobileStyle65()
void QWindowsMobileStylePrivate::drawTabBarTab(QPainter *painter, const QStyleOptionTab *tab)
{
+#ifndef QT_NO_TABBAR
#ifdef Q_WS_WINCE_WM
if (wm65) {
tintImagesButton(tab->palette.button().color());
@@ -4207,6 +4208,7 @@ void QWindowsMobileStylePrivate::drawTabBarTab(QPainter *painter, const QStyleOp
}
}
painter->restore();
+#endif //QT_NO_TABBAR
}
void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItemV4 *option, QRect rect)
@@ -4412,7 +4414,7 @@ void QWindowsMobileStylePrivate::drawScrollbarHandleUp(QPainter *p, QStyleOption
void QWindowsMobileStylePrivate::drawScrollbarHandleDown(QPainter *p, QStyleOptionSlider *opt, bool completeFrame, bool secondScrollBar)
{
-
+#ifndef QT_NO_SCROLLBAR
#ifdef Q_WS_WINCE_WM
if (wm65) {
tintImagesHigh(opt->palette.highlight().color());
@@ -4469,10 +4471,12 @@ void QWindowsMobileStylePrivate::drawScrollbarHandleDown(QPainter *p, QStyleOpti
arrowOpt.rect.adjust(1, 0, 1, 0);
q_func()->proxy()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &arrowOpt, p, 0);
}
+#endif //QT_NO_SCROLLBAR
}
void QWindowsMobileStylePrivate::drawScrollbarGroove(QPainter *p,const QStyleOptionSlider *opt)
{
+#ifndef QT_NO_SCROLLBAR
#ifdef Q_OS_WINCE_WM
if (wm65) {
p->fillRect(opt->rect, QColor(231, 231, 231));
@@ -4498,6 +4502,7 @@ void QWindowsMobileStylePrivate::drawScrollbarGroove(QPainter *p,const QStyleOpt
fill = opt->palette.light();
}
p->fillRect(opt->rect, fill);
+#endif //QT_NO_SCROLLBAR
}
QWindowsMobileStyle::QWindowsMobileStyle(QWindowsMobileStylePrivate &dd) : QWindowsStyle(dd) {
@@ -6325,16 +6330,20 @@ QSize QWindowsMobileStyle::sizeFromContents(ContentsType type, const QStyleOptio
switch (type) {
case CT_PushButton:
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
+ newSize = QCommonStyle::sizeFromContents(type, option, size, widget);
int w = newSize.width(),
h = newSize.height();
int defwidth = 0;
if (button->features & QStyleOptionButton::AutoDefaultButton)
defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, button, widget);
- if (w < 75 + defwidth && button->icon.isNull())
- w = 75 + defwidth;
- if (h < 23 + defwidth)
- h = 23 + defwidth;
+
+ int minwidth = int(QStyleHelper::dpiScaled(55.0f));
+ int minheight = int(QStyleHelper::dpiScaled(19.0f));
+
+ if (w < minwidth + defwidth && button->icon.isNull())
+ w = minwidth + defwidth;
+ if (h < minheight + defwidth)
+ h = minheight + defwidth;
newSize = QSize(w + 4, h + 4);
}
break;
diff --git a/src/gui/styles/qwindowsmobilestyle_p.h b/src/gui/styles/qwindowsmobilestyle_p.h
index 1e8c7ff..139a4ab 100644
--- a/src/gui/styles/qwindowsmobilestyle_p.h
+++ b/src/gui/styles/qwindowsmobilestyle_p.h
@@ -60,6 +60,10 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_STYLE_WINDOWSMOBILE
+class QStyleOptionTab;
+class QStyleOptionSlider;
+class QStyleOptionViewItemV4;
+
class QWindowsMobileStylePrivate : public QWindowsStylePrivate
{
Q_DECLARE_PUBLIC(QWindowsMobileStyle)
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index 94974fc..f978bd8 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -938,7 +938,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph)
g.advance = qRound(metrics.xoff);
QT_WRITE(fd, &g, sizeof(g));
- QT_WRITE(fd, img.bits(), img.numBytes());
+ QT_WRITE(fd, img.bits(), img.byteCount());
glyphPos = oldSize - glyphDataOffset;
#if 0 && defined(DEBUG_FONTENGINE)
@@ -948,7 +948,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph)
quint32 *gmap = (quint32 *)(fontData + glyphMapOffset);
gmap[glyph] = qToBigEndian(glyphPos);
- glyphDataSize = glyphPos + sizeof(g) + img.numBytes();
+ glyphDataSize = glyphPos + sizeof(g) + img.byteCount();
quint32 *blockSizePtr = (quint32 *)(fontData + glyphDataOffset - 4);
*blockSizePtr = qToBigEndian(glyphDataSize);
}
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 7d81d5a..b0d0baf 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -51,6 +51,7 @@
#include "qdebug.h"
#include "qboxlayout.h"
#include "qpainter.h"
+#include "qmargins.h"
#include "qabstractscrollarea_p.h"
#include <qwidget.h>
@@ -868,6 +869,22 @@ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int b
}
/*!
+ \since 4.6
+ Sets \a margins around the scrolling area. This is useful for
+ applications such as spreadsheets with "locked" rows and columns.
+ The marginal space is is left blank; put widgets in the unused
+ area.
+
+ By default all margins are zero.
+
+*/
+void QAbstractScrollArea::setViewportMargins(const QMargins &margins)
+{
+ setViewportMargins(margins.left(), margins.top(),
+ margins.right(), margins.bottom());
+}
+
+/*!
\fn bool QAbstractScrollArea::event(QEvent *event)
\reimp
@@ -946,7 +963,7 @@ bool QAbstractScrollArea::event(QEvent *e)
if (g) {
QScrollBar *hBar = horizontalScrollBar();
QScrollBar *vBar = verticalScrollBar();
- QPointF delta = g->lastOffset();
+ QPointF delta = g->delta();
if (!delta.isNull()) {
if (QApplication::isRightToLeft())
delta.rx() *= -1;
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
index b3a1861..18d1e96 100644
--- a/src/gui/widgets/qabstractscrollarea.h
+++ b/src/gui/widgets/qabstractscrollarea.h
@@ -52,6 +52,7 @@ QT_MODULE(Gui)
#ifndef QT_NO_SCROLLAREA
+class QMargins;
class QScrollBar;
class QAbstractScrollAreaPrivate;
@@ -95,6 +96,7 @@ protected Q_SLOTS:
protected:
QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0);
void setViewportMargins(int left, int top, int right, int bottom);
+ void setViewportMargins(const QMargins &margins);
bool event(QEvent *);
virtual bool viewportEvent(QEvent *);
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp
index 9f9e353..f33a98f 100644
--- a/src/gui/widgets/qlcdnumber.cpp
+++ b/src/gui/widgets/qlcdnumber.cpp
@@ -85,7 +85,7 @@ public:
decimal point with setSmallDecimalPoint().
QLCDNumber emits the overflow() signal when it is asked to display
- something beyond its range. The range is set by setNumDigits(),
+ something beyond its range. The range is set by setDigitCount(),
but setSmallDecimalPoint() also influences it. If the display is
set to hexadecimal, octal or binary, the integer equivalent of the
value is displayed.
@@ -160,7 +160,7 @@ public:
This signal is emitted whenever the QLCDNumber is asked to display
a too-large number or a too-long string.
- It is never emitted by setNumDigits().
+ It is never emitted by setDigitCount().
*/
@@ -345,7 +345,7 @@ static const char *getSegments(char ch) // gets list of segments f
The \a parent and \a name arguments are passed to the QFrame
constructor.
- \sa setNumDigits(), setSmallDecimalPoint()
+ \sa setDigitCount(), setSmallDecimalPoint()
*/
QLCDNumber::QLCDNumber(QWidget *parent, const char *name)
@@ -367,7 +367,7 @@ QLCDNumber::QLCDNumber(QWidget *parent, const char *name)
The \a parent and \a name arguments are passed to the QFrame
constructor.
- \sa setNumDigits(), setSmallDecimalPoint()
+ \sa setDigitCount(), setSmallDecimalPoint()
*/
QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name)
@@ -387,7 +387,7 @@ QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name)
The \a parent argument is passed to the QFrame constructor.
- \sa setNumDigits(), setSmallDecimalPoint()
+ \sa setDigitCount(), setSmallDecimalPoint()
*/
QLCDNumber::QLCDNumber(QWidget *parent)
@@ -407,7 +407,7 @@ QLCDNumber::QLCDNumber(QWidget *parent)
The \a parent argument is passed to the QFrame constructor.
- \sa setNumDigits(), setSmallDecimalPoint()
+ \sa setDigitCount(), setSmallDecimalPoint()
*/
QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent)
@@ -426,7 +426,7 @@ void QLCDNumberPrivate::init()
val = 0;
base = QLCDNumber::Dec;
smallPoint = false;
- q->setNumDigits(ndigits);
+ q->setDigitCount(ndigits);
q->setSegmentStyle(QLCDNumber::Filled);
q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
}
@@ -441,8 +441,21 @@ QLCDNumber::~QLCDNumber()
/*!
+ \obsolete
\property QLCDNumber::numDigits
\brief the current number of digits displayed
+ \sa setDigitCount
+*/
+
+void QLCDNumber::setNumDigits(int numDigits)
+{
+ setDigitCount(numDigits);
+}
+
+/*!
+ \since 4.6
+ \property QLCDNumber::digitCount
+ \brief the current number of digits displayed
Corresponds to the current number of digits. If \l
QLCDNumber::smallDecimalPoint is false, the decimal point occupies
@@ -453,7 +466,7 @@ QLCDNumber::~QLCDNumber()
\sa smallDecimalPoint
*/
-void QLCDNumber::setNumDigits(int numDigits)
+void QLCDNumber::setDigitCount(int numDigits)
{
Q_D(QLCDNumber);
if (numDigits > 99) {
@@ -508,13 +521,19 @@ int QLCDNumber::numDigits() const
return d->ndigits;
}
+int QLCDNumber::digitCount() const
+{
+ Q_D(const QLCDNumber);
+ return d->ndigits;
+}
+
/*!
\overload
Returns true if \a num is too big to be displayed in its entirety;
otherwise returns false.
- \sa display(), numDigits(), smallDecimalPoint()
+ \sa display(), digitCount(), smallDecimalPoint()
*/
bool QLCDNumber::checkOverflow(int num) const
@@ -530,7 +549,7 @@ bool QLCDNumber::checkOverflow(int num) const
Returns true if \a num is too big to be displayed in its entirety;
otherwise returns false.
- \sa display(), numDigits(), smallDecimalPoint()
+ \sa display(), digitCount(), smallDecimalPoint()
*/
bool QLCDNumber::checkOverflow(double num) const
@@ -1256,7 +1275,7 @@ QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const
*/
QSize QLCDNumber::sizeHint() const
{
- return QSize(10 + 9 * (numDigits() + (smallDecimalPoint() ? 0 : 1)), 23);
+ return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23);
}
/*! \reimp */
diff --git a/src/gui/widgets/qlcdnumber.h b/src/gui/widgets/qlcdnumber.h
index 9753f31..e65637d 100644
--- a/src/gui/widgets/qlcdnumber.h
+++ b/src/gui/widgets/qlcdnumber.h
@@ -60,6 +60,7 @@ class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget
Q_ENUMS(Mode SegmentStyle)
Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint)
Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits)
+ Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount)
Q_PROPERTY(Mode mode READ mode WRITE setMode)
Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle)
Q_PROPERTY(double value READ value WRITE display)
@@ -82,8 +83,10 @@ public:
bool smallDecimalPoint() const;
- int numDigits() const;
- void setNumDigits(int nDigits);
+ QT_DEPRECATED int numDigits() const;
+ QT_DEPRECATED void setNumDigits(int nDigits);
+ int digitCount() const;
+ void setDigitCount(int nDigits);
bool checkOverflow(double num) const;
bool checkOverflow(int num) const;
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index e4252b5..f5dbe1c 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1102,6 +1102,17 @@ void QLineEdit::setTextMargins(int left, int top, int right, int bottom)
}
/*!
+ \since 4.6
+ Sets the \a margins around the text inside the frame.
+
+ See also textMargins().
+*/
+void QLineEdit::setTextMargins(const QMargins &margins)
+{
+ setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
+}
+
+/*!
Returns the widget's text margins for \a left, \a top, \a right, and \a bottom.
\since 4.5
@@ -1121,6 +1132,18 @@ void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) con
}
/*!
+ \since 4.6
+ Returns the widget's text margins.
+
+ \sa setTextMargins()
+*/
+QMargins QLineEdit::textMargins() const
+{
+ Q_D(const QLineEdit);
+ return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin);
+}
+
+/*!
\property QLineEdit::inputMask
\brief The validation input mask
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index 214509a..ac918c7 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -44,6 +44,7 @@
#include <QtGui/qframe.h>
#include <QtCore/qstring.h>
+#include <QtCore/qmargins.h>
QT_BEGIN_HEADER
@@ -158,7 +159,9 @@ public:
bool hasAcceptableInput() const;
void setTextMargins(int left, int top, int right, int bottom);
+ void setTextMargins(const QMargins &margins);
void getTextMargins(int *left, int *top, int *right, int *bottom) const;
+ QMargins textMargins() const;
public Q_SLOTS:
void setText(const QString &);
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 0de7421..18adc6c 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -1465,7 +1465,7 @@ bool QPlainTextEdit::event(QEvent *e)
// QPlainTextEdit scrolls by lines only in vertical direction
QFontMetrics fm(document()->defaultFont());
int lineHeight = fm.height();
- int newX = hBar->value() - g->lastOffset().x();
+ int newX = hBar->value() - g->delta().x();
int newY = d->originalOffsetY - offset.y()/lineHeight;
hBar->setValue(newX);
vBar->setValue(newY);
diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp
index d92b1ea..0074c91 100644
--- a/src/gui/widgets/qprintpreviewwidget.cpp
+++ b/src/gui/widgets/qprintpreviewwidget.cpp
@@ -663,7 +663,9 @@ void QPrintPreviewWidget::setZoomFactor(qreal factor)
}
/*!
+ \obsolete
Returns the number of pages in the preview.
+ \sa pageCount()
*/
int QPrintPreviewWidget::numPages() const
{
@@ -672,6 +674,16 @@ int QPrintPreviewWidget::numPages() const
}
/*!
+ \since 4.6
+ Returns the number of pages in the preview.
+*/
+int QPrintPreviewWidget::pageCount() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->pages.size();
+}
+
+/*!
Returns the currently viewed page in the preview.
*/
int QPrintPreviewWidget::currentPage() const
diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h
index 2823873..08e596d 100644
--- a/src/gui/widgets/qprintpreviewwidget.h
+++ b/src/gui/widgets/qprintpreviewwidget.h
@@ -82,7 +82,8 @@ public:
ViewMode viewMode() const;
ZoomMode zoomMode() const;
int currentPage() const;
- int numPages() const;
+ QT_DEPRECATED int numPages() const;
+ int pageCount() const;
void setVisible(bool visible);
public Q_SLOTS:
diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp
index 04378d4..b687f34 100644
--- a/src/multimedia/audio/qaudio.cpp
+++ b/src/multimedia/audio/qaudio.cpp
@@ -71,23 +71,23 @@ public:
/*!
\enum QAudio::Error
- \value NoError No errors have occurred
- \value OpenError An error opening the audio device
- \value IOError An error occurred during read/write of audio device
- \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate
- \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time.
+ \value NoError No errors have occurred
+ \value OpenError An error opening the audio device
+ \value IOError An error occurred during read/write of audio device
+ \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate
+ \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time.
*/
/*!
\enum QAudio::State
- \value ActiveState Audio data is being processed, this state is set after start() is called
- and while audio data is available to be processed.
- \value SuspendState The audio device is in a suspended state, this state will only be entered
- after suspend() is called.
- \value StopState The audio device is closed, not processing any audio data
- \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state
- is set after start() is called and while no audio data is available to be processed.
+ \value ActiveState Audio data is being processed, this state is set after start() is called
+ and while audio data is available to be processed.
+ \value SuspendedState The audio device is in a suspended state, this state will only be entered
+ after suspend() is called.
+ \value StoppedState The audio device is closed, not processing any audio data
+ \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state
+ is set after start() is called and while no audio data is available to be processed.
*/
/*!
diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h
index a66f0b1..531e1a7 100644
--- a/src/multimedia/audio/qaudio.h
+++ b/src/multimedia/audio/qaudio.h
@@ -56,7 +56,7 @@ QT_MODULE(Multimedia)
namespace QAudio
{
enum Error { NoError, OpenError, IOError, UnderrunError, FatalError };
- enum State { ActiveState, SuspendState, StopState, IdleState };
+ enum State { ActiveState, SuspendedState, StoppedState, IdleState };
enum Mode { AudioInput, AudioOutput };
}
diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp
index 8804fb6..89e4394 100644
--- a/src/multimedia/audio/qaudiodevicefactory.cpp
+++ b/src/multimedia/audio/qaudiodevicefactory.cpp
@@ -94,10 +94,10 @@ public:
int bufferSize() const { return 0; }
void setNotifyInterval(int ) {}
int notifyInterval() const { return 0; }
- qint64 totalTime() const { return 0; }
- qint64 clock() const { return 0; }
+ qint64 processedUSecs() const { return 0; }
+ qint64 elapsedUSecs() const { return 0; }
QAudio::Error error() const { return QAudio::OpenError; }
- QAudio::State state() const { return QAudio::StopState; }
+ QAudio::State state() const { return QAudio::StoppedState; }
QAudioFormat format() const { return QAudioFormat(); }
};
@@ -115,18 +115,18 @@ public:
int bufferSize() const { return 0; }
void setNotifyInterval(int ) {}
int notifyInterval() const { return 0; }
- qint64 totalTime() const { return 0; }
- qint64 clock() const { return 0; }
+ qint64 processedUSecs() const { return 0; }
+ qint64 elapsedUSecs() const { return 0; }
QAudio::Error error() const { return QAudio::OpenError; }
- QAudio::State state() const { return QAudio::StopState; }
+ QAudio::State state() const { return QAudio::StoppedState; }
QAudioFormat format() const { return QAudioFormat(); }
};
-QList<QAudioDeviceInfo> QAudioDeviceFactory::deviceList(QAudio::Mode mode)
+QList<QAudioDeviceInfo> QAudioDeviceFactory::availableDevices(QAudio::Mode mode)
{
QList<QAudioDeviceInfo> devices;
#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA))
- foreach (const QByteArray &handle, QAudioDeviceInfoInternal::deviceList(mode))
+ foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode))
devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode);
#endif
QFactoryLoader* l = loader();
@@ -134,7 +134,7 @@ QList<QAudioDeviceInfo> QAudioDeviceFactory::deviceList(QAudio::Mode mode)
foreach (QString const& key, l->keys()) {
QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(l->instance(key));
if (plugin) {
- foreach (QByteArray const& handle, plugin->deviceList(mode))
+ foreach (QByteArray const& handle, plugin->availableDevices(mode))
devices << QAudioDeviceInfo(key, handle, mode);
}
@@ -149,7 +149,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice()
QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default")));
if (plugin) {
- QList<QByteArray> list = plugin->deviceList(QAudio::AudioInput);
+ QList<QByteArray> list = plugin->availableDevices(QAudio::AudioInput);
if (list.size() > 0)
return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput);
}
@@ -164,7 +164,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice()
QAudioEngineFactoryInterface* plugin = qobject_cast<QAudioEngineFactoryInterface*>(loader()->instance(QLatin1String("default")));
if (plugin) {
- QList<QByteArray> list = plugin->deviceList(QAudio::AudioOutput);
+ QList<QByteArray> list = plugin->availableDevices(QAudio::AudioOutput);
if (list.size() > 0)
return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput);
}
diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h
index 008e4a8..2466455 100644
--- a/src/multimedia/audio/qaudiodevicefactory_p.h
+++ b/src/multimedia/audio/qaudiodevicefactory_p.h
@@ -72,7 +72,7 @@ class QAbstractAudioDeviceInfo;
class QAudioDeviceFactory
{
public:
- static QList<QAudioDeviceInfo> deviceList(QAudio::Mode mode);
+ static QList<QAudioDeviceInfo> availableDevices(QAudio::Mode mode);
static QAudioDeviceInfo defaultInputDevice();
static QAudioDeviceInfo defaultOutputDevice();
diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp
index dce2884..5e3adcb 100644
--- a/src/multimedia/audio/qaudiodeviceinfo.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo.cpp
@@ -121,7 +121,7 @@ public:
classes that communicate with the device--such as
QAudioInput, and QAudioOutput. The static
functions defaultInputDevice(), defaultOutputDevice(), and
- deviceList() let you get a list of all available
+ availableDevices() let you get a list of all available
devices. Devices are fetch according to the value of mode
this is specified by the QAudio::Mode enum.
The QAudioDeviceInfo returned are only valid for the QAudio::Mode.
@@ -129,7 +129,7 @@ public:
For instance:
\code
- foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput))
+ foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
qDebug() << "Device name: " << deviceInfo.deviceName();
\endcode
@@ -327,9 +327,9 @@ QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice()
Returns a list of audio devices that support \a mode.
*/
-QList<QAudioDeviceInfo> QAudioDeviceInfo::deviceList(QAudio::Mode mode)
+QList<QAudioDeviceInfo> QAudioDeviceInfo::availableDevices(QAudio::Mode mode)
{
- return QAudioDeviceFactory::deviceList(mode);
+ return QAudioDeviceFactory::availableDevices(mode);
}
diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h
index 53b9904..5c7cb98 100644
--- a/src/multimedia/audio/qaudiodeviceinfo.h
+++ b/src/multimedia/audio/qaudiodeviceinfo.h
@@ -92,7 +92,7 @@ public:
static QAudioDeviceInfo defaultInputDevice();
static QAudioDeviceInfo defaultOutputDevice();
- static QList<QAudioDeviceInfo> deviceList(QAudio::Mode mode);
+ static QList<QAudioDeviceInfo> availableDevices(QAudio::Mode mode);
private:
QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode);
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
index e828238..5de6c70 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
@@ -382,7 +382,7 @@ void QAudioDeviceInfoInternal::updateLists()
close();
}
-QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
+QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
QList<QByteArray> devices;
QByteArray filter;
@@ -444,7 +444,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
QByteArray QAudioDeviceInfoInternal::defaultInputDevice()
{
- QList<QByteArray> devices = deviceList(QAudio::AudioInput);
+ QList<QByteArray> devices = availableDevices(QAudio::AudioInput);
if(devices.size() == 0)
return QByteArray();
@@ -453,7 +453,7 @@ QByteArray QAudioDeviceInfoInternal::defaultInputDevice()
QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
{
- QList<QByteArray> devices = deviceList(QAudio::AudioOutput);
+ QList<QByteArray> devices = availableDevices(QAudio::AudioOutput);
if(devices.size() == 0)
return QByteArray();
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h
index 10078ca..5a807af 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h
@@ -92,7 +92,7 @@ public:
QList<QAudioFormat::SampleType> sampleTypeList();
static QByteArray defaultInputDevice();
static QByteArray defaultOutputDevice();
- static QList<QByteArray> deviceList(QAudio::Mode);
+ static QList<QByteArray> availableDevices(QAudio::Mode);
private:
bool open();
diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
index ec07748..8905119 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
@@ -324,7 +324,7 @@ QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
return get_device_info(audioDevice, QAudio::AudioOutput);
}
-QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
+QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
QList<QByteArray> devices;
diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h
index 60532a8..0fd3ef5 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h
+++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h
@@ -87,7 +87,7 @@ public:
static QByteArray defaultInputDevice();
static QByteArray defaultOutputDevice();
- static QList<QByteArray> deviceList(QAudio::Mode mode);
+ static QList<QByteArray> availableDevices(QAudio::Mode mode);
};
QT_END_NAMESPACE
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index 69d5c94..33af022 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -103,6 +103,7 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
} else {
nearest.setFrequency(11025);
nearest.setChannels(1);
+ nearest.setByteOrder(QAudioFormat::LittleEndian);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(8);
nearest.setCodec(QLatin1String("audio/pcm"));
@@ -333,7 +334,7 @@ void QAudioDeviceInfoInternal::updateLists()
}
}
-QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode)
+QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
Q_UNUSED(mode)
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h
index 0d2ee29..e191b6f 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h
@@ -93,7 +93,7 @@ public:
QList<QAudioFormat::SampleType> sampleTypeList();
static QByteArray defaultInputDevice();
static QByteArray defaultOutputDevice();
- static QList<QByteArray> deviceList(QAudio::Mode);
+ static QList<QByteArray> availableDevices(QAudio::Mode);
private:
QAudio::Mode mode;
diff --git a/src/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp
index c6e9d97..88e3804 100644
--- a/src/multimedia/audio/qaudioengine.cpp
+++ b/src/multimedia/audio/qaudioengine.cpp
@@ -189,12 +189,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn virtual qint64 QAbstractAudioOutput::totalTime() const
+ \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
*/
/*!
- \fn virtual qint64 QAbstractAudioOutput::clock() const
+ \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states.
*/
@@ -304,12 +304,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn virtual qint64 QAbstractAudioInput::totalTime() const
+ \fn virtual qint64 QAbstractAudioInput::processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
*/
/*!
- \fn virtual qint64 QAbstractAudioInput::clock() const
+ \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states.
*/
diff --git a/src/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h
index 57a9ae6..f9e80c1 100644
--- a/src/multimedia/audio/qaudioengine.h
+++ b/src/multimedia/audio/qaudioengine.h
@@ -86,8 +86,8 @@ public:
virtual int bufferSize() const = 0;
virtual void setNotifyInterval(int milliSeconds) = 0;
virtual int notifyInterval() const = 0;
- virtual qint64 totalTime() const = 0;
- virtual qint64 clock() const = 0;
+ virtual qint64 processedUSecs() const = 0;
+ virtual qint64 elapsedUSecs() const = 0;
virtual QAudio::Error error() const = 0;
virtual QAudio::State state() const = 0;
virtual QAudioFormat format() const = 0;
@@ -113,8 +113,8 @@ public:
virtual int bufferSize() const = 0;
virtual void setNotifyInterval(int milliSeconds) = 0;
virtual int notifyInterval() const = 0;
- virtual qint64 totalTime() const = 0;
- virtual qint64 clock() const = 0;
+ virtual qint64 processedUSecs() const = 0;
+ virtual qint64 elapsedUSecs() const = 0;
virtual QAudio::Error error() const = 0;
virtual QAudio::State state() const = 0;
virtual QAudioFormat format() const = 0;
diff --git a/src/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h
index fe30e0d..82dfa15 100644
--- a/src/multimedia/audio/qaudioengineplugin.h
+++ b/src/multimedia/audio/qaudioengineplugin.h
@@ -60,7 +60,7 @@ QT_MODULE(Multimedia)
struct Q_MULTIMEDIA_EXPORT QAudioEngineFactoryInterface : public QFactoryInterface
{
- virtual QList<QByteArray> deviceList(QAudio::Mode) const = 0;
+ virtual QList<QByteArray> availableDevices(QAudio::Mode) const = 0;
virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0;
@@ -80,7 +80,7 @@ public:
~QAudioEnginePlugin();
virtual QStringList keys() const = 0;
- virtual QList<QByteArray> deviceList(QAudio::Mode) const = 0;
+ virtual QList<QByteArray> availableDevices(QAudio::Mode) const = 0;
virtual QAbstractAudioInput* createInput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioOutput* createOutput(const QByteArray& device, const QAudioFormat& format = QAudioFormat()) = 0;
virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0;
diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp
index 86fe85b..b2bbe14 100644
--- a/src/multimedia/audio/qaudioformat.cpp
+++ b/src/multimedia/audio/qaudioformat.cpp
@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+#include <QDebug>
#include <QtMultimedia/qaudioformat.h>
@@ -214,16 +214,13 @@ bool QAudioFormat::operator!=(const QAudioFormat& other) const
}
/*!
- Returns true if any of the parameters are invalid.
+ Returns true if all of the parameters are valid.
*/
-bool QAudioFormat::isNull() const
+bool QAudioFormat::isValid() const
{
- return d->frequency == -1 && d->channels == -1 &&
- d->sampleSize == -1 &&
- d->byteOrder == QAudioFormat::Endian(QSysInfo::ByteOrder) &&
- d->sampleType == QAudioFormat::Unknown &&
- d->codec.isNull();
+ return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 &&
+ d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty();
}
/*!
diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h
index d5841ce..7e92c2f 100644
--- a/src/multimedia/audio/qaudioformat.h
+++ b/src/multimedia/audio/qaudioformat.h
@@ -71,7 +71,7 @@ public:
bool operator==(const QAudioFormat &other) const;
bool operator!=(const QAudioFormat &other) const;
- bool isNull() const;
+ bool isValid() const;
void setFrequency(int frequency);
int frequency() const;
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp
index 7a3be23..e794eaf 100644
--- a/src/multimedia/audio/qaudioinput.cpp
+++ b/src/multimedia/audio/qaudioinput.cpp
@@ -121,15 +121,15 @@ QT_BEGIN_NAMESPACE
when the state changes (stateChanged()).
QAudioInput provides several ways of measuring the time that has
- passed since the start() of the recording. The \c totalTime()
+ passed since the start() of the recording. The \c processedUSecs()
function returns the length of the stream in microseconds written,
i.e., it leaves out the times the audio input was suspended or idle.
- The clock() function returns the time elapsed since start() was called regardless of
+ The elapsedUSecs() function returns the time elapsed since start() was called regardless of
which states the QAudioInput has been in.
If an error should occur, you can fetch its reason with error().
The possible error reasons are described by the QAudio::Error
- enum. The QAudioInput will enter the \l{QAudio::}{StopState} when
+ enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when
an error is encountered. Connect to the stateChanged() signal to
handle the error:
@@ -176,37 +176,44 @@ QAudioInput::~QAudioInput()
}
/*!
- Uses the \a device as the QIODevice to transfer data.
- If \a device is null then the class creates an internal QIODevice.
+ Uses the \a device as the QIODevice to transfer data.
+ Passing a QIODevice allows the data to be transfered without any extra code.
+ All that is required is to open the QIODevice.
+
+ \sa QIODevice
+*/
+
+void QAudioInput::start(QIODevice* device)
+{
+ /*
+ -If currently not StoppedState, stop
+ -If previous start was push mode, delete internal QIODevice.
+ -open audio input.
+ If ok, NoError and ActiveState, else OpenError and StoppedState.
+ -emit stateChanged()
+ */
+ d->start(device);
+}
+
+/*!
Returns a pointer to the QIODevice being used to handle the data
transfer. This QIODevice can be used to read() audio data
directly.
- Passing a QIODevice allows the data to be transfered without any extra code.
- All that is required is to open the QIODevice.
\sa QIODevice
*/
-QIODevice* QAudioInput::start(QIODevice* device)
+QIODevice* QAudioInput::start()
{
/*
- PULL MODE (valid QIODevice)
- -If currently not StopState, stop
- -If previous start was push mode, delete internal QIODevice.
- -open audio input.
- If ok, NoError and ActiveState, else OpenError and StopState.
- -emit stateChanged()
- -return device
-
- PUSH MODE (device = 0)
- -If currently not StopState, stop
+ -If currently not StoppedState, stop
-If no internal QIODevice, create one.
-open audio input.
- -If ok, NoError and IdleState, else OpenError and StopState
+ -If ok, NoError and IdleState, else OpenError and StoppedState
-emit stateChanged()
-return internal QIODevice
*/
- return d->start(device);
+ return d->start(0);
}
/*!
@@ -225,8 +232,8 @@ QAudioFormat QAudioInput::format() const
void QAudioInput::stop()
{
/*
- -If StopState, return
- -set to StopState
+ -If StoppedState, return
+ -set to StoppedState
-detach from audio device
-emit stateChanged()
*/
@@ -255,7 +262,7 @@ void QAudioInput::suspend()
/*
-If not ActiveState|IdleState, return
-stop processing audio, saving all buffered audio data
- -set NoError and SuspendState
+ -set NoError and SuspendedState
-emit stateChanged()
*/
d->suspend();
@@ -268,7 +275,7 @@ void QAudioInput::suspend()
void QAudioInput::resume()
{
/*
- -If SuspendState, return
+ -If SuspendedState, return
-resume audio
-(PULL MODE): set ActiveState, NoError
-(PUSH MODE): set IdleState, NoError
@@ -357,9 +364,9 @@ int QAudioInput::notifyInterval() const
was called in microseconds.
*/
-qint64 QAudioInput::totalTime() const
+qint64 QAudioInput::processedUSecs() const
{
- return d->totalTime();
+ return d->processedUSecs();
}
/*!
@@ -367,9 +374,9 @@ qint64 QAudioInput::totalTime() const
Suspend states.
*/
-qint64 QAudioInput::clock() const
+qint64 QAudioInput::elapsedUSecs() const
{
- return d->clock();
+ return d->elapsedUSecs();
}
/*!
diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h
index c8094f5..bf93a27 100644
--- a/src/multimedia/audio/qaudioinput.h
+++ b/src/multimedia/audio/qaudioinput.h
@@ -71,7 +71,9 @@ public:
QAudioFormat format() const;
- QIODevice* start(QIODevice *device = 0);
+ void start(QIODevice *device);
+ QIODevice* start();
+
void stop();
void reset();
void suspend();
@@ -86,8 +88,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index 9eb8cfb..8a8f0db 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -75,7 +75,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor
intervalTime = 1000;
audioBuffer = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
resuming = false;
@@ -206,7 +206,7 @@ int QAudioInputPrivate::setFormat()
QIODevice* QAudioInputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
+ if(deviceState != QAudio::StoppedState)
close();
if(!pullMode && audioSource) {
@@ -234,10 +234,10 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
void QAudioInputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
close();
emit stateChanged(deviceState);
@@ -283,7 +283,7 @@ bool QAudioInputPrivate::open()
}
if (( err < 0)||(handle == 0)) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -367,7 +367,7 @@ bool QAudioInputPrivate::open()
if( err < 0) {
qWarning()<<errMessage;
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -413,7 +413,7 @@ bool QAudioInputPrivate::open()
void QAudioInputPrivate::close()
{
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
timer->stop();
if ( handle ) {
@@ -490,7 +490,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
if(l < 0) {
close();
errorState = QAudio::IOError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
} else if(l == 0) {
errorState = QAudio::NoError;
@@ -508,7 +508,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
void QAudioInputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
int err = 0;
if(handle) {
@@ -558,7 +558,7 @@ int QAudioInputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioInputPrivate::totalTime() const
+qint64 QAudioInputPrivate::processedUSecs() const
{
return totalTimeValue;
}
@@ -567,14 +567,14 @@ void QAudioInputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState||resuming) {
timer->stop();
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
emit stateChanged(deviceState);
}
}
void QAudioInputPrivate::userFeed()
{
- if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState)
+ if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return;
#ifdef DEBUG_AUDIO
QTime now(QTime::currentTime());
@@ -606,12 +606,12 @@ bool QAudioInputPrivate::deviceReady()
return true;
}
-qint64 QAudioInputPrivate::clock() const
+qint64 QAudioInputPrivate::elapsedUSecs() const
{
if(!handle)
return 0;
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h
index 2ed7453..67d5cf5 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.h
+++ b/src/multimedia/audio/qaudioinput_alsa_p.h
@@ -91,8 +91,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
QAudioFormat format() const;
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index cb05920..d63045f 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.cpp
+++ b/src/multimedia/audio/qaudioinput_mac_p.cpp
@@ -526,7 +526,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co
internalBufferSize = default_buffer_size;
clockFrequency = AudioGetHostClockFrequency() / 1000;
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
intervalTimer = new QTimer(this);
intervalTimer->setInterval(1000);
@@ -708,7 +708,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
QIODevice* op = device;
if (!open()) {
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
}
@@ -736,12 +736,12 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
void QAudioInputPrivate::stop()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadStop();
audioBuffer->flush(true);
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
}
@@ -749,11 +749,11 @@ void QAudioInputPrivate::stop()
void QAudioInputPrivate::reset()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadStop();
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
}
@@ -765,7 +765,7 @@ void QAudioInputPrivate::suspend()
audioThreadStop();
errorCode = QAudio::NoError;
- stateCode = QAudio::SuspendState;
+ stateCode = QAudio::SuspendedState;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
}
@@ -773,7 +773,7 @@ void QAudioInputPrivate::suspend()
void QAudioInputPrivate::resume()
{
QMutexLocker lock(&mutex);
- if (stateCode == QAudio::SuspendState) {
+ if (stateCode == QAudio::SuspendedState) {
audioThreadStart();
errorCode = QAudio::NoError;
@@ -812,14 +812,14 @@ int QAudioInputPrivate::notifyInterval() const
return intervalTimer->interval();
}
-qint64 QAudioInputPrivate::totalTime() const
+qint64 QAudioInputPrivate::processedUSecs() const
{
return totalFrames * 1000000 / audioFormat.frequency();
}
-qint64 QAudioInputPrivate::clock() const
+qint64 QAudioInputPrivate::elapsedUSecs() const
{
- if (stateCode == QAudio::StopState)
+ if (stateCode == QAudio::StoppedState)
return 0;
return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000);
@@ -875,7 +875,7 @@ void QAudioInputPrivate::audioDeviceError()
audioDeviceStop();
errorCode = QAudio::IOError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection);
}
}
diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h
index a080648..2dbb808 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.h
+++ b/src/multimedia/audio/qaudioinput_mac_p.h
@@ -129,8 +129,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index a059e76..b7f9ffd 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -71,7 +71,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor
totalTimeValue = 0;
intervalTime = 1000;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
resuming = false;
@@ -173,7 +173,7 @@ QAudioFormat QAudioInputPrivate::format() const
QIODevice* QAudioInputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
+ if(deviceState != QAudio::StoppedState)
close();
if(!pullMode && audioSource) {
@@ -201,7 +201,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
void QAudioInputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
close();
@@ -260,7 +260,7 @@ bool QAudioInputPrivate::open()
(DWORD_PTR) this,
CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
qWarning("QAudioInput: failed to open audio device");
return false;
@@ -269,7 +269,7 @@ bool QAudioInputPrivate::open()
if(waveBlocks == 0) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
qWarning("QAudioInput: failed to allocate blocks. open failed");
return false;
@@ -286,7 +286,7 @@ bool QAudioInputPrivate::open()
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",i,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -295,7 +295,7 @@ bool QAudioInputPrivate::open()
if(result) {
qWarning("QAudioInput: failed to start audio input");
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return false;
}
@@ -309,12 +309,12 @@ bool QAudioInputPrivate::open()
void QAudioInputPrivate::close()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
waveInReset(hWaveIn);
waveInClose(hWaveIn);
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
int count = 0;
while(!finished && count < 100) {
@@ -333,6 +333,9 @@ void QAudioInputPrivate::close()
int QAudioInputPrivate::bytesReady() const
{
+ if(period_size == 0 || buffer_size == 0)
+ return 0;
+
int buf = ((buffer_size/period_size)-waveFreeBlockCount)*period_size;
if(buf < 0)
buf = 0;
@@ -400,14 +403,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
}
result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",header,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
}
header++;
@@ -435,14 +438,14 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
void QAudioInputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
deviceState = QAudio::ActiveState;
for(int i=0; i<buffer_size/period_size; i++) {
result = waveInAddBuffer(hWaveIn, &waveBlocks[i], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",i,result);
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
return;
}
@@ -488,7 +491,7 @@ int QAudioInputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioInputPrivate::totalTime() const
+qint64 QAudioInputPrivate::processedUSecs() const
{
return totalTimeValue;
}
@@ -497,7 +500,7 @@ void QAudioInputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState) {
waveInReset(hWaveIn);
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
emit stateChanged(deviceState);
}
}
@@ -510,7 +513,7 @@ void QAudioInputPrivate::feedback()
#endif
bytesAvailable = bytesReady();
- if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState))
+ if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState))
emit processMore();
}
@@ -539,9 +542,9 @@ bool QAudioInputPrivate::deviceReady()
return true;
}
-qint64 QAudioInputPrivate::clock() const
+qint64 QAudioInputPrivate::elapsedUSecs() const
{
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
return timeStampOpened.elapsed()*1000;
diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h
index 26c470d..a2bd687 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.h
+++ b/src/multimedia/audio/qaudioinput_win32_p.h
@@ -91,8 +91,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp
index 81b9496..f8f2fa1 100644
--- a/src/multimedia/audio/qaudiooutput.cpp
+++ b/src/multimedia/audio/qaudiooutput.cpp
@@ -125,12 +125,12 @@ QT_BEGIN_NAMESPACE
not emitted. A typical use-case would be to update a
\l{QSlider}{slider} that allows seeking in the stream.
If you want the time since playback started regardless of which
- states the audio output has been in, clock() is the function for you.
+ states the audio output has been in, elapsedUSecs() is the function for you.
If an error occurs, you can fetch the \l{QAudio::Error}{error
type} with the error() function. Please see the QAudio::Error enum
for a description of the possible errors that are reported. When
- an error is encountered, the state changes to QAudio::StopState.
+ an error is encountered, the state changes to QAudio::StoppedState.
You can check for errors by connecting to the stateChanged()
signal:
@@ -188,36 +188,42 @@ QAudioFormat QAudioOutput::format() const
/*!
Uses the \a device as the QIODevice to transfer data.
- If \a device is null then the class creates an internal QIODevice.
- Returns a pointer to the QIODevice being used to handle the data
- transfer. This QIODevice can be used to write() audio data
- directly.
Passing a QIODevice allows the data to be transfered without any extra code.
All that is required is to open the QIODevice.
\sa QIODevice
*/
-QIODevice* QAudioOutput::start(QIODevice* device)
+void QAudioOutput::start(QIODevice* device)
{
/*
- PULL MODE (valid QIODevice)
- -If currently not StopState, stop.
+ -If currently not StoppedState, stop.
-If previous start was push mode, delete internal QIODevice.
-open audio output.
- -If ok, NoError and ActiveState, else OpenError and StopState
+ -If ok, NoError and ActiveState, else OpenError and StoppedState
-emit stateChanged()
- -return device
+ */
+ d->start(device);
+}
+
+/*!
+ Returns a pointer to the QIODevice being used to handle the data
+ transfer. This QIODevice can be used to write() audio data directly.
- PUSH MODE (device = 0)
- -If currently not StopState, stop.
+ \sa QIODevice
+*/
+
+QIODevice* QAudioOutput::start()
+{
+ /*
+ -If currently not StoppedState, stop.
-If no internal QIODevice, create one.
-open audio output.
- -If ok, NoError and IdleState, else OpenError and StopState
+ -If ok, NoError and IdleState, else OpenError and StoppedState
-emit stateChanged()
-return internal QIODevice
*/
- return d->start(device);
+ return d->start(0);
}
/*!
@@ -227,8 +233,8 @@ QIODevice* QAudioOutput::start(QIODevice* device)
void QAudioOutput::stop()
{
/*
- -If StopState, return
- -set to StopState
+ -If StoppedState, return
+ -set to StoppedState
-detach from audio device
-emit stateChanged()
*/
@@ -257,7 +263,7 @@ void QAudioOutput::suspend()
/*
-If not ActiveState|IdleState, return
-stop processing audio, saving all buffered audio data
- -set NoError and SuspendState
+ -set NoError and SuspendedState
-emit stateChanged()
*/
d->suspend();
@@ -270,7 +276,7 @@ void QAudioOutput::suspend()
void QAudioOutput::resume()
{
/*
- -If SuspendState, return
+ -If SuspendedState, return
-resume audio
-(PULL MODE): set ActiveState, NoError
-(PUSH MODE): set IdleState, NoError
@@ -358,9 +364,9 @@ int QAudioOutput::notifyInterval() const
was called in microseconds.
*/
-qint64 QAudioOutput::totalTime() const
+qint64 QAudioOutput::processedUSecs() const
{
- return d->totalTime();
+ return d->processedUSecs();
}
/*!
@@ -368,9 +374,9 @@ qint64 QAudioOutput::totalTime() const
Suspend states.
*/
-qint64 QAudioOutput::clock() const
+qint64 QAudioOutput::elapsedUSecs() const
{
- return d->clock();
+ return d->elapsedUSecs();
}
/*!
diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h
index bb3496e..38bab8e 100644
--- a/src/multimedia/audio/qaudiooutput.h
+++ b/src/multimedia/audio/qaudiooutput.h
@@ -71,7 +71,9 @@ public:
QAudioFormat format() const;
- QIODevice* start(QIODevice *device = 0);
+ void start(QIODevice *device);
+ QIODevice* start();
+
void stop();
void reset();
void suspend();
@@ -86,8 +88,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index 689da89..e9784d2 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -77,7 +77,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF
intervalTime = 1000;
audioBuffer = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
resuming = false;
@@ -215,8 +215,8 @@ int QAudioOutputPrivate::setFormat()
QIODevice* QAudioOutputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
- deviceState = QAudio::StopState;
+ if(deviceState != QAudio::StoppedState)
+ deviceState = QAudio::StoppedState;
errorState = QAudio::NoError;
@@ -256,9 +256,9 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
void QAudioOutputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
close();
emit stateChanged(deviceState);
}
@@ -304,7 +304,7 @@ bool QAudioOutputPrivate::open()
}
if (( err < 0)||(handle == 0)) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
return false;
}
snd_pcm_nonblock( handle, 0 );
@@ -387,7 +387,7 @@ bool QAudioOutputPrivate::open()
if( err < 0) {
qWarning()<<errMessage;
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
return false;
}
snd_pcm_hw_params_get_buffer_size(hwparams,&buffer_frames);
@@ -431,7 +431,7 @@ bool QAudioOutputPrivate::open()
void QAudioOutputPrivate::close()
{
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
timer->stop();
if ( handle ) {
@@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
if(err < 0) {
close();
errorState = QAudio::FatalError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
}
return 0;
@@ -507,7 +507,7 @@ int QAudioOutputPrivate::periodSize() const
void QAudioOutputPrivate::setBufferSize(int value)
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
buffer_size = value;
}
@@ -529,14 +529,14 @@ int QAudioOutputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioOutputPrivate::totalTime() const
+qint64 QAudioOutputPrivate::processedUSecs() const
{
return totalTimeValue;
}
void QAudioOutputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
int err = 0;
if(handle) {
@@ -571,7 +571,7 @@ void QAudioOutputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) {
timer->stop();
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
errorState = QAudio::NoError;
emit stateChanged(deviceState);
}
@@ -579,7 +579,7 @@ void QAudioOutputPrivate::suspend()
void QAudioOutputPrivate::userFeed()
{
- if(deviceState == QAudio::StopState || deviceState == QAudio::SuspendState)
+ if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState)
return;
#ifdef DEBUG_AUDIO
QTime now(QTime::currentTime());
@@ -658,12 +658,12 @@ bool QAudioOutputPrivate::deviceReady()
return true;
}
-qint64 QAudioOutputPrivate::clock() const
+qint64 QAudioOutputPrivate::elapsedUSecs() const
{
if(!handle)
return 0;
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h
index 298e89e..619ecef 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.h
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.h
@@ -91,8 +91,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
QAudioFormat format() const;
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp
index f23db80..e0651bf 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp
@@ -288,7 +288,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF
internalBufferSize = default_buffer_size;
clockFrequency = AudioGetHostClockFrequency() / 1000;
errorCode = QAudio::NoError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
audioThreadState = Stopped;
intervalTimer = new QTimer(this);
@@ -436,7 +436,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
QIODevice* op = device;
if (!open()) {
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
}
@@ -468,10 +468,10 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
void QAudioOutputPrivate::stop()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadDrain();
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::NoError;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
@@ -480,10 +480,10 @@ void QAudioOutputPrivate::stop()
void QAudioOutputPrivate::reset()
{
QMutexLocker lock(&mutex);
- if (stateCode != QAudio::StopState) {
+ if (stateCode != QAudio::StoppedState) {
audioThreadStop();
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
errorCode = QAudio::NoError;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
@@ -495,7 +495,7 @@ void QAudioOutputPrivate::suspend()
if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) {
audioThreadStop();
- stateCode = QAudio::SuspendState;
+ stateCode = QAudio::SuspendedState;
errorCode = QAudio::NoError;
QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode));
}
@@ -504,7 +504,7 @@ void QAudioOutputPrivate::suspend()
void QAudioOutputPrivate::resume()
{
QMutexLocker lock(&mutex);
- if (stateCode == QAudio::SuspendState) {
+ if (stateCode == QAudio::SuspendedState) {
audioThreadStart();
stateCode = QAudio::ActiveState;
@@ -525,7 +525,7 @@ int QAudioOutputPrivate::periodSize() const
void QAudioOutputPrivate::setBufferSize(int bs)
{
- if (stateCode == QAudio::StopState)
+ if (stateCode == QAudio::StoppedState)
internalBufferSize = bs;
}
@@ -544,14 +544,14 @@ int QAudioOutputPrivate::notifyInterval() const
return intervalTimer->interval();
}
-qint64 QAudioOutputPrivate::totalTime() const
+qint64 QAudioOutputPrivate::processedUSecs() const
{
return totalFrames * 1000000 / audioFormat.frequency();
}
-qint64 QAudioOutputPrivate::clock() const
+qint64 QAudioOutputPrivate::elapsedUSecs() const
{
- if (stateCode == QAudio::StopState)
+ if (stateCode == QAudio::StoppedState)
return 0;
return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000);
@@ -614,7 +614,7 @@ void QAudioOutputPrivate::audioDeviceError()
audioDeviceStop();
errorCode = QAudio::IOError;
- stateCode = QAudio::StopState;
+ stateCode = QAudio::StoppedState;
QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection);
}
}
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h
index 04b3239..76d06a9 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.h
+++ b/src/multimedia/audio/qaudiooutput_mac_p.h
@@ -128,8 +128,8 @@ public:
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 1810ed2..2cfc472 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -71,7 +71,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF
intervalTime = 1000;
audioBuffer = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
audioSource = 0;
pullMode = true;
finished = false;
@@ -157,7 +157,7 @@ QAudioFormat QAudioOutputPrivate::format() const
QIODevice* QAudioOutputPrivate::start(QIODevice* device)
{
- if(deviceState != QAudio::StopState)
+ if(deviceState != QAudio::StoppedState)
close();
if(!pullMode && audioSource) {
@@ -187,7 +187,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
void QAudioOutputPrivate::stop()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
close();
if(!pullMode && audioSource) {
@@ -255,7 +255,7 @@ bool QAudioOutputPrivate::open()
(DWORD_PTR) this,
CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
errorState = QAudio::OpenError;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
qWarning("QAudioOutput: open error");
return false;
@@ -277,10 +277,10 @@ bool QAudioOutputPrivate::open()
void QAudioOutputPrivate::close()
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
return;
- deviceState = QAudio::StopState;
+ deviceState = QAudio::StoppedState;
int delay = (buffer_size-bytesFree())*1000/(settings.frequency()
*settings.channels()*(settings.sampleSize()/8));
waveOutReset(hWaveOut);
@@ -308,7 +308,7 @@ int QAudioOutputPrivate::periodSize() const
void QAudioOutputPrivate::setBufferSize(int value)
{
- if(deviceState == QAudio::StopState)
+ if(deviceState == QAudio::StoppedState)
buffer_size = value;
}
@@ -330,7 +330,7 @@ int QAudioOutputPrivate::notifyInterval() const
return intervalTime;
}
-qint64 QAudioOutputPrivate::totalTime() const
+qint64 QAudioOutputPrivate::processedUSecs() const
{
return totalTimeValue;
}
@@ -390,7 +390,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
void QAudioOutputPrivate::resume()
{
- if(deviceState == QAudio::SuspendState) {
+ if(deviceState == QAudio::SuspendedState) {
deviceState = QAudio::ActiveState;
errorState = QAudio::NoError;
waveOutRestart(hWaveOut);
@@ -403,7 +403,7 @@ void QAudioOutputPrivate::suspend()
{
if(deviceState == QAudio::ActiveState) {
waveOutPause(hWaveOut);
- deviceState = QAudio::SuspendState;
+ deviceState = QAudio::SuspendedState;
errorState = QAudio::NoError;
emit stateChanged(deviceState);
}
@@ -417,7 +417,7 @@ void QAudioOutputPrivate::feedback()
#endif
bytesAvailable = bytesFree();
- if(!(deviceState==QAudio::StopState||deviceState==QAudio::SuspendState)) {
+ if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState)) {
if(bytesAvailable >= period_size)
QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection);
}
@@ -491,9 +491,9 @@ bool QAudioOutputPrivate::deviceReady()
return true;
}
-qint64 QAudioOutputPrivate::clock() const
+qint64 QAudioOutputPrivate::elapsedUSecs() const
{
- if (deviceState == QAudio::StopState)
+ if (deviceState == QAudio::StoppedState)
return 0;
return timeStampOpened.elapsed()*1000;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h
index bcf8e1e..f90b8c2 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.h
+++ b/src/multimedia/audio/qaudiooutput_win32_p.h
@@ -90,8 +90,8 @@ public:
int bufferSize() const;
void setNotifyInterval(int milliSeconds);
int notifyInterval() const;
- qint64 totalTime() const;
- qint64 clock() const;
+ qint64 processedUSecs() const;
+ qint64 elapsedUSecs() const;
QAudio::Error error() const;
QAudio::State state() const;
diff --git a/src/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp
index bfeb2a0..e57adb6 100644
--- a/src/multimedia/video/qimagevideobuffer.cpp
+++ b/src/multimedia/video/qimagevideobuffer.cpp
@@ -85,7 +85,7 @@ uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine)
d->mapMode = mode;
if (numBytes)
- *numBytes = d->image.numBytes();
+ *numBytes = d->image.byteCount();
if (bytesPerLine)
*bytesPerLine = d->image.bytesPerLine();
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 1124337..8dd7a00 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -372,7 +372,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket,
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);
if (priv && priv->method != QAuthenticatorPrivate::None) {
QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
- request.setHeaderField("authorization", response);
+ request.setHeaderField("Authorization", response);
}
}
}
@@ -381,7 +381,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket,
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);
if (priv && priv->method != QAuthenticatorPrivate::None) {
QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
- request.setHeaderField("proxy-authorization", response);
+ request.setHeaderField("Proxy-Authorization", response);
}
}
}
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 73a8703..7dfb7af 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -984,14 +984,14 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
cookie.setExpirationDate(dt);
} else if (field.first == "domain") {
QByteArray rawDomain = field.second;
+ QString maybeLeadingDot;
if (rawDomain.startsWith('.')) {
+ maybeLeadingDot = QLatin1Char('.');
rawDomain = rawDomain.mid(1);
}
+
QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain)));
- // always add the dot, there are some servers that forget the
- // leading dot. This is actually forbidden according to RFC 2109,
- // but all browsers accept it anyway so we do that as well
- cookie.setDomain(QLatin1Char('.') + normalizedDomain);
+ cookie.setDomain(maybeLeadingDot + normalizedDomain);
} else if (field.first == "max-age") {
bool ok = false;
int secs = field.second.toInt(&ok);
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index 8430966..19f7217 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -198,6 +198,13 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieLis
if (cookie.domain().isEmpty()) {
cookie.setDomain(defaultDomain);
} else {
+ // Ensure the domain starts with a dot if its field was not empty
+ // in the HTTP header. There are some servers that forget the
+ // leading dot and this is actually forbidden according to RFC 2109,
+ // but all browsers accept it anyway so we do that as well.
+ if (!cookie.domain().startsWith(QLatin1Char('.')))
+ cookie.setDomain(QLatin1Char('.') + cookie.domain());
+
QString domain = cookie.domain();
if (!(isParentDomain(domain, defaultDomain)
|| isParentDomain(defaultDomain, domain))) {
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index 64c5152..afd3570 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -161,9 +161,11 @@ public Q_SLOTS:
cond.wakeOne();
}
#ifndef QT_NO_THREAD
- if (!wait(QHOSTINFO_THREAD_WAIT))
+ if (!wait(QHOSTINFO_THREAD_WAIT)) {
terminate();
- wait();
+ // Don't wait forever; see QTBUG-5296.
+ wait(QHOSTINFO_THREAD_WAIT);
+ }
#endif
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 8228c7e..8c5bf0e 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -2107,7 +2107,7 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
q->state()->rectangleClip = use_system_clip ? systemClip.boundingRect() : QRect(0, 0, width, height);
updateClipScissorTest();
- if (systemClip.numRects() == 1) {
+ if (systemClip.rectCount() == 1) {
if (systemClip.boundingRect() == QRect(0, 0, width, height))
use_system_clip = false;
#ifndef QT_GL_NO_SCISSOR_TEST
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index ad177dc..8063fc8 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -4078,7 +4078,7 @@ QImage QGLWidget::grabFrameBuffer(bool withAlpha)
glReadPixels(0, 0, w, h, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, res.bits());
const QVector<QColor> pal = QColormap::instance().colormap();
if (pal.size()) {
- res.setNumColors(pal.size());
+ res.setColorCount(pal.size());
for (int i = 0; i < pal.size(); i++)
res.setColor(i, pal.at(i).rgb());
}
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index 0eaab28..fcb0ea2 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -102,7 +102,7 @@ private:
class QGLPixmapBlurFilter : public QGLCustomShaderStage, public QGLPixmapFilter<QPixmapBlurFilter>
{
public:
- QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint);
+ QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHints hints);
void setUniforms(QGLShaderProgram *program);
@@ -123,13 +123,13 @@ private:
mutable bool m_haveCached;
mutable int m_cachedRadius;
- mutable QGraphicsBlurEffect::BlurHint m_hint;
+ mutable QGraphicsBlurEffect::BlurHints m_hints;
};
class QGLPixmapDropShadowFilter : public QGLCustomShaderStage, public QGLPixmapFilter<QPixmapDropShadowFilter>
{
public:
- QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHint hint);
+ QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHints hints);
void setUniforms(QGLShaderProgram *program);
@@ -143,7 +143,7 @@ private:
mutable bool m_haveCached;
mutable int m_cachedRadius;
- mutable QGraphicsBlurEffect::BlurHint m_hint;
+ mutable QGraphicsBlurEffect::BlurHints m_hints;
};
extern QGLWidget *qt_gl_share_widget();
@@ -159,19 +159,19 @@ QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *pr
case QPixmapFilter::BlurFilter: {
const QPixmapBlurFilter *proto = static_cast<const QPixmapBlurFilter *>(prototype);
- if (proto->blurHint() == QGraphicsBlurEffect::AnimationHint) {
+ if (proto->blurHints() & QGraphicsBlurEffect::AnimationHint) {
if (!d->animationBlurFilter)
- d->animationBlurFilter.reset(new QGLPixmapBlurFilter(proto->blurHint()));
+ d->animationBlurFilter.reset(new QGLPixmapBlurFilter(proto->blurHints()));
return d->animationBlurFilter.data();
}
- if (proto->blurHint() == QGraphicsBlurEffect::PerformanceHint || proto->radius() <= 5) {
- if (!d->fastBlurFilter)
- d->fastBlurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::PerformanceHint));
- return d->fastBlurFilter.data();
+ if ((proto->blurHints() & QGraphicsBlurEffect::QualityHint) && proto->radius() > 5) {
+ if (!d->blurFilter)
+ d->blurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::QualityHint));
+ return d->blurFilter.data();
}
- if (!d->blurFilter)
- d->blurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::QualityHint));
- return d->blurFilter.data();
+ if (!d->fastBlurFilter)
+ d->fastBlurFilter.reset(new QGLPixmapBlurFilter(QGraphicsBlurEffect::PerformanceHint));
+ return d->fastBlurFilter.data();
}
case QPixmapFilter::DropShadowFilter: {
@@ -316,11 +316,11 @@ static const char *qt_gl_texture_sampling_helper =
" return texture2D(src, srcCoords).a;\n"
"}\n";
-QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHint hint)
+QGLPixmapBlurFilter::QGLPixmapBlurFilter(QGraphicsBlurEffect::BlurHints hints)
: m_animatedBlur(false)
, m_haveCached(false)
, m_cachedRadius(0)
- , m_hint(hint)
+ , m_hints(hints)
{
}
@@ -503,7 +503,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
QGLBlurTextureCache *blurTextureCache = QGLBlurTextureCache::cacheForContext(ctx);
- if (m_hint == QGraphicsBlurEffect::AnimationHint && blurTextureCache->fitsInCache(src)) {
+ if ((m_hints & QGraphicsBlurEffect::AnimationHint) && blurTextureCache->fitsInCache(src)) {
QRect targetRect = src.rect().adjusted(-qMaxCachedBlurLevel, -qMaxCachedBlurLevel, qMaxCachedBlurLevel, qMaxCachedBlurLevel);
// ensure even dimensions (going to divide by two)
targetRect.setWidth((targetRect.width() + 1) & ~1);
@@ -514,7 +514,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
info = blurTextureCache->takeBlurTextureInfo(src);
} else {
m_animatedBlur = false;
- m_hint = QGraphicsBlurEffect::QualityHint;
+ m_hints = QGraphicsBlurEffect::QualityHint;
m_singlePass = false;
QGLFramebufferObjectFormat format;
@@ -594,7 +594,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
if (!m_haveCached || !m_animatedBlur) {
m_haveCached = true;
m_animatedBlur = true;
- m_hint = QGraphicsBlurEffect::AnimationHint;
+ m_hints = QGraphicsBlurEffect::AnimationHint;
filter->setSource(qt_gl_interpolate_filter);
}
@@ -653,7 +653,7 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
int actualRadius = qRound(radius());
int filterRadius = actualRadius;
int fastRadii[] = { 1, 2, 3, 5, 8, 15, 25 };
- if (m_hint != QGraphicsBlurEffect::QualityHint) {
+ if (!(m_hints & QGraphicsBlurEffect::QualityHint)) {
uint i = 0;
for (; i < (sizeof(fastRadii)/sizeof(*fastRadii))-1; ++i) {
if (fastRadii[i+1] > filterRadius)
@@ -762,7 +762,7 @@ void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program)
return;
}
- if (m_hint == QGraphicsBlurEffect::QualityHint) {
+ if (m_hints & QGraphicsBlurEffect::QualityHint) {
if (m_singlePass)
program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height());
else if (m_horizontalBlur)
@@ -912,10 +912,10 @@ QByteArray QGLPixmapBlurFilter::generateGaussianShader(int radius, bool singlePa
return source;
}
-QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHint hint)
+QGLPixmapDropShadowFilter::QGLPixmapDropShadowFilter(QGraphicsBlurEffect::BlurHints hints)
: m_haveCached(false)
, m_cachedRadius(0)
- , m_hint(hint)
+ , m_hints(hints)
{
}
@@ -1018,7 +1018,7 @@ void QGLPixmapDropShadowFilter::setUniforms(QGLShaderProgram *program)
alpha);
}
- if (m_hint == QGraphicsBlurEffect::QualityHint) {
+ if (m_hints & QGraphicsBlurEffect::QualityHint) {
if (m_singlePass)
program->setUniformValue("delta", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height());
else if (m_horizontalBlur)
diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp
index 1c02fd0..4d7a69c 100644
--- a/src/opengl/qgraphicsshadereffect.cpp
+++ b/src/opengl/qgraphicsshadereffect.cpp
@@ -241,7 +241,7 @@ void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code)
/*#
\reimp
*/
-void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
+void QGraphicsShaderEffect::draw(QPainter *painter)
{
Q_D(QGraphicsShaderEffect);
@@ -256,13 +256,13 @@ void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *sourc
bool usingShader = d->customShaderStage->setOnPainter(painter);
QPoint offset;
- if (source->isPixmap()) {
+ if (sourceIsPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
- const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
+ const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset);
painter->drawPixmap(offset, pixmap);
} else {
// Draw pixmap in device coordinates to avoid pixmap scaling.
- const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
painter->drawPixmap(offset, pixmap);
@@ -273,7 +273,7 @@ void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *sourc
if (usingShader)
d->customShaderStage->removeFromPainter(painter);
#else
- source->draw(painter);
+ drawSource(painter);
#endif
}
diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h
index de7f00c..de65ebb 100644
--- a/src/opengl/qgraphicsshadereffect_p.h
+++ b/src/opengl/qgraphicsshadereffect_p.h
@@ -76,7 +76,7 @@ public:
void setPixelShaderFragment(const QByteArray& code);
protected:
- void draw(QPainter *painter, QGraphicsEffectSource *source);
+ void draw(QPainter *painter);
void setUniformsDirty();
virtual void setUniforms(QGLShaderProgram *program);
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 5ca37ef..fb55097 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -452,7 +452,7 @@ QImage QGLPixmapData::fillImage(const QColor &color) const
if (pixelType() == BitmapType) {
img = QImage(w, h, QImage::Format_MonoLSB);
- img.setNumColors(2);
+ img.setColorCount(2);
img.setColor(0, QColor(Qt::color0).rgba());
img.setColor(1, QColor(Qt::color1).rgba());
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 047d9d8..75b7fa5 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -1753,13 +1753,13 @@ void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
// QRegion copy on the heap for the test if we can.
QRegion clip = d->systemClip; // Reference-counted, no alloc.
QRect clipRect;
- if (clip.numRects() == 1) {
+ if (clip.rectCount() == 1) {
clipRect = clip.boundingRect().intersected(r);
} else if (clip.isEmpty()) {
clipRect = r;
} else {
clip = clip.intersect(r);
- if (clip.numRects() != 1) {
+ if (clip.rectCount() != 1) {
d->maskValid = false;
d->maskIsSet = false;
d->maskRect = QRect();
@@ -1810,7 +1810,7 @@ void QVGPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
Q_D(QVGPaintEngine);
// Use the QRect case if the region consists of a single rectangle.
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
clip(region.boundingRect(), op);
return;
}
@@ -1853,7 +1853,7 @@ void QVGPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
clip = r;
else
clip = clip.intersect(r);
- if (clip.numRects() == 1) {
+ if (clip.rectCount() == 1) {
d->maskValid = false;
d->maskIsSet = false;
d->maskRect = clip.boundingRect();
@@ -1871,7 +1871,7 @@ void QVGPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
case Qt::IntersectClip:
{
- if (region.numRects() != 1) {
+ if (region.rectCount() != 1) {
// If there is more than one rectangle, then intersecting
// the rectangles one by one in modifyMask() will not give
// the desired result. So fall back to path-based clipping.
@@ -2148,7 +2148,7 @@ QRegion QVGPaintEngine::defaultClipRegion()
bool QVGPaintEngine::isDefaultClipRegion(const QRegion& region)
{
- if (region.numRects() != 1)
+ if (region.rectCount() != 1)
return false;
QPaintDevice *pdev = paintDevice();
@@ -3544,7 +3544,7 @@ void QVGCompositionHelper::fillBackground
d->clearColor = color;
d->clearOpacity = 1.0f;
}
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
QRect r = region.boundingRect();
vgClear(r.x(), screenSize.height() - r.y() - r.height(),
r.width(), r.height());
@@ -3569,7 +3569,7 @@ void QVGCompositionHelper::fillBackground
d->ensureBrush(brush);
d->setFillRule(VG_EVEN_ODD);
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
fillBackgroundRect(region.boundingRect(), d);
} else {
const QVector<QRect> rects = region.rects();
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index 87d81f0..7be4a2a 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -528,7 +528,7 @@ QString QAccessibleDisplay::text(Text t, int child) const
#ifndef QT_NO_LCDNUMBER
} else if (qobject_cast<QLCDNumber*>(object())) {
QLCDNumber *l = qobject_cast<QLCDNumber*>(object());
- if (l->numDigits())
+ if (l->digitCount())
str = QString::number(l->value());
else
str = QString::number(l->intValue());
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index cb4fb88..daefa21 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -176,7 +176,7 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
return QDirectFBScreen::depth(imageFormat);
case QPaintDevice::PdmNumColors: {
if (!lockedImage.isNull())
- return lockedImage.numColors();
+ return lockedImage.colorCount();
DFBResult result;
IDirectFBPalette *palette = 0;
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 449bc0d..eb771ba 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -214,7 +214,7 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage:
const int height = image.height();
const int bplQt = image.bytesPerLine();
if (bplQt == bplDFB && bplQt == (image.width() * image.depth() / 8)) {
- memcpy(mem, image.bits(), image.numBytes());
+ memcpy(mem, image.bits(), image.byteCount());
} else {
for (int i=0; i<height; ++i) {
memcpy(mem, image.scanLine(i), bplQt);
@@ -225,7 +225,7 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage:
}
}
#ifdef QT_DIRECTFB_PALETTE
- if (image.numColors() != 0 && surface)
+ if (image.colorCount() != 0 && surface)
QDirectFBScreen::setSurfaceColorTable(surface, image);
#endif
return surface;
@@ -497,7 +497,7 @@ void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface,
if (!surface)
return;
- const int numColors = image.numColors();
+ const int numColors = image.colorCount();
if (numColors == 0)
return;
@@ -1066,7 +1066,7 @@ static inline QColor colorFromName(const QString &name)
QRegExp rx("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])");
rx.setCaseSensitivity(Qt::CaseInsensitive);
if (rx.exactMatch(name)) {
- Q_ASSERT(rx.numCaptures() == 4);
+ Q_ASSERT(rx.captureCount() == 4);
int ints[4];
int i;
for (i=0; i<4; ++i) {
@@ -1564,7 +1564,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int)
primary->SetColor(primary, 0xff, 0xff, 0xff, cmd.windowOpacity);
}
const QRegion &region = cmd.source;
- const int rectCount = region.numRects();
+ const int rectCount = region.rectCount();
DFBRectangle source;
if (rectCount == 1) {
::initParameters(source, region.boundingRect(), cmd.windowPosition);
@@ -1619,7 +1619,7 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
d_ptr->primarySurface->SetColor(d_ptr->primarySurface,
color.red(), color.green(), color.blue(),
color.alpha());
- const int n = region.numRects();
+ const int n = region.rectCount();
if (n == 1) {
const QRect r = region.boundingRect();
d_ptr->primarySurface->FillRectangle(d_ptr->primarySurface, r.x(), r.y(), r.width(), r.height());
@@ -1680,7 +1680,7 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags
if (!(flipFlags & DSFLIP_BLIT)) {
surface->Flip(surface, 0, flipFlags);
} else {
- if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.numRects() > 1) {
+ if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.rectCount() > 1) {
const QVector<QRect> rects = region.rects();
const DFBSurfaceFlipFlags nonWaitFlags = flipFlags & ~DSFLIP_WAIT;
for (int i=0; i<rects.size(); ++i) {
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index 3fbefc3..c9a010f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -311,7 +311,7 @@ bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.isEmpty())
return false;
dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- if (region.numRects() == 1) {
+ if (region.rectCount() == 1) {
scrollSurface(dfbSurface, region.boundingRect(), dx, dy);
} else {
const QVector<QRect> rects = region.rects();
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
index 4a3787f..51a6c4e 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
@@ -199,7 +199,7 @@ void PvrEglWindowSurface::setDirectRegion(const QRegion &r, int id)
if (region.isEmpty()) {
pvrQwsClearVisibleRegion(drawable);
- } else if (region.numRects() == 1) {
+ } else if (region.rectCount() == 1) {
QRect rect = region.boundingRect();
PvrQwsRect pvrRect;
pvrRect.x = rect.x();
diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index 98879b0..c95b63c 100644
--- a/src/plugins/imageformats/gif/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
@@ -335,7 +335,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32;
if (image->isNull()) {
(*image) = QImage(swidth, sheight, format);
- memset(image->bits(), 0, image->numBytes());
+ memset(image->bits(), 0, image->byteCount());
// ### size of the upcoming frame, should rather
// be known before decoding it.
@@ -393,7 +393,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
backingstore = QImage(qMax(backingstore.width(), w),
qMax(backingstore.height(), h),
QImage::Format_RGB32);
- memset(image->bits(), 0, image->numBytes());
+ memset(image->bits(), 0, image->byteCount());
}
for (int ln=0; ln<h; ln++) {
memcpy(backingstore.scanLine(ln),
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp
index e01b33a..4d819d1 100644
--- a/src/plugins/imageformats/ico/qicohandler.cpp
+++ b/src/plugins/imageformats/ico/qicohandler.cpp
@@ -379,7 +379,7 @@ void ICOReader::findColorInfo(QImage & image)
void ICOReader::readColorTable(QImage & image)
{
if (iod) {
- image.setNumColors(icoAttrib.ncolors);
+ image.setColorCount(icoAttrib.ncolors);
uchar rgb[4];
for (int i=0; i<icoAttrib.ncolors; i++) {
if (iod->read((char*)rgb, 4) != 4) {
@@ -574,7 +574,7 @@ QImage ICOReader::iconAt(int index)
if (!image.isNull()) {
QImage mask(image.width(), image.height(), QImage::Format_Mono);
if (!mask.isNull()) {
- mask.setNumColors(2);
+ mask.setColorCount(2);
mask.setColor(0, qRgba(255,255,255,0xff));
mask.setColor(1, qRgba(0 ,0 ,0 ,0xff));
read1BitBMP(mask);
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index 3b23e56..6b2f885 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -741,7 +741,7 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
*dest = QImage(size, format);
if (format == QImage::Format_Indexed8) {
- dest->setNumColors(256);
+ dest->setColorCount(256);
for (int i = 0; i < 256; i++)
dest->setColor(i, qRgb(i,i,i));
}
@@ -851,7 +851,7 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
} else if (cinfo.output_components == 1) {
if (outImage->size() != QSize(sWidth, sHeight) || outImage->format() != QImage::Format_Indexed8)
*outImage = QImage(sWidth, sHeight, QImage::Format_Indexed8);
- outImage->setNumColors(256);
+ outImage->setColorCount(256);
for (int i = 0; i < 256; ++i)
outImage->setColor(i, qRgb(i,i,i));
} else {
@@ -1054,7 +1054,7 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
case QImage::Format_MonoLSB:
case QImage::Format_Indexed8:
gray = true;
- for (int i = image.numColors(); gray && i--;) {
+ for (int i = image.colorCount(); gray && i--;) {
gray = gray & (qRed(cmap[i]) == qGreen(cmap[i]) &&
qRed(cmap[i]) == qBlue(cmap[i]));
}
diff --git a/src/qt3support/painting/q3paintdevicemetrics.h b/src/qt3support/painting/q3paintdevicemetrics.h
index 830dd90..4f1603b 100644
--- a/src/qt3support/painting/q3paintdevicemetrics.h
+++ b/src/qt3support/painting/q3paintdevicemetrics.h
@@ -63,7 +63,7 @@ public:
int logicalDpiY() const { return pdev->logicalDpiY(); }
int physicalDpiX() const { return pdev->physicalDpiX(); }
int physicalDpiY() const { return pdev->physicalDpiY(); }
- int numColors() const { return pdev->numColors(); }
+ int numColors() const { return pdev->colorCount(); }
int depth() const { return pdev->depth(); }
private:
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 2b60a46..216f325 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1093,6 +1093,8 @@ void QScriptEnginePrivate::setContextFlags(JSC::ExecState *exec, uint flags)
void QScriptEnginePrivate::mark(JSC::MarkStack& markStack)
{
+ Q_Q(QScriptEngine);
+
markStack.append(originalGlobalObject());
markStack.append(globalObject());
if (originalGlobalObjectProxy)
@@ -1130,6 +1132,22 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack)
markStack.append((*it)->prototype);
}
}
+
+ {
+ QScriptContext *context = q->currentContext();
+
+ while (context) {
+ JSC::ScopeChainNode *node = frameForContext(context)->scopeChain();
+ JSC::ScopeChainIterator it(node);
+ for (it = node->begin(); it != node->end(); ++it) {
+ JSC::JSObject *object = *it;
+ if (object)
+ markStack.append(object);
+ }
+
+ context = context->parentContext();
+ }
+ }
}
bool QScriptEnginePrivate::isCollecting() const
@@ -2281,7 +2299,8 @@ QScriptContext *QScriptEngine::pushContext()
return the new top frame. (might be the same as exec if a new stackframe was not needed) or 0 if stack overflow
*/
JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSValue _thisObject,
- const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor)
+ const JSC::ArgList& args, JSC::JSObject *callee, bool calledAsConstructor,
+ bool clearScopeChain)
{
JSC::JSValue thisObject = _thisObject;
if (calledAsConstructor) {
@@ -2315,7 +2334,14 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV
for (it = args.begin(); it != args.end(); ++it)
newCallFrame[++dst] = *it;
newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize;
- newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
+
+ if (!clearScopeChain) {
+ newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
+ } else {
+ JSC::JSObject *jscObject = originalGlobalObject();
+ JSC::ScopeChainNode *scn = new JSC::ScopeChainNode(0, jscObject, &exec->globalData(), jscObject);
+ newCallFrame->init(0, /*vPC=*/0, scn, exec, flags | ShouldRestoreCallFrame, argc, callee);
+ }
} else {
setContextFlags(newCallFrame, flags);
#if ENABLE(JIT)
diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h
index 3f438da..7db61e1 100644
--- a/src/script/api/qscriptengine.h
+++ b/src/script/api/qscriptengine.h
@@ -56,6 +56,7 @@
#include <QtScript/qscriptvalue.h>
#include <QtScript/qscriptcontext.h>
#include <QtScript/qscriptstring.h>
+#include <QtScript/qscriptprogram.h>
QT_BEGIN_HEADER
@@ -67,7 +68,6 @@ class QDateTime;
class QScriptClass;
class QScriptEngineAgent;
class QScriptEnginePrivate;
-class QScriptProgram;
#ifndef QT_NO_QOBJECT
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index d12b0f4..e7cdcda 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -174,7 +174,7 @@ public:
static JSC::Register *thisRegisterForFrame(JSC::ExecState *frame);
JSC::CallFrame *pushContext(JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList& args,
- JSC::JSObject *callee, bool calledAsConstructor = false);
+ JSC::JSObject *callee, bool calledAsConstructor = false, bool clearScopeChain = false);
void popContext();
void mark(JSC::MarkStack& markStack);
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 52a1e6d..d6cbb41 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -71,6 +71,7 @@
#include "bridge/qscriptclassobject_p.h"
#include "bridge/qscriptvariant_p.h"
#include "bridge/qscriptqobject_p.h"
+#include "bridge/qscriptdeclarativeclass_p.h"
/*!
\since 4.3
@@ -1496,6 +1497,8 @@ QVariant QScriptValue::toVariant() const
#endif
else if (isArray())
return QScriptEnginePrivate::variantListFromArray(*this);
+ else if (QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(*this))
+ return dc->toVariant(QScriptDeclarativeClass::object(*this));
// try to convert to primitive
JSC::ExecState *exec = d->engine->currentFrame;
JSC::JSValue savedException;
@@ -1586,6 +1589,8 @@ QObject *QScriptValue::toQObject() const
if (isQObject()) {
QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
return static_cast<QScript::QObjectDelegate*>(object->delegate())->value();
+ } else if (QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(*this)) {
+ return dc->toQObject(QScriptDeclarativeClass::object(*this));
} else if (isVariant()) {
QVariant var = toVariant();
int type = var.userType();
diff --git a/src/script/bridge/bridge.pri b/src/script/bridge/bridge.pri
index 666a07e..09e2dfb 100644
--- a/src/script/bridge/bridge.pri
+++ b/src/script/bridge/bridge.pri
@@ -5,7 +5,9 @@ SOURCES += \
$$PWD/qscriptvariant.cpp \
$$PWD/qscriptqobject.cpp \
$$PWD/qscriptglobalobject.cpp \
- $$PWD/qscriptactivationobject.cpp
+ $$PWD/qscriptactivationobject.cpp \
+ $$PWD/qscriptdeclarativeobject.cpp \
+ $$PWD/qscriptdeclarativeclass.cpp
HEADERS += \
$$PWD/qscriptfunction_p.h \
@@ -14,4 +16,6 @@ HEADERS += \
$$PWD/qscriptvariant_p.h \
$$PWD/qscriptqobject_p.h \
$$PWD/qscriptglobalobject_p.h \
- $$PWD/qscriptactivationobject_p.h
+ $$PWD/qscriptactivationobject_p.h \
+ $$PWD/qscriptdeclarativeobject_p.h \
+ $$PWD/qscriptdeclarativeclass_p.h
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp
new file mode 100644
index 0000000..b5d9bf5
--- /dev/null
+++ b/src/script/bridge/qscriptdeclarativeclass.cpp
@@ -0,0 +1,356 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qscriptdeclarativeclass_p.h"
+#include "qscriptdeclarativeobject_p.h"
+#include "qscriptobject_p.h"
+#include <QtScript/qscriptstring.h>
+#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptengineagent.h>
+#include <private/qscriptengine_p.h>
+#include <private/qscriptvalue_p.h>
+#include <private/qscriptqobject_p.h>
+#include <private/qscriptactivationobject_p.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier()
+{
+ new (&d) JSC::Identifier();
+}
+
+QScriptDeclarativeClass::PersistentIdentifier::~PersistentIdentifier()
+{
+ ((JSC::Identifier &)d).JSC::Identifier::~Identifier();
+}
+
+QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier(const PersistentIdentifier &other)
+{
+ identifier = other.identifier;
+ new (&d) JSC::Identifier((JSC::Identifier &)(other.d));
+}
+
+QScriptDeclarativeClass::PersistentIdentifier &
+QScriptDeclarativeClass::PersistentIdentifier::operator=(const PersistentIdentifier &other)
+{
+ identifier = other.identifier;
+ ((JSC::Identifier &)d) = (JSC::Identifier &)(other.d);
+ return *this;
+}
+
+QScriptDeclarativeClass::QScriptDeclarativeClass(QScriptEngine *engine)
+: d_ptr(new QScriptDeclarativeClassPrivate)
+{
+ Q_ASSERT(sizeof(void*) == sizeof(JSC::Identifier));
+ d_ptr->q_ptr = this;
+ d_ptr->engine = engine;
+}
+
+QScriptValue QScriptDeclarativeClass::newObject(QScriptEngine *engine,
+ QScriptDeclarativeClass *scriptClass,
+ Object *object)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(scriptClass);
+
+ QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine));
+
+ JSC::ExecState* exec = p->currentFrame;
+ QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure);
+ result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object));
+ return p->scriptValueFromJSCValue(result);
+}
+
+QScriptDeclarativeClass *QScriptDeclarativeClass::scriptClass(const QScriptValue &v)
+{
+ QScriptValuePrivate *d = QScriptValuePrivate::get(v);
+ if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
+ return 0;
+ QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
+ QScriptObjectDelegate *delegate = scriptObject->delegate();
+ if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+ return 0;
+ return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass();
+}
+
+QScriptDeclarativeClass::Object *QScriptDeclarativeClass::object(const QScriptValue &v)
+{
+ QScriptValuePrivate *d = QScriptValuePrivate::get(v);
+ if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
+ return 0;
+ QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
+ QScriptObjectDelegate *delegate = scriptObject->delegate();
+ if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+ return 0;
+ return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->object();
+}
+
+QScriptValue QScriptDeclarativeClass::function(const QScriptValue &v, const Identifier &name)
+{
+ QScriptValuePrivate *d = QScriptValuePrivate::get(v);
+
+ if (!d->isObject())
+ return QScriptValue();
+
+ JSC::ExecState *exec = d->engine->currentFrame;
+ JSC::JSObject *object = d->jscValue.getObject();
+ JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
+ JSC::JSValue result;
+
+ JSC::Identifier id(exec, (JSC::UString::Rep *)name);
+
+ if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
+ result = slot.getValue(exec, id);
+ if (QScript::isFunction(result))
+ return d->engine->scriptValueFromJSCValue(result);
+ }
+
+ return QScriptValue();
+}
+
+QScriptValue QScriptDeclarativeClass::property(const QScriptValue &v, const Identifier &name)
+{
+ QScriptValuePrivate *d = QScriptValuePrivate::get(v);
+
+ if (!d->isObject())
+ return QScriptValue();
+
+ JSC::ExecState *exec = d->engine->currentFrame;
+ JSC::JSObject *object = d->jscValue.getObject();
+ JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
+ JSC::JSValue result;
+
+ JSC::Identifier id(exec, (JSC::UString::Rep *)name);
+
+ if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
+ result = slot.getValue(exec, id);
+ return d->engine->scriptValueFromJSCValue(result);
+ }
+
+ return QScriptValue();
+}
+
+/*
+Returns the scope chain entry at \a index. If index is less than 0, returns
+entries starting at the end. For example, scopeChainValue(context, -1) will return
+the value last in the scope chain.
+*/
+QScriptValue QScriptDeclarativeClass::scopeChainValue(QScriptContext *context, int index)
+{
+ context->activationObject(); //ensure the creation of the normal scope for native context
+ const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(context);
+ QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
+
+ JSC::ScopeChainNode *node = frame->scopeChain();
+ JSC::ScopeChainIterator it(node);
+
+ if (index < 0) {
+ int count = 0;
+ for (it = node->begin(); it != node->end(); ++it)
+ ++count;
+
+ index = qAbs(index);
+ if (index > count)
+ return QScriptValue();
+ else
+ index = count - index;
+ }
+
+ for (it = node->begin(); it != node->end(); ++it) {
+
+ if (index == 0) {
+
+ JSC::JSObject *object = *it;
+ if (!object) return QScriptValue();
+
+ if (object->inherits(&QScript::QScriptActivationObject::info)
+ && (static_cast<QScript::QScriptActivationObject*>(object)->delegate() != 0)) {
+ // Return the object that property access is being delegated to
+ object = static_cast<QScript::QScriptActivationObject*>(object)->delegate();
+ }
+ return engine->scriptValueFromJSCValue(object);
+
+ } else {
+ --index;
+ }
+
+ }
+
+ return QScriptValue();
+}
+
+/*!
+ Enters a new execution context and returns the associated
+ QScriptContext object.
+
+ Once you are done with the context, you should call popContext() to
+ restore the old context.
+
+ By default, the `this' object of the new context is the Global Object.
+ The context's \l{QScriptContext::callee()}{callee}() will be invalid.
+
+ Unlike pushContext(), the default scope chain is reset to include
+ only the global object and the QScriptContext's activation object.
+
+ \sa QScriptEngine::popContext()
+*/
+QScriptContext * QScriptDeclarativeClass::pushCleanContext(QScriptEngine *engine)
+{
+ if (!engine)
+ return 0;
+
+ QScriptEnginePrivate *d = QScriptEnginePrivate::get(engine);
+
+ JSC::CallFrame* newFrame = d->pushContext(d->currentFrame,
+ d->currentFrame->globalData().dynamicGlobalObject,
+ JSC::ArgList(), /*callee = */0, false, true);
+
+ if (engine->agent())
+ engine->agent()->contextPush();
+
+ return d->contextForFrame(newFrame);
+}
+
+QScriptDeclarativeClass::~QScriptDeclarativeClass()
+{
+}
+
+QScriptEngine *QScriptDeclarativeClass::engine() const
+{
+ return d_ptr->engine;
+}
+
+QScriptDeclarativeClass::PersistentIdentifier
+QScriptDeclarativeClass::createPersistentIdentifier(const QString &str)
+{
+ QScriptEnginePrivate *p =
+ static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(d_ptr->engine));
+ JSC::ExecState* exec = p->currentFrame;
+
+ PersistentIdentifier rv(true);
+ new (&rv.d) JSC::Identifier(exec, (UChar *)str.constData(), str.size());
+ rv.identifier = (void *)((JSC::Identifier &)rv.d).ustring().rep();
+ return rv;
+}
+
+QScriptDeclarativeClass::PersistentIdentifier
+QScriptDeclarativeClass::createPersistentIdentifier(const Identifier &id)
+{
+ QScriptEnginePrivate *p =
+ static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(d_ptr->engine));
+ JSC::ExecState* exec = p->currentFrame;
+
+ PersistentIdentifier rv(true);
+ new (&rv.d) JSC::Identifier(exec, (JSC::UString::Rep *)id);
+ rv.identifier = (void *)((JSC::Identifier &)rv.d).ustring().rep();
+ return rv;
+}
+
+QString QScriptDeclarativeClass::toString(const Identifier &identifier)
+{
+ JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
+ return QString((QChar *)r->data(), r->size());
+}
+
+quint32 QScriptDeclarativeClass::toArrayIndex(const Identifier &identifier, bool *ok)
+{
+ JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
+ JSC::UString s(r);
+ return s.toArrayIndex(ok);
+}
+
+QScriptClass::QueryFlags
+QScriptDeclarativeClass::queryProperty(Object *object, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ Q_UNUSED(flags);
+ return 0;
+}
+
+QScriptValue QScriptDeclarativeClass::property(Object *object, const Identifier &name)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ return QScriptValue();
+}
+
+void QScriptDeclarativeClass::setProperty(Object *object, const Identifier &name,
+ const QScriptValue &value)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ Q_UNUSED(value);
+}
+
+QScriptValue::PropertyFlags
+QScriptDeclarativeClass::propertyFlags(Object *object, const Identifier &name)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ return 0;
+}
+
+QStringList QScriptDeclarativeClass::propertyNames(Object *object)
+{
+ Q_UNUSED(object);
+ return QStringList();
+}
+
+QObject *QScriptDeclarativeClass::toQObject(Object *, bool *ok)
+{
+ if (ok) *ok = false;
+ return 0;
+}
+
+QVariant QScriptDeclarativeClass::toVariant(Object *, bool *ok)
+{
+ if (ok) *ok = false;
+ return QVariant();
+}
+
+QScriptContext *QScriptDeclarativeClass::context() const
+{
+ return d_ptr->context;
+}
+
diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h
new file mode 100644
index 0000000..d0e653d
--- /dev/null
+++ b/src/script/bridge/qscriptdeclarativeclass_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** 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 QSCRIPTDECLARATIVECLASS_P_H
+#define QSCRIPTDECLARATIVECLASS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobjectdefs.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtScript/qscriptclass.h>
+
+QT_BEGIN_NAMESPACE
+
+class QScriptDeclarativeClassPrivate;
+class PersistentIdentifierPrivate;
+class QScriptContext;
+class Q_SCRIPT_EXPORT QScriptDeclarativeClass
+{
+public:
+ typedef void* Identifier;
+
+ struct Object { virtual ~Object() {} };
+
+ static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *);
+ static QScriptDeclarativeClass *scriptClass(const QScriptValue &);
+ static Object *object(const QScriptValue &);
+
+ static QScriptValue function(const QScriptValue &, const Identifier &);
+ static QScriptValue property(const QScriptValue &, const Identifier &);
+
+ static QScriptValue scopeChainValue(QScriptContext *, int index);
+ static QScriptContext *pushCleanContext(QScriptEngine *);
+
+ class Q_SCRIPT_EXPORT PersistentIdentifier
+ {
+ public:
+ Identifier identifier;
+
+ PersistentIdentifier();
+ ~PersistentIdentifier();
+ PersistentIdentifier(const PersistentIdentifier &other);
+ PersistentIdentifier &operator=(const PersistentIdentifier &other);
+
+ private:
+ friend class QScriptDeclarativeClass;
+ PersistentIdentifier(bool) : identifier(0), d(0) {}
+ void *d;
+ };
+
+ QScriptDeclarativeClass(QScriptEngine *engine);
+ virtual ~QScriptDeclarativeClass();
+
+ QScriptEngine *engine() const;
+
+ PersistentIdentifier createPersistentIdentifier(const QString &);
+ PersistentIdentifier createPersistentIdentifier(const Identifier &);
+
+ QString toString(const Identifier &);
+ quint32 toArrayIndex(const Identifier &, bool *ok);
+
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+
+ virtual QScriptValue property(Object *, const Identifier &);
+ virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+ virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &);
+
+ virtual QStringList propertyNames(Object *);
+
+ virtual QObject *toQObject(Object *, bool *ok = 0);
+ virtual QVariant toVariant(Object *, bool *ok = 0);
+
+ QScriptContext *context() const;
+protected:
+ friend class QScriptDeclarativeClassPrivate;
+ QScopedPointer<QScriptDeclarativeClassPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/script/bridge/qscriptdeclarativeobject.cpp b/src/script/bridge/qscriptdeclarativeobject.cpp
new file mode 100644
index 0000000..1af632d
--- /dev/null
+++ b/src/script/bridge/qscriptdeclarativeobject.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "config.h"
+#include "qscriptdeclarativeobject_p.h"
+
+#include "../api/qscriptengine.h"
+#include "../api/qscriptengine_p.h"
+#include "../api/qscriptcontext.h"
+#include "../api/qscriptcontext_p.h"
+#include "../api/qscriptclass.h"
+#include "../api/qscriptclasspropertyiterator.h"
+
+#include "Error.h"
+#include "PropertyNameArray.h"
+
+#include <QtCore/qstringlist.h>
+
+Q_DECLARE_METATYPE(QScriptContext*)
+Q_DECLARE_METATYPE(QScriptValue)
+Q_DECLARE_METATYPE(QScriptValueList)
+
+QT_BEGIN_NAMESPACE
+
+namespace QScript
+{
+
+DeclarativeObjectDelegate::DeclarativeObjectDelegate(QScriptDeclarativeClass *c,
+ QScriptDeclarativeClass::Object *o)
+: m_class(c), m_object(o)
+{
+}
+
+DeclarativeObjectDelegate::~DeclarativeObjectDelegate()
+{
+ delete m_object;
+}
+
+QScriptObjectDelegate::Type DeclarativeObjectDelegate::type() const
+{
+ return DeclarativeClassObject;
+}
+
+bool DeclarativeObjectDelegate::getOwnPropertySlot(QScriptObject* object,
+ JSC::ExecState *exec,
+ const JSC::Identifier &propertyName,
+ JSC::PropertySlot &slot)
+{
+ QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
+ QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
+
+ QScriptDeclarativeClassPrivate *p = QScriptDeclarativeClassPrivate::get(m_class);
+ p->context = reinterpret_cast<QScriptContext *>(exec);
+ QScriptClass::QueryFlags flags =
+ m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess);
+ if (flags & QScriptClass::HandlesReadAccess) {
+ QScriptValue value = m_class->property(m_object, identifier);
+ p->context = 0;
+ slot.setValue(engine->scriptValueToJSCValue(value));
+ return true;
+ }
+ p->context = 0;
+
+ return QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot);
+}
+
+void DeclarativeObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec,
+ const JSC::Identifier &propertyName,
+ JSC::JSValue value, JSC::PutPropertySlot &slot)
+{
+ QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
+ QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
+
+ QScriptDeclarativeClassPrivate *p = QScriptDeclarativeClassPrivate::get(m_class);
+ p->context = reinterpret_cast<QScriptContext *>(exec);
+ QScriptClass::QueryFlags flags =
+ m_class->queryProperty(m_object, identifier, QScriptClass::HandlesWriteAccess);
+ if (flags & QScriptClass::HandlesWriteAccess) {
+ m_class->setProperty(m_object, identifier, engine->scriptValueFromJSCValue(value));
+ p->context = 0;
+ return;
+ }
+ p->context = 0;
+
+ QScriptObjectDelegate::put(object, exec, propertyName, value, slot);
+}
+
+bool DeclarativeObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState *exec,
+ const JSC::Identifier &propertyName,
+ bool checkDontDelete)
+{
+ return QScriptObjectDelegate::deleteProperty(object, exec, propertyName, checkDontDelete);
+}
+
+bool DeclarativeObjectDelegate::getPropertyAttributes(const QScriptObject* object,
+ JSC::ExecState *exec,
+ const JSC::Identifier &propertyName,
+ unsigned &attribs) const
+{
+ QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
+
+ QScriptClass::QueryFlags flags =
+ m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess);
+ if (flags & QScriptClass::HandlesReadAccess) {
+ QScriptValue::PropertyFlags flags = m_class->propertyFlags(m_object, identifier);
+ attribs = 0;
+ if (flags & QScriptValue::ReadOnly)
+ attribs |= JSC::ReadOnly;
+ if (flags & QScriptValue::SkipInEnumeration)
+ attribs |= JSC::DontEnum;
+ if (flags & QScriptValue::Undeletable)
+ attribs |= JSC::DontDelete;
+ if (flags & QScriptValue::PropertyGetter)
+ attribs |= JSC::Getter;
+ if (flags & QScriptValue::PropertySetter)
+ attribs |= JSC::Setter;
+ attribs |= flags & QScriptValue::UserRange;
+ return true;
+ }
+ return QScriptObjectDelegate::getPropertyAttributes(object, exec, propertyName, attribs);
+}
+
+void DeclarativeObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState *exec,
+ JSC::PropertyNameArray &propertyNames,
+ bool includeNonEnumerable)
+{
+ QStringList properties = m_class->propertyNames(m_object);
+ for (int ii = 0; ii < properties.count(); ++ii) {
+ const QString &name = properties.at(ii);
+ propertyNames.add(JSC::Identifier(exec, name));
+ }
+
+ QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, includeNonEnumerable);
+}
+
+JSC::CallType DeclarativeObjectDelegate::getCallData(QScriptObject *object, JSC::CallData &callData)
+{
+ return QScriptObjectDelegate::getCallData(object, callData);
+}
+
+JSC::ConstructType DeclarativeObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData &constructData)
+{
+ return QScriptObjectDelegate::getConstructData(object, constructData);
+}
+
+bool DeclarativeObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState *exec,
+ JSC::JSValue value, JSC::JSValue proto)
+{
+ return QScriptObjectDelegate::hasInstance(object, exec, value, proto);
+}
+
+} // namespace QScript
+
+QT_END_NAMESPACE
diff --git a/src/script/bridge/qscriptdeclarativeobject_p.h b/src/script/bridge/qscriptdeclarativeobject_p.h
new file mode 100644
index 0000000..73e5527
--- /dev/null
+++ b/src/script/bridge/qscriptdeclarativeobject_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** 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 QSCRIPTDECLARATIVEOBJECT_P_H
+#define QSCRIPTDECLARATIVEOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobjectdefs.h>
+
+#include "config.h"
+#include "qscriptobject_p.h"
+#include "qscriptdeclarativeclass_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QScriptClass;
+
+class QScriptDeclarativeClassPrivate
+{
+public:
+ QScriptDeclarativeClassPrivate() : engine(0), q_ptr(0), context(0) {}
+
+ QScriptEngine *engine;
+ QScriptDeclarativeClass *q_ptr;
+ QScriptContext *context;
+
+ static QScriptDeclarativeClassPrivate *get(QScriptDeclarativeClass *c) {
+ return c->d_ptr.data();
+ }
+};
+
+namespace QScript
+{
+
+class DeclarativeObjectDelegate : public QScriptObjectDelegate
+{
+public:
+ DeclarativeObjectDelegate(QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object *o);
+ ~DeclarativeObjectDelegate();
+
+ virtual Type type() const;
+
+ QScriptDeclarativeClass *scriptClass() const { return m_class; }
+ QScriptDeclarativeClass::Object *object() const { return m_object; }
+
+ virtual bool getOwnPropertySlot(QScriptObject*, JSC::ExecState*,
+ const JSC::Identifier& propertyName,
+ JSC::PropertySlot&);
+ virtual void put(QScriptObject*, JSC::ExecState* exec,
+ const JSC::Identifier& propertyName,
+ JSC::JSValue, JSC::PutPropertySlot&);
+ virtual bool deleteProperty(QScriptObject*, JSC::ExecState*,
+ const JSC::Identifier& propertyName,
+ bool checkDontDelete = true);
+ virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*,
+ const JSC::Identifier&,
+ unsigned&) const;
+ virtual void getOwnPropertyNames(QScriptObject*, JSC::ExecState*,
+ JSC::PropertyNameArray&,
+ bool includeNonEnumerable = false);
+
+ virtual JSC::CallType getCallData(QScriptObject*, JSC::CallData&);
+ virtual JSC::ConstructType getConstructData(QScriptObject*, JSC::ConstructData&);
+
+ virtual bool hasInstance(QScriptObject*, JSC::ExecState*,
+ JSC::JSValue value, JSC::JSValue proto);
+
+private:
+ QScriptDeclarativeClass *m_class;
+ QScriptDeclarativeClass::Object *m_object;
+};
+
+} // namespace QScript
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h
index 9dd9d88..0992eec 100644
--- a/src/script/bridge/qscriptobject_p.h
+++ b/src/script/bridge/qscriptobject_p.h
@@ -127,7 +127,8 @@ public:
enum Type {
QtObject,
Variant,
- ClassObject
+ ClassObject,
+ DeclarativeClassObject
};
QScriptObjectDelegate();
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index 1719239..319055e 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -314,6 +314,7 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query)
QSqlRecord newRec = query.record();
bool columnsChanged = (newRec != d->rec);
bool hasQuerySize = query.driver()->hasFeature(QSqlDriver::QuerySize);
+ bool hasNewData = (newRec != QSqlRecord()) || !query.lastError().isValid();
if (d->colOffsets.size() != newRec.count() || columnsChanged)
d->initColOffsets(newRec.count());
@@ -328,13 +329,13 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query)
d->error = QSqlError();
d->query = query;
d->rec = newRec;
-
+
if (mustClearModel)
endRemoveRows();
-
- d->atEnd = false;
- if (columnsChanged)
+ d->atEnd = false;
+
+ if (columnsChanged && hasNewData)
reset();
if (!query.isActive() || query.isForwardOnly()) {
diff --git a/src/src.pro b/src/src.pro
index 5307612..8dec49b 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -8,17 +8,12 @@ wince*:{
} else:symbian {
SRC_SUBDIRS += src_s60main src_corelib src_xml src_gui src_network src_sql src_testlib src_s60installs
} else {
- SRC_SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic src_corelib src_xml src_network src_gui src_sql src_testlib
+ SRC_SUBDIRS += src_corelib src_xml src_network src_gui src_sql src_testlib
!vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support
+ include(tools/tools.pro)
contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus
- !cross_compile {
- contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_tools_uic3
- }
-}
-win32:{
- SRC_SUBDIRS += src_activeqt
- !wince*: SRC_SUBDIRS += src_tools_idc
}
+win32:SRC_SUBDIRS += src_activeqt
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl
contains(QT_CONFIG, openvg): SRC_SUBDIRS += src_openvg
@@ -41,14 +36,6 @@ src_s60installs.subdir = $$QT_SOURCE_TREE/src/s60installs
src_s60installs.target = sub-s60installs
src_winmain.subdir = $$QT_SOURCE_TREE/src/winmain
src_winmain.target = sub-winmain
-src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap
-src_tools_bootstrap.target = sub-tools-bootstrap
-src_tools_moc.subdir = $$QT_SOURCE_TREE/src/tools/moc
-src_tools_moc.target = sub-moc
-src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc
-src_tools_rcc.target = sub-rcc
-src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic
-src_tools_uic.target = sub-uic
src_corelib.subdir = $$QT_SOURCE_TREE/src/corelib
src_corelib.target = sub-corelib
src_xml.subdir = $$QT_SOURCE_TREE/src/xml
@@ -79,12 +66,8 @@ src_phonon.subdir = $$QT_SOURCE_TREE/src/phonon
src_phonon.target = sub-phonon
src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia
src_multimedia.target = sub-multimedia
-src_tools_uic3.subdir = $$QT_SOURCE_TREE/src/tools/uic3
-src_tools_uic3.target = sub-uic3
src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt
src_activeqt.target = sub-activeqt
-src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc
-src_tools_idc.target = sub-idc
src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins
src_plugins.target = sub-plugins
src_testlib.subdir = $$QT_SOURCE_TREE/src/testlib
@@ -98,9 +81,6 @@ src_declarative.target = sub-declarative
#CONFIG += ordered
!wince*:!symbian:!ordered {
- src_tools_moc.depends = src_tools_bootstrap
- src_tools_rcc.depends = src_tools_bootstrap
- src_tools_uic.depends = src_tools_bootstrap
src_corelib.depends = src_tools_moc src_tools_rcc
src_gui.depends = src_corelib src_tools_uic
embedded: src_gui.depends += src_network
@@ -116,10 +96,10 @@ src_declarative.target = sub-declarative
src_sql.depends = src_corelib
src_testlib.depends = src_corelib
src_qt3support.depends = src_gui src_xml src_network src_sql
+ src_tools_idc.depends = src_corelib # target defined in tools.pro
+ src_tools_uic3.depends = src_qt3support src_xml # target defined in tools.pro
src_phonon.depends = src_gui
src_multimedia.depends = src_gui
- src_tools_uic3.depends = src_qt3support src_xml
- src_tools_idc.depends = src_corelib
src_tools_activeqt.depends = src_tools_idc src_gui
src_declarative.depends = src_xml src_gui src_script src_network src_svg
src_plugins.depends = src_gui src_sql src_svg
@@ -140,14 +120,12 @@ src_declarative.target = sub-declarative
!symbian {
# This creates a sub-src rule
sub_src_target.CONFIG = recursive
-sub_src_target.recurse = $$SRC_SUBDIRS
+sub_src_target.recurse = $$TOOLS_SUBDIRS $$SRC_SUBDIRS
sub_src_target.target = sub-src
sub_src_target.recurse_target =
QMAKE_EXTRA_TARGETS += sub_src_target
# This gives us a top level debug/release
-EXTRA_DEBUG_TARGETS =
-EXTRA_RELEASE_TARGETS =
for(subname, SRC_SUBDIRS) {
subdir = $$subname
!isEmpty($${subname}.subdir):subdir = $$eval($${subname}.subdir)
@@ -189,4 +167,3 @@ QMAKE_EXTRA_TARGETS += debug release
}
SUBDIRS += $$SRC_SUBDIRS
-
diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp
index 3398737..88cb37f 100644
--- a/src/testlib/qbenchmarkvalgrind.cpp
+++ b/src/testlib/qbenchmarkvalgrind.cpp
@@ -114,7 +114,7 @@ qint64 QBenchmarkValgrindUtils::extractResult(const QString &fileName)
while (!file.atEnd()) {
const QString line(QLatin1String(file.readLine()));
if (rxValue.indexIn(line) != -1) {
- Q_ASSERT(rxValue.numCaptures() == 1);
+ Q_ASSERT(rxValue.captureCount() == 1);
bool ok;
val = rxValue.cap(1).toLongLong(&ok);
Q_ASSERT(ok);
diff --git a/src/tools/tools.pro b/src/tools/tools.pro
new file mode 100644
index 0000000..25527e3
--- /dev/null
+++ b/src/tools/tools.pro
@@ -0,0 +1,72 @@
+TEMPLATE = subdirs
+
+TOOLS_SUBDIRS = src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic
+!cross_compile {
+ contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_tools_uic3
+ win32:!wince*: SRC_SUBDIRS += src_tools_idc
+}
+
+# Set subdir and respective target name
+src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap
+src_tools_bootstrap.target = sub-tools-bootstrap
+src_tools_moc.subdir = $$QT_SOURCE_TREE/src/tools/moc
+src_tools_moc.target = sub-moc
+src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc
+src_tools_rcc.target = sub-rcc
+src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic
+src_tools_uic.target = sub-uic
+src_tools_uic3.subdir = $$QT_SOURCE_TREE/src/tools/uic3
+src_tools_uic3.target = sub-uic3
+src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc
+src_tools_idc.target = sub-idc
+
+!wince*:!symbian:!ordered {
+ # Set dependencies for each subdir
+ src_tools_moc.depends = src_tools_bootstrap
+ src_tools_rcc.depends = src_tools_bootstrap
+ src_tools_uic.depends = src_tools_bootstrap
+}
+
+# Special handling, depending on type of project, if it used debug/release or only has one configuration
+EXTRA_DEBUG_TARGETS =
+EXTRA_RELEASE_TARGETS =
+!symbian {
+ for(subname, TOOLS_SUBDIRS) {
+ subdir = $$subname
+ !isEmpty($${subname}.subdir):subdir = $$eval($${subname}.subdir)
+ subpro = $$subdir/$${basename(subdir)}.pro
+ !exists($$subpro):next()
+ subtarget = $$replace(subdir, [^A-Za-z0-9], _)
+ reg_src = $$replace(QT_SOURCE_TREE, \\\\, \\\\)
+ subdir = $$replace(subdir, $$reg_src, $$QT_BUILD_TREE)
+ subdir = $$replace(subdir, /, $$QMAKE_DIR_SEP)
+ subdir = $$replace(subdir, \\\\, $$QMAKE_DIR_SEP)
+ SUB_TEMPLATE = $$list($$fromfile($$subpro, TEMPLATE))
+ !isEqual(subname, src_tools_bootstrap):if(isEqual($$SUB_TEMPLATE, lib) | isEqual($$SUB_TEMPLATE, subdirs) | isEqual(subname, src_tools_idc) | isEqual(subname, src_tools_uic3)):!separate_debug_info {
+ #debug
+ eval(debug-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS)
+ eval(debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) debug))
+ EXTRA_DEBUG_TARGETS += debug-$${subtarget}
+ QMAKE_EXTRA_TARGETS += debug-$${subtarget}
+ #release
+ eval(release-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_RELEASE_TARGETS)
+ eval(release-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) release))
+ EXTRA_RELEASE_TARGETS += release-$${subtarget}
+ QMAKE_EXTRA_TARGETS += release-$${subtarget}
+ } else { #do not have a real debug target/release
+ #debug
+ eval(debug-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS)
+ eval(debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) first))
+ EXTRA_DEBUG_TARGETS += debug-$${subtarget}
+ QMAKE_EXTRA_TARGETS += debug-$${subtarget}
+ #release
+ eval(release-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_RELEASE_TARGETS)
+ eval(release-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) first))
+ EXTRA_RELEASE_TARGETS += release-$${subtarget}
+ QMAKE_EXTRA_TARGETS += release-$${subtarget}
+ }
+ }
+}
+
+SUBDIRS = $$TOOLS_SUBDIRS $$SUBDIRS
+isEqual(TARGET,tools): SUBDIRS += $$SRC_SUBDIRS
diff --git a/src/tools/uic3/embed.cpp b/src/tools/uic3/embed.cpp
index d699623..2eb4dd5 100644
--- a/src/tools/uic3/embed.cpp
+++ b/src/tools/uic3/embed.cpp
@@ -177,7 +177,7 @@ void Ui3Reader::embed(const char *project, const QStringList &images)
e->width = img.width();
e->height = img.height();
e->depth = img.depth();
- e->numColors = img.numColors();
+ e->numColors = img.colorCount();
e->colorTable = new QRgb[e->numColors];
e->alpha = img.hasAlphaBuffer();
QVector<QRgb> ct = img.colorTable();
@@ -195,7 +195,7 @@ void Ui3Reader::embed(const char *project, const QStringList &images)
#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
e->compressed =
#endif
- embedData( out, img.bits(), img.numBytes() );
+ embedData( out, img.bits(), img.byteCount() );
out << "\n};\n\n";
if ( e->numColors ) {
out << s.sprintf( "static const QRgb %s_ctable[] = {",
diff --git a/src/xmlpatterns/functions/qpatternmatchingfns.cpp b/src/xmlpatterns/functions/qpatternmatchingfns.cpp
index cb421cb..a7275f6 100644
--- a/src/xmlpatterns/functions/qpatternmatchingfns.cpp
+++ b/src/xmlpatterns/functions/qpatternmatchingfns.cpp
@@ -82,7 +82,7 @@ Item ReplaceFN::evaluateSingleton(const DynamicContext::Ptr &context) const
if(arg)
input = arg.stringValue();
- const QString replacement(m_replacementString.isNull() ? parseReplacement(regexp.numCaptures(), context)
+ const QString replacement(m_replacementString.isNull() ? parseReplacement(regexp.captureCount(), context)
: m_replacementString);
diff --git a/src/xmlpatterns/functions/qpatternplatform_p.h b/src/xmlpatterns/functions/qpatternplatform_p.h
index e007381..a85cd0c 100644
--- a/src/xmlpatterns/functions/qpatternplatform_p.h
+++ b/src/xmlpatterns/functions/qpatternplatform_p.h
@@ -180,7 +180,7 @@ namespace QPatternist
inline int PatternPlatform::captureCount() const
{
if(m_compiledParts.testFlag(PatternPrecompiled))
- return m_pattern.numCaptures();
+ return m_pattern.captureCount();
else
return -1;
}