summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.tests/unix/openssl/openssl.pri12
-rw-r--r--dist/changes-4.6.067
-rw-r--r--doc/src/classes/phonon-api.qdoc (renamed from doc/src/phonon-api.qdoc)0
-rw-r--r--doc/src/classes/q3asciicache.qdoc (renamed from doc/src/q3asciicache.qdoc)0
-rw-r--r--doc/src/classes/q3asciidict.qdoc (renamed from doc/src/q3asciidict.qdoc)0
-rw-r--r--doc/src/classes/q3cache.qdoc (renamed from doc/src/q3cache.qdoc)0
-rw-r--r--doc/src/classes/q3dict.qdoc (renamed from doc/src/q3dict.qdoc)0
-rw-r--r--doc/src/classes/q3intcache.qdoc (renamed from doc/src/q3intcache.qdoc)0
-rw-r--r--doc/src/classes/q3intdict.qdoc (renamed from doc/src/q3intdict.qdoc)0
-rw-r--r--doc/src/classes/q3memarray.qdoc (renamed from doc/src/q3memarray.qdoc)0
-rw-r--r--doc/src/classes/q3popupmenu.qdoc (renamed from doc/src/q3popupmenu.qdoc)0
-rw-r--r--doc/src/classes/q3ptrdict.qdoc (renamed from doc/src/q3ptrdict.qdoc)0
-rw-r--r--doc/src/classes/q3ptrlist.qdoc (renamed from doc/src/q3ptrlist.qdoc)0
-rw-r--r--doc/src/classes/q3ptrqueue.qdoc (renamed from doc/src/q3ptrqueue.qdoc)0
-rw-r--r--doc/src/classes/q3ptrstack.qdoc (renamed from doc/src/q3ptrstack.qdoc)0
-rw-r--r--doc/src/classes/q3ptrvector.qdoc (renamed from doc/src/q3ptrvector.qdoc)0
-rw-r--r--doc/src/classes/q3sqlfieldinfo.qdoc (renamed from doc/src/q3sqlfieldinfo.qdoc)0
-rw-r--r--doc/src/classes/q3sqlrecordinfo.qdoc (renamed from doc/src/q3sqlrecordinfo.qdoc)0
-rw-r--r--doc/src/classes/q3valuelist.qdoc (renamed from doc/src/q3valuelist.qdoc)0
-rw-r--r--doc/src/classes/q3valuestack.qdoc (renamed from doc/src/q3valuestack.qdoc)0
-rw-r--r--doc/src/classes/q3valuevector.qdoc (renamed from doc/src/q3valuevector.qdoc)0
-rw-r--r--doc/src/classes/qalgorithms.qdoc (renamed from doc/src/qalgorithms.qdoc)0
-rw-r--r--doc/src/classes/qcache.qdoc (renamed from doc/src/qcache.qdoc)0
-rw-r--r--doc/src/classes/qcolormap.qdoc (renamed from doc/src/qcolormap.qdoc)0
-rw-r--r--doc/src/classes/qdesktopwidget.qdoc (renamed from doc/src/qdesktopwidget.qdoc)0
-rw-r--r--doc/src/classes/qiterator.qdoc (renamed from doc/src/qiterator.qdoc)0
-rw-r--r--doc/src/classes/qmacstyle.qdoc (renamed from doc/src/qstyles.qdoc)0
-rw-r--r--doc/src/classes/qnamespace.qdoc (renamed from doc/src/qnamespace.qdoc)0
-rw-r--r--doc/src/classes/qpagesetupdialog.qdoc (renamed from doc/src/qpagesetupdialog.qdoc)0
-rw-r--r--doc/src/classes/qpaintdevice.qdoc (renamed from doc/src/qpaintdevice.qdoc)0
-rw-r--r--doc/src/classes/qpair.qdoc (renamed from doc/src/qpair.qdoc)0
-rw-r--r--doc/src/classes/qpatternistdummy.cpp (renamed from doc/src/qpatternistdummy.cpp)0
-rw-r--r--doc/src/classes/qplugin.qdoc (renamed from doc/src/qplugin.qdoc)0
-rw-r--r--doc/src/classes/qprintdialog.qdoc (renamed from doc/src/qprintdialog.qdoc)0
-rw-r--r--doc/src/classes/qprinterinfo.qdoc (renamed from doc/src/qprinterinfo.qdoc)0
-rw-r--r--doc/src/classes/qset.qdoc (renamed from doc/src/qset.qdoc)0
-rw-r--r--doc/src/classes/qsignalspy.qdoc (renamed from doc/src/qsignalspy.qdoc)0
-rw-r--r--doc/src/classes/qsizepolicy.qdoc (renamed from doc/src/qsizepolicy.qdoc)0
-rw-r--r--doc/src/classes/qtdesigner-api.qdoc1413
-rw-r--r--doc/src/classes/qtendian.qdoc (renamed from doc/src/qtendian.qdoc)0
-rw-r--r--doc/src/classes/qtestevent.qdoc (renamed from doc/src/qtestevent.qdoc)0
-rw-r--r--doc/src/classes/qvarlengtharray.qdoc (renamed from doc/src/qvarlengtharray.qdoc)0
-rw-r--r--doc/src/classes/qwaitcondition.qdoc (renamed from doc/src/qwaitcondition.qdoc)0
-rw-r--r--doc/src/groups.qdoc111
-rw-r--r--doc/src/implicit-sharing.qdoc144
-rw-r--r--doc/src/qtdesigner.qdoc1373
-rw-r--r--examples/script/customclass/bytearrayclass.cpp9
-rw-r--r--examples/script/customclass/main.cpp4
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp15
-rw-r--r--src/corelib/tools/qshareddata.cpp2
-rw-r--r--src/gui/accessible/accessible.pri3
-rw-r--r--src/gui/accessible/qaccessible_mac_cocoa.mm234
-rw-r--r--src/gui/egl/qegl.cpp11
-rw-r--r--src/gui/egl/qegl_p.h3
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp163
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h5
-rw-r--r--src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp9
-rw-r--r--src/gui/graphicsview/qgraphicstransform.cpp340
-rw-r--r--src/gui/graphicsview/qgraphicstransform.h1
-rw-r--r--src/gui/image/image.pri6
-rw-r--r--src/gui/image/qimage.cpp17
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp110
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks_p.h89
-rw-r--r--src/gui/image/qpixmap.cpp24
-rw-r--r--src/gui/image/qpixmap_x11.cpp23
-rw-r--r--src/gui/image/qpixmap_x11_p.h12
-rw-r--r--src/gui/image/qpixmapdata_p.h1
-rw-r--r--src/gui/kernel/qapplication.cpp106
-rw-r--r--src/gui/kernel/qgesture.cpp4
-rw-r--r--src/gui/kernel/qwidget.cpp21
-rw-r--r--src/gui/kernel/qwidget_mac.mm7
-rw-r--r--src/gui/kernel/qwidget_win.cpp26
-rw-r--r--src/gui/painting/painting.pri8
-rw-r--r--src/gui/painting/qdrawhelper.cpp72
-rw-r--r--src/gui/painting/qregion.cpp28
-rw-r--r--src/gui/painting/qregion.h5
-rw-r--r--src/gui/painting/qregion_mac.cpp38
-rw-r--r--src/gui/painting/qregion_win.cpp514
-rw-r--r--src/gui/painting/qwindowsurface_x11.cpp4
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp18
-rw-r--r--src/gui/text/qfontengine_ft.cpp4
-rw-r--r--src/gui/util/qcompleter.cpp6
-rw-r--r--src/gui/widgets/qmenubar.cpp2
-rw-r--r--src/opengl/qgl.cpp37
-rw-r--r--src/opengl/qgl_p.h14
-rw-r--r--src/opengl/qgl_x11.cpp199
-rw-r--r--src/opengl/qgl_x11egl.cpp173
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp5
-rw-r--r--src/svg/qsvggraphics.cpp286
-rw-r--r--src/svg/qsvggraphics_p.h51
-rw-r--r--src/svg/qsvghandler.cpp590
-rw-r--r--src/svg/qsvgnode_p.h1
-rw-r--r--src/svg/qsvgstyle.cpp126
-rw-r--r--src/svg/qsvgstyle_p.h80
-rw-r--r--src/testlib/qtestcase.cpp7
-rw-r--r--src/tools/moc/moc.cpp2
-rw-r--r--tests/arthur/data/1.2/textArea01.svg2
-rw-r--r--tests/arthur/data/qps/linear_gradients_perspectives_qps.pngbin78017 -> 77944 bytes
-rw-r--r--tests/arthur/data/qps/linear_gradients_qps.pngbin82119 -> 162643 bytes
-rw-r--r--tests/arthur/data/qps/lineconsistency_qps.pngbin12500 -> 12388 bytes
-rw-r--r--tests/arthur/data/qps/linedashes2_aa_qps.pngbin28956 -> 28418 bytes
-rw-r--r--tests/arthur/data/qps/paths_aa_qps.pngbin92711 -> 92147 bytes
-rw-r--r--tests/arthur/data/qps/paths_qps.pngbin20637 -> 20392 bytes
-rw-r--r--tests/arthur/data/qps/radial_gradients_perspectives_qps.pngbin133150 -> 131744 bytes
-rw-r--r--tests/arthur/data/qps/radial_gradients_qps.pngbin156036 -> 161009 bytes
-rw-r--r--tests/arthur/data/qps/rasterops.qps167
-rw-r--r--tests/arthur/data/qps/rasterops_qps.pngbin20400 -> 11059 bytes
-rw-r--r--tests/arthur/data/qps/text_perspectives_qps.pngbin112750 -> 116847 bytes
-rw-r--r--tests/arthur/data/qps/text_qps.pngbin72027 -> 32991 bytes
-rw-r--r--tests/arthur/lance/interactivewidget.cpp2
-rw-r--r--tests/arthur/lance/lance.pro2
-rw-r--r--tests/arthur/lance/main.cpp16
-rw-r--r--tests/arthur/lance/widgets.h151
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/moc/tst_moc.cpp7
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp27
-rw-r--r--tests/auto/qhelpenginecore/data/collection.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/collection1.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/linguist-3.3.8.qchbin131072 -> 131072 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/qmake-3.3.8.qchbin61440 -> 61440 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/qmake-4.3.0.qchbin93184 -> 93184 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/test.qchbin22528 -> 22528 bytes
-rw-r--r--tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp40
-rw-r--r--tests/auto/qhelpindexmodel/data/collection.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/collection1.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/linguist-3.3.8.qchbin131072 -> 131072 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/qmake-3.3.8.qchbin61440 -> 61440 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/qmake-4.3.0.qchbin93184 -> 93184 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/test.qchbin22528 -> 22528 bytes
-rw-r--r--tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp6
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp265
-rw-r--r--tests/manual/windowflags/controllerwindow.cpp263
-rw-r--r--tests/manual/windowflags/controllerwindow.h (renamed from src/gui/painting/qregion_wince.cpp)136
-rw-r--r--tests/manual/windowflags/main.cpp52
-rw-r--r--tests/manual/windowflags/previewwindow.cpp146
-rw-r--r--tests/manual/windowflags/previewwindow.h81
-rw-r--r--tests/manual/windowflags/windowflags.pro5
-rw-r--r--tools/linguist/lupdate/cpp.cpp4
-rw-r--r--tools/linguist/shared/qm.cpp2
139 files changed, 4562 insertions, 3451 deletions
diff --git a/config.tests/unix/openssl/openssl.pri b/config.tests/unix/openssl/openssl.pri
index bc95479..f069396 100644
--- a/config.tests/unix/openssl/openssl.pri
+++ b/config.tests/unix/openssl/openssl.pri
@@ -1,9 +1,3 @@
-!cross_compile {
- TRY_INCLUDEPATHS = /include /usr/include /usr/local/include $$QMAKE_INCDIR $$INCLUDEPATH
- # LSB doesn't allow using headers from /include or /usr/include
- linux-lsb-g++:TRY_INCLUDEPATHS = $$QMAKE_INCDIR $$INCLUDEPATH
- for(p, TRY_INCLUDEPATHS) {
- pp = $$join(p, "", "", "/openssl")
- exists($$pp):INCLUDEPATH *= $$p
- }
-}
+# Empty file since Qt 4.6
+# I'm too lazy to find all places where this file is included
+
diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0
index 383c6b7..7a6decf 100644
--- a/dist/changes-4.6.0
+++ b/dist/changes-4.6.0
@@ -34,9 +34,15 @@ information about a particular change.
- Significant external contribution from Milan Burda for planned removal
of (non-unicode) Windows 9x/ME support.
+ - QRegion is no longer a GDI object by default. This means it is no
+ longer subjuect to gui-thread only nor does it potentially impact
+ the 10.000 GDI object limit per process. By explicitly calling
+ .handle() a GDI object will be created and memory managed by
+ QRegion. The native handle is for reading out only. Any GDI calls
+ made on the HRGN handle will not affect the QRegion.
****************************************************************************
-* Important Behavior Changes *
+* Important Behavior Changes *
****************************************************************************
- The experimental Direct3D paint engine has been removed. The reason for
@@ -71,33 +77,32 @@ information about a particular change.
QGraphicsItem::ItemSendsGeometryChanges (which is enabled by default by
QGraphicsWidget and QGraphicsProxyWidget).
-- QDesktopWidget on X11 no longer emits the resized(int) signal when screens
- are added or removed. This was not done on other platforms. Use the
- screenCountChanged signal instead
-
-- QUrl's parser is more strict when for hostnames in URLs. QUrl now
- enforces STD 3 rules:
-
- * each individual hostname section (between dots) must be at most
- 63 ASCII characters in length;
-
- * only letters, digits, and the hyphen character are allowed in the
- ASCII range; letters outside the ASCII range follow the normal
- IDN rules
-
- That means QUrl no longer accepts some URLs that were invalid
- before, but weren't interpreted as such.
-
-- The Unix configure-time check for STL is stricter now in Qt
- 4.6.0. This means some legacy STL implementations may fail to pass
- the test and, therefore, Qt will automatically disable STL support.
-
- This is a binary-compatible change: existing code will continue to
- work without being recompiled. However, it affects the source code,
- since some STL-compatibility API will not be enabled.
-
- Platforms affected by this change:
- * solaris-cc-* with the default (Cstd) C++ STL library
- recommendation: use -library=stlport4
- See Sun Studio's documentation for the effects of this option
-
+ - QDesktopWidget on X11 no longer emits the resized(int) signal when screens
+ are added or removed. This was not done on other platforms. Use the
+ screenCountChanged signal instead
+
+ - QUrl's parser is more strict when for hostnames in URLs. QUrl now
+ enforces STD 3 rules:
+
+ * each individual hostname section (between dots) must be at most
+ 63 ASCII characters in length;
+
+ * only letters, digits, and the hyphen character are allowed in the
+ ASCII range; letters outside the ASCII range follow the normal
+ IDN rules
+
+ That means QUrl no longer accepts some URLs that were invalid
+ before, but weren't interpreted as such.
+
+ - The Unix configure-time check for STL is stricter now in Qt
+ 4.6.0. This means some legacy STL implementations may fail to pass
+ the test and, therefore, Qt will automatically disable STL support.
+
+ This is a binary-compatible change: existing code will continue to
+ work without being recompiled. However, it affects the source code,
+ since some STL-compatibility API will not be enabled.
+
+ Platforms affected by this change:
+ * solaris-cc-* with the default (Cstd) C++ STL library
+ recommendation: use -library=stlport4
+ See Sun Studio's documentation for the effects of this option
diff --git a/doc/src/phonon-api.qdoc b/doc/src/classes/phonon-api.qdoc
index 09274bf..09274bf 100644
--- a/doc/src/phonon-api.qdoc
+++ b/doc/src/classes/phonon-api.qdoc
diff --git a/doc/src/q3asciicache.qdoc b/doc/src/classes/q3asciicache.qdoc
index 43537cc..43537cc 100644
--- a/doc/src/q3asciicache.qdoc
+++ b/doc/src/classes/q3asciicache.qdoc
diff --git a/doc/src/q3asciidict.qdoc b/doc/src/classes/q3asciidict.qdoc
index 9a51db1..9a51db1 100644
--- a/doc/src/q3asciidict.qdoc
+++ b/doc/src/classes/q3asciidict.qdoc
diff --git a/doc/src/q3cache.qdoc b/doc/src/classes/q3cache.qdoc
index d8799b6..d8799b6 100644
--- a/doc/src/q3cache.qdoc
+++ b/doc/src/classes/q3cache.qdoc
diff --git a/doc/src/q3dict.qdoc b/doc/src/classes/q3dict.qdoc
index 0e6d51d..0e6d51d 100644
--- a/doc/src/q3dict.qdoc
+++ b/doc/src/classes/q3dict.qdoc
diff --git a/doc/src/q3intcache.qdoc b/doc/src/classes/q3intcache.qdoc
index dfff679..dfff679 100644
--- a/doc/src/q3intcache.qdoc
+++ b/doc/src/classes/q3intcache.qdoc
diff --git a/doc/src/q3intdict.qdoc b/doc/src/classes/q3intdict.qdoc
index cef2e79..cef2e79 100644
--- a/doc/src/q3intdict.qdoc
+++ b/doc/src/classes/q3intdict.qdoc
diff --git a/doc/src/q3memarray.qdoc b/doc/src/classes/q3memarray.qdoc
index b9c1f73..b9c1f73 100644
--- a/doc/src/q3memarray.qdoc
+++ b/doc/src/classes/q3memarray.qdoc
diff --git a/doc/src/q3popupmenu.qdoc b/doc/src/classes/q3popupmenu.qdoc
index a2cfe08..a2cfe08 100644
--- a/doc/src/q3popupmenu.qdoc
+++ b/doc/src/classes/q3popupmenu.qdoc
diff --git a/doc/src/q3ptrdict.qdoc b/doc/src/classes/q3ptrdict.qdoc
index 38ca0bb..38ca0bb 100644
--- a/doc/src/q3ptrdict.qdoc
+++ b/doc/src/classes/q3ptrdict.qdoc
diff --git a/doc/src/q3ptrlist.qdoc b/doc/src/classes/q3ptrlist.qdoc
index 3000940..3000940 100644
--- a/doc/src/q3ptrlist.qdoc
+++ b/doc/src/classes/q3ptrlist.qdoc
diff --git a/doc/src/q3ptrqueue.qdoc b/doc/src/classes/q3ptrqueue.qdoc
index b3af5f6..b3af5f6 100644
--- a/doc/src/q3ptrqueue.qdoc
+++ b/doc/src/classes/q3ptrqueue.qdoc
diff --git a/doc/src/q3ptrstack.qdoc b/doc/src/classes/q3ptrstack.qdoc
index 1650d69..1650d69 100644
--- a/doc/src/q3ptrstack.qdoc
+++ b/doc/src/classes/q3ptrstack.qdoc
diff --git a/doc/src/q3ptrvector.qdoc b/doc/src/classes/q3ptrvector.qdoc
index fa78de5..fa78de5 100644
--- a/doc/src/q3ptrvector.qdoc
+++ b/doc/src/classes/q3ptrvector.qdoc
diff --git a/doc/src/q3sqlfieldinfo.qdoc b/doc/src/classes/q3sqlfieldinfo.qdoc
index ba064f3..ba064f3 100644
--- a/doc/src/q3sqlfieldinfo.qdoc
+++ b/doc/src/classes/q3sqlfieldinfo.qdoc
diff --git a/doc/src/q3sqlrecordinfo.qdoc b/doc/src/classes/q3sqlrecordinfo.qdoc
index 64236d2..64236d2 100644
--- a/doc/src/q3sqlrecordinfo.qdoc
+++ b/doc/src/classes/q3sqlrecordinfo.qdoc
diff --git a/doc/src/q3valuelist.qdoc b/doc/src/classes/q3valuelist.qdoc
index fd73763..fd73763 100644
--- a/doc/src/q3valuelist.qdoc
+++ b/doc/src/classes/q3valuelist.qdoc
diff --git a/doc/src/q3valuestack.qdoc b/doc/src/classes/q3valuestack.qdoc
index e3ae677..e3ae677 100644
--- a/doc/src/q3valuestack.qdoc
+++ b/doc/src/classes/q3valuestack.qdoc
diff --git a/doc/src/q3valuevector.qdoc b/doc/src/classes/q3valuevector.qdoc
index 353b7fa..353b7fa 100644
--- a/doc/src/q3valuevector.qdoc
+++ b/doc/src/classes/q3valuevector.qdoc
diff --git a/doc/src/qalgorithms.qdoc b/doc/src/classes/qalgorithms.qdoc
index 7634322..7634322 100644
--- a/doc/src/qalgorithms.qdoc
+++ b/doc/src/classes/qalgorithms.qdoc
diff --git a/doc/src/qcache.qdoc b/doc/src/classes/qcache.qdoc
index 6c88ede..6c88ede 100644
--- a/doc/src/qcache.qdoc
+++ b/doc/src/classes/qcache.qdoc
diff --git a/doc/src/qcolormap.qdoc b/doc/src/classes/qcolormap.qdoc
index 95f7dc0..95f7dc0 100644
--- a/doc/src/qcolormap.qdoc
+++ b/doc/src/classes/qcolormap.qdoc
diff --git a/doc/src/qdesktopwidget.qdoc b/doc/src/classes/qdesktopwidget.qdoc
index 56a882d..56a882d 100644
--- a/doc/src/qdesktopwidget.qdoc
+++ b/doc/src/classes/qdesktopwidget.qdoc
diff --git a/doc/src/qiterator.qdoc b/doc/src/classes/qiterator.qdoc
index 416b4bc..416b4bc 100644
--- a/doc/src/qiterator.qdoc
+++ b/doc/src/classes/qiterator.qdoc
diff --git a/doc/src/qstyles.qdoc b/doc/src/classes/qmacstyle.qdoc
index ae2d95b..ae2d95b 100644
--- a/doc/src/qstyles.qdoc
+++ b/doc/src/classes/qmacstyle.qdoc
diff --git a/doc/src/qnamespace.qdoc b/doc/src/classes/qnamespace.qdoc
index 2d40fdd..2d40fdd 100644
--- a/doc/src/qnamespace.qdoc
+++ b/doc/src/classes/qnamespace.qdoc
diff --git a/doc/src/qpagesetupdialog.qdoc b/doc/src/classes/qpagesetupdialog.qdoc
index 7f0b09e..7f0b09e 100644
--- a/doc/src/qpagesetupdialog.qdoc
+++ b/doc/src/classes/qpagesetupdialog.qdoc
diff --git a/doc/src/qpaintdevice.qdoc b/doc/src/classes/qpaintdevice.qdoc
index 0f4e9a0..0f4e9a0 100644
--- a/doc/src/qpaintdevice.qdoc
+++ b/doc/src/classes/qpaintdevice.qdoc
diff --git a/doc/src/qpair.qdoc b/doc/src/classes/qpair.qdoc
index 6d8a0f9..6d8a0f9 100644
--- a/doc/src/qpair.qdoc
+++ b/doc/src/classes/qpair.qdoc
diff --git a/doc/src/qpatternistdummy.cpp b/doc/src/classes/qpatternistdummy.cpp
index a690184..a690184 100644
--- a/doc/src/qpatternistdummy.cpp
+++ b/doc/src/classes/qpatternistdummy.cpp
diff --git a/doc/src/qplugin.qdoc b/doc/src/classes/qplugin.qdoc
index 4fbd198..4fbd198 100644
--- a/doc/src/qplugin.qdoc
+++ b/doc/src/classes/qplugin.qdoc
diff --git a/doc/src/qprintdialog.qdoc b/doc/src/classes/qprintdialog.qdoc
index 8011f62..8011f62 100644
--- a/doc/src/qprintdialog.qdoc
+++ b/doc/src/classes/qprintdialog.qdoc
diff --git a/doc/src/qprinterinfo.qdoc b/doc/src/classes/qprinterinfo.qdoc
index a4ffeb2..a4ffeb2 100644
--- a/doc/src/qprinterinfo.qdoc
+++ b/doc/src/classes/qprinterinfo.qdoc
diff --git a/doc/src/qset.qdoc b/doc/src/classes/qset.qdoc
index 0db3775..0db3775 100644
--- a/doc/src/qset.qdoc
+++ b/doc/src/classes/qset.qdoc
diff --git a/doc/src/qsignalspy.qdoc b/doc/src/classes/qsignalspy.qdoc
index 4ee7590..4ee7590 100644
--- a/doc/src/qsignalspy.qdoc
+++ b/doc/src/classes/qsignalspy.qdoc
diff --git a/doc/src/qsizepolicy.qdoc b/doc/src/classes/qsizepolicy.qdoc
index c74beb8..c74beb8 100644
--- a/doc/src/qsizepolicy.qdoc
+++ b/doc/src/classes/qsizepolicy.qdoc
diff --git a/doc/src/classes/qtdesigner-api.qdoc b/doc/src/classes/qtdesigner-api.qdoc
new file mode 100644
index 0000000..d7c47b1
--- /dev/null
+++ b/doc/src/classes/qtdesigner-api.qdoc
@@ -0,0 +1,1413 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QDesignerMemberSheetExtension
+
+ \brief The QDesignerMemberSheetExtension class allows you to
+ manipulate a widget's member functions which is displayed when
+ configuring connections using Qt Designer's mode for editing
+ signals and slots.
+
+ \inmodule QtDesigner
+
+ QDesignerMemberSheetExtension is a collection of functions that is
+ typically used to query a widget's member functions, and to
+ manipulate the member functions' appearance in \QD's signals and
+ slots editing mode. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 2
+
+ When implementing a custom widget plugin, a pointer to \QD's
+ current QDesignerFormEditorInterface object (\c formEditor in the
+ example above) is provided by the
+ QDesignerCustomWidgetInterface::initialize() function's parameter.
+
+ The member sheet (and any other extension), can be retrieved by
+ querying \QD's extension manager using the qt_extension()
+ function. When you want to release the extension, you only need to
+ delete the pointer.
+
+ All widgets have a default member sheet used in \QD's signals and
+ slots editing mode with the widget's member functions. But
+ QDesignerMemberSheetExtension also provides an interface for
+ creating custom member sheet extensions.
+
+ \warning \QD uses the QDesignerMemberSheetExtension to facilitate
+ the signal and slot editing mode. Whenever a connection between
+ two widgets is requested, \QD will query for the widgets' member
+ sheet extensions. If a widget has an implemented member sheet
+ extension, this extension will override the default member sheet.
+
+ To create a member sheet extension, your extension class must
+ inherit from both QObject and QDesignerMemberSheetExtension. Then,
+ since we are implementing an interface, we must ensure that it's
+ made known to the meta object system using the Q_INTERFACES()
+ macro:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 3
+
+ This enables \QD to use qobject_cast() to query for
+ supported interfaces using nothing but a QObject pointer.
+
+ In \QD the extensions are not created until they are
+ required. For that reason, when implementing a member sheet
+ extension, you must also create a QExtensionFactory, i.e a class
+ that is able to make an instance of your extension, and register
+ it using \QD's \l {QExtensionManager}{extension manager}.
+
+ When a widget's member sheet extension is required, \QD's \l
+ {QExtensionManager}{extension manager} will run through all its
+ registered factories calling QExtensionFactory::createExtension()
+ for each until the first one that is able to create a member sheet
+ extension for that widget, is found. This factory will then make
+ an instance of the extension. If no such factory is found, \QD
+ will use the default member sheet.
+
+ There are four available types of extensions in \QD:
+ QDesignerContainerExtension, QDesignerMemberSheetExtension,
+ QDesignerPropertySheetExtension and
+ QDesignerTaskMenuExtension. \QD's behavior is the same whether the
+ requested extension is associated with a multi page container, a
+ member sheet, a property sheet or a task menu.
+
+ The QExtensionFactory class provides a standard extension
+ factory, and can also be used as an interface for custom
+ extension factories. You can either create a new
+ QExtensionFactory and reimplement the
+ QExtensionFactory::createExtension() function. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 4
+
+ Or you can use an existing factory, expanding the
+ QExtensionFactory::createExtension() function to make the factory
+ able to create a member sheet extension as well. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 5
+
+ For a complete example using an extension class, see \l
+ {designer/taskmenuextension}{Task Menu Extension example}. The
+ example shows how to create a custom widget plugin for Qt
+ Designer, and how to to use the QDesignerTaskMenuExtension class
+ to add custom items to \QD's task menu.
+
+ \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
+ Extensions}
+*/
+
+/*!
+ \fn QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension()
+
+ Destroys the member sheet extension.
+*/
+
+/*!
+ \fn int QDesignerMemberSheetExtension::count() const
+
+ Returns the extension's number of member functions.
+*/
+
+/*!
+ \fn int QDesignerMemberSheetExtension::indexOf(const QString &name) const
+
+ Returns the index of the member function specified by the given \a
+ name.
+
+ \sa memberName()
+*/
+
+/*!
+ \fn QString QDesignerMemberSheetExtension::memberName(int index) const
+
+ Returns the name of the member function with the given \a index.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn QString QDesignerMemberSheetExtension::memberGroup(int index) const
+
+ Returns the name of the member group specified for the function
+ with the given \a index.
+
+ \sa indexOf(), setMemberGroup()
+*/
+
+/*!
+ \fn void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group)
+
+ Sets the member group of the member function with the given \a
+ index, to \a group.
+
+ \sa indexOf(), memberGroup()
+*/
+
+/*!
+ \fn bool QDesignerMemberSheetExtension::isVisible(int index) const
+
+ Returns true if the member function with the given \a index is
+ visible in \QD's signal and slot editor, otherwise false.
+
+ \sa indexOf(), setVisible()
+*/
+
+/*!
+ \fn void QDesignerMemberSheetExtension::setVisible(int index, bool visible)
+
+ If \a visible is true, the member function with the given \a index
+ is visible in \QD's signals and slots editing mode; otherwise the
+ member function is hidden.
+
+ \sa indexOf(), isVisible()
+*/
+
+/*!
+ \fn virtual bool QDesignerMemberSheetExtension::isSignal(int index) const
+
+ Returns true if the member function with the given \a index is a
+ signal, otherwise false.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn bool QDesignerMemberSheetExtension::isSlot(int index) const
+
+ Returns true if the member function with the given \a index is a
+ slot, otherwise false.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const
+
+ Returns true if the member function with the given \a index is
+ inherited from QWidget, otherwise false.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn QString QDesignerMemberSheetExtension::declaredInClass(int index) const
+
+ Returns the name of the class in which the member function with
+ the given \a index is declared.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn QString QDesignerMemberSheetExtension::signature(int index) const
+
+ Returns the signature of the member function with the given \a
+ index.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn QList<QByteArray> QDesignerMemberSheetExtension::parameterTypes(int index) const
+
+ Returns the parameter types of the member function with the given
+ \a index, as a QByteArray list.
+
+ \sa indexOf(), parameterNames()
+*/
+
+/*!
+ \fn QList<QByteArray> QDesignerMemberSheetExtension::parameterNames(int index) const
+
+ Returns the parameter names of the member function with the given
+ \a index, as a QByteArray list.
+
+ \sa indexOf(), parameterTypes()
+*/
+
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerLayoutDecorationExtension
+ \brief The QDesignerLayoutDecorationExtension class provides an extension to a layout in \QD.
+ \inmodule QtDesigner
+ \internal
+*/
+
+/*!
+ \enum QDesignerLayoutDecorationExtension::InsertMode
+
+ This enum describes the modes that are used to insert items into a layout.
+
+ \value InsertWidgetMode Widgets are inserted into empty cells in a layout.
+ \value InsertRowMode Whole rows are inserted into a vertical or grid layout.
+ \value InsertColumnMode Whole columns are inserted into a horizontal or grid layout.
+*/
+
+/*!
+ \fn virtual QDesignerLayoutDecorationExtension::~QDesignerLayoutDecorationExtension()
+
+ Destroys the extension.
+*/
+
+/*!
+ \fn virtual QList<QWidget*> QDesignerLayoutDecorationExtension::widgets(QLayout *layout) const
+
+ Returns the widgets that are managed by the given \a layout.
+
+ \sa insertWidget(), removeWidget()
+*/
+
+/*!
+ \fn QRect QDesignerLayoutDecorationExtension::itemInfo(int index) const
+
+ Returns the rectangle covered by the item at the given \a index in the layout.
+*/
+
+/*!
+ \fn int QDesignerLayoutDecorationExtension::indexOf(QWidget *widget) const
+
+ Returns the index of the specified \a widget in the layout.
+*/
+
+/*!
+ \fn int QDesignerLayoutDecorationExtension::indexOf(QLayoutItem *item) const
+
+ Returns the index of the specified layout \a item.
+*/
+
+/*!
+ \fn QDesignerLayoutDecorationExtension::InsertMode QDesignerLayoutDecorationExtension::currentInsertMode() const
+
+ Returns the current insertion mode.
+*/
+
+/*!
+ \fn int QDesignerLayoutDecorationExtension::currentIndex() const
+
+ Returns the current index in the layout.
+*/
+
+/*!
+ \fn QPair<int, int> QDesignerLayoutDecorationExtension::currentCell() const
+
+ Returns a pair containing the row and column of the current cell in the layout.
+*/
+
+/*!
+ \fn void QDesignerLayoutDecorationExtension::insertWidget(QWidget *widget, const QPair<int, int> &cell)
+
+ Inserts the given \a widget into the specified \a cell in the layout.
+
+ \sa removeWidget()
+*/
+
+/*!
+ \fn void QDesignerLayoutDecorationExtension::removeWidget(QWidget *widget)
+
+ Removes the specified \a widget from the layout.
+
+ \sa insertWidget()
+*/
+
+/*!
+ \fn void QDesignerLayoutDecorationExtension::insertRow(int row)
+
+ Inserts a new row into the form at the position specified by \a row.
+*/
+
+/*!
+ \fn void QDesignerLayoutDecorationExtension::insertColumn(int column)
+
+ Inserts a new column into the form at the position specified by \a column.
+*/
+
+/*!
+ \fn void QDesignerLayoutDecorationExtension::simplify()
+
+ Simplifies the layout by removing unnecessary empty rows and columns, and by changing the
+ number of rows or columns spanned by widgets.
+*/
+
+/*!
+ \fn int QDesignerLayoutDecorationExtension::findItemAt(const QPoint &position) const
+
+ Returns the index of the item in the layout that covers the given \a position.
+*/
+
+/*!
+ \fn int QDesignerLayoutDecorationExtension::findItemAt(int row, int column) const
+
+ Returns the item in the layout that occupies the specified \a row and \a column in the layout.
+
+ Currently, this only applies to grid layouts.
+*/
+
+/*!
+ \fn void QDesignerLayoutDecorationExtension::adjustIndicator(const QPoint &position, int index)
+
+ Adjusts the indicator for the item specified by \a index so that
+ it lies at the given \a position on the form.
+*/
+
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerContainerExtension
+ \brief The QDesignerContainerExtension class allows you to add pages to
+ a custom multi-page container in Qt Designer's workspace.
+ \inmodule QtDesigner
+
+ QDesignerContainerExtension provide an interface for creating
+ custom container extensions. A container extension consists of a
+ collection of functions that \QD needs to manage a multi-page
+ container plugin, and a list of the container's pages.
+
+ \image containerextension-example.png
+
+ \warning This is \e not an extension for container plugins in
+ general, only custom \e multi-page containers.
+
+ To create a container extension, your extension class must inherit
+ from both QObject and QDesignerContainerExtension. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6
+
+ Since we are implementing an interface, we must ensure that it's
+ made known to the meta object system using the Q_INTERFACES()
+ macro. This enables \QD to use the qobject_cast() function to
+ query for supported interfaces using nothing but a QObject
+ pointer.
+
+ You must reimplement several functions to enable \QD to manage a
+ custom multi-page container widget: \QD uses count() to keep track
+ of the number pages in your container, widget() to return the page
+ at a given index in the list of the container's pages, and
+ currentIndex() to return the list index of the selected page. \QD
+ uses the addWidget() function to add a given page to the
+ container, expecting it to be appended to the list of pages, while
+ it expects the insertWidget() function to add a given page to the
+ container by inserting it at a given index.
+
+ In \QD the extensions are not created until they are
+ required. For that reason you must also create a
+ QExtensionFactory, i.e a class that is able to make an instance of
+ your extension, and register it using \QD's \l
+ {QExtensionManager}{extension manager}.
+
+ When a container extension is required, \QD's \l
+ {QExtensionManager}{extension manager} will run through all its
+ registered factories calling QExtensionFactory::createExtension()
+ for each until the first one that is able to create a container
+ extension, is found. This factory will then create the extension
+ for the plugin.
+
+ There are four available types of extensions in \QD:
+ QDesignerContainerExtension , QDesignerMemberSheetExtension,
+ QDesignerPropertySheetExtension and QDesignerTaskMenuExtension.
+ \QD's behavior is the same whether the requested extension is
+ associated with a multi page container, a member sheet, a property
+ sheet or a task menu.
+
+ The QExtensionFactory class provides a standard extension factory,
+ and can also be used as an interface for custom extension
+ factories. You can either create a new QExtensionFactory and
+ reimplement the QExtensionFactory::createExtension() function. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7
+
+ Or you can use an existing factory, expanding the
+ QExtensionFactory::createExtension() function to make the factory
+ able to create a container extension as well. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8
+
+ For a complete example using the QDesignerContainerExtension
+ class, see the \l {designer/containerextension}{Container
+ Extension example}. The example shows how to create a custom
+ multi-page plugin for \QD.
+
+ \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
+ Extensions}
+*/
+
+/*!
+ \fn QDesignerContainerExtension::~QDesignerContainerExtension()
+
+ Destroys the extension.
+*/
+
+/*!
+ \fn int QDesignerContainerExtension::count() const
+
+ Returns the number of pages in the container.
+*/
+
+/*!
+ \fn QWidget *QDesignerContainerExtension::widget(int index) const
+
+ Returns the page at the given \a index in the extension's list of
+ pages.
+
+ \sa addWidget(), insertWidget()
+*/
+
+/*!
+ \fn int QDesignerContainerExtension::currentIndex() const
+
+ Returns the index of the currently selected page in the
+ container.
+
+ \sa setCurrentIndex()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::setCurrentIndex(int index)
+
+ Sets the currently selected page in the container to be the
+ page at the given \a index in the extension's list of pages.
+
+ \sa currentIndex()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::addWidget(QWidget *page)
+
+ Adds the given \a page to the container by appending it to the
+ extension's list of pages.
+
+ \sa insertWidget(), remove(), widget()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page)
+
+ Adds the given \a page to the container by inserting it at the
+ given \a index in the extension's list of pages.
+
+ \sa addWidget(), remove(), widget()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::remove(int index)
+
+ Removes the page at the given \a index from the extension's list
+ of pages.
+
+ \sa addWidget(), insertWidget()
+*/
+
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerTaskMenuExtension
+ \brief The QDesignerTaskMenuExtension class allows you to add custom
+ menu entries to Qt Designer's task menu.
+ \inmodule QtDesigner
+
+ QDesignerTaskMenuExtension provides an interface for creating
+ custom task menu extensions. It is typically used to create task
+ menu entries that are specific to a plugin in \QD.
+
+ \QD uses the QDesignerTaskMenuExtension to feed its task
+ menu. Whenever a task menu is requested, \QD will query
+ for the selected widget's task menu extension.
+
+ \image taskmenuextension-example-faded.png
+
+ A task menu extension is a collection of QActions. The actions
+ appear as entries in the task menu when the plugin with the
+ specified extension is selected. The image above shows the custom
+ \gui {Edit State...} action which appears in addition to \QD's
+ default task menu entries: \gui Cut, \gui Copy, \gui Paste etc.
+
+ To create a custom task menu extension, your extension class must
+ inherit from both QObject and QDesignerTaskMenuExtension. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9
+
+ Since we are implementing an interface, we must ensure that it
+ is made known to the meta-object system using the Q_INTERFACES()
+ macro. This enables \QD to use the qobject_cast() function to
+ query for supported interfaces using nothing but a QObject
+ pointer.
+
+ You must reimplement the taskActions() function to return a list
+ of actions that will be included in \QD task menu. Optionally, you
+ can reimplement the preferredEditAction() function to set the
+ action that is invoked when selecting your plugin and pressing
+ \key F2. The preferred edit action must be one of the actions
+ returned by taskActions() and, if it's not defined, pressing the
+ \key F2 key will simply be ignored.
+
+ In \QD, extensions are not created until they are required. A
+ task menu extension, for example, is created when you click the
+ right mouse button over a widget in \QD's workspace. For that
+ reason you must also construct an extension factory, using either
+ QExtensionFactory or a subclass, and register it using \QD's
+ \l {QExtensionManager}{extension manager}.
+
+ When a task menu extension is required, \QD's \l
+ {QExtensionManager}{extension manager} will run through all its
+ registered factories calling QExtensionFactory::createExtension()
+ for each until it finds one that is able to create a task menu
+ extension for the selected widget. This factory will then make an
+ instance of the extension.
+
+ There are four available types of extensions in \QD:
+ QDesignerContainerExtension, QDesignerMemberSheetExtension,
+ QDesignerPropertySheetExtension, and QDesignerTaskMenuExtension.
+ \QD's behavior is the same whether the requested extension is
+ associated with a container, a member sheet, a property sheet or a
+ task menu.
+
+ The QExtensionFactory class provides a standard extension factory,
+ and can also be used as an interface for custom extension
+ factories. You can either create a new QExtensionFactory and
+ reimplement the QExtensionFactory::createExtension() function. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 10
+
+ Or you can use an existing factory, expanding the
+ QExtensionFactory::createExtension() function to make the factory
+ able to create a task menu extension as well. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 11
+
+ For a complete example using the QDesignerTaskMenuExtension class,
+ see the \l {designer/taskmenuextension}{Task Menu Extension
+ example}. The example shows how to create a custom widget plugin
+ for \QD, and how to to use the QDesignerTaskMenuExtension
+ class to add custom items to \QD's task menu.
+
+ \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
+ Extensions}
+*/
+
+/*!
+ \fn QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension()
+
+ Destroys the task menu extension.
+*/
+
+/*!
+ \fn QAction *QDesignerTaskMenuExtension::preferredEditAction() const
+
+ Returns the action that is invoked when selecting a plugin with
+ the specified extension and pressing \key F2.
+
+ The action must be one of the actions returned by taskActions().
+*/
+
+/*!
+ \fn QList<QAction*> QDesignerTaskMenuExtension::taskActions() const
+
+ Returns the task menu extension as a list of actions which will be
+ included in \QD's task menu when a plugin with the specified
+ extension is selected.
+
+ The function must be reimplemented to add actions to the list.
+*/
+
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerCustomWidgetCollectionInterface
+
+ \brief The QDesignerCustomWidgetCollectionInterface class allows
+ you to include several custom widgets in one single library.
+
+ \inmodule QtDesigner
+
+ When implementing a custom widget plugin, you build it as a
+ separate library. If you want to include several custom widget
+ plugins in the same library, you must in addition subclass
+ QDesignerCustomWidgetCollectionInterface.
+
+ QDesignerCustomWidgetCollectionInterface contains one single
+ function returning a list of the collection's
+ QDesignerCustomWidgetInterface objects. For example, if you have
+ several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and
+ \c CustomWidgetThree, the class definition may look like this:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 12
+
+ In the class constructor you add the interfaces to your custom
+ widgets to the list which you return in the customWidgets()
+ function:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 13
+
+ Note that instead of exporting each custom widget plugin using the
+ Q_EXPORT_PLUGIN2() macro, you export the entire collection. The
+ Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct
+ the custom widgets. Without this macro, there is no way for \QD to
+ use them.
+
+ \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for
+ Qt Designer}
+*/
+
+/*!
+ \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() {
+
+ Destroys the custom widget collection interface.
+*/
+
+/*!
+ \fn QList<QDesignerCustomWidgetInterface*> QDesignerCustomWidgetCollectionInterface::customWidgets() const
+
+ Returns a list of interfaces to the collection's custom widgets.
+*/
+
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerCustomWidgetInterface
+
+ \brief The QDesignerCustomWidgetInterface class enables Qt Designer
+ to access and construct custom widgets.
+
+ \inmodule QtDesigner
+
+ QDesignerCustomWidgetInterface provides a custom widget with an
+ interface. The class contains a set of functions that must be subclassed
+ to return basic information about the widget, such as its class name and
+ the name of its header file. Other functions must be implemented to
+ initialize the plugin when it is loaded, and to construct instances of
+ the custom widget for \QD to use.
+
+ When implementing a custom widget you must subclass
+ QDesignerCustomWidgetInterface to expose your widget to \QD. For
+ example, this is the declaration for the plugin used in the
+ \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that
+ enables an analog clock custom widget to be used by \QD:
+
+ \snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0
+
+ Note that the only part of the class definition that is specific
+ to this particular custom widget is the class name. In addition,
+ since we are implementing an interface, we must ensure that it's
+ made known to the meta object system using the Q_INTERFACES()
+ macro. This enables \QD to use the qobject_cast() function to
+ query for supported interfaces using nothing but a QObject
+ pointer.
+
+ After \QD loads a custom widget plugin, it calls the interface's
+ initialize() function to enable it to set up any resources that it
+ may need. This function is called with a QDesignerFormEditorInterface
+ parameter that provides the plugin with a gateway to all of \QD's API.
+
+ \QD constructs instances of the custom widget by calling the plugin's
+ createWidget() function with a suitable parent widget. Plugins must
+ construct and return an instance of a custom widget with the specified
+ parent widget.
+
+ In the implementation of the class you must remember to export
+ your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2()
+ macro. For example, if a library called \c libcustomwidgetplugin.so
+ (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget
+ class called \c MyCustomWidget, we can export it by adding the
+ following line to the file containing the plugin implementation:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 14
+
+ This macro ensures that \QD can access and construct the custom widget.
+ Without this macro, there is no way for \QD to use it.
+
+ When implementing a custom widget plugin, you build it as a
+ separate library. If you want to include several custom widget
+ plugins in the same library, you must in addition subclass
+ QDesignerCustomWidgetCollectionInterface.
+
+ \warning If your custom widget plugin contains QVariant
+ properties, be aware that only the following \l
+ {QVariant::Type}{types} are supported:
+
+ \list
+ \o QVariant::ByteArray
+ \o QVariant::Bool
+ \o QVariant::Color
+ \o QVariant::Cursor
+ \o QVariant::Date
+ \o QVariant::DateTime
+ \o QVariant::Double
+ \o QVariant::Int
+ \o QVariant::Point
+ \o QVariant::Rect
+ \o QVariant::Size
+ \o QVariant::SizePolicy
+ \o QVariant::String
+ \o QVariant::Time
+ \o QVariant::UInt
+ \endlist
+
+ For a complete example using the QDesignerCustomWidgetInterface
+ class, see the \l {designer/customwidgetplugin}{Custom Widget
+ Example}. The example shows how to create a custom widget plugin
+ for \QD.
+
+ \sa QDesignerCustomWidgetCollectionInterface {Creating Custom
+ Widgets for Qt Designer}
+*/
+
+/*!
+ \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface()
+
+ Destroys the custom widget interface.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::name() const
+
+ Returns the class name of the custom widget supplied by the interface.
+
+ The name returned \e must be identical to the class name used for the
+ custom widget.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::group() const
+
+ Returns the name of the group to which the custom widget belongs.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::toolTip() const
+
+ Returns a short description of the widget that can be used by \QD
+ in a tool tip.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::whatsThis() const
+
+ Returns a description of the widget that can be used by \QD in
+ "What's This?" help for the widget.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::includeFile() const
+
+ Returns the path to the include file that \l uic uses when
+ creating code for the custom widget.
+*/
+
+/*!
+ \fn QIcon QDesignerCustomWidgetInterface::icon() const
+
+ Returns the icon used to represent the custom widget in \QD's
+ widget box.
+*/
+
+/*!
+ \fn bool QDesignerCustomWidgetInterface::isContainer() const
+
+ Returns true if the custom widget is intended to be used as a
+ container; otherwise returns false.
+
+ Most custom widgets are not used to hold other widgets, so their
+ implementations of this function will return false, but custom
+ containers will return true to ensure that they behave correctly
+ in \QD.
+*/
+
+/*!
+ \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent)
+
+ Returns a new instance of the custom widget, with the given \a
+ parent.
+*/
+
+/*!
+ \fn bool QDesignerCustomWidgetInterface::isInitialized() const
+
+ Returns true if the widget has been initialized; otherwise returns
+ false.
+
+ \sa initialize()
+*/
+
+/*!
+ \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor)
+
+ Initializes the widget for use with the specified \a formEditor
+ interface.
+
+ \sa isInitialized()
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::domXml() const
+
+ Returns the XML that is used to describe the custom widget's
+ properties to \QD.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::codeTemplate() const
+
+ This function is reserved for future use by \QD.
+
+ \omit
+ Returns the code template that \QD includes in forms that contain
+ the custom widget when they are saved.
+ \endomit
+*/
+
+/*!
+ \macro QDESIGNER_WIDGET_EXPORT
+ \relates QDesignerCustomWidgetInterface
+ \since 4.1
+
+ This macro is used when defining custom widgets to ensure that they are
+ correctly exported from plugins for use with \QD.
+
+ On some platforms, the symbols required by \QD to create new widgets
+ are removed from plugins by the build system, making them unusable.
+ Using this macro ensures that the symbols are retained on those platforms,
+ and has no side effects on other platforms.
+
+ For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin}
+ example exports a custom widget class with the following declaration:
+
+ \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0
+ \dots
+ \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2
+
+ \sa {Creating Custom Widgets for Qt Designer}
+*/
+
+
+// Doc: Abstract class
+
+/*!
+ \class QDesignerDnDItemInterface
+ \brief The QDesignerDnDItemInterface class provides an interface that is used to manage items
+ during a drag and drop operation.
+ \inmodule QtDesigner
+ \internal
+*/
+
+/*!
+ \enum QDesignerDnDItemInterface::DropType
+
+ This enum describes the result of a drag and drop operation.
+
+ \value MoveDrop The item was moved.
+ \value CopyDrop The item was copied.
+*/
+
+/*!
+ \fn QDesignerDnDItemInterface::QDesignerDnDItemInterface()
+
+ Constructs a new interface to a drag and drop item.
+*/
+
+/*!
+ \fn QDesignerDnDItemInterface::~QDesignerDnDItemInterface()
+
+ Destroys the interface to the item.
+*/
+
+/*!
+ \fn DomUI *QDesignerDnDItemInterface::domUi() const
+
+ Returns a user interface object for the item.
+*/
+
+/*!
+ \fn QWidget *QDesignerDnDItemInterface::widget() const
+
+ Returns the widget being copied or moved in the drag and drop operation.
+
+ \sa source()
+*/
+
+/*!
+ \fn QWidget *QDesignerDnDItemInterface::decoration() const
+
+ Returns the widget used to represent the item.
+*/
+
+/*!
+ \fn QPoint QDesignerDnDItemInterface::hotSpot() const
+
+ Returns the cursor's hotspot.
+
+ \sa QDrag::hotSpot()
+*/
+
+/*!
+ \fn DropType QDesignerDnDItemInterface::type() const
+
+ Returns the type of drag and drop operation in progress.
+*/
+
+/*!
+ \fn QWidget *QDesignerDnDItemInterface::source() const
+
+ Returns the widget that is the source of the drag and drop operation; i.e. the original
+ container of the widget being dragged.
+
+ \sa widget()
+*/
+
+
+// Doc: Abstract class
+
+/*!
+ \class QDesignerIconCacheInterface
+ \brief The QDesignerIconCacheInterface class provides an interface to \QD's icon cache.
+ \inmodule QtDesigner
+ \internal
+*/
+
+/*!
+ \fn QDesignerIconCacheInterface::QDesignerIconCacheInterface(QObject *parent)
+
+ Constructs a new interface with the given \a parent.
+*/
+
+/*!
+ \fn QIcon QDesignerIconCacheInterface::nameToIcon(const QString &filePath, const QString &qrcPath)
+
+ Returns the icon associated with the name specified by \a filePath in the resource
+ file specified by \a qrcPath.
+
+ If \a qrcPath refers to a valid resource file, the name used for the file path is a path
+ within those resources; otherwise the file path refers to a local file.
+
+ \sa {The Qt Resource System}, nameToPixmap()
+*/
+
+/*!
+ \fn QPixmap QDesignerIconCacheInterface::nameToPixmap(const QString &filePath, const QString &qrcPath)
+
+ Returns the pixmap associated with the name specified by \a filePath in the resource
+ file specified by \a qrcPath.
+
+ If \a qrcPath refers to a valid resource file, the name used for the file path is a path
+ within those resources; otherwise the file path refers to a local file.
+
+ \sa {The Qt Resource System}, nameToIcon()
+*/
+
+/*!
+ \fn QString QDesignerIconCacheInterface::iconToFilePath(const QIcon &icon) const
+
+ Returns the file path associated with the given \a icon. The file path is a path within
+ an application resources.
+*/
+
+/*!
+ \fn QString QDesignerIconCacheInterface::iconToQrcPath(const QIcon &icon) const
+
+ Returns the path to the resource file that refers to the specified \a icon. The resource
+ path refers to a local file.
+*/
+
+/*!
+ \fn QString QDesignerIconCacheInterface::pixmapToFilePath(const QPixmap &pixmap) const
+
+ Returns the file path associated with the given \a pixmap. The file path is a path within
+ an application resources.
+*/
+
+/*!
+ \fn QString QDesignerIconCacheInterface::pixmapToQrcPath(const QPixmap &pixmap) const
+
+ Returns the path to the resource file that refers to the specified \a pixmap. The resource
+ path refers to a local file.
+*/
+
+/*!
+ \fn QList<QPixmap> QDesignerIconCacheInterface::pixmapList() const
+
+ Returns a list of pixmaps for the icons provided by the icon cache.
+*/
+
+/*!
+ \fn QList<QIcon> QDesignerIconCacheInterface::iconList() const
+
+ Returns a list of icons provided by the icon cache.
+*/
+
+/*!
+ \fn QString QDesignerIconCacheInterface::resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory) const
+
+ Returns a path to a resource specified by the \a filePath within
+ the resource file located at \a qrcPath. If \a workingDirectory is
+ a valid path to a directory, the path returned will be relative to
+ that directory; otherwise an absolute path is returned.
+
+ \omit
+ ### Needs checking
+ \endomit
+*/
+
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerPropertySheetExtension
+
+ \brief The QDesignerPropertySheetExtension class allows you to
+ manipulate a widget's properties which is displayed in Qt
+ Designer's property editor.
+
+ \sa QDesignerDynamicPropertySheetExtension
+
+ \inmodule QtDesigner
+
+ QDesignerPropertySheetExtension provides a collection of functions that
+ are typically used to query a widget's properties, and to
+ manipulate the properties' appearance in the property editor. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15
+
+ Note that if you change the value of a property using the
+ QDesignerPropertySheetExtension::setProperty() function, the undo
+ stack is not updated. To ensure that a property's value can be
+ reverted using the undo stack, you must use the
+ QDesignerFormWindowCursorInterface::setProperty() function, or its
+ buddy \l
+ {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
+ instead.
+
+ When implementing a custom widget plugin, a pointer to \QD's
+ current QDesignerFormEditorInterface object (\c formEditor in the
+ example above) is provided by the
+ QDesignerCustomWidgetInterface::initialize() function's parameter.
+
+ The property sheet, or any other extension, can be retrieved by
+ querying \QD's extension manager using the qt_extension()
+ function. When you want to release the extension, you only need to
+ delete the pointer.
+
+ All widgets have a default property sheet which populates \QD's
+ property editor with the widget's properties (i.e the ones defined
+ with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension
+ also provides an interface for creating custom property sheet
+ extensions.
+
+ \warning \QD uses the QDesignerPropertySheetExtension to feed its
+ property editor. Whenever a widget is selected in its workspace,
+ \QD will query for the widget's property sheet extension. If the
+ selected widget has an implemented property sheet extension, this
+ extension will override the default property sheet.
+
+ To create a property sheet extension, your extension class must
+ inherit from both QObject and
+ QDesignerPropertySheetExtension. Then, since we are implementing
+ an interface, we must ensure that it's made known to the meta
+ object system using the Q_INTERFACES() macro:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16
+
+ This enables \QD to use qobject_cast() to query for supported
+ interfaces using nothing but a QObject pointer.
+
+ In \QD the extensions are not created until they are
+ required. For that reason, when implementing a property sheet
+ extension, you must also create a QExtensionFactory, i.e a class
+ that is able to make an instance of your extension, and register
+ it using \QD's \l {QExtensionManager}{extension manager}.
+
+ When a property sheet extension is required, \QD's \l
+ {QExtensionManager}{extension manager} will run through all its
+ registered factories calling QExtensionFactory::createExtension()
+ for each until the first one that is able to create a property
+ sheet extension for the selected widget, is found. This factory
+ will then make an instance of the extension. If no such factory
+ can be found, \QD will use the default property sheet.
+
+ There are four available types of extensions in \QD:
+ QDesignerContainerExtension, QDesignerMemberSheetExtension,
+ QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
+ Designer's behavior is the same whether the requested extension is
+ associated with a multi page container, a member sheet, a property
+ sheet or a task menu.
+
+ The QExtensionFactory class provides a standard extension factory,
+ and can also be used as an interface for custom extension
+ factories. You can either create a new QExtensionFactory and
+ reimplement the QExtensionFactory::createExtension() function. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 17
+
+ Or you can use an existing factory, expanding the
+ QExtensionFactory::createExtension() function to make the factory
+ able to create a property sheet extension extension as well. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18
+
+ For a complete example using an extension class, see the \l
+ {designer/taskmenuextension}{Task Menu Extension example}. The
+ example shows how to create a custom widget plugin for Qt
+ Designer, and how to to use the QDesignerTaskMenuExtension class
+ to add custom items to \QD's task menu.
+
+ \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
+ Extensions}
+*/
+
+/*!
+ \fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension()
+
+ Destroys the property sheet extension.
+*/
+
+/*!
+ \fn int QDesignerPropertySheetExtension::count() const
+
+ Returns the selected widget's number of properties.
+*/
+
+/*!
+ \fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const
+
+ Returns the index for a given property \a name.
+
+ \sa propertyName()
+*/
+
+/*!
+ \fn QString QDesignerPropertySheetExtension::propertyName(int index) const
+
+ Returns the name of the property at the given \a index.
+
+ \sa indexOf()
+*/
+
+/*!
+ \fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const
+
+ Returns the property group for the property at the given \a index.
+
+ \QD's property editor supports property groups, i.e. sections of
+ related properties. A property can be related to a group using the
+ setPropertyGroup() function. The default group of any property is
+ the name of the class that defines it. For example, the
+ QObject::objectName property appears within the QObject property
+ group.
+
+ \sa indexOf(), setPropertyGroup()
+*/
+
+/*!
+ \fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group)
+
+ Sets the property group for the property at the given \a index to
+ \a group.
+
+ Relating a property to a group makes it appear within that group's
+ section in the property editor. The default property group of any
+ property is the name of the class that defines it. For example,
+ the QObject::objectName property appears within the QObject
+ property group.
+
+ \sa indexOf(), property(), propertyGroup()
+*/
+
+/*!
+ \fn bool QDesignerPropertySheetExtension::hasReset(int index) const
+
+ Returns true if the property at the given \a index has a reset
+ button in \QD's property editor, otherwise false.
+
+ \sa indexOf(), reset()
+*/
+
+/*!
+ \fn bool QDesignerPropertySheetExtension::reset(int index)
+
+ Resets the value of the property at the given \a index, to the
+ default value. Returns true if a default value could be found, otherwise false.
+
+ \sa indexOf(), hasReset(), isChanged()
+*/
+
+/*!
+ \fn bool QDesignerPropertySheetExtension::isVisible(int index) const
+
+ Returns true if the property at the given \a index is visible in
+ \QD's property editor, otherwise false.
+
+ \sa indexOf(), setVisible()
+*/
+
+/*!
+ \fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible)
+
+ If \a visible is true, the property at the given \a index is
+ visible in \QD's property editor; otherwise the property is
+ hidden.
+
+ \sa indexOf(), isVisible()
+*/
+
+/*!
+ \fn bool QDesignerPropertySheetExtension::isAttribute(int index) const
+
+ Returns true if the property at the given \a index is an attribute,
+ which will be \e excluded from the UI file, otherwise false.
+
+ \sa indexOf(), setAttribute()
+*/
+
+/*!
+ \fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute)
+
+ If \a attribute is true, the property at the given \a index is
+ made an attribute which will be \e excluded from the UI file;
+ otherwise it will be included.
+
+ \sa indexOf(), isAttribute()
+*/
+
+/*!
+ \fn QVariant QDesignerPropertySheetExtension::property(int index) const
+
+ Returns the value of the property at the given \a index.
+
+ \sa indexOf(), setProperty(), propertyGroup()
+*/
+
+/*!
+ \fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value)
+
+ Sets the \a value of the property at the given \a index.
+
+ \warning If you change the value of a property using this
+ function, the undo stack is not updated. To ensure that a
+ property's value can be reverted using the undo stack, you must
+ use the QDesignerFormWindowCursorInterface::setProperty()
+ function, or its buddy \l
+ {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
+ instead.
+
+ \sa indexOf(), property(), propertyGroup()
+*/
+
+/*!
+ \fn bool QDesignerPropertySheetExtension::isChanged(int index) const
+
+ Returns true if the value of the property at the given \a index
+ differs from the property's default value, otherwise false.
+
+ \sa indexOf(), setChanged(), reset()
+*/
+
+/*!
+ \fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed)
+
+ Sets whether the property at the given \a index is different from
+ its default value, or not, depending on the \a changed parameter.
+
+ \sa indexOf(), isChanged()
+*/
+
+// Doc: Interface only
+
+/*!
+ \class QDesignerDynamicPropertySheetExtension
+
+ \brief The QDesignerDynamicPropertySheetExtension class allows you to
+ manipulate a widget's dynamic properties in Qt Designer's property editor.
+
+ \sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties}
+
+ \inmodule QtDesigner
+ \since 4.3
+*/
+
+/*!
+ \fn QDesignerDynamicPropertySheetExtension::~QDesignerDynamicPropertySheetExtension()
+
+ Destroys the dynamic property sheet extension.
+*/
+
+/*!
+ \fn bool QDesignerDynamicPropertySheetExtension::dynamicPropertiesAllowed() const
+
+ Returns true if the widget supports dynamic properties; otherwise returns false.
+*/
+
+/*!
+ \fn int QDesignerDynamicPropertySheetExtension::addDynamicProperty(const QString &propertyName, const QVariant &value)
+
+ Adds a dynamic property named \a propertyName and sets its value to \a value.
+ Returns the index of the property if it was added successfully; otherwise returns -1 to
+ indicate failure.
+*/
+
+/*!
+ \fn bool QDesignerDynamicPropertySheetExtension::removeDynamicProperty(int index)
+
+ Removes the dynamic property at the given \a index.
+ Returns true if the operation succeeds; otherwise returns false.
+*/
+
+/*!
+ \fn bool QDesignerDynamicPropertySheetExtension::isDynamicProperty(int index) const
+
+ Returns true if the property at the given \a index is a dynamic property; otherwise
+ returns false.
+*/
+
+/*!
+ \fn bool QDesignerDynamicPropertySheetExtension::canAddDynamicProperty(const QString &propertyName) const
+
+ Returns true if \a propertyName is a valid, unique name for a dynamic
+ property; otherwise returns false.
+
+*/
diff --git a/doc/src/qtendian.qdoc b/doc/src/classes/qtendian.qdoc
index dcffb5d..dcffb5d 100644
--- a/doc/src/qtendian.qdoc
+++ b/doc/src/classes/qtendian.qdoc
diff --git a/doc/src/qtestevent.qdoc b/doc/src/classes/qtestevent.qdoc
index 2e111b3..2e111b3 100644
--- a/doc/src/qtestevent.qdoc
+++ b/doc/src/classes/qtestevent.qdoc
diff --git a/doc/src/qvarlengtharray.qdoc b/doc/src/classes/qvarlengtharray.qdoc
index ac6bb6e..ac6bb6e 100644
--- a/doc/src/qvarlengtharray.qdoc
+++ b/doc/src/classes/qvarlengtharray.qdoc
diff --git a/doc/src/qwaitcondition.qdoc b/doc/src/classes/qwaitcondition.qdoc
index ae94e35..ae94e35 100644
--- a/doc/src/qwaitcondition.qdoc
+++ b/doc/src/classes/qwaitcondition.qdoc
diff --git a/doc/src/groups.qdoc b/doc/src/groups.qdoc
index 731ac58..f7296a3 100644
--- a/doc/src/groups.qdoc
+++ b/doc/src/groups.qdoc
@@ -202,20 +202,6 @@
*/
/*!
- \group explicitly-shared
- \ingroup groups
-
- \title Explicitly Shared Classes
- \brief Classes that use explicit sharing to manage internal data.
-
- \keyword explicit sharing
- \keyword explicitly shared
-
- Unlike many of Qt's data types, which use \l{implicit sharing}, these
- classes use explicit sharing to manage internal data.
-*/
-
-/*!
\group geomanagement
\title Layout Classes
\ingroup groups
@@ -377,103 +363,6 @@
*/
/*!
- \group shared
- \title Implicitly Shared Classes
- \ingroup architecture
- \ingroup groups
-
- \brief Classes that use reference counting for fast copying.
-
- \keyword implicit data sharing
- \keyword implicit sharing
- \keyword implicitly shared
- \keyword reference counting
- \keyword shared implicitly
- \keyword shared classes
-
- Many C++ classes in Qt use implicit data sharing to maximize
- resource usage and minimize copying. Implicitly shared classes are
- both safe and efficient when passed as arguments, because only a
- pointer to the data is passed around, and the data is copied only
- if and when a function writes to it, i.e., \e {copy-on-write}.
-
- \tableofcontents
-
- \section1 Overview
-
- A shared class consists of a pointer to a shared data block that
- contains a reference count and the data.
-
- When a shared object is created, it sets the reference count to 1. The
- reference count is incremented whenever a new object references the
- shared data, and decremented when the object dereferences the shared
- data. The shared data is deleted when the reference count becomes
- zero.
-
- \keyword deep copy
- \keyword shallow copy
-
- When dealing with shared objects, there are two ways of copying an
- object. We usually speak about \e deep and \e shallow copies. A deep
- copy implies duplicating an object. A shallow copy is a reference
- copy, i.e. just a pointer to a shared data block. Making a deep copy
- can be expensive in terms of memory and CPU. Making a shallow copy is
- very fast, because it only involves setting a pointer and incrementing
- the reference count.
-
- Object assignment (with operator=()) for implicitly shared objects is
- implemented using shallow copies.
-
- The benefit of sharing is that a program does not need to duplicate
- data unnecessarily, which results in lower memory use and less copying
- of data. Objects can easily be assigned, sent as function arguments,
- and returned from functions.
-
- Implicit sharing takes place behind the scenes; the programmer
- does not need to worry about it. Even in multithreaded
- applications, implicit sharing takes place, as explained in
- \l{Threads and Implicit Sharing}.
-
- \section1 Implicit Sharing in Detail
-
- Implicit sharing automatically detaches the object from a shared
- block if the object is about to change and the reference count is
- greater than one. (This is often called \e {copy-on-write} or
- \e {value semantics}.)
-
- An implicitly shared class has total control of its internal data. In
- any member functions that modify its data, it automatically detaches
- before modifying the data.
-
- The QPen class, which uses implicit sharing, detaches from the shared
- data in all member functions that change the internal data.
-
- Code fragment:
- \snippet doc/src/snippets/code/doc_src_groups.qdoc 0
-
- \section1 List of Classes
-
- The classes listed below automatically detach from common data if
- an object is about to be changed. The programmer will not even
- notice that the objects are shared. Thus you should treat
- separate instances of them as separate objects. They will always
- behave as separate objects but with the added benefit of sharing
- data whenever possible. For this reason, you can pass instances
- of these classes as arguments to functions by value without
- concern for the copying overhead.
-
- Example:
- \snippet doc/src/snippets/code/doc_src_groups.qdoc 1
-
- In this example, \c p1 and \c p2 share data until QPainter::begin()
- is called for \c p2, because painting a pixmap will modify it.
-
- \warning Do not copy an implicitly shared container (QMap,
- QVector, etc.) while you are iterating over it using an non-const
- \l{STL-style iterator}.
-*/
-
-/*!
\group ssl
\title Secure Sockets Layer (SSL) Classes
\ingroup groups
diff --git a/doc/src/implicit-sharing.qdoc b/doc/src/implicit-sharing.qdoc
new file mode 100644
index 0000000..85630dc
--- /dev/null
+++ b/doc/src/implicit-sharing.qdoc
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/* TODO: Move some of the documentation from QSharedDataPointer into this
+ document. */
+
+/*!
+ \group shared
+ \title Implicitly Shared Classes
+ \ingroup architecture
+ \ingroup groups
+
+ \brief Classes that use reference counting for fast copying.
+
+ \keyword implicit data sharing
+ \keyword implicit sharing
+ \keyword implicitly shared
+ \keyword reference counting
+ \keyword shared implicitly
+ \keyword shared classes
+
+ Many C++ classes in Qt use implicit data sharing to maximize
+ resource usage and minimize copying. Implicitly shared classes are
+ both safe and efficient when passed as arguments, because only a
+ pointer to the data is passed around, and the data is copied only
+ if and when a function writes to it, i.e., \e {copy-on-write}.
+
+ \tableofcontents
+
+ \section1 Overview
+
+ A shared class consists of a pointer to a shared data block that
+ contains a reference count and the data.
+
+ When a shared object is created, it sets the reference count to 1. The
+ reference count is incremented whenever a new object references the
+ shared data, and decremented when the object dereferences the shared
+ data. The shared data is deleted when the reference count becomes
+ zero.
+
+ \keyword deep copy
+ \keyword shallow copy
+
+ When dealing with shared objects, there are two ways of copying an
+ object. We usually speak about \e deep and \e shallow copies. A deep
+ copy implies duplicating an object. A shallow copy is a reference
+ copy, i.e. just a pointer to a shared data block. Making a deep copy
+ can be expensive in terms of memory and CPU. Making a shallow copy is
+ very fast, because it only involves setting a pointer and incrementing
+ the reference count.
+
+ Object assignment (with operator=()) for implicitly shared objects is
+ implemented using shallow copies.
+
+ The benefit of sharing is that a program does not need to duplicate
+ data unnecessarily, which results in lower memory use and less copying
+ of data. Objects can easily be assigned, sent as function arguments,
+ and returned from functions.
+
+ Implicit sharing takes place behind the scenes; the programmer
+ does not need to worry about it. Even in multithreaded
+ applications, implicit sharing takes place, as explained in
+ \l{Threads and Implicit Sharing}.
+
+ When implementing your own implicitly shared classes, use the
+ QSharedData and QSharedDataPointer classes.
+
+ \section1 Implicit Sharing in Detail
+
+ Implicit sharing automatically detaches the object from a shared
+ block if the object is about to change and the reference count is
+ greater than one. (This is often called \e {copy-on-write} or
+ \e {value semantics}.)
+
+ An implicitly shared class has total control of its internal data. In
+ any member functions that modify its data, it automatically detaches
+ before modifying the data.
+
+ The QPen class, which uses implicit sharing, detaches from the shared
+ data in all member functions that change the internal data.
+
+ Code fragment:
+ \snippet doc/src/snippets/code/doc_src_groups.qdoc 0
+
+
+ \section1 List of Classes
+
+ The classes listed below automatically detach from common data if
+ an object is about to be changed. The programmer will not even
+ notice that the objects are shared. Thus you should treat
+ separate instances of them as separate objects. They will always
+ behave as separate objects but with the added benefit of sharing
+ data whenever possible. For this reason, you can pass instances
+ of these classes as arguments to functions by value without
+ concern for the copying overhead.
+
+ Example:
+ \snippet doc/src/snippets/code/doc_src_groups.qdoc 1
+
+ In this example, \c p1 and \c p2 share data until QPainter::begin()
+ is called for \c p2, because painting a pixmap will modify it.
+
+ \warning Do not copy an implicitly shared container (QMap,
+ QVector, etc.) while you are iterating over it using an non-const
+ \l{STL-style iterator}.
+*/
diff --git a/doc/src/qtdesigner.qdoc b/doc/src/qtdesigner.qdoc
index d913b32..0959bd9 100644
--- a/doc/src/qtdesigner.qdoc
+++ b/doc/src/qtdesigner.qdoc
@@ -166,1376 +166,3 @@
\sa {Qt Designer Manual}, {QtUiTools Module}
*/
-
-/*!
- \class QDesignerMemberSheetExtension
-
- \brief The QDesignerMemberSheetExtension class allows you to
- manipulate a widget's member functions which is displayed when
- configuring connections using Qt Designer's mode for editing
- signals and slots.
-
- \inmodule QtDesigner
-
- QDesignerMemberSheetExtension is a collection of functions that is
- typically used to query a widget's member functions, and to
- manipulate the member functions' appearance in \QD's signals and
- slots editing mode. For example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 2
-
- When implementing a custom widget plugin, a pointer to \QD's
- current QDesignerFormEditorInterface object (\c formEditor in the
- example above) is provided by the
- QDesignerCustomWidgetInterface::initialize() function's parameter.
-
- The member sheet (and any other extension), can be retrieved by
- querying \QD's extension manager using the qt_extension()
- function. When you want to release the extension, you only need to
- delete the pointer.
-
- All widgets have a default member sheet used in \QD's signals and
- slots editing mode with the widget's member functions. But
- QDesignerMemberSheetExtension also provides an interface for
- creating custom member sheet extensions.
-
- \warning \QD uses the QDesignerMemberSheetExtension to facilitate
- the signal and slot editing mode. Whenever a connection between
- two widgets is requested, \QD will query for the widgets' member
- sheet extensions. If a widget has an implemented member sheet
- extension, this extension will override the default member sheet.
-
- To create a member sheet extension, your extension class must
- inherit from both QObject and QDesignerMemberSheetExtension. Then,
- since we are implementing an interface, we must ensure that it's
- made known to the meta object system using the Q_INTERFACES()
- macro:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 3
-
- This enables \QD to use qobject_cast() to query for
- supported interfaces using nothing but a QObject pointer.
-
- In \QD the extensions are not created until they are
- required. For that reason, when implementing a member sheet
- extension, you must also create a QExtensionFactory, i.e a class
- that is able to make an instance of your extension, and register
- it using \QD's \l {QExtensionManager}{extension manager}.
-
- When a widget's member sheet extension is required, \QD's \l
- {QExtensionManager}{extension manager} will run through all its
- registered factories calling QExtensionFactory::createExtension()
- for each until the first one that is able to create a member sheet
- extension for that widget, is found. This factory will then make
- an instance of the extension. If no such factory is found, \QD
- will use the default member sheet.
-
- There are four available types of extensions in \QD:
- QDesignerContainerExtension, QDesignerMemberSheetExtension,
- QDesignerPropertySheetExtension and
- QDesignerTaskMenuExtension. \QD's behavior is the same whether the
- requested extension is associated with a multi page container, a
- member sheet, a property sheet or a task menu.
-
- The QExtensionFactory class provides a standard extension
- factory, and can also be used as an interface for custom
- extension factories. You can either create a new
- QExtensionFactory and reimplement the
- QExtensionFactory::createExtension() function. For example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 4
-
- Or you can use an existing factory, expanding the
- QExtensionFactory::createExtension() function to make the factory
- able to create a member sheet extension as well. For example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 5
-
- For a complete example using an extension class, see \l
- {designer/taskmenuextension}{Task Menu Extension example}. The
- example shows how to create a custom widget plugin for Qt
- Designer, and how to to use the QDesignerTaskMenuExtension class
- to add custom items to \QD's task menu.
-
- \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
- Extensions}
-*/
-
-/*!
- \fn QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension()
-
- Destroys the member sheet extension.
-*/
-
-/*!
- \fn int QDesignerMemberSheetExtension::count() const
-
- Returns the extension's number of member functions.
-*/
-
-/*!
- \fn int QDesignerMemberSheetExtension::indexOf(const QString &name) const
-
- Returns the index of the member function specified by the given \a
- name.
-
- \sa memberName()
-*/
-
-/*!
- \fn QString QDesignerMemberSheetExtension::memberName(int index) const
-
- Returns the name of the member function with the given \a index.
-
- \sa indexOf()
-*/
-
-/*!
- \fn QString QDesignerMemberSheetExtension::memberGroup(int index) const
-
- Returns the name of the member group specified for the function
- with the given \a index.
-
- \sa indexOf(), setMemberGroup()
-*/
-
-/*!
- \fn void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group)
-
- Sets the member group of the member function with the given \a
- index, to \a group.
-
- \sa indexOf(), memberGroup()
-*/
-
-/*!
- \fn bool QDesignerMemberSheetExtension::isVisible(int index) const
-
- Returns true if the member function with the given \a index is
- visible in \QD's signal and slot editor, otherwise false.
-
- \sa indexOf(), setVisible()
-*/
-
-/*!
- \fn void QDesignerMemberSheetExtension::setVisible(int index, bool visible)
-
- If \a visible is true, the member function with the given \a index
- is visible in \QD's signals and slots editing mode; otherwise the
- member function is hidden.
-
- \sa indexOf(), isVisible()
-*/
-
-/*!
- \fn virtual bool QDesignerMemberSheetExtension::isSignal(int index) const
-
- Returns true if the member function with the given \a index is a
- signal, otherwise false.
-
- \sa indexOf()
-*/
-
-/*!
- \fn bool QDesignerMemberSheetExtension::isSlot(int index) const
-
- Returns true if the member function with the given \a index is a
- slot, otherwise false.
-
- \sa indexOf()
-*/
-
-/*!
- \fn bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const
-
- Returns true if the member function with the given \a index is
- inherited from QWidget, otherwise false.
-
- \sa indexOf()
-*/
-
-/*!
- \fn QString QDesignerMemberSheetExtension::declaredInClass(int index) const
-
- Returns the name of the class in which the member function with
- the given \a index is declared.
-
- \sa indexOf()
-*/
-
-/*!
- \fn QString QDesignerMemberSheetExtension::signature(int index) const
-
- Returns the signature of the member function with the given \a
- index.
-
- \sa indexOf()
-*/
-
-/*!
- \fn QList<QByteArray> QDesignerMemberSheetExtension::parameterTypes(int index) const
-
- Returns the parameter types of the member function with the given
- \a index, as a QByteArray list.
-
- \sa indexOf(), parameterNames()
-*/
-
-/*!
- \fn QList<QByteArray> QDesignerMemberSheetExtension::parameterNames(int index) const
-
- Returns the parameter names of the member function with the given
- \a index, as a QByteArray list.
-
- \sa indexOf(), parameterTypes()
-*/
-
-
-// Doc: Interface only
-
-/*!
- \class QDesignerLayoutDecorationExtension
- \brief The QDesignerLayoutDecorationExtension class provides an extension to a layout in \QD.
- \inmodule QtDesigner
- \internal
-*/
-
-/*!
- \enum QDesignerLayoutDecorationExtension::InsertMode
-
- This enum describes the modes that are used to insert items into a layout.
-
- \value InsertWidgetMode Widgets are inserted into empty cells in a layout.
- \value InsertRowMode Whole rows are inserted into a vertical or grid layout.
- \value InsertColumnMode Whole columns are inserted into a horizontal or grid layout.
-*/
-
-/*!
- \fn virtual QDesignerLayoutDecorationExtension::~QDesignerLayoutDecorationExtension()
-
- Destroys the extension.
-*/
-
-/*!
- \fn virtual QList<QWidget*> QDesignerLayoutDecorationExtension::widgets(QLayout *layout) const
-
- Returns the widgets that are managed by the given \a layout.
-
- \sa insertWidget(), removeWidget()
-*/
-
-/*!
- \fn QRect QDesignerLayoutDecorationExtension::itemInfo(int index) const
-
- Returns the rectangle covered by the item at the given \a index in the layout.
-*/
-
-/*!
- \fn int QDesignerLayoutDecorationExtension::indexOf(QWidget *widget) const
-
- Returns the index of the specified \a widget in the layout.
-*/
-
-/*!
- \fn int QDesignerLayoutDecorationExtension::indexOf(QLayoutItem *item) const
-
- Returns the index of the specified layout \a item.
-*/
-
-/*!
- \fn QDesignerLayoutDecorationExtension::InsertMode QDesignerLayoutDecorationExtension::currentInsertMode() const
-
- Returns the current insertion mode.
-*/
-
-/*!
- \fn int QDesignerLayoutDecorationExtension::currentIndex() const
-
- Returns the current index in the layout.
-*/
-
-/*!
- \fn QPair<int, int> QDesignerLayoutDecorationExtension::currentCell() const
-
- Returns a pair containing the row and column of the current cell in the layout.
-*/
-
-/*!
- \fn void QDesignerLayoutDecorationExtension::insertWidget(QWidget *widget, const QPair<int, int> &cell)
-
- Inserts the given \a widget into the specified \a cell in the layout.
-
- \sa removeWidget()
-*/
-
-/*!
- \fn void QDesignerLayoutDecorationExtension::removeWidget(QWidget *widget)
-
- Removes the specified \a widget from the layout.
-
- \sa insertWidget()
-*/
-
-/*!
- \fn void QDesignerLayoutDecorationExtension::insertRow(int row)
-
- Inserts a new row into the form at the position specified by \a row.
-*/
-
-/*!
- \fn void QDesignerLayoutDecorationExtension::insertColumn(int column)
-
- Inserts a new column into the form at the position specified by \a column.
-*/
-
-/*!
- \fn void QDesignerLayoutDecorationExtension::simplify()
-
- Simplifies the layout by removing unnecessary empty rows and columns, and by changing the
- number of rows or columns spanned by widgets.
-*/
-
-/*!
- \fn int QDesignerLayoutDecorationExtension::findItemAt(const QPoint &position) const
-
- Returns the index of the item in the layout that covers the given \a position.
-*/
-
-/*!
- \fn int QDesignerLayoutDecorationExtension::findItemAt(int row, int column) const
-
- Returns the item in the layout that occupies the specified \a row and \a column in the layout.
-
- Currently, this only applies to grid layouts.
-*/
-
-/*!
- \fn void QDesignerLayoutDecorationExtension::adjustIndicator(const QPoint &position, int index)
-
- Adjusts the indicator for the item specified by \a index so that
- it lies at the given \a position on the form.
-*/
-
-
-// Doc: Interface only
-
-/*!
- \class QDesignerContainerExtension
- \brief The QDesignerContainerExtension class allows you to add pages to
- a custom multi-page container in Qt Designer's workspace.
- \inmodule QtDesigner
-
- QDesignerContainerExtension provide an interface for creating
- custom container extensions. A container extension consists of a
- collection of functions that \QD needs to manage a multi-page
- container plugin, and a list of the container's pages.
-
- \image containerextension-example.png
-
- \warning This is \e not an extension for container plugins in
- general, only custom \e multi-page containers.
-
- To create a container extension, your extension class must inherit
- from both QObject and QDesignerContainerExtension. For example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6
-
- Since we are implementing an interface, we must ensure that it's
- made known to the meta object system using the Q_INTERFACES()
- macro. This enables \QD to use the qobject_cast() function to
- query for supported interfaces using nothing but a QObject
- pointer.
-
- You must reimplement several functions to enable \QD to manage a
- custom multi-page container widget: \QD uses count() to keep track
- of the number pages in your container, widget() to return the page
- at a given index in the list of the container's pages, and
- currentIndex() to return the list index of the selected page. \QD
- uses the addWidget() function to add a given page to the
- container, expecting it to be appended to the list of pages, while
- it expects the insertWidget() function to add a given page to the
- container by inserting it at a given index.
-
- In \QD the extensions are not created until they are
- required. For that reason you must also create a
- QExtensionFactory, i.e a class that is able to make an instance of
- your extension, and register it using \QD's \l
- {QExtensionManager}{extension manager}.
-
- When a container extension is required, \QD's \l
- {QExtensionManager}{extension manager} will run through all its
- registered factories calling QExtensionFactory::createExtension()
- for each until the first one that is able to create a container
- extension, is found. This factory will then create the extension
- for the plugin.
-
- There are four available types of extensions in \QD:
- QDesignerContainerExtension , QDesignerMemberSheetExtension,
- QDesignerPropertySheetExtension and QDesignerTaskMenuExtension.
- \QD's behavior is the same whether the requested extension is
- associated with a multi page container, a member sheet, a property
- sheet or a task menu.
-
- The QExtensionFactory class provides a standard extension factory,
- and can also be used as an interface for custom extension
- factories. You can either create a new QExtensionFactory and
- reimplement the QExtensionFactory::createExtension() function. For
- example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7
-
- Or you can use an existing factory, expanding the
- QExtensionFactory::createExtension() function to make the factory
- able to create a container extension as well. For example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8
-
- For a complete example using the QDesignerContainerExtension
- class, see the \l {designer/containerextension}{Container
- Extension example}. The example shows how to create a custom
- multi-page plugin for \QD.
-
- \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
- Extensions}
-*/
-
-/*!
- \fn QDesignerContainerExtension::~QDesignerContainerExtension()
-
- Destroys the extension.
-*/
-
-/*!
- \fn int QDesignerContainerExtension::count() const
-
- Returns the number of pages in the container.
-*/
-
-/*!
- \fn QWidget *QDesignerContainerExtension::widget(int index) const
-
- Returns the page at the given \a index in the extension's list of
- pages.
-
- \sa addWidget(), insertWidget()
-*/
-
-/*!
- \fn int QDesignerContainerExtension::currentIndex() const
-
- Returns the index of the currently selected page in the
- container.
-
- \sa setCurrentIndex()
-*/
-
-/*!
- \fn void QDesignerContainerExtension::setCurrentIndex(int index)
-
- Sets the currently selected page in the container to be the
- page at the given \a index in the extension's list of pages.
-
- \sa currentIndex()
-*/
-
-/*!
- \fn void QDesignerContainerExtension::addWidget(QWidget *page)
-
- Adds the given \a page to the container by appending it to the
- extension's list of pages.
-
- \sa insertWidget(), remove(), widget()
-*/
-
-/*!
- \fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page)
-
- Adds the given \a page to the container by inserting it at the
- given \a index in the extension's list of pages.
-
- \sa addWidget(), remove(), widget()
-*/
-
-/*!
- \fn void QDesignerContainerExtension::remove(int index)
-
- Removes the page at the given \a index from the extension's list
- of pages.
-
- \sa addWidget(), insertWidget()
-*/
-
-
-// Doc: Interface only
-
-/*!
- \class QDesignerTaskMenuExtension
- \brief The QDesignerTaskMenuExtension class allows you to add custom
- menu entries to Qt Designer's task menu.
- \inmodule QtDesigner
-
- QDesignerTaskMenuExtension provides an interface for creating
- custom task menu extensions. It is typically used to create task
- menu entries that are specific to a plugin in \QD.
-
- \QD uses the QDesignerTaskMenuExtension to feed its task
- menu. Whenever a task menu is requested, \QD will query
- for the selected widget's task menu extension.
-
- \image taskmenuextension-example-faded.png
-
- A task menu extension is a collection of QActions. The actions
- appear as entries in the task menu when the plugin with the
- specified extension is selected. The image above shows the custom
- \gui {Edit State...} action which appears in addition to \QD's
- default task menu entries: \gui Cut, \gui Copy, \gui Paste etc.
-
- To create a custom task menu extension, your extension class must
- inherit from both QObject and QDesignerTaskMenuExtension. For
- example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9
-
- Since we are implementing an interface, we must ensure that it
- is made known to the meta-object system using the Q_INTERFACES()
- macro. This enables \QD to use the qobject_cast() function to
- query for supported interfaces using nothing but a QObject
- pointer.
-
- You must reimplement the taskActions() function to return a list
- of actions that will be included in \QD task menu. Optionally, you
- can reimplement the preferredEditAction() function to set the
- action that is invoked when selecting your plugin and pressing
- \key F2. The preferred edit action must be one of the actions
- returned by taskActions() and, if it's not defined, pressing the
- \key F2 key will simply be ignored.
-
- In \QD, extensions are not created until they are required. A
- task menu extension, for example, is created when you click the
- right mouse button over a widget in \QD's workspace. For that
- reason you must also construct an extension factory, using either
- QExtensionFactory or a subclass, and register it using \QD's
- \l {QExtensionManager}{extension manager}.
-
- When a task menu extension is required, \QD's \l
- {QExtensionManager}{extension manager} will run through all its
- registered factories calling QExtensionFactory::createExtension()
- for each until it finds one that is able to create a task menu
- extension for the selected widget. This factory will then make an
- instance of the extension.
-
- There are four available types of extensions in \QD:
- QDesignerContainerExtension, QDesignerMemberSheetExtension,
- QDesignerPropertySheetExtension, and QDesignerTaskMenuExtension.
- \QD's behavior is the same whether the requested extension is
- associated with a container, a member sheet, a property sheet or a
- task menu.
-
- The QExtensionFactory class provides a standard extension factory,
- and can also be used as an interface for custom extension
- factories. You can either create a new QExtensionFactory and
- reimplement the QExtensionFactory::createExtension() function. For
- example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 10
-
- Or you can use an existing factory, expanding the
- QExtensionFactory::createExtension() function to make the factory
- able to create a task menu extension as well. For example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 11
-
- For a complete example using the QDesignerTaskMenuExtension class,
- see the \l {designer/taskmenuextension}{Task Menu Extension
- example}. The example shows how to create a custom widget plugin
- for \QD, and how to to use the QDesignerTaskMenuExtension
- class to add custom items to \QD's task menu.
-
- \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
- Extensions}
-*/
-
-/*!
- \fn QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension()
-
- Destroys the task menu extension.
-*/
-
-/*!
- \fn QAction *QDesignerTaskMenuExtension::preferredEditAction() const
-
- Returns the action that is invoked when selecting a plugin with
- the specified extension and pressing \key F2.
-
- The action must be one of the actions returned by taskActions().
-*/
-
-/*!
- \fn QList<QAction*> QDesignerTaskMenuExtension::taskActions() const
-
- Returns the task menu extension as a list of actions which will be
- included in \QD's task menu when a plugin with the specified
- extension is selected.
-
- The function must be reimplemented to add actions to the list.
-*/
-
-
-// Doc: Interface only
-
-/*!
- \class QDesignerCustomWidgetCollectionInterface
-
- \brief The QDesignerCustomWidgetCollectionInterface class allows
- you to include several custom widgets in one single library.
-
- \inmodule QtDesigner
-
- When implementing a custom widget plugin, you build it as a
- separate library. If you want to include several custom widget
- plugins in the same library, you must in addition subclass
- QDesignerCustomWidgetCollectionInterface.
-
- QDesignerCustomWidgetCollectionInterface contains one single
- function returning a list of the collection's
- QDesignerCustomWidgetInterface objects. For example, if you have
- several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and
- \c CustomWidgetThree, the class definition may look like this:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 12
-
- In the class constructor you add the interfaces to your custom
- widgets to the list which you return in the customWidgets()
- function:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 13
-
- Note that instead of exporting each custom widget plugin using the
- Q_EXPORT_PLUGIN2() macro, you export the entire collection. The
- Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct
- the custom widgets. Without this macro, there is no way for \QD to
- use them.
-
- \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for
- Qt Designer}
-*/
-
-/*!
- \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() {
-
- Destroys the custom widget collection interface.
-*/
-
-/*!
- \fn QList<QDesignerCustomWidgetInterface*> QDesignerCustomWidgetCollectionInterface::customWidgets() const
-
- Returns a list of interfaces to the collection's custom widgets.
-*/
-
-
-// Doc: Interface only
-
-/*!
- \class QDesignerCustomWidgetInterface
-
- \brief The QDesignerCustomWidgetInterface class enables Qt Designer
- to access and construct custom widgets.
-
- \inmodule QtDesigner
-
- QDesignerCustomWidgetInterface provides a custom widget with an
- interface. The class contains a set of functions that must be subclassed
- to return basic information about the widget, such as its class name and
- the name of its header file. Other functions must be implemented to
- initialize the plugin when it is loaded, and to construct instances of
- the custom widget for \QD to use.
-
- When implementing a custom widget you must subclass
- QDesignerCustomWidgetInterface to expose your widget to \QD. For
- example, this is the declaration for the plugin used in the
- \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that
- enables an analog clock custom widget to be used by \QD:
-
- \snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0
-
- Note that the only part of the class definition that is specific
- to this particular custom widget is the class name. In addition,
- since we are implementing an interface, we must ensure that it's
- made known to the meta object system using the Q_INTERFACES()
- macro. This enables \QD to use the qobject_cast() function to
- query for supported interfaces using nothing but a QObject
- pointer.
-
- After \QD loads a custom widget plugin, it calls the interface's
- initialize() function to enable it to set up any resources that it
- may need. This function is called with a QDesignerFormEditorInterface
- parameter that provides the plugin with a gateway to all of \QD's API.
-
- \QD constructs instances of the custom widget by calling the plugin's
- createWidget() function with a suitable parent widget. Plugins must
- construct and return an instance of a custom widget with the specified
- parent widget.
-
- In the implementation of the class you must remember to export
- your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2()
- macro. For example, if a library called \c libcustomwidgetplugin.so
- (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget
- class called \c MyCustomWidget, we can export it by adding the
- following line to the file containing the plugin implementation:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 14
-
- This macro ensures that \QD can access and construct the custom widget.
- Without this macro, there is no way for \QD to use it.
-
- When implementing a custom widget plugin, you build it as a
- separate library. If you want to include several custom widget
- plugins in the same library, you must in addition subclass
- QDesignerCustomWidgetCollectionInterface.
-
- \warning If your custom widget plugin contains QVariant
- properties, be aware that only the following \l
- {QVariant::Type}{types} are supported:
-
- \list
- \o QVariant::ByteArray
- \o QVariant::Bool
- \o QVariant::Color
- \o QVariant::Cursor
- \o QVariant::Date
- \o QVariant::DateTime
- \o QVariant::Double
- \o QVariant::Int
- \o QVariant::Point
- \o QVariant::Rect
- \o QVariant::Size
- \o QVariant::SizePolicy
- \o QVariant::String
- \o QVariant::Time
- \o QVariant::UInt
- \endlist
-
- For a complete example using the QDesignerCustomWidgetInterface
- class, see the \l {designer/customwidgetplugin}{Custom Widget
- Example}. The example shows how to create a custom widget plugin
- for \QD.
-
- \sa QDesignerCustomWidgetCollectionInterface {Creating Custom
- Widgets for Qt Designer}
-*/
-
-/*!
- \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface()
-
- Destroys the custom widget interface.
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::name() const
-
- Returns the class name of the custom widget supplied by the interface.
-
- The name returned \e must be identical to the class name used for the
- custom widget.
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::group() const
-
- Returns the name of the group to which the custom widget belongs.
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::toolTip() const
-
- Returns a short description of the widget that can be used by \QD
- in a tool tip.
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::whatsThis() const
-
- Returns a description of the widget that can be used by \QD in
- "What's This?" help for the widget.
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::includeFile() const
-
- Returns the path to the include file that \l uic uses when
- creating code for the custom widget.
-*/
-
-/*!
- \fn QIcon QDesignerCustomWidgetInterface::icon() const
-
- Returns the icon used to represent the custom widget in \QD's
- widget box.
-*/
-
-/*!
- \fn bool QDesignerCustomWidgetInterface::isContainer() const
-
- Returns true if the custom widget is intended to be used as a
- container; otherwise returns false.
-
- Most custom widgets are not used to hold other widgets, so their
- implementations of this function will return false, but custom
- containers will return true to ensure that they behave correctly
- in \QD.
-*/
-
-/*!
- \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent)
-
- Returns a new instance of the custom widget, with the given \a
- parent.
-*/
-
-/*!
- \fn bool QDesignerCustomWidgetInterface::isInitialized() const
-
- Returns true if the widget has been initialized; otherwise returns
- false.
-
- \sa initialize()
-*/
-
-/*!
- \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor)
-
- Initializes the widget for use with the specified \a formEditor
- interface.
-
- \sa isInitialized()
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::domXml() const
-
- Returns the XML that is used to describe the custom widget's
- properties to \QD.
-*/
-
-/*!
- \fn QString QDesignerCustomWidgetInterface::codeTemplate() const
-
- This function is reserved for future use by \QD.
-
- \omit
- Returns the code template that \QD includes in forms that contain
- the custom widget when they are saved.
- \endomit
-*/
-
-/*!
- \macro QDESIGNER_WIDGET_EXPORT
- \relates QDesignerCustomWidgetInterface
- \since 4.1
-
- This macro is used when defining custom widgets to ensure that they are
- correctly exported from plugins for use with \QD.
-
- On some platforms, the symbols required by \QD to create new widgets
- are removed from plugins by the build system, making them unusable.
- Using this macro ensures that the symbols are retained on those platforms,
- and has no side effects on other platforms.
-
- For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin}
- example exports a custom widget class with the following declaration:
-
- \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0
- \dots
- \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2
-
- \sa {Creating Custom Widgets for Qt Designer}
-*/
-
-
-// Doc: Abstract class
-
-/*!
- \class QDesignerDnDItemInterface
- \brief The QDesignerDnDItemInterface class provides an interface that is used to manage items
- during a drag and drop operation.
- \inmodule QtDesigner
- \internal
-*/
-
-/*!
- \enum QDesignerDnDItemInterface::DropType
-
- This enum describes the result of a drag and drop operation.
-
- \value MoveDrop The item was moved.
- \value CopyDrop The item was copied.
-*/
-
-/*!
- \fn QDesignerDnDItemInterface::QDesignerDnDItemInterface()
-
- Constructs a new interface to a drag and drop item.
-*/
-
-/*!
- \fn QDesignerDnDItemInterface::~QDesignerDnDItemInterface()
-
- Destroys the interface to the item.
-*/
-
-/*!
- \fn DomUI *QDesignerDnDItemInterface::domUi() const
-
- Returns a user interface object for the item.
-*/
-
-/*!
- \fn QWidget *QDesignerDnDItemInterface::widget() const
-
- Returns the widget being copied or moved in the drag and drop operation.
-
- \sa source()
-*/
-
-/*!
- \fn QWidget *QDesignerDnDItemInterface::decoration() const
-
- Returns the widget used to represent the item.
-*/
-
-/*!
- \fn QPoint QDesignerDnDItemInterface::hotSpot() const
-
- Returns the cursor's hotspot.
-
- \sa QDrag::hotSpot()
-*/
-
-/*!
- \fn DropType QDesignerDnDItemInterface::type() const
-
- Returns the type of drag and drop operation in progress.
-*/
-
-/*!
- \fn QWidget *QDesignerDnDItemInterface::source() const
-
- Returns the widget that is the source of the drag and drop operation; i.e. the original
- container of the widget being dragged.
-
- \sa widget()
-*/
-
-
-// Doc: Abstract class
-
-/*!
- \class QDesignerIconCacheInterface
- \brief The QDesignerIconCacheInterface class provides an interface to \QD's icon cache.
- \inmodule QtDesigner
- \internal
-*/
-
-/*!
- \fn QDesignerIconCacheInterface::QDesignerIconCacheInterface(QObject *parent)
-
- Constructs a new interface with the given \a parent.
-*/
-
-/*!
- \fn QIcon QDesignerIconCacheInterface::nameToIcon(const QString &filePath, const QString &qrcPath)
-
- Returns the icon associated with the name specified by \a filePath in the resource
- file specified by \a qrcPath.
-
- If \a qrcPath refers to a valid resource file, the name used for the file path is a path
- within those resources; otherwise the file path refers to a local file.
-
- \sa {The Qt Resource System}, nameToPixmap()
-*/
-
-/*!
- \fn QPixmap QDesignerIconCacheInterface::nameToPixmap(const QString &filePath, const QString &qrcPath)
-
- Returns the pixmap associated with the name specified by \a filePath in the resource
- file specified by \a qrcPath.
-
- If \a qrcPath refers to a valid resource file, the name used for the file path is a path
- within those resources; otherwise the file path refers to a local file.
-
- \sa {The Qt Resource System}, nameToIcon()
-*/
-
-/*!
- \fn QString QDesignerIconCacheInterface::iconToFilePath(const QIcon &icon) const
-
- Returns the file path associated with the given \a icon. The file path is a path within
- an application resources.
-*/
-
-/*!
- \fn QString QDesignerIconCacheInterface::iconToQrcPath(const QIcon &icon) const
-
- Returns the path to the resource file that refers to the specified \a icon. The resource
- path refers to a local file.
-*/
-
-/*!
- \fn QString QDesignerIconCacheInterface::pixmapToFilePath(const QPixmap &pixmap) const
-
- Returns the file path associated with the given \a pixmap. The file path is a path within
- an application resources.
-*/
-
-/*!
- \fn QString QDesignerIconCacheInterface::pixmapToQrcPath(const QPixmap &pixmap) const
-
- Returns the path to the resource file that refers to the specified \a pixmap. The resource
- path refers to a local file.
-*/
-
-/*!
- \fn QList<QPixmap> QDesignerIconCacheInterface::pixmapList() const
-
- Returns a list of pixmaps for the icons provided by the icon cache.
-*/
-
-/*!
- \fn QList<QIcon> QDesignerIconCacheInterface::iconList() const
-
- Returns a list of icons provided by the icon cache.
-*/
-
-/*!
- \fn QString QDesignerIconCacheInterface::resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory) const
-
- Returns a path to a resource specified by the \a filePath within
- the resource file located at \a qrcPath. If \a workingDirectory is
- a valid path to a directory, the path returned will be relative to
- that directory; otherwise an absolute path is returned.
-
- \omit
- ### Needs checking
- \endomit
-*/
-
-
-// Doc: Interface only
-
-/*!
- \class QDesignerPropertySheetExtension
-
- \brief The QDesignerPropertySheetExtension class allows you to
- manipulate a widget's properties which is displayed in Qt
- Designer's property editor.
-
- \sa QDesignerDynamicPropertySheetExtension
-
- \inmodule QtDesigner
-
- QDesignerPropertySheetExtension provides a collection of functions that
- are typically used to query a widget's properties, and to
- manipulate the properties' appearance in the property editor. For
- example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15
-
- Note that if you change the value of a property using the
- QDesignerPropertySheetExtension::setProperty() function, the undo
- stack is not updated. To ensure that a property's value can be
- reverted using the undo stack, you must use the
- QDesignerFormWindowCursorInterface::setProperty() function, or its
- buddy \l
- {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
- instead.
-
- When implementing a custom widget plugin, a pointer to \QD's
- current QDesignerFormEditorInterface object (\c formEditor in the
- example above) is provided by the
- QDesignerCustomWidgetInterface::initialize() function's parameter.
-
- The property sheet, or any other extension, can be retrieved by
- querying \QD's extension manager using the qt_extension()
- function. When you want to release the extension, you only need to
- delete the pointer.
-
- All widgets have a default property sheet which populates \QD's
- property editor with the widget's properties (i.e the ones defined
- with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension
- also provides an interface for creating custom property sheet
- extensions.
-
- \warning \QD uses the QDesignerPropertySheetExtension to feed its
- property editor. Whenever a widget is selected in its workspace,
- \QD will query for the widget's property sheet extension. If the
- selected widget has an implemented property sheet extension, this
- extension will override the default property sheet.
-
- To create a property sheet extension, your extension class must
- inherit from both QObject and
- QDesignerPropertySheetExtension. Then, since we are implementing
- an interface, we must ensure that it's made known to the meta
- object system using the Q_INTERFACES() macro:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16
-
- This enables \QD to use qobject_cast() to query for supported
- interfaces using nothing but a QObject pointer.
-
- In \QD the extensions are not created until they are
- required. For that reason, when implementing a property sheet
- extension, you must also create a QExtensionFactory, i.e a class
- that is able to make an instance of your extension, and register
- it using \QD's \l {QExtensionManager}{extension manager}.
-
- When a property sheet extension is required, \QD's \l
- {QExtensionManager}{extension manager} will run through all its
- registered factories calling QExtensionFactory::createExtension()
- for each until the first one that is able to create a property
- sheet extension for the selected widget, is found. This factory
- will then make an instance of the extension. If no such factory
- can be found, \QD will use the default property sheet.
-
- There are four available types of extensions in \QD:
- QDesignerContainerExtension, QDesignerMemberSheetExtension,
- QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
- Designer's behavior is the same whether the requested extension is
- associated with a multi page container, a member sheet, a property
- sheet or a task menu.
-
- The QExtensionFactory class provides a standard extension factory,
- and can also be used as an interface for custom extension
- factories. You can either create a new QExtensionFactory and
- reimplement the QExtensionFactory::createExtension() function. For
- example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 17
-
- Or you can use an existing factory, expanding the
- QExtensionFactory::createExtension() function to make the factory
- able to create a property sheet extension extension as well. For
- example:
-
- \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18
-
- For a complete example using an extension class, see the \l
- {designer/taskmenuextension}{Task Menu Extension example}. The
- example shows how to create a custom widget plugin for Qt
- Designer, and how to to use the QDesignerTaskMenuExtension class
- to add custom items to \QD's task menu.
-
- \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
- Extensions}
-*/
-
-/*!
- \fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension()
-
- Destroys the property sheet extension.
-*/
-
-/*!
- \fn int QDesignerPropertySheetExtension::count() const
-
- Returns the selected widget's number of properties.
-*/
-
-/*!
- \fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const
-
- Returns the index for a given property \a name.
-
- \sa propertyName()
-*/
-
-/*!
- \fn QString QDesignerPropertySheetExtension::propertyName(int index) const
-
- Returns the name of the property at the given \a index.
-
- \sa indexOf()
-*/
-
-/*!
- \fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const
-
- Returns the property group for the property at the given \a index.
-
- \QD's property editor supports property groups, i.e. sections of
- related properties. A property can be related to a group using the
- setPropertyGroup() function. The default group of any property is
- the name of the class that defines it. For example, the
- QObject::objectName property appears within the QObject property
- group.
-
- \sa indexOf(), setPropertyGroup()
-*/
-
-/*!
- \fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group)
-
- Sets the property group for the property at the given \a index to
- \a group.
-
- Relating a property to a group makes it appear within that group's
- section in the property editor. The default property group of any
- property is the name of the class that defines it. For example,
- the QObject::objectName property appears within the QObject
- property group.
-
- \sa indexOf(), property(), propertyGroup()
-*/
-
-/*!
- \fn bool QDesignerPropertySheetExtension::hasReset(int index) const
-
- Returns true if the property at the given \a index has a reset
- button in \QD's property editor, otherwise false.
-
- \sa indexOf(), reset()
-*/
-
-/*!
- \fn bool QDesignerPropertySheetExtension::reset(int index)
-
- Resets the value of the property at the given \a index, to the
- default value. Returns true if a default value could be found, otherwise false.
-
- \sa indexOf(), hasReset(), isChanged()
-*/
-
-/*!
- \fn bool QDesignerPropertySheetExtension::isVisible(int index) const
-
- Returns true if the property at the given \a index is visible in
- \QD's property editor, otherwise false.
-
- \sa indexOf(), setVisible()
-*/
-
-/*!
- \fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible)
-
- If \a visible is true, the property at the given \a index is
- visible in \QD's property editor; otherwise the property is
- hidden.
-
- \sa indexOf(), isVisible()
-*/
-
-/*!
- \fn bool QDesignerPropertySheetExtension::isAttribute(int index) const
-
- Returns true if the property at the given \a index is an attribute,
- which will be \e excluded from the UI file, otherwise false.
-
- \sa indexOf(), setAttribute()
-*/
-
-/*!
- \fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute)
-
- If \a attribute is true, the property at the given \a index is
- made an attribute which will be \e excluded from the UI file;
- otherwise it will be included.
-
- \sa indexOf(), isAttribute()
-*/
-
-/*!
- \fn QVariant QDesignerPropertySheetExtension::property(int index) const
-
- Returns the value of the property at the given \a index.
-
- \sa indexOf(), setProperty(), propertyGroup()
-*/
-
-/*!
- \fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value)
-
- Sets the \a value of the property at the given \a index.
-
- \warning If you change the value of a property using this
- function, the undo stack is not updated. To ensure that a
- property's value can be reverted using the undo stack, you must
- use the QDesignerFormWindowCursorInterface::setProperty()
- function, or its buddy \l
- {QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
- instead.
-
- \sa indexOf(), property(), propertyGroup()
-*/
-
-/*!
- \fn bool QDesignerPropertySheetExtension::isChanged(int index) const
-
- Returns true if the value of the property at the given \a index
- differs from the property's default value, otherwise false.
-
- \sa indexOf(), setChanged(), reset()
-*/
-
-/*!
- \fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed)
-
- Sets whether the property at the given \a index is different from
- its default value, or not, depending on the \a changed parameter.
-
- \sa indexOf(), isChanged()
-*/
-
-// Doc: Interface only
-
-/*!
- \class QDesignerDynamicPropertySheetExtension
-
- \brief The QDesignerDynamicPropertySheetExtension class allows you to
- manipulate a widget's dynamic properties in Qt Designer's property editor.
-
- \sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties}
-
- \inmodule QtDesigner
- \since 4.3
-*/
-
-/*!
- \fn QDesignerDynamicPropertySheetExtension::~QDesignerDynamicPropertySheetExtension()
-
- Destroys the dynamic property sheet extension.
-*/
-
-/*!
- \fn bool QDesignerDynamicPropertySheetExtension::dynamicPropertiesAllowed() const
-
- Returns true if the widget supports dynamic properties; otherwise returns false.
-*/
-
-/*!
- \fn int QDesignerDynamicPropertySheetExtension::addDynamicProperty(const QString &propertyName, const QVariant &value)
-
- Adds a dynamic property named \a propertyName and sets its value to \a value.
- Returns the index of the property if it was added successfully; otherwise returns -1 to
- indicate failure.
-*/
-
-/*!
- \fn bool QDesignerDynamicPropertySheetExtension::removeDynamicProperty(int index)
-
- Removes the dynamic property at the given \a index.
- Returns true if the operation succeeds; otherwise returns false.
-*/
-
-/*!
- \fn bool QDesignerDynamicPropertySheetExtension::isDynamicProperty(int index) const
-
- Returns true if the property at the given \a index is a dynamic property; otherwise
- returns false.
-*/
-
-/*!
- \fn bool QDesignerDynamicPropertySheetExtension::canAddDynamicProperty(const QString &propertyName) const
-
- Returns true if \a propertyName is a valid, unique name for a dynamic
- property; otherwise returns false.
-
-*/
diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp
index 81a0b8a..2044a16 100644
--- a/examples/script/customclass/bytearrayclass.cpp
+++ b/examples/script/customclass/bytearrayclass.cpp
@@ -100,7 +100,7 @@ ByteArrayClass::ByteArrayClass(QScriptEngine *engine)
QScriptValue global = engine->globalObject();
proto.setPrototype(global.property("Object").property("prototype"));
- ctor = engine->newFunction(construct);
+ ctor = engine->newFunction(construct, proto);
ctor.setData(qScriptValueFromValue(engine, this));
}
//! [0]
@@ -224,7 +224,10 @@ QScriptValue ByteArrayClass::construct(QScriptContext *ctx, QScriptEngine *)
ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctx->callee().data());
if (!cls)
return QScriptValue();
- int size = ctx->argument(0).toInt32();
+ QScriptValue arg = ctx->argument(0);
+ if (arg.instanceOf(ctx->callee()))
+ return cls->newInstance(qscriptvalue_cast<QByteArray>(arg));
+ int size = arg.toInt32();
return cls->newInstance(size);
}
//! [2]
@@ -240,7 +243,7 @@ QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray
void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba)
{
- ba = qscriptvalue_cast<QByteArray>(obj.data());
+ ba = qvariant_cast<QByteArray>(obj.data().toVariant());
}
diff --git a/examples/script/customclass/main.cpp b/examples/script/customclass/main.cpp
index 05aefd5..3b98f5c 100644
--- a/examples/script/customclass/main.cpp
+++ b/examples/script/customclass/main.cpp
@@ -52,6 +52,7 @@ int main(int argc, char **argv)
eng.globalObject().setProperty("ByteArray", baClass->constructor());
qDebug() << "ba = new ByteArray(4):" << eng.evaluate("ba = new ByteArray(4)").toString();
+ qDebug() << "ba instanceof ByteArray:" << eng.evaluate("ba instanceof ByteArray").toBool();
qDebug() << "ba.length:" << eng.evaluate("ba.length").toNumber();
qDebug() << "ba[1] = 123; ba[1]:" << eng.evaluate("ba[1] = 123; ba[1]").toNumber();
qDebug() << "ba[7] = 224; ba.length:" << eng.evaluate("ba[7] = 224; ba.length").toNumber();
@@ -65,6 +66,9 @@ int main(int argc, char **argv)
qDebug() << "ba.toBase64().toLatin1String():" << eng.evaluate("b64.toLatin1String()").toString();
qDebug() << "ba.valueOf():" << eng.evaluate("ba.valueOf()").toString();
qDebug() << "ba.chop(2); ba.length:" << eng.evaluate("ba.chop(2); ba.length").toNumber();
+ qDebug() << "ba2 = new ByteArray(ba):" << eng.evaluate("ba2 = new ByteArray(ba)").toString();
+ qDebug() << "ba2.equals(ba):" << eng.evaluate("ba2.equals(ba)").toBool();
+ qDebug() << "ba2.equals(new ByteArray()):" << eng.evaluate("ba2.equals(new ByteArray())").toBool();
return 0;
}
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp
index e5eb308..1c1c72a 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistory.cpp
@@ -32,7 +32,6 @@
/*!
\class QWebHistoryItem
- \ingroup explicitly-shared
\since 4.4
\brief The QWebHistoryItem class represents one item in the history of a QWebPage
@@ -52,13 +51,17 @@
\row \o userData() \o The user specific data that was stored with the history item.
\endtable
- \note QWebHistoryItem objects are value based and \l{explicitly shared}.
+ \note QWebHistoryItem objects are value based, but \e{explicitly shared}. Changing
+ a QWebHistoryItem instance by calling setUserData() will change all copies of that
+ instance.
\sa QWebHistory, QWebPage::history(), QWebHistoryInterface
*/
/*!
- Constructs a history item from \a other.
+ Constructs a history item from \a other. The new item and \a other
+ will share their data, and modifying either this item or \a other will
+ modify both instances.
*/
QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other)
: d(other.d)
@@ -66,7 +69,9 @@ QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other)
}
/*!
- Assigns the \a other history item to this.
+ Assigns the \a other history item to this. This item and \a other
+ will share their data, and modifying either this item or \a other will
+ modify both instances.
*/
QWebHistoryItem &QWebHistoryItem::operator=(const QWebHistoryItem &other)
{
@@ -163,6 +168,8 @@ QVariant QWebHistoryItem::userData() const
\since 4.5
Stores user specific data \a userData with the history item.
+
+ \note All copies of this item will be modified.
\sa userData()
*/
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp
index 3cd37a7..6cd220c 100644
--- a/src/corelib/tools/qshareddata.cpp
+++ b/src/corelib/tools/qshareddata.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QSharedData is designed to be used with QSharedDataPointer or
QExplicitlySharedDataPointer to implement custom \l{implicitly
- shared} or \l {explicitly shared} classes. QSharedData provides
+ shared} or explicitly shared classes. QSharedData provides
\l{thread-safe} reference counting.
See QSharedDataPointer and QExplicitlySharedDataPointer for details.
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
index 76b6687..ad2fb4c 100644
--- a/src/gui/accessible/accessible.pri
+++ b/src/gui/accessible/accessible.pri
@@ -14,7 +14,8 @@ contains(QT_CONFIG, accessibility) {
mac:!embedded {
HEADERS += accessible/qaccessible_mac_p.h
- OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm
+ OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \
+ accessible/qaccessible_mac_cocoa.mm
} else:win32 {
SOURCES += accessible/qaccessible_win.cpp
} else {
diff --git a/src/gui/accessible/qaccessible_mac_cocoa.mm b/src/gui/accessible/qaccessible_mac_cocoa.mm
index e69de29..1cb2ffa 100644
--- a/src/gui/accessible/qaccessible_mac_cocoa.mm
+++ b/src/gui/accessible/qaccessible_mac_cocoa.mm
@@ -0,0 +1,234 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessible.h"
+#include "qaccessible_mac_p.h"
+#include "qdebug.h"
+#include "qtabwidget.h"
+
+#include <private/qt_mac_p.h>
+#include <private/qcocoaview_mac_p.h>
+#include <private/qwidget_p.h>
+
+
+#ifndef QT_NO_ACCESSIBILITY
+
+#ifdef QT_MAC_USE_COCOA
+
+QT_BEGIN_NAMESPACE
+
+//#define MAC_ACCESSIBILTY_DEVELOPER_MODE
+
+#ifdef MAC_ACCESSIBILTY_DEVELOPER_MODE
+#define MAC_ACCESSIBILTY_DEBUG qDebug
+#else
+#define MAC_ACCESSIBILTY_DEBUG if (0) qDebug
+#endif
+
+typedef QMap<QAccessible::Role, NSString *> QMacAccessibiltyRoleMap;
+Q_GLOBAL_STATIC(QMacAccessibiltyRoleMap, qMacAccessibiltyRoleMap);
+
+static QAInterface interfaceForView(QT_MANGLE_NAMESPACE(QCocoaView) *view)
+{
+ return QAInterface(QAccessible::queryAccessibleInterface([view qt_qwidget]));
+}
+
+/*
+ Set up mappings from Qt accessibilty roles to Mac accessibilty roles.
+*/
+static void populateRoleMap()
+{
+ QMacAccessibiltyRoleMap &roleMap = *qMacAccessibiltyRoleMap();
+ roleMap[QAccessible::MenuItem] = NSAccessibilityMenuItemRole;
+ roleMap[QAccessible::MenuBar] = NSAccessibilityMenuBarRole;
+ roleMap[QAccessible::ScrollBar] = NSAccessibilityScrollBarRole;
+ roleMap[QAccessible::Grip] = NSAccessibilityGrowAreaRole;
+ roleMap[QAccessible::Window] = NSAccessibilityWindowRole;
+ roleMap[QAccessible::Dialog] = NSAccessibilityWindowRole;
+ roleMap[QAccessible::AlertMessage] = NSAccessibilityWindowRole;
+ roleMap[QAccessible::ToolTip] = NSAccessibilityWindowRole;
+ roleMap[QAccessible::HelpBalloon] = NSAccessibilityWindowRole;
+ roleMap[QAccessible::PopupMenu] = NSAccessibilityMenuRole;
+ roleMap[QAccessible::Application] = NSAccessibilityApplicationRole;
+ roleMap[QAccessible::Pane] = NSAccessibilityGroupRole;
+ roleMap[QAccessible::Grouping] = NSAccessibilityGroupRole;
+ roleMap[QAccessible::Separator] = NSAccessibilitySplitterRole;
+ roleMap[QAccessible::ToolBar] = NSAccessibilityToolbarRole;
+ roleMap[QAccessible::PageTab] = NSAccessibilityRadioButtonRole;
+ roleMap[QAccessible::ButtonMenu] = NSAccessibilityMenuButtonRole;
+ roleMap[QAccessible::ButtonDropDown] = NSAccessibilityPopUpButtonRole;
+ roleMap[QAccessible::SpinBox] = NSAccessibilityIncrementorRole;
+ roleMap[QAccessible::Slider] = NSAccessibilitySliderRole;
+ roleMap[QAccessible::ProgressBar] = NSAccessibilityProgressIndicatorRole;
+ roleMap[QAccessible::ComboBox] = NSAccessibilityPopUpButtonRole;
+ roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole;
+ roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole;
+ roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole;
+ roleMap[QAccessible::Table] = NSAccessibilityTableRole;
+ roleMap[QAccessible::StatusBar] = NSAccessibilityStaticTextRole;
+ roleMap[QAccessible::Column] = NSAccessibilityColumnRole;
+ roleMap[QAccessible::ColumnHeader] = NSAccessibilityColumnRole;
+ roleMap[QAccessible::Row] = NSAccessibilityRowRole;
+ roleMap[QAccessible::RowHeader] = NSAccessibilityRowRole;
+ roleMap[QAccessible::Cell] = NSAccessibilityTextFieldRole;
+ roleMap[QAccessible::PushButton] = NSAccessibilityButtonRole;
+ roleMap[QAccessible::EditableText] = NSAccessibilityTextFieldRole;
+ roleMap[QAccessible::Link] = NSAccessibilityTextFieldRole;
+ roleMap[QAccessible::Indicator] = NSAccessibilityValueIndicatorRole;
+ roleMap[QAccessible::Splitter] = NSAccessibilitySplitGroupRole;
+ roleMap[QAccessible::List] = NSAccessibilityListRole;
+ roleMap[QAccessible::ListItem] = NSAccessibilityStaticTextRole;
+ roleMap[QAccessible::Cell] = NSAccessibilityStaticTextRole;
+}
+
+/*
+ Returns a Mac accessibility role for the given interface, or
+ NSAccessibilityUnknownRole if no role mapping is found.
+*/
+static NSString *macRoleForInterface(QAInterface interface)
+{
+ const QAccessible::Role qtRole = interface.role();
+ QMacAccessibiltyRoleMap &roleMap = *qMacAccessibiltyRoleMap();
+
+ if (roleMap.isEmpty())
+ populateRoleMap();
+
+ MAC_ACCESSIBILTY_DEBUG() << "role for" << interface.object() << "interface role" << hex << qtRole;
+
+ if (roleMap.contains(qtRole)) {
+ MAC_ACCESSIBILTY_DEBUG() << "return" << roleMap[qtRole];
+ return roleMap[qtRole];
+ }
+
+ MAC_ACCESSIBILTY_DEBUG() << "return NSAccessibilityUnknownRole";
+ return NSAccessibilityUnknownRole;
+}
+
+/*
+ Is the interface a QTabBar embedded in a QTabWidget?
+ (as opposed to a stand-alone tab bar)
+*/
+static bool isEmbeddedTabBar(const QAInterface &interface)
+{
+ QObject *object = interface.object();
+ if (interface.role() == QAccessible::PageTabList && object)
+ return (qobject_cast<QTabWidget *>(object->parent()));
+
+ return false;
+}
+
+static bool isInterfaceIgnored(QAInterface interface)
+{
+ // Mac accessibility does not have an attribute that corresponds to the
+ // Invisible/Offscreen state. Use the ignore facility to disable them.
+ const QAccessible::State state = interface.state();
+ if (state & QAccessible::Invisible ||
+ state & QAccessible::Offscreen )
+ return false;
+
+ // Hide QTabBars that has a QTabWidget parent (the QTabWidget handles the accessibility)
+ if (isEmbeddedTabBar(interface))
+ return false;
+
+ if (QObject * const object = interface.object()) {
+ const QString className = QLatin1String(object->metaObject()->className());
+
+ // Prevent VoiceOver from focusing on tool tips by ignoring those
+ // interfaces. Shifting VoiceOver focus to the tool tip is confusing
+ // and the contents of the tool tip is avalible through the description
+ // attribute anyway.
+ if (className == QLatin1String("QTipLabel"))
+ return false;
+ }
+
+ // Hide interfaces with an unknown role. When developing it's often useful to disable
+ // this check to see all interfaces in the hierarchy.
+#ifndef MAC_ACCESSIBILTY_DEVELOPER_MODE
+ return [macRoleForInterface(interface) isEqualToString: NSAccessibilityUnknownRole];
+#else
+ return NO;
+#endif
+}
+
+QT_END_NAMESPACE
+
+@implementation QT_MANGLE_NAMESPACE(QCocoaView) (Accessibility)
+
+- (BOOL)accessibilityIsIgnored
+{
+ QAInterface interface = interfaceForView(self);
+ return isInterfaceIgnored(interface);
+}
+
+- (NSArray *)accessibilityAttributeNames
+{
+ QAInterface interface = interfaceForView(self);
+
+ static NSArray *attributes = nil;
+ if (attributes == nil) {
+ attributes = [super accessibilityAttributeNames];
+
+ }
+ return attributes;
+}
+
+- (id)accessibilityAttributeValue:(NSString *)attribute
+{
+ MAC_ACCESSIBILTY_DEBUG() << "accessibilityAttributeValue" << self << QCFString::toQString(reinterpret_cast<CFStringRef>(attribute));
+
+ QAInterface interface = interfaceForView(self);
+
+ // Switch on the attribute name and call the appropriate handler function.
+ // Pass the call on to the NSView class for attributes we don't handle.
+ if ([attribute isEqualToString:@"AXRole"]) {
+ return macRoleForInterface(interface);
+ } else {
+ return [super accessibilityAttributeValue:attribute];
+ }
+}
+
+@end
+
+#endif // QT_MAC_USE_COCOA
+
+#endif // QT_NO_ACCESSIBILITY
+
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index 89d9d1b..ebdac9a 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -400,4 +400,15 @@ void QEglContext::dumpAllConfigs()
delete [] configs;
}
+QString QEglContext::extensions()
+{
+ const char* exts = eglQueryString(dpy, EGL_EXTENSIONS);
+ return QString(QLatin1String(exts));
+}
+
+bool QEglContext::hasExtension(const char* extensionName)
+{
+ return extensions().contains(QLatin1String(extensionName));
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h
index ddf7d27..3ae1489 100644
--- a/src/gui/egl/qegl_p.h
+++ b/src/gui/egl/qegl_p.h
@@ -122,6 +122,9 @@ public:
void dumpAllConfigs();
+ QString extensions();
+ bool hasExtension(const char* extensionName);
+
private:
QEgl::API apiType;
EGLDisplay dpy;
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 3884af9..eaf9896 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -135,38 +135,39 @@
\section1 Transformation
- QGraphicsItem supports affine transformations in addition to its base
- position, pos(). To change the item's transformation, you can pass
- a transformation matrix to setTransform()
-
- Item transformations accumulate from parent to child, so if both a
- parent and child item are rotated 90 degrees, the child's total
- transformation will be 180 degrees. Similarly, if the item's
- parent is scaled to 2x its original size, its children will also
- be twice as large. An item's transformation does not affect its
- own local geometry; all geometry functions (e.g., contains(),
- update(), and all the mapping functions) still operate in local
- coordinates. For convenience, QGraphicsItem provides the functions
- sceneTransform(), which returns the item's total transformation
+ QGraphicsItem supports projective transformations in addition to its base
+ position, pos(). There are several ways to change an item's transformation.
+ For simple transformations, you can call either of the convenience
+ functions setRotation() or setScale(), or you can pass any transformation
+ matrix to setTransform(). For advanced transformation control you also have
+ the option of setting several combined transformations by calling
+ setTransformations().
+
+ Item transformations accumulate from parent to child, so if both a parent
+ and child item are rotated 90 degrees, the child's total transformation
+ will be 180 degrees. Similarly, if the item's parent is scaled to 2x its
+ original size, its children will also be twice as large. An item's
+ transformation does not affect its own local geometry; all geometry
+ functions (e.g., contains(), update(), and all the mapping functions) still
+ operate in local coordinates. For convenience, QGraphicsItem provides the
+ functions sceneTransform(), which returns the item's total transformation
matrix (including its position and all parents' positions and
- transformations), and scenePos(), which returns its position in
- scene coordinates. To reset an item's matrix, call
- resetTransform().
+ transformations), and scenePos(), which returns its position in scene
+ coordinates. To reset an item's matrix, call resetTransform().
- Another way to apply transformation to an item is to use the , or
- set the different transformation properties (transformOrigin,
- x/y/zRotation, x/yScale, horizontal/verticalShear). Those
- properties come in addition to the base transformation
+ Certain transformation operations produce a different outcome depending on
+ the order in which they are applied. For example, if you scale an
+ transform, and then rotate it, you may get a different result than if the
+ transform was rotated first. However, the order you set the transformation
+ properties on QGraphicsItem does not affect the resulting transformation;
+ QGraphicsItem always applies the properties in a fixed, defined order:
- The order you set the transformation properties does not affect
- the resulting transformation The resulting transformation is
- always computed in the following order
-
- \code
- [Origin] [Base] [RotateX] [RotateY] [RotateZ] [Shear] [Scale] [-Origin]
- \endcode
-
- Where [Base] is the stransformation set by setTransform
+ \list
+ \o The item's base transform is applied (transform())
+ \o The item's transformations list is applied in order (transformations())
+ \o The item is rotated relative to its transform origin point (rotation(), transformOriginPoint())
+ \o The item is scaled relative to its transform origin point (scale(), transformOriginPoint())
+ \endlist
\section1 Painting
@@ -2969,11 +2970,10 @@ QMatrix QGraphicsItem::matrix() const
Returns this item's transformation matrix.
- Either the one set by setTransform, or the resulting transformation from
- all the transfmation properties
-
- If no matrix or transformation property has been set, the
- identity matrix is returned.
+ The transformation matrix is combined with the item's rotation(), scale()
+ and transformations() into a combined transformations for the item.
+
+ The default transformation matrix is an identity matrix.
\sa setTransform(), sceneTransform()
*/
@@ -2987,13 +2987,13 @@ QTransform QGraphicsItem::transform() const
/*!
\since 4.6
- Returns the rotation around the Z axis.
-
- The default is 0
+ Returns the clockwise rotation, in degrees, around the Z axis. The default
+ value is 0 (i.e., the item is not rotated).
- \warning The value doesn't take in account any rotation set with the setTransform() method.
+ The rotation is combined with the item's scale(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
- \sa setRotation(), {Transformations}
+ \sa setRotation(), transformOriginPoint(), {Transformations}
*/
qreal QGraphicsItem::rotation() const
{
@@ -3005,9 +3005,19 @@ qreal QGraphicsItem::rotation() const
/*!
\since 4.6
- Sets the rotation around the Z axis to \a angle degrees.
+ Sets the clockwise rotation \a angle, in degrees, around the Z axis. The
+ default value is 0 (i.e., the item is not rotated). Assigning a negative
+ value will rotate the item counter-clockwise. Normally the rotation angle
+ is in the range (-360, 360), but it's also possible to assign values
+ outside of this range (e.g., a rotation of 370 degrees is the same as a
+ rotation of 10 degrees).
+
+ The item is rotated around its transform origin point, which by default
+ is (0, 0). You can select a different transformation origin by calling
+ setTransformOriginPoint().
- \warning The value doesn't take in account any rotation set with the setTransform() method.
+ The rotation is combined with the item's scale(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
\sa rotation(), setTransformOriginPoint(), {Transformations}
*/
@@ -3027,13 +3037,13 @@ void QGraphicsItem::setRotation(qreal angle)
/*!
\since 4.6
- Returns the scale factor of the item.
+ Returns the scale factor of the item. The default scale factor is 1.0
+ (i.e., the item is not scaled).
- The default is 1
+ The scale is combined with the item's rotation(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
- \warning The value doesn't take in account any scaling set with the setTransform() method.
-
- \sa setScale(), {Transformations}
+ \sa setScale(), rotation(), {Transformations}
*/
qreal QGraphicsItem::scale() const
{
@@ -3045,9 +3055,17 @@ qreal QGraphicsItem::scale() const
/*!
\since 4.6
- Sets the scale factor of the item to \a factor.
+ Sets the scale \a factor of the item. The default scale factor is 1.0
+ (i.e., the item is not scaled). A scale factor of 0.0 will collapse the
+ item to a single point. If you provide a negative scale factor, the
+ item will be flipped and mirrored (i.e., rotated 180 degrees).
+
+ The item is scaled around its transform origin point, which by default
+ is (0, 0). You can select a different transformation origin by calling
+ setTransformOriginPoint().
- \warning The value doesn't take in account any scaling set with the setTransform() method.
+ The scale is combined with the item's rotation(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
\sa scale(), setTransformOriginPoint(), {Transformations}
*/
@@ -3068,9 +3086,17 @@ void QGraphicsItem::setScale(qreal factor)
/*!
\since 4.6
- returns list of graphics transformations on the item.
+ Returns a list of graphics transforms that currently apply to this item.
- \sa scale(), setTransformOriginPoint(), {Transformations}
+ QGraphicsTransform is for applying and controlling a chain of individual
+ transformation operations on an item. It's particularily useful in
+ animations, where each transform operation needs to be interpolated
+ independently, or differently.
+
+ The transformations are combined with the item's rotation(), scale() and
+ transform() to map the item's coordinate system to the parent item.
+
+ \sa scale(), rotation(), transformOriginPoint(), {Transformations}
*/
QList<QGraphicsTransform *> QGraphicsItem::transformations() const
{
@@ -3082,7 +3108,20 @@ QList<QGraphicsTransform *> QGraphicsItem::transformations() const
/*!
\since 4.6
- Sets a list of graphics transformations on the item to \a transformations.
+ Sets a list of graphics \a transformations (QGraphicsTransform) that
+ currently apply to this item.
+
+ If all you want is to rotate or scale an item, you should call setRotation()
+ or setScale() instead. If you want to set an arbitrary transformation on
+ an item, you can call setTransform().
+
+ QGraphicsTransform is for applying and controlling a chain of individual
+ transformation operations on an item. It's particularily useful in
+ animations, where each transform operation needs to be interpolated
+ independently, or differently.
+
+ The transformations are combined with the item's rotation(), scale() and
+ transform() to map the item's coordinate system to the parent item.
\sa scale(), setTransformOriginPoint(), {Transformations}
*/
@@ -3098,7 +3137,9 @@ void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transf
d_ptr->dirtySceneTransform = 1;
}
-
+/*!
+ \internal
+*/
void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t)
{
if (!transformData)
@@ -3432,7 +3473,9 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
to map an item coordiate to a scene coordinate, or mapFromScene() to map
from scene coordinates to item coordinates.
- \warning using this function doesnt affect the value of the transformation properties
+ The transformation matrix is combined with the item's rotation(), scale()
+ and transformations() into a combined transformation that maps the item's
+ coordinate system to its parent.
\sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations}
*/
@@ -3491,7 +3534,8 @@ void QGraphicsItem::resetTransform()
/*!
\obsolete
- Use setZRotation() instead
+
+ Use setRotation() instead
Rotates the current item transformation \a angle degrees clockwise around
its origin. To translate around an arbitrary point (x, y), you need to
@@ -3501,8 +3545,6 @@ void QGraphicsItem::resetTransform()
\snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 6
- \warning using this functionhas no effect on the zRotation value
-
\sa setTransform(), transform(), scale(), shear(), translate()
*/
void QGraphicsItem::rotate(qreal angle)
@@ -3512,6 +3554,7 @@ void QGraphicsItem::rotate(qreal angle)
/*!
\obsolete
+
Use setScale() instead
Scales the current item transformation by (\a sx, \a sy) around its
@@ -3522,8 +3565,6 @@ void QGraphicsItem::rotate(qreal angle)
\snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 7
- \warning using this function has no effect on the xScale or yScale value
-
\sa setTransform(), transform()
*/
void QGraphicsItem::scale(qreal sx, qreal sy)
@@ -3533,11 +3574,10 @@ void QGraphicsItem::scale(qreal sx, qreal sy)
/*!
\obsolete
- Use setShear instead.
- Shears the current item transformation by (\a sh, \a sv).
+ Use setTransform() instead.
- \warning using this function has no effect on the horizontalShear or verticalShear value
+ Shears the current item transformation by (\a sh, \a sv).
\sa setTransform(), transform()
*/
@@ -3548,6 +3588,7 @@ void QGraphicsItem::shear(qreal sh, qreal sv)
/*!
\obsolete
+
Use setPos() or setTransformOriginPoint() instead.
Translates the current item transformation by (\a dx, \a dy).
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index b8d98c1..5c3622b 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -468,7 +468,8 @@ public:
QGraphicsItem *q_ptr;
};
-struct QGraphicsItemPrivate::TransformData {
+struct QGraphicsItemPrivate::TransformData
+{
QTransform transform;
qreal scale;
qreal rotation;
@@ -481,7 +482,7 @@ struct QGraphicsItemPrivate::TransformData {
scale(1.0), rotation(0.0),
xOrigin(0.0), yOrigin(0.0),
onlyTransform(true)
- {}
+ { }
QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const
{
diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
index 3cb33d1..07d23b7 100644
--- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
+++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
@@ -525,7 +525,7 @@ QGraphicsSceneBspTreeIndex::~QGraphicsSceneBspTreeIndex()
}
/*!
- \reimp
+ \internal
Clear the all the BSP index.
*/
void QGraphicsSceneBspTreeIndex::clear()
@@ -566,7 +566,7 @@ void QGraphicsSceneBspTreeIndex::removeItem(QGraphicsItem *item)
}
/*!
- \reimp
+ \internal
Update the BSP when the \a item 's bounding rect has changed.
*/
void QGraphicsSceneBspTreeIndex::prepareBoundingRectChange(const QGraphicsItem *item)
@@ -682,7 +682,7 @@ void QGraphicsSceneBspTreeIndex::setBspTreeDepth(int depth)
}
/*!
- \reimp
+ \internal
This method react to the \a rect change of the scene and
reset the BSP tree index.
@@ -695,11 +695,10 @@ void QGraphicsSceneBspTreeIndex::updateSceneRect(const QRectF &rect)
}
/*!
- \reimp
+ \internal
This method react to the \a change of the \a item and use the \a value to
update the BSP tree if necessary.
-
*/
void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp
index b55d78e..890aff7 100644
--- a/src/gui/graphicsview/qgraphicstransform.cpp
+++ b/src/gui/graphicsview/qgraphicstransform.cpp
@@ -39,6 +39,43 @@
**
****************************************************************************/
+/*!
+ \class QGraphicsTransform
+ \brief The QGraphicsTransform class is an abstract base class for building
+ advanced transformations on QGraphicsItems.
+ \since 4.6
+
+ As an alternative to QGraphicsItem::transform, QGraphicsTransform lets you
+ create and control advanced transformations that can be configured
+ independently using specialized properties.
+
+ QGraphicsItem allows you to assign any number of QGraphicsTransform
+ instances to one QGraphicsItem. Each QGraphicsTransform is applied in
+ order, one at a time, to the QGraphicsItem it's assigned to.
+
+ QGraphicsTransform is particularily useful for animations. Whereas
+ QGraphicsItem::setTransform() lets you assign any transform directly to an
+ item, there is no direct way to interpolate between two different
+ transformations (e.g., when transitioning between two states, each for
+ which the item has a different arbitrary transform assigned). Using
+ QGraphicsTransform you can interpolate the property values of each
+ independent transformation. The resulting operation is then combined into a
+ single transform which is applied to QGraphicsItem.
+
+ If you want to create your own configurable transformation, you can create
+ a subclass of QGraphicsTransform (or any or the existing subclasses), and
+ reimplement the pure virtual applyTo() function, which takes a pointer to a
+ QTransform. Each operation you would like to apply should be exposed as
+ properties (e.g., customTransform->setVerticalShear(2.5)). Inside you
+ reimplementation of applyTo(), you can modify the provided transform
+ respectively.
+
+ QGraphicsTransform can be used together with QGraphicsItem::setTransform(),
+ QGraphicsItem::setRotation(), and QGraphicsItem::setScale().
+
+ \sa QGraphicsItem::transform(), QGraphicsScale, QGraphicsRotation, QGraphicsRotation3D
+*/
+
#include "qgraphicstransform.h"
#include "qgraphicsitem_p.h"
#include "qgraphicstransform_p.h"
@@ -51,7 +88,6 @@
QT_BEGIN_NAMESPACE
-
void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
{
if (item == i)
@@ -77,15 +113,38 @@ void QGraphicsTransformPrivate::updateItem(QGraphicsItem *item)
item->d_ptr->dirtySceneTransform = 1;
}
-void QGraphicsTransform::update()
+/*!
+ Constructs a new QGraphicsTransform with the given \a parent.
+*/
+QGraphicsTransform::QGraphicsTransform(QObject *parent)
+ : QObject(*new QGraphicsTransformPrivate, parent)
+{
+}
+
+/*!
+ Destroys the graphics transform.
+*/
+QGraphicsTransform::~QGraphicsTransform()
{
Q_D(QGraphicsTransform);
- if (d->item)
- d->updateItem(d->item);
+ d->setItem(0);
+}
+
+/*!
+ \internal
+*/
+QGraphicsTransform::QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent)
+ : QObject(p, parent)
+{
}
/*!
- returns this object as a QTransform.
+ Applies this transformation to an identity transform, and returns the
+ resulting transform.
+
+ This is equivalent to passing an identity transform to applyTo().
+
+ \sa applyTo()
*/
QTransform QGraphicsTransform::transform() const
{
@@ -95,76 +154,65 @@ QTransform QGraphicsTransform::transform() const
}
/*!
- \class QGraphicsTransform
- \brief The QGraphicsTransform class is an abstract base class for tranformations on QGraphicsItems.
- \since 4.6
-
- The classes that inherit QGraphicsTransform express different types of transformations
- that can be applied to graphics items.
+ \fn void QGraphicsTransform::applyTo(QTransform *transform) const
- A list of these transformations can be applied to any graphics item. These
- transformations are then easily modifyable and usable from e.g. within animations.
+ This pure virtual method has to be reimplemented in derived classes.
- QGraphicsTransform is an abstract base class that is implemented by QGraphicsScale,
- QGraphicsRotation and QGraphicsRotation3D. Subclasses have to implement the applyTo method.
+ It applies this transformation to \a transform.
- \sa QGraphicsItem::transform(), QGraphicsScale, QGraphicsRotation, QGraphicsRotation3D
+ \sa QGraphicsItem::transform()
*/
/*!
- Constructs a new QGraphicsTransform with \a parent.
-*/
-QGraphicsTransform::QGraphicsTransform(QObject *parent) :
- QObject(*new QGraphicsTransformPrivate, parent)
-{
-}
+ Notifies that this transform operation has changed its parameters in such a
+ way that applyTo() will return a different result than before.
-/*!
- Destructs the graphics transform.
+ When implementing you own custom graphics transform, you must call this
+ function every time you change a parameter, to let QGraphicsItem know that
+ its transformation needs to be updated.
+
+ \sa applyTo()
*/
-QGraphicsTransform::~QGraphicsTransform()
+void QGraphicsTransform::update()
{
Q_D(QGraphicsTransform);
- d->setItem(0);
+ if (d->item)
+ d->updateItem(d->item);
}
/*!
- \internal
-*/
-QGraphicsTransform::QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent)
- : QObject(p, parent)
-{
-}
-
-/*! \fn void QGraphicsTransform::applyTo(QTransform *transform) const
+ \class QGraphicsScale
+ \brief The QGraphicsScale class provides a scale transformation.
+ \since 4.6
- This pure virtual method has to be reimplemented in derived classes.
+ QGraphicsScene provides certain parameters to help control how the scale
+ should be applied.
- It applies this transformation to \a transform.
-*/
+ The origin is the point that the item is scaled from (i.e., it stays fixed
+ relative to the parent as the rest of the item grows). By default the
+ origin is QPointF(0, 0).
+ The two parameters xScale and yScale describe the scale factors to apply in
+ horizontal and vertical direction. They can take on any value, including 0
+ (to collapse the item to a point) or negativate value. A negative xScale
+ value will mirror the item horizontally. A negative yScale value will flip
+ the item vertically.
-/*!
- \class QGraphicsScale
- \brief The QGraphicsScale class provides a way to scale a graphics item in 2 dimensions.
- \since 4.6
-
- QGraphicsScale contains an \a origin around which the scaling happens, and two
- scale factors, xScale and yScale, the x and one for the y axis.
+ \sa QGraphicsTransform, QGraphicsItem::setScale(), QTransform::scale()
*/
class QGraphicsScalePrivate : public QGraphicsTransformPrivate
{
public:
QGraphicsScalePrivate()
- : xScale(1), yScale(1) {}
+ : xScale(1), yScale(1) {}
QPointF origin;
qreal xScale;
qreal yScale;
};
/*!
- Constructs a new graphics scale object with \a parent.
+ Constructs an empty QGraphicsScale object with the given \a parent.
*/
QGraphicsScale::QGraphicsScale(QObject *parent)
: QGraphicsTransform(*new QGraphicsScalePrivate, parent)
@@ -172,24 +220,26 @@ QGraphicsScale::QGraphicsScale(QObject *parent)
}
/*!
- Destroys the object
+ Destroys the graphics scale.
*/
QGraphicsScale::~QGraphicsScale()
{
}
/*!
- \property QGraphicsScale::origin
- The origin of the scale. All scaling will be done relative to this point.
+ \property QGraphicsScale::origin
+ \brief The QGraphicsScene class provides the origin of the scale.
+
+ All scaling will be done relative to this point (i.e., this point
+ will stay fixed, relative to the parent, when the item is scaled).
- The \a origin is in other words the fixed point for the transformation.
+ \sa xScale, yScale
*/
QPointF QGraphicsScale::origin() const
{
Q_D(const QGraphicsScale);
return d->origin;
}
-
void QGraphicsScale::setOrigin(const QPointF &point)
{
Q_D(QGraphicsScale);
@@ -199,26 +249,21 @@ void QGraphicsScale::setOrigin(const QPointF &point)
}
/*!
- \fn QGraphicsScale::originChanged()
-
- This signal is emitted whenever the origin of the object
- changes.
-*/
-
-/*!
- \property QGraphicsScale::xScale
+ \property QGraphicsScale::xScale
+ \brief the horizontal scale factor.
- The scale factor in x direction. The x direction is
- in the graphics items logical coordinates.
+ The scale factor can be any real number; the default value is 1.0. If you
+ set the factor to 0.0, the item will be collapsed to a single point. If you
+ provide a negative value, the item will be mirrored horizontally around its
+ origin.
- \sa yScale
+ \sa yScale, origin
*/
qreal QGraphicsScale::xScale() const
{
Q_D(const QGraphicsScale);
return d->xScale;
}
-
void QGraphicsScale::setXScale(qreal scale)
{
Q_D(QGraphicsScale);
@@ -230,19 +275,21 @@ void QGraphicsScale::setXScale(qreal scale)
}
/*!
- \property QGraphicsScale::yScale
+ \property QGraphicsScale::yScale
+ \brief the vertical scale factor.
- The scale factor in y direction. The y direction is
- in the graphics items logical coordinates.
+ The scale factor can be any real number; the default value is 1.0. If you
+ set the factor to 0.0, the item will be collapsed to a single point. If you
+ provide a negative value, the item will be flipped vertically around its
+ origin.
- \sa xScale
+ \sa xScale, origin
*/
qreal QGraphicsScale::yScale() const
{
Q_D(const QGraphicsScale);
return d->yScale;
}
-
void QGraphicsScale::setYScale(qreal scale)
{
Q_D(QGraphicsScale);
@@ -254,14 +301,7 @@ void QGraphicsScale::setYScale(qreal scale)
}
/*!
- \fn QGraphicsScale::scaleChanged()
-
- This signal is emitted whenever the xScale or yScale of the object
- changes.
-*/
-
-/*!
- \reimp
+ \reimp
*/
void QGraphicsScale::applyTo(QTransform *transform) const
{
@@ -272,12 +312,41 @@ void QGraphicsScale::applyTo(QTransform *transform) const
}
/*!
- \class QGraphicsRotation
- \brief The QGraphicsRotation class provides a way to rotate a graphics item in 2 dimensions.
- \since 4.6
+ \fn QGraphicsScale::originChanged()
+
+ QGraphicsScale emits this signal when its origin changes.
+
+ \sa QGraphicsScale::origin
+*/
+
+/*!
+ \fn QGraphicsScale::scaleChanged()
+
+ This signal is emitted whenever the xScale or yScale of the object
+ changes.
- QGraphicsRotation contains an \a origin around which the rotation happens, and one
- angle in degrees describing the amount of the rotation.
+ \sa QGraphicsScale::xScale, QGraphicsScale::yScale
+*/
+
+/*!
+ \class QGraphicsRotation
+ \brief The QGraphicsRotation class provides a rotation transformation.
+ \since 4.6
+
+ QGraphicsRotation provides certain parameters to help control how the
+ rotation should be applied.
+
+ The origin is the point that the item is rotated around (i.e., it stays
+ fixed relative to the parent as the rest of the item is rotated). By
+ default the origin is QPointF(0, 0).
+
+ The angle property provides the number of degrees to rotate the item
+ clockwise around the origin. This value also be negative, indicating a
+ counter-clockwise rotation. For animation purposes it may also be useful to
+ provide rotation angles exceeding (-360, 360) degrees, for instance to
+ animate how an item rotates several times.
+
+ \sa QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate()
*/
class QGraphicsRotationPrivate : public QGraphicsTransformPrivate
@@ -291,7 +360,7 @@ public:
};
/*!
- Constructs a new graphics rotation with \a parent.
+ Constructs a new QGraphicsRotation with the given \a parent.
*/
QGraphicsRotation::QGraphicsRotation(QObject *parent)
: QGraphicsTransform(*new QGraphicsRotationPrivate, parent)
@@ -299,7 +368,7 @@ QGraphicsRotation::QGraphicsRotation(QObject *parent)
}
/*!
- \internal
+ \internal
*/
QGraphicsRotation::QGraphicsRotation(QGraphicsRotationPrivate &p, QObject *parent)
: QGraphicsTransform(p, parent)
@@ -307,24 +376,26 @@ QGraphicsRotation::QGraphicsRotation(QGraphicsRotationPrivate &p, QObject *paren
}
/*!
- Destructs the object
+ Destroys the graphics rotation.
*/
QGraphicsRotation::~QGraphicsRotation()
{
}
/*!
- \property QGraphicsRotation::origin
- The origin around which this object will rotate the graphics item.
+ \property QGraphicsRotation::origin
+ \brief the origin of the rotation.
- The \a origin is in other words the fixed point for the transformation.
+ All rotations will be done relative to this point (i.e., this point
+ will stay fixed, relative to the parent, when the item is rotated).
+
+ \sa angle
*/
QPointF QGraphicsRotation::origin() const
{
Q_D(const QGraphicsRotation);
return d->origin;
}
-
void QGraphicsRotation::setOrigin(const QPointF &point)
{
Q_D(QGraphicsRotation);
@@ -334,22 +405,22 @@ void QGraphicsRotation::setOrigin(const QPointF &point)
}
/*!
- \fn QGraphicsRotation::originChanged()
+ \property QGraphicsRotation::angle
+ \brief the angle for clockwise rotation, in degrees.
- This signal is emitted whenever the origin of the object
- changes.
-*/
+ The angle can be any real number; the default value is 0.0. A value of 180
+ will rotate 180 degrees, clockwise. If you provide a negative number, the
+ item will be rotated counter-clockwise. Normally the rotation angle will be
+ in the range (-360, 360), but you can also provide numbers outside of this
+ range (e.g., a angle of 370 degrees gives the same result as 10 degrees).
-/*!
- \property QGraphicsRotation::angle
- The angle, in degrees, of the rotation.
+ \sa origin
*/
qreal QGraphicsRotation::angle() const
{
Q_D(const QGraphicsRotation);
return d->angle;
}
-
void QGraphicsRotation::setAngle(qreal angle)
{
Q_D(QGraphicsRotation);
@@ -361,33 +432,50 @@ void QGraphicsRotation::setAngle(qreal angle)
}
/*!
- \fn void QGraphicsRotation::angleChanged()
-
- This signal is emitted whenever the angle of the object
- changes.
-*/
-
-/*!
- \reimp
+ \reimp
*/
void QGraphicsRotation::applyTo(QTransform *t) const
{
Q_D(const QGraphicsRotation);
- if(d->angle) {
+ if (d->angle) {
t->translate(d->origin.x(), d->origin.y());
t->rotate(d->angle);
t->translate(-d->origin.x(), -d->origin.y());
}
}
+/*!
+ \fn QGraphicsRotation::originChanged()
+
+ This signal is emitted whenever the origin has changed.
+
+ \sa QGraphicsRotation::origin
+*/
/*!
- \class QGraphicsRotation3D
- \brief The QGraphicsRotation3D class provides a way to rotate a graphics item in 3 dimensions.
- \since 4.6
+ \fn void QGraphicsRotation::angleChanged()
- In addition to the origin and angle of a simple QGraphicsRotation, QGraphicsRotation3D contains
- also an axis that describes around which axis in space the rotation is supposed to happen.
+ This signal is emitted whenever the angle has changed.
+
+ \sa QGraphicsRotation::angle
+*/
+
+/*!
+ \class QGraphicsRotation3D
+ \brief The QGraphicsRotation3D class provides rotation in 3 dimensions.
+ \since 4.6
+
+ QGraphicsRotation3D extends QGraphicsRotation with the ability to rotate
+ around a given axis.
+
+ You can provide the desired axis by assigning a QVector3D to the axis
+ property. The angle property, which is provided by QGraphicsRotation, now
+ describes the number of degrees to rotate around this axis.
+
+ By default the axis is (0, 0, 1), giving QGraphicsRotation3D the same
+ default behavior as QGraphicsRotation (i.e., rotation around the Z axis).
+
+ \sa QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate()
*/
class QGraphicsRotation3DPrivate : public QGraphicsRotationPrivate
@@ -399,7 +487,7 @@ public:
};
/*!
- Constructs a new 3D rotation with \a parent.
+ Constructs a new QGraphicsRotation3D with the given \a parent.
*/
QGraphicsRotation3D::QGraphicsRotation3D(QObject *parent)
: QGraphicsRotation(*new QGraphicsRotation3DPrivate, parent)
@@ -407,7 +495,7 @@ QGraphicsRotation3D::QGraphicsRotation3D(QObject *parent)
}
/*!
- Destroys the object
+ Destroys the 3D graphics rotation.
*/
QGraphicsRotation3D::~QGraphicsRotation3D()
{
@@ -415,15 +503,22 @@ QGraphicsRotation3D::~QGraphicsRotation3D()
/*!
\property QGraphicsRotation3D::axis
+ \brief a rotation axis, specified by a vector in 3D space.
+
+ This can be any axis in 3D space. By default the axis is (0, 0, 1),
+ which is aligned with the Z axis and provides the same behavior
+ for the rotation angle as QGraphicsRotation. If you provide another
+ axis, QGraphicsRotation3D will provide a transformation that rotates
+ around this axis. For example, if you would like to rotate an item
+ around its X axis, you could pass (1, 0, 0) as the axis.
- A rotation axis is specified by a vector in 3D space.
+ \sa QTransform, QGraphicsRotation::angle
*/
QVector3D QGraphicsRotation3D::axis()
{
Q_D(QGraphicsRotation3D);
return d->axis;
}
-
void QGraphicsRotation3D::setAxis(const QVector3D &axis)
{
Q_D(QGraphicsRotation3D);
@@ -431,17 +526,10 @@ void QGraphicsRotation3D::setAxis(const QVector3D &axis)
update();
}
-/*!
- \fn void QGraphicsRotation3D::axisChanged()
-
- This signal is emitted whenever the axis of the object
- changes.
-*/
-
-const qreal inv_dist_to_plane = 1. / 1024.;
+static const qreal inv_dist_to_plane = 1. / 1024.;
/*!
- \reimp
+ \reimp
*/
void QGraphicsRotation3D::applyTo(QTransform *t) const
{
@@ -474,6 +562,12 @@ void QGraphicsRotation3D::applyTo(QTransform *t) const
t->translate(-d->origin.x(), -d->origin.y());
}
+/*!
+ \fn void QGraphicsRotation3D::axisChanged()
+
+ This signal is emitted whenever the axis of the object changes.
+*/
+
#include "moc_qgraphicstransform.cpp"
QT_END_NAMESPACE
diff --git a/src/gui/graphicsview/qgraphicstransform.h b/src/gui/graphicsview/qgraphicstransform.h
index b5d8d84..d7c07d0 100644
--- a/src/gui/graphicsview/qgraphicstransform.h
+++ b/src/gui/graphicsview/qgraphicstransform.h
@@ -70,6 +70,7 @@ protected Q_SLOTS:
protected:
QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent);
+
private:
friend class QGraphicsItem;
friend class QGraphicsItemPrivate;
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index bf348af..b9c36dc 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -25,7 +25,9 @@ HEADERS += \
image/qpixmapcache_p.h \
image/qpixmapdata_p.h \
image/qpixmapdatafactory_p.h \
- image/qpixmapfilter_p.h
+ image/qpixmapfilter_p.h \
+ image/qimagepixmapcleanuphooks_p.h \
+
SOURCES += \
image/qbitmap.cpp \
@@ -47,6 +49,8 @@ SOURCES += \
image/qmovie.cpp \
image/qpixmap_raster.cpp \
image/qnativeimage.cpp \
+ image/qimagepixmapcleanuphooks.cpp \
+
win32 {
SOURCES += image/qpixmap_win.cpp
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index e8ca7a9..bb77fb5 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -49,6 +49,7 @@
#include "qimagewriter.h"
#include "qstringlist.h"
#include "qvariant.h"
+#include "qimagepixmapcleanuphooks_p.h"
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
@@ -106,14 +107,6 @@ static inline bool checkPixelSize(const QImage::Format format)
}
-// ### Qt 5: remove
-typedef void (*_qt_image_cleanup_hook)(int);
-Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0;
-
-// ### Qt 5: rename
-typedef void (*_qt_image_cleanup_hook_64)(qint64);
-Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0;
-
static QImage rotated90(const QImage &src);
static QImage rotated180(const QImage &src);
static QImage rotated270(const QImage &src);
@@ -257,8 +250,8 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
QImageData::~QImageData()
{
- if (is_cached && qt_image_cleanup_hook_64)
- qt_image_cleanup_hook_64((((qint64) ser_no) << 32) | ((qint64) detach_no));
+ if (is_cached)
+ QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no));
delete paintEngine;
if (data && own_data)
free(data);
@@ -1342,8 +1335,8 @@ QImage::operator QVariant() const
void QImage::detach()
{
if (d) {
- if (d->is_cached && qt_image_cleanup_hook_64 && d->ref == 1)
- qt_image_cleanup_hook_64(cacheKey());
+ if (d->is_cached && d->ref == 1)
+ QImagePixmapCleanupHooks::executeImageHooks(cacheKey());
if (d->ref != 1 || d->ro_data)
*this = copy();
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
new file mode 100644
index 0000000..7d1c5fb
--- /dev/null
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qimagepixmapcleanuphooks_p.h"
+#include "qpixmapdata_p.h"
+
+
+// Legacy, single instance hooks: ### Qt 5: remove
+typedef void (*_qt_pixmap_cleanup_hook)(int);
+typedef void (*_qt_pixmap_cleanup_hook_64)(qint64);
+typedef void (*_qt_image_cleanup_hook)(int);
+Q_GUI_EXPORT _qt_pixmap_cleanup_hook qt_pixmap_cleanup_hook = 0;
+Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0;
+Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0;
+Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0;
+
+
+QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks = 0;
+
+
+QImagePixmapCleanupHooks::QImagePixmapCleanupHooks()
+{
+ qt_image_and_pixmap_cleanup_hooks = this;
+}
+
+QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance()
+{
+ if (!qt_image_and_pixmap_cleanup_hooks)
+ qt_image_and_pixmap_cleanup_hooks = new QImagePixmapCleanupHooks;
+ return qt_image_and_pixmap_cleanup_hooks;
+}
+
+void QImagePixmapCleanupHooks::addPixmapHook(_qt_pixmap_cleanup_hook_pm hook)
+{
+ pixmapHooks.append(hook);
+}
+
+void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook)
+{
+ imageHooks.append(hook);
+}
+
+void QImagePixmapCleanupHooks::removePixmapHook(_qt_pixmap_cleanup_hook_pm hook)
+{
+ pixmapHooks.removeAll(hook);
+}
+
+void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
+{
+ imageHooks.removeAll(hook);
+}
+
+
+void QImagePixmapCleanupHooks::executePixmapHooks(QPixmap* pm)
+{
+ for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapHooks.count(); ++i)
+ qt_image_and_pixmap_cleanup_hooks->pixmapHooks[i](pm);
+
+ if (qt_pixmap_cleanup_hook_64)
+ qt_pixmap_cleanup_hook_64(pm->cacheKey());
+}
+
+
+void QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
+{
+ for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i)
+ qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key);
+
+ if (qt_image_cleanup_hook_64)
+ qt_image_cleanup_hook_64(key);
+}
+
diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h
new file mode 100644
index 0000000..e765e69
--- /dev/null
+++ b/src/gui/image/qimagepixmapcleanuphooks_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QIMAGEPIXMAP_CLEANUPHOOKS_P_H
+#define QIMAGEPIXMAP_CLEANUPHOOKS_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 <QtGui/qpixmap.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef void (*_qt_image_cleanup_hook_64)(qint64);
+typedef void (*_qt_pixmap_cleanup_hook_pm)(QPixmap*);
+
+class QImagePixmapCleanupHooks;
+extern QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks;
+
+class Q_GUI_EXPORT QImagePixmapCleanupHooks
+{
+public:
+ QImagePixmapCleanupHooks();
+
+ static QImagePixmapCleanupHooks *instance();
+
+ void addPixmapHook(_qt_pixmap_cleanup_hook_pm);
+ void addImageHook(_qt_image_cleanup_hook_64);
+
+ void removePixmapHook(_qt_pixmap_cleanup_hook_pm);
+ void removeImageHook(_qt_image_cleanup_hook_64);
+
+ static void executePixmapHooks(QPixmap*);
+ static void executeImageHooks(qint64 key);
+
+private:
+ QList<_qt_image_cleanup_hook_64> imageHooks;
+ QList<_qt_pixmap_cleanup_hook_pm> pixmapHooks;
+};
+
+QT_END_NAMESPACE
+
+#endif // QIMAGEPIXMAP_CLEANUPHOOKS_P_H
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 18829f4..82835d5 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -43,6 +43,7 @@
#include "qpixmap.h"
#include "qpixmapdata_p.h"
+#include "qimagepixmapcleanuphooks_p.h"
#include "qbitmap.h"
#include "qcolormap.h"
@@ -81,14 +82,6 @@
QT_BEGIN_NAMESPACE
// ### Qt 5: remove
-typedef void (*_qt_pixmap_cleanup_hook)(int);
-Q_GUI_EXPORT _qt_pixmap_cleanup_hook qt_pixmap_cleanup_hook = 0;
-
-// ### Qt 5: rename
-typedef void (*_qt_pixmap_cleanup_hook_64)(qint64);
-Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0;
-
-// ### Qt 5: remove
Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap)
{
return pixmap.cacheKey();
@@ -656,7 +649,7 @@ void QPixmap::resize_helper(const QSize &s)
QX11PixmapData *x11Data = data->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(data) : 0;
if (x11Data) {
pm.x11SetScreen(x11Data->xinfo.screen());
- uninit = x11Data->uninit;
+ uninit = x11Data->flags & QX11PixmapData::Uninitialized;
}
#elif defined(Q_WS_MAC)
QMacPixmapData *macData = data->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data) : 0;
@@ -1357,8 +1350,8 @@ bool QPixmap::isDetached() const
void QPixmap::deref()
{
if (data && !data->ref.deref()) { // Destroy image if last ref
- if (data->is_cached && qt_pixmap_cleanup_hook_64)
- qt_pixmap_cleanup_hook_64(cacheKey());
+ if (data->is_cached)
+ QImagePixmapCleanupHooks::executePixmapHooks(this);
delete data;
data = 0;
}
@@ -1897,9 +1890,6 @@ int QPixmap::defaultDepth()
#endif
}
-typedef void (*_qt_pixmap_cleanup_hook_64)(qint64);
-extern _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64;
-
/*!
Detaches the pixmap from shared pixmap data.
@@ -1925,8 +1915,8 @@ void QPixmap::detach()
rasterData->image.detach();
}
- if (data->is_cached && qt_pixmap_cleanup_hook_64 && data->ref == 1)
- qt_pixmap_cleanup_hook_64(cacheKey());
+ if (data->is_cached && data->ref == 1)
+ QImagePixmapCleanupHooks::executePixmapHooks(this);
#if defined(Q_WS_MAC)
QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(data) : 0;
@@ -1946,7 +1936,7 @@ void QPixmap::detach()
#if defined(Q_WS_X11)
if (data->classId() == QPixmapData::X11Class) {
QX11PixmapData *d = static_cast<QX11PixmapData*>(data);
- d->uninit = false;
+ d->flags &= ~QX11PixmapData::Uninitialized;
// reset the cache data
if (d->hd2) {
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 86cf515..be3d070 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -313,7 +313,7 @@ int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
QX11PixmapData::QX11PixmapData(PixelType type)
: QPixmapData(type, X11Class), hd(0),
- uninit(true), read_only(false), x11_mask(0), picture(0), mask_picture(0), hd2(0),
+ flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0), gl_surface(0),
share_mode(QPixmap::ImplicitlyShared), pengine(0)
{
}
@@ -1217,7 +1217,7 @@ void QX11PixmapData::release()
XFreePixmap(xinfo.display(), hd2);
hd2 = 0;
}
- if (!read_only)
+ if (!(flags & Readonly))
XFreePixmap(xinfo.display(), hd);
hd = 0;
}
@@ -1876,7 +1876,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
} else { // color pixmap
QPixmap pm;
QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(pm.data);
- x11Data->uninit = false;
+ x11Data->flags &= ~QX11PixmapData::Uninitialized;
x11Data->xinfo = xinfo;
x11Data->d = d;
x11Data->w = w;
@@ -2018,7 +2018,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
QPixmap pm(data);
- data->uninit = false;
+ data->flags &= ~QX11PixmapData::Uninitialized;
pm.x11SetScreen(scr);
GC gc = XCreateGC(dpy, pm.handle(), 0, 0);
@@ -2060,7 +2060,7 @@ QPaintEngine* QX11PixmapData::paintEngine() const
{
QX11PixmapData *that = const_cast<QX11PixmapData*>(this);
- if (read_only && share_mode == QPixmap::ImplicitlyShared) {
+ if ((flags & Readonly) && share_mode == QPixmap::ImplicitlyShared) {
// if someone wants to draw onto us, copy the shared contents
// and turn it into a fully fledged QPixmap
::Pixmap hd_copy = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()),
@@ -2082,7 +2082,7 @@ QPaintEngine* QX11PixmapData::paintEngine() const
XFreeGC(X11->display, gc);
}
that->hd = hd_copy;
- that->read_only = false;
+ that->flags &= ~QX11PixmapData::Readonly;
}
if (!that->pengine)
@@ -2133,7 +2133,7 @@ void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect)
setSerialNumber(++qt_pixmap_serial);
- uninit = false;
+ flags &= ~Uninitialized;
xinfo = x11Data->xinfo;
d = x11Data->d;
w = rect.width();
@@ -2201,7 +2201,7 @@ void QX11PixmapData::convertToARGB32(bool preserveContents)
return;
// Q_ASSERT(count == 1);
- if (read_only && share_mode == QPixmap::ExplicitlyShared)
+ if ((flags & Readonly) && share_mode == QPixmap::ExplicitlyShared)
return;
Pixmap pm = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()),
@@ -2211,10 +2211,10 @@ void QX11PixmapData::convertToARGB32(bool preserveContents)
if (picture) {
if (preserveContents)
XRenderComposite(X11->display, PictOpSrc, picture, 0, p, 0, 0, 0, 0, 0, 0, w, h);
- if (!read_only)
+ if (!(flags & Readonly))
XRenderFreePicture(X11->display, picture);
}
- if (hd && !read_only)
+ if (hd && !(flags & Readonly))
XFreePixmap(X11->display, hd);
if (x11_mask) {
XFreePixmap(X11->display, x11_mask);
@@ -2252,9 +2252,8 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
QX11PixmapData *data = new QX11PixmapData(depth == 1 ? QPixmapData::BitmapType : QPixmapData::PixmapType);
data->setSerialNumber(++qt_pixmap_serial);
- data->read_only = true;
+ data->flags = QX11PixmapData::Readonly;
data->share_mode = mode;
- data->uninit = false;
data->w = width;
data->h = height;
data->is_null = (width <= 0 || height <= 0);
diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h
index 3de9a0f..835fea4 100644
--- a/src/gui/image/qpixmap_x11_p.h
+++ b/src/gui/image/qpixmap_x11_p.h
@@ -99,6 +99,7 @@ private:
friend class QX11PaintEngine;
friend class QX11WindowSurface;
friend class QRasterWindowSurface;
+ friend class QGLContextPrivate; // Needs to access xinfo, gl_surface & flags
void release();
@@ -108,14 +109,21 @@ private:
Qt::HANDLE hd;
- uint uninit : 1;
- uint read_only : 1;
+ enum Flag {
+ NoFlags = 0x0,
+ Uninitialized = 0x1,
+ Readonly = 0x2,
+ InvertedWhenBoundToTexture = 0x4,
+ GlSurfaceCreatedWithAlpha = 0x8
+ };
+ uint flags;
QX11Info xinfo;
Qt::HANDLE x11_mask;
Qt::HANDLE picture;
Qt::HANDLE mask_picture;
Qt::HANDLE hd2; // sorted in the default display depth
+ Qt::HANDLE gl_surface;
#ifndef QT_NO_XRENDER
void convertToARGB32(bool preserveContents = true);
#endif
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index 29dafaf..32b419e 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -116,6 +116,7 @@ private:
friend class QPixmap;
friend class QGLContextPrivate;
friend class QX11PixmapData;
+ friend class QGLTextureCache; //Needs to check the reference count
QAtomicInt ref;
int detach_no;
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 5181689..e210556 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -179,11 +179,11 @@ QApplicationPrivate::~QApplicationPrivate()
QApplication contains the main event loop, where all events from the window
system and other sources are processed and dispatched. It also handles the
- application's initialization and finalization, and provides session
- management. In addition, it handles most system-wide and application-wide
- settings.
+ application's initialization, finalization, and provides session
+ management. In addition, QApplication handles most of the system-wide and
+ application-wide settings.
- For any GUI application using Qt, there is precisely one QApplication
+ For any GUI application using Qt, there is precisely \bold one QApplication
object, no matter whether the application has 0, 1, 2 or more windows at
any given time. For non-GUI Qt applications, use QCoreApplication instead,
as it does not depend on the \l QtGui library.
@@ -239,9 +239,9 @@ QApplicationPrivate::~QApplicationPrivate()
saveState() for details.
\endlist
- The QApplication object does so much initialization. Hence, it \e{must} be
+ Since the QApplication object does so much initialization, it \e{must} be
created before any other objects related to the user interface are created.
- Since QApplication also deals with common command line arguments, it is
+ QApplication also deals with common command line arguments. Hence, it is
usually a good idea to create it \e before any interpretation or
modification of \c argv is done in the application itself.
@@ -673,9 +673,9 @@ QApplication::QApplication(int &argc, char **argv, int _internal)
On X11, the window system is initialized if \a GUIenabled is true. If
\a GUIenabled is false, the application does not connect to the X server.
- On Windows and Macintosh, currently the window system is always
- initialized, regardless of the value of GUIenabled. This may change in
- future versions of Qt.
+ On Windows and Mac OS, currently the window system is always initialized,
+ regardless of the value of GUIenabled. This may change in future versions
+ of Qt.
The following example shows how to create an application that uses a
graphical interface when available.
@@ -1194,21 +1194,22 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
\since 4.4
\brief defines a threshold for auto maximizing widgets
- The auto maximize threshold is only available as part of Qt for Windows CE.
+ \bold{The auto maximize threshold is only available as part of Qt for
+ Windows CE.}
This property defines a threshold for the size of a window as a percentage
of the screen size. If the minimum size hint of a window exceeds the
- threshold, calling show() will then cause the window to be maximized
+ threshold, calling show() will cause the window to be maximized
automatically.
- Setting the threshold to be 100 or greater means that it will cause it to
- always be maximized. Setting it to be 50 means that the widget is maximized
- if the vertical minimum size hint is at least 50% of the vertical screen
- size.
+ Setting the threshold to 100 or greater means that the widget will always
+ be maximized. Alternatively, setting the threshold to 50 means that the
+ widget will be maximized only if the vertical minimum size hint is at least
+ 50% of the vertical screen size.
- If -1 is specified then this will disable the feature.
+ Setting the threshold to -1 disables the feature.
- On Windows CE the default is -1 (i.e. it is disabled).
+ On Windows CE the default is -1 (i.e., it is disabled).
On Windows Mobile the default is 40.
*/
@@ -1217,9 +1218,9 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
\since 4.5
\brief toggles automatic SIP (software input panel) visibility
- The auto SIP property is only available as part of Qt for Windows CE.
+ \bold{The auto SIP property is only available as part of Qt for Windows CE.}
- Set this property to true to automatically display the SIP when entering
+ Set this property to \c true to automatically display the SIP when entering
widgets that accept keyboard input. This property only affects widgets with
the WA_InputMethodEnabled attribute set.
*/
@@ -1517,7 +1518,7 @@ int QApplication::colorSpec()
strategy. Use this option if your application uses buttons, menus,
texts and pixmaps with few colors. With this option, the
application uses system global colors. This works fine for most
- applications under X11, but on Windows machines it may cause
+ applications under X11, but on the Windows platform, it may cause
dithering of non-standard colors.
\o QApplication::CustomColor. Use this option if your application
needs a small number of custom colors. On X11, this option is the
@@ -3513,12 +3514,12 @@ void QApplication::changeOverrideCursor(const QCursor &cursor)
We recommend that you connect clean-up code to the
\l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
- application's \c{main()} function because on some platforms the
- QApplication::exec() call may not return. For example, on Windows when the
- user logs off, the system terminates the process after Qt closes all
- top-level windows. Hence, there is no guarantee that the application will
- have time to exit its event loop and execute code at the end of the
- \c{main()} function after the QApplication::exec() call.
+ application's \c{main()} function. This is because, on some platforms the
+ QApplication::exec() call may not return. For example, on the Windows
+ platform, when the user logs off, the system terminates the process after Qt
+ closes all top-level windows. Hence, there is \e{no guarantee} that the
+ application will have time to exit its event loop and execute code at the
+ end of the \c{main()} function, after the QApplication::exec() call.
\sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
QCoreApplication::exec()
@@ -4762,7 +4763,7 @@ bool QApplication::keypadNavigationEnabled()
On Mac OS X, this works more at the application level and will cause the
application icon to bounce in the dock.
- On Windows this causes the window's taskbar entry to flash for a time. If
+ On Windows, this causes the window's taskbar entry to flash for a time. If
\a msec is zero, the flashing will stop and the taskbar entry will turn a
different color (currently orange).
@@ -4779,24 +4780,22 @@ bool QApplication::keypadNavigationEnabled()
caret display. Usually the text cursor is displayed for half the cursor
flash time, then hidden for the same amount of time, but this may vary.
- The default value on X11 is 1000 milliseconds. On Windows, the control
- panel value is used. Widgets should not cache this value since it may be
- changed at any time by the user changing the global desktop settings.
+ The default value on X11 is 1000 milliseconds. On Windows, the
+ \gui{Control Panel} value is used and setting this property sets the cursor
+ flash time for all applications.
- \note On Microsoft Windows, setting this property sets the cursor flash
- time for all applications.
+ We recommend that widgets do not cache this value as it may change at any
+ time if the user changes the global desktop settings.
*/
/*!
\property QApplication::doubleClickInterval
- \brief the time limit in milliseconds that distinguishes a double click from two
- consecutive mouse clicks
-
- The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the
- operating system's value is used.
+ \brief the time limit in milliseconds that distinguishes a double click
+ from two consecutive mouse clicks
- On Microsoft Windows, calling this function sets the double click interval
- for all applications.
+ The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
+ operating system's value is used. However, on Windows, calling this
+ function sets the double click interval for all applications.
*/
/*!
@@ -4805,7 +4804,7 @@ bool QApplication::keypadNavigationEnabled()
from two consecutive key presses
\since 4.2
- The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the
+ The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
operating system's value is used.
*/
@@ -4870,7 +4869,7 @@ bool QApplication::keypadNavigationEnabled()
You need not have a main widget; connecting lastWindowClosed() to quit()
is an alternative.
- For X11, this function also resizes and moves the main widget according
+ On X11, this function also resizes and moves the main widget according
to the \e -geometry command-line option, so you should set the default
geometry (using \l QWidget::setGeometry()) before calling setMainWidget().
@@ -4899,9 +4898,10 @@ bool QApplication::keypadNavigationEnabled()
Application cursors are stored on an internal stack. setOverrideCursor()
pushes the cursor onto the stack, and restoreOverrideCursor() pops the
active cursor off the stack. changeOverrideCursor() changes the curently
- active application override cursor. Every setOverrideCursor() must
- eventually be followed by a corresponding restoreOverrideCursor(),
- otherwise the stack will never be emptied.
+ active application override cursor.
+
+ Every setOverrideCursor() must eventually be followed by a corresponding
+ restoreOverrideCursor(), otherwise the stack will never be emptied.
Example:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0
@@ -5082,19 +5082,19 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
*/
/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration)
- \overload
+ \overload
- Requests a QDecoration object for \a decoration from the QDecorationFactory.
+ Requests a QDecoration object for \a decoration from the
+ QDecorationFactory.
- The string must be one of the QDecorationFactory::keys(). Keys are
- case insensitive.
+ The string must be one of the QDecorationFactory::keys(). Keys are case
+ insensitive.
- A later call to the QApplication constructor will override the
- requested style when a "-style" option is passed in as a commandline
- parameter.
+ A later call to the QApplication constructor will override the requested
+ style when a "-style" option is passed in as a commandline parameter.
- Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object
- returned is set as the application's GUI style.
+ Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object
+ returned is set as the application's GUI style.
*/
/*!
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index d53b419..1f98013 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -153,7 +153,7 @@ QGesture::QGesture(QObject *parent)
: QObject(*new QGesturePrivate, parent)
{
if (parent)
- installEventFilter(parent);
+ parent->installEventFilter(this);
}
/*! \internal
@@ -162,7 +162,7 @@ QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
: QObject(dd, parent)
{
if (parent)
- installEventFilter(parent);
+ parent->installEventFilter(this);
}
/*!
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index e24b7cb..6ee229a 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -3497,11 +3497,16 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh)
minh = qMax(minh, 0);
}
createExtra();
- if (extra->minw == minw && extra->minh == minh)
+ int mw = minw, mh = minh;
+ if (mw == QWIDGETSIZE_MAX)
+ mw = 0;
+ if (mh == QWIDGETSIZE_MAX)
+ mh = 0;
+ if (extra->minw == mw && extra->minh == mh)
return false;
- extra->minw = minw;
- extra->minh = minh;
- extra->explicitMinSize = (minw ? Qt::Horizontal : 0) | (minh ? Qt::Vertical : 0);
+ extra->minw = mw;
+ extra->minh = mh;
+ extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);
return true;
}
@@ -3561,7 +3566,8 @@ bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh)
return false;
extra->maxw = maxw;
extra->maxh = maxh;
- extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0);
+ extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) |
+ (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0);
return true;
}
@@ -3640,6 +3646,8 @@ void QWidget::setBaseSize(int basew, int baseh)
This will override the default size constraints set by QLayout.
+ To remove constraints, set the size to QWIDGETSIZE_MAX.
+
Alternatively, if you want the widget to have a
fixed size based on its contents, you can call
QLayout::setSizeConstraint(QLayout::SetFixedSize);
@@ -3681,7 +3689,8 @@ void QWidget::setFixedSize(int w, int h)
else
d->updateGeometry_helper(true);
- resize(w, h);
+ if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX)
+ resize(w, h);
}
void QWidget::setMinimumWidth(int w)
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 70eea3a..3bbf5d4 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3100,7 +3100,12 @@ void QWidgetPrivate::update_sys(const QRegion &rgn)
return;
dirtyOnWidget += rgn;
#ifndef QT_MAC_USE_COCOA
- HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgn.toQDRgn()), true);
+ RgnHandle rgnHandle = rgn.toQDRgnForUpdate_sys();
+ if (rgnHandle)
+ HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true);
+ else {
+ HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow.
+ }
#else
// Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect.
const QRect &boundingRect = rgn.boundingRect();
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 46fa3be..2f230d7 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -467,6 +467,17 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
}
+ if (topLevel) {
+ if (data.window_flags & Qt::CustomizeWindowHint
+ && data.window_flags & Qt::WindowTitleHint) {
+ HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE);
+ if (data.window_flags & Qt::WindowCloseButtonHint)
+ EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
+ else
+ EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
+ }
+ }
+
q->setAttribute(Qt::WA_WState_Created); // accept move/resize events
hd = 0; // no display context
@@ -638,16 +649,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
|| (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
q->setAttribute(Qt::WA_DropSiteRegistered, true);
-
- if (data.window_flags & Qt::CustomizeWindowHint
- && data.window_flags & Qt::WindowTitleHint) {
- HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE);
- if (data.window_flags & Qt::WindowCloseButtonHint)
- EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
- else
- EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
- }
-
#ifdef Q_WS_WINCE
// Show borderless toplevel windows in tasklist & NavBar
if (!parent) {
@@ -1524,6 +1525,11 @@ bool QWidgetPrivate::shouldShowMaximizeButton()
{
if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint)
return false;
+ // if the user explicitely asked for the maximize button, we try to add
+ // it even if the window has fixed size.
+ if (data.window_flags & Qt::CustomizeWindowHint &&
+ data.window_flags & Qt::WindowMaximizeButtonHint)
+ return true;
if (extra) {
if ((extra->maxw && extra->maxw != QWIDGETSIZE_MAX && extra->maxw != QLAYOUTSIZE_MAX)
|| (extra->maxh && extra->maxh != QWIDGETSIZE_MAX && extra->maxh != QLAYOUTSIZE_MAX))
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 34d1779..d226be2 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -100,8 +100,8 @@ win32 {
painting/qcolormap_win.cpp \
painting/qpaintdevice_win.cpp \
painting/qprintengine_win.cpp \
- painting/qprinterinfo_win.cpp \
- painting/qregion_win.cpp
+ painting/qprinterinfo_win.cpp
+
!win32-borland:!wince*:LIBS += -lmsimg32
}
@@ -126,10 +126,6 @@ embedded {
painting/qwindowsurface_raster.cpp \
}
-wince* {
- SOURCES -= painting/qregion_win.cpp
-}
-
unix:x11 {
HEADERS += \
painting/qpaintengine_x11_p.h
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 979390a..b6603e4 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -4794,30 +4794,60 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *
if (sy < 0)
sy += image_height;
- while (length) {
- int l = qMin(image_width - sx, length);
- if (buffer_size < l)
- l = buffer_size;
-
- DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x;
- const SRC *src = (SRC*)data->texture.scanLine(sy) + sx;
- if (modeSource && coverage == 255) {
+ if (modeSource && coverage == 255) {
+ // Copy the first texture block
+ length = image_width;
+ while (length) {
+ int l = qMin(image_width - sx, length);
+ if (buffer_size < l)
+ l = buffer_size;
+ DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x;
+ const SRC *src = (SRC*)data->texture.scanLine(sy) + sx;
qt_memconvert<DST, SRC>(dest, src, l);
- } else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 &&
- (quintptr(dest) & 3) == (quintptr(src) & 3))
- {
- blendUntransformed_dest24(dest, src, coverage, l);
- } else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 &&
- (quintptr(dest) & 3) == (quintptr(src) & 3))
- {
- blendUntransformed_dest16(dest, src, coverage, l);
- } else {
- blendUntransformed_unaligned(dest, src, coverage, l);
+ length -= l;
+ sx = 0;
}
- x += l;
- length -= l;
- sx = 0;
+ // Now use the rasterBuffer as the source of the texture,
+ // We can now progressively copy larger blocks
+ // - Less cpu time in code figuring out what to copy
+ // We are dealing with one block of data
+ // - More likely to fit in the cache
+ // - can use memcpy
+ int copy_image_width = image_width;
+ length = spans->len - image_width;
+ DST *src = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x;
+ DST *dest = src + copy_image_width;
+ while (copy_image_width < length) {
+ qt_memconvert(dest, src, copy_image_width);
+ dest += copy_image_width;
+ length -= copy_image_width;
+ copy_image_width *= 2;
+ }
+ qt_memconvert(dest, src, length);
+ } else {
+ while (length) {
+ int l = qMin(image_width - sx, length);
+ if (buffer_size < l)
+ l = buffer_size;
+ DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x;
+ const SRC *src = (SRC*)data->texture.scanLine(sy) + sx;
+ if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 &&
+ (quintptr(dest) & 3) == (quintptr(src) & 3))
+ {
+ blendUntransformed_dest24(dest, src, coverage, l);
+ } else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 &&
+ (quintptr(dest) & 3) == (quintptr(src) & 3))
+ {
+ blendUntransformed_dest16(dest, src, coverage, l);
+ } else {
+ blendUntransformed_unaligned(dest, src, coverage, l);
+ }
+
+ x += l;
+ length -= l;
+ sx = 0;
+ }
}
++spans;
}
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index 762e9e0..d59f3ff 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -49,7 +49,7 @@
#include <qdebug.h>
-#if defined(Q_OS_UNIX) || defined(Q_OS_WINCE)
+#if defined(Q_OS_UNIX) || defined(Q_WS_WIN)
#include "qimage.h"
#include "qbitmap.h"
#include <stdlib.h>
@@ -545,7 +545,7 @@ QRegion& QRegion::operator|=(const QRegion &r)
\sa intersected()
*/
-#if !defined (Q_OS_UNIX) && !defined (Q_OS_WINCE)
+#if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN)
QRegion& QRegion::operator+=(const QRect &r)
{
return operator+=(QRegion(r));
@@ -561,16 +561,14 @@ QRegion& QRegion::operator+=(const QRect &r)
\sa intersected()
*/
-#if !defined(Q_WS_WIN) || defined(Q_OS_WINCE)
QRegion& QRegion::operator&=(const QRegion &r)
{ return *this = *this & r; }
-#endif
/*!
\overload
\since 4.4
*/
-#if defined (Q_OS_UNIX) || defined (Q_OS_WINCE)
+#if defined (Q_OS_UNIX) || defined (Q_WS_WIN)
QRegion& QRegion::operator&=(const QRect &r)
{
return *this = *this & r;
@@ -591,10 +589,8 @@ QRegion& QRegion::operator&=(const QRect &r)
\sa subtracted()
*/
-#if !defined(Q_WS_WIN) || defined(Q_OS_WINCE)
QRegion& QRegion::operator-=(const QRegion &r)
{ return *this = *this - r; }
-#endif
/*!
Applies the xored() function to this region and \a r and
@@ -731,7 +727,7 @@ bool QRegion::intersects(const QRect &rect) const
return false;
}
-#if !defined (Q_OS_UNIX) && !defined (Q_OS_WINCE)
+#if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN)
/*!
\overload
\since 4.4
@@ -1086,7 +1082,7 @@ Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion &region)
return result;
}
-#if defined(Q_OS_UNIX) || defined(Q_OS_WINCE)
+#if defined(Q_OS_UNIX) || defined(Q_WS_WIN)
//#define QT_REGION_DEBUG
/*
@@ -1627,9 +1623,9 @@ QT_END_INCLUDE_NAMESPACE
QT_BEGIN_INCLUDE_NAMESPACE
# include "qregion_mac.cpp"
QT_END_INCLUDE_NAMESPACE
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_WS_WIN)
QT_BEGIN_INCLUDE_NAMESPACE
-# include "qregion_wince.cpp"
+# include "qregion_win.cpp"
QT_END_INCLUDE_NAMESPACE
#elif defined(Q_WS_QWS)
static QRegionPrivate qrp;
@@ -3829,7 +3825,7 @@ QRegion::QRegion(const QRect &r, RegionType t)
#if defined(Q_WS_X11)
d->rgn = 0;
d->xrectangles = 0;
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_WS_WIN)
d->rgn = 0;
#endif
if (t == Rectangle) {
@@ -3851,7 +3847,7 @@ QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule)
#if defined(Q_WS_X11)
d->rgn = 0;
d->xrectangles = 0;
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_WS_WIN)
d->rgn = 0;
#endif
d->qt_rgn = PolygonRegion(a.constData(), a.size(),
@@ -3881,7 +3877,7 @@ QRegion::QRegion(const QBitmap &bm)
#if defined(Q_WS_X11)
d->rgn = 0;
d->xrectangles = 0;
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_WS_WIN)
d->rgn = 0;
#endif
d->qt_rgn = qt_bitmapToRegion(bm);
@@ -3896,7 +3892,7 @@ void QRegion::cleanUp(QRegion::QRegionData *x)
XDestroyRegion(x->rgn);
if (x->xrectangles)
free(x->xrectangles);
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_WS_WIN)
if (x->rgn)
qt_win_dispose_rgn(x->rgn);
#endif
@@ -3932,7 +3928,7 @@ QRegion QRegion::copy() const
#if defined(Q_WS_X11)
x->rgn = 0;
x->xrectangles = 0;
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_WS_WIN)
x->rgn = 0;
#endif
if (d->qt_rgn)
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index bfedcb1..84024ce 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -59,7 +59,7 @@ QT_MODULE(Gui)
template <class T> class QVector;
class QVariant;
-#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN)
struct QRegionPrivate;
#endif
@@ -148,6 +148,7 @@ public:
#elif defined(Q_WS_MAC)
#if defined Q_WS_MAC32
RgnHandle toQDRgn() const;
+ RgnHandle toQDRgnForUpdate_sys() const;
static QRegion fromQDRgn(RgnHandle shape);
#endif
#ifdef QT_MAC_USE_COCOA
@@ -199,7 +200,7 @@ private:
#elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
mutable RgnHandle unused; // Here for binary compatability reasons. ### Qt 5 remove.
#endif
-#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN)
QRegionPrivate *qt_rgn;
#endif
};
diff --git a/src/gui/painting/qregion_mac.cpp b/src/gui/painting/qregion_mac.cpp
index b57f234..9b0e99f 100644
--- a/src/gui/painting/qregion_mac.cpp
+++ b/src/gui/painting/qregion_mac.cpp
@@ -155,6 +155,44 @@ RgnHandle QRegion::toQDRgn() const
}
return rgnHandle;
}
+
+/*!
+ \internal
+ Create's a RegionHandle, it's the caller's responsibility to release.
+ Returns 0 if the QRegion overflows.
+*/
+RgnHandle QRegion::toQDRgnForUpdate_sys() const
+{
+ RgnHandle rgnHandle = qt_mac_get_rgn();
+ if(d->qt_rgn && d->qt_rgn->numRects) {
+ RgnHandle tmp_rgn = qt_mac_get_rgn();
+ int n = d->qt_rgn->numRects;
+ const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData();
+ while (n--) {
+
+ // detect overflow. Tested for use with HIViewSetNeedsDisplayInRegion
+ // in QWidgetPrivate::update_sys().
+ enum { HIViewSetNeedsDisplayInRegionOverflow = 10000 }; // empirically determined conservative value
+ qDebug() << qt_r->x() << qt_r->y() << qt_r->right() << qt_r->bottom();
+ if (qt_r->right() > HIViewSetNeedsDisplayInRegionOverflow || qt_r->bottom() > HIViewSetNeedsDisplayInRegionOverflow) {
+ qt_mac_dispose_rgn(tmp_rgn);
+ qt_mac_dispose_rgn(rgnHandle);
+ return 0;
+ }
+
+ SetRectRgn(tmp_rgn,
+ qMax(SHRT_MIN, qt_r->x()),
+ qMax(SHRT_MIN, qt_r->y()),
+ qMin(SHRT_MAX, qt_r->right() + 1),
+ qMin(SHRT_MAX, qt_r->bottom() + 1));
+ UnionRgn(rgnHandle, tmp_rgn, rgnHandle);
+ ++qt_r;
+ }
+ qt_mac_dispose_rgn(tmp_rgn);
+ }
+ return rgnHandle;
+}
+
#endif
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
diff --git a/src/gui/painting/qregion_win.cpp b/src/gui/painting/qregion_win.cpp
index 249b1a6..2d5e76b 100644
--- a/src/gui/painting/qregion_win.cpp
+++ b/src/gui/painting/qregion_win.cpp
@@ -39,27 +39,25 @@
**
****************************************************************************/
+#include "qatomic.h"
#include "qbitmap.h"
#include "qbuffer.h"
#include "qimage.h"
#include "qpolygon.h"
#include "qregion.h"
#include "qt_windows.h"
+#include "qpainterpath.h"
+#include "qguifunctions_wince.h"
QT_BEGIN_NAMESPACE
+QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 };
-/*
- In Windows versions before Windows Vista CreateRectRgn - when called in a multi-threaded
- environment - might return an invalid handle. This function works around this limitation
- by verifying the handle with a quick GetRegionData() call and re-creates the region
- if necessary.
-*/
HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom)
{
const int tries = 10;
for (int i = 0; i < tries; ++i) {
- HRGN region = 0;
+ HRGN region;
switch (type) {
case QRegion::Rectangle:
region = CreateRectRgn(left, top, right, bottom);
@@ -80,497 +78,73 @@ HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right,
return 0;
}
-#ifndef Q_OS_WINCE
-HRGN qt_tryCreatePolygonRegion(const QPolygon &a, Qt::FillRule fillRule)
-{
- const int tries = 10;
- for (int i = 0; i < tries; ++i) {
- HRGN region = CreatePolygonRgn(reinterpret_cast<const POINT*>(a.data()), a.size(),
- fillRule == Qt::OddEvenFill ? ALTERNATE : WINDING);
- if (region) {
- if (GetRegionData(region, 0, 0))
- return region;
- else
- DeleteObject(region);
- }
- }
- return 0;
-}
-#endif
-
-QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0 };
-
-QRegion::QRegion()
- : d(&shared_empty)
-{
- d->ref.ref();
-}
-
-#ifndef Q_OS_WINCE //implementation for WindowsCE in qregion_wce.cpp
-QRegion::QRegion(const QRect &r, RegionType t)
-{
- if (r.isEmpty()) {
- d = &shared_empty;
- d->ref.ref();
- } else {
- d = new QRegionData;
- d->ref = 1;
- if (t == Rectangle)
- d->rgn = qt_tryCreateRegion(t, r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
- else if (t == Ellipse) {
- // need to add 1 to width/height for the ellipse to have correct boundingrect.
- d->rgn = qt_tryCreateRegion(t, r.x(), r.y(), r.x() + r.width() + 1, r.y() + r.height() + 1);
- }
- }
-}
-#endif
-
-#ifndef Q_OS_WINCE //implementation for WindowsCE in qregion_wce.cpp
-QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule)
-{
- if (a.size() < 3) {
- d = &shared_empty;
- d->ref.ref();
- } else {
- d = new QRegionData;
- d->ref = 1;
- d->rgn = qt_tryCreatePolygonRegion(a, fillRule);
- }
-}
-#endif
-
-QRegion::QRegion(const QRegion &r)
-{
- d = r.d;
- d->ref.ref();
-}
-
-HRGN qt_win_bitmapToRegion(const QBitmap& bitmap)
-{
- HRGN region=0;
- QImage image = bitmap.toImage();
- const int MAXRECT = 256;
- struct RData {
- RGNDATAHEADER header;
- RECT rect[MAXRECT];
- };
- RData data;
-
-#define FlushSpans \
- { \
- data.header.dwSize = sizeof(RGNDATAHEADER); \
- data.header.iType = RDH_RECTANGLES; \
- data.header.nCount = n; \
- data.header.nRgnSize = 0; \
- data.header.rcBound.bottom = y; \
- HRGN r = ExtCreateRegion(0, \
- sizeof(RGNDATAHEADER)+n*sizeof(RECT),(RGNDATA*)&data); \
- if (region) { \
- CombineRgn(region, region, r, RGN_OR); \
- DeleteObject(r); \
- } else { \
- region = r; \
- } \
- data.header.rcBound.top = y; \
- }
-
-#define AddSpan \
- { \
- data.rect[n].left=prev1; \
- data.rect[n].top=y; \
- data.rect[n].right=x-1+1; \
- data.rect[n].bottom=y+1; \
- n++; \
- if (n == MAXRECT) { \
- FlushSpans \
- n=0; \
- } \
- }
-
- data.header.rcBound.top = 0;
- data.header.rcBound.left = 0;
- data.header.rcBound.right = image.width()-1;
- int n = 0;
-
- int zero = 0x00;
-
- int x, y;
- for (y = 0; y < image.height(); ++y) {
- uchar *line = image.scanLine(y);
- int w = image.width();
- uchar all=zero;
- int prev1 = -1;
- for (x = 0; x < w;) {
- uchar byte = line[x/8];
- if (x > w - 8 || byte != all) {
- for (int b = 8; b > 0 && x < w; --b) {
- if (!(byte & 0x01) == !all) {
- // More of the same
- } else {
- // A change.
- if (all != zero) {
- AddSpan;
- all = zero;
- } else {
- prev1 = x;
- all = ~zero;
- }
- }
- byte >>= 1;
- ++x;
- }
- } else {
- x += 8;
- }
- }
- if (all != zero) {
- AddSpan;
- }
- }
- if (n) {
- FlushSpans;
- }
-
- if (!region) {
- // Surely there is some better way.
- region = qt_tryCreateRegion(QRegion::Rectangle, 0,0,1,1);
- CombineRgn(region, region, region, RGN_XOR);
- }
- return region;
-}
-
-#ifndef Q_OS_WINCE //implementation for WindowsCE in qregion_wce.cpp
-QRegion::QRegion(const QBitmap &bm)
-{
- if (bm.isNull()) {
- d = &shared_empty;
- d->ref.ref();
- } else {
- d = new QRegionData;
- d->ref = 1;
- d->rgn = qt_win_bitmapToRegion(bm);
- }
-}
-#endif
-
-void QRegion::cleanUp(QRegion::QRegionData *x)
-{
- if (x->rgn)
- DeleteObject(x->rgn);
- delete x;
-}
-
-QRegion::~QRegion()
-{
- if (!d->ref.deref())
- cleanUp(d);
-}
-
-QRegion &QRegion::operator=(const QRegion &r)
-{
- r.d->ref.ref();
- if (!d->ref.deref())
- cleanUp(d);
- d = r.d;
- return *this;
-}
-
-
-QRegion QRegion::copy() const
-{
- QRegion r;
- QRegionData *x = new QRegionData;
- x->ref = 1;
- if (d->rgn) {
- x->rgn = qt_tryCreateRegion(QRegion::Rectangle, 0, 0, 2, 2);
- CombineRgn(x->rgn, d->rgn, 0, RGN_COPY);
- } else {
- x->rgn = 0;
- }
- if (!r.d->ref.deref())
- cleanUp(r.d);
- r.d = x;
- return r;
-}
-
-bool QRegion::isEmpty() const
-{
- return (d == &shared_empty || boundingRect().isEmpty());
-}
-
-
-bool QRegion::contains(const QPoint &p) const
-{
- return d->rgn ? PtInRegion(d->rgn, p.x(), p.y()) : false;
-}
-
-bool QRegion::contains(const QRect &r) const
-{
- if (!d->rgn)
- return false;
- RECT rect;
- SetRect(&rect, r.left(), r.top(), r.right(), r.bottom());
- return RectInRegion(d->rgn, &rect);
-}
-
-
-void QRegion::translate(int dx, int dy)
-{
- if (!d->rgn || (dx == 0 && dy == 0))
- return;
- detach();
- OffsetRgn(d->rgn, dx, dy);
-}
-
-
-#define RGN_NOP -1
-
-// Duplicates of those in qregion.cpp
-#define QRGN_OR 6
-#define QRGN_AND 7
-#define QRGN_SUB 8
-#define QRGN_XOR 9
-
-/*
- Performs the actual OR, AND, SUB and XOR operation between regions.
- Sets the resulting region handle to 0 to indicate an empty region.
-*/
-
-QRegion QRegion::winCombine(const QRegion &r, int op) const
+QRegion qt_region_from_HRGN(HRGN rgn)
{
- int both=RGN_NOP,
- left=RGN_NOP,
- right=RGN_NOP;
- switch (op) {
- case QRGN_OR:
- both = RGN_OR;
- left = right = RGN_COPY;
- break;
- case QRGN_AND:
- both = RGN_AND;
- break;
- case QRGN_SUB:
- both = RGN_DIFF;
- left = RGN_COPY;
- break;
- case QRGN_XOR:
- both = RGN_XOR;
- left = right = RGN_COPY;
- break;
- default:
- qWarning("QRegion: Internal error in winCombine");
- }
-
- int allCombineRgnResults = NULLREGION;
- QRegion result;
- result.detach();
- result.d->rgn = qt_tryCreateRegion(QRegion::Rectangle, 0, 0, 0, 0);
- if (d->rgn && r.d->rgn)
- allCombineRgnResults = CombineRgn(result.d->rgn, d->rgn, r.d->rgn, both);
- else if (d->rgn && left != RGN_NOP)
- allCombineRgnResults = CombineRgn(result.d->rgn, d->rgn, d->rgn, left);
- else if (r.d->rgn && right != RGN_NOP)
- allCombineRgnResults = CombineRgn(result.d->rgn, r.d->rgn, r.d->rgn, right);
-
- if (allCombineRgnResults == NULLREGION || allCombineRgnResults == ERROR)
- result = QRegion();
-
- //##### do not delete this. A null pointer is different from an empty region in SelectClipRgn in qpainter_win! (M)
-// if (allCombineRgnResults == NULLREGION) {
-// if (result.data->rgn)
-// DeleteObject(result.data->rgn);
-// result.data->rgn = 0; // empty region
-// }
- return result;
-}
-
-QRegion QRegion::unite(const QRegion &r) const
-{
- if (!d->rgn)
- return r;
- if (!r.d->rgn)
- return *this;
- return winCombine(r, QRGN_OR);
-}
-
-QRegion QRegion::unite(const QRect &r) const
-{
- return unite(QRegion(r));
-}
-
-QRegion QRegion::intersect(const QRegion &r) const
-{
- if (!r.d->rgn || !d->rgn)
- return QRegion();
- return winCombine(r, QRGN_AND);
-}
-
-QRegion QRegion::subtract(const QRegion &r) const
-{
- if (!r.d->rgn || !d->rgn)
- return *this;
- return winCombine(r, QRGN_SUB);
-}
-
-QRegion QRegion::eor(const QRegion &r) const
-{
- if (!d->rgn)
- return r;
- if (!r.d->rgn)
- return *this;
- return winCombine(r, QRGN_XOR);
-}
-
-
-QRect QRegion::boundingRect() const
-{
- if (!d->rgn)
- return QRect();
- RECT r;
- if (GetRgnBox(d->rgn, &r) == NULLREGION)
- return QRect();
- else
- return QRect(r.left, r.top, r.right - r.left, r.bottom - r.top);
-}
-
-QVector<QRect> QRegion::rects() const
-{
- if (d->rgn == 0)
- return QVector<QRect>();
-
- int numBytes = GetRegionData(d->rgn, 0, 0);
+ int numBytes = GetRegionData(rgn, 0, 0);
if (numBytes == 0)
- return QVector<QRect>();
+ return QRegion();
char *buf = new char[numBytes];
if (buf == 0)
- return QVector<QRect>();
+ return QRegion();
RGNDATA *rd = reinterpret_cast<RGNDATA*>(buf);
- if (GetRegionData(d->rgn, numBytes, rd) == 0) {
+ if (GetRegionData(rgn, numBytes, rd) == 0) {
delete [] buf;
- return QVector<QRect>();
+ return QRegion();
}
- QVector<QRect> a(rd->rdh.nCount);
+ QRegion region;
RECT *r = reinterpret_cast<RECT*>(rd->Buffer);
- for (int i = 0; i < a.size(); ++i) {
- a[i].setCoords(r->left, r->top, r->right - 1, r->bottom - 1);
+ for (int i = 0; i < rd->rdh.nCount; ++i) {
+ QRect rect;
+ rect.setCoords(r->left, r->top, r->right - 1, r->bottom - 1);
++r;
+ region |= rect;
}
delete [] buf;
- return a;
-}
-
-void QRegion::setRects(const QRect *rects, int num)
-{
- *this = QRegion();
- if (!rects || num == 0 || (num == 1 && rects->isEmpty()))
- return;
- for (int i = 0; i < num; ++i)
- *this |= rects[i];
-}
-
-int QRegion::numRects() const
-{
- if (d->rgn == 0)
- return 0;
-
- const int numBytes = GetRegionData(d->rgn, 0, 0);
- if (numBytes == 0)
- return 0;
-
- char *buf = new char[numBytes];
- if (buf == 0)
- return 0;
-
- RGNDATA *rd = reinterpret_cast<RGNDATA*>(buf);
- if (GetRegionData(d->rgn, numBytes, rd) == 0) {
- delete[] buf;
- return 0;
- }
-
- const int n = rd->rdh.nCount;
- delete[] buf;
- return n;
+ return region;
}
-bool QRegion::operator==(const QRegion &r) const
+void qt_win_dispose_rgn(HRGN r)
{
- if (d == r.d)
- return true;
- if ((d->rgn == 0) ^ (r.d->rgn == 0)) // one is empty, not both
- return false;
- return d->rgn == 0 ? true // both empty
- : EqualRgn(d->rgn, r.d->rgn); // both non-empty
+ if (r)
+ DeleteObject(r);
}
-QRegion& QRegion::operator+=(const QRegion &r)
+static void qt_add_rect(HRGN &winRegion, QRect r)
{
- if (!r.d->rgn)
- return *this;
-
- if (!d->rgn) {
- *this = r;
- return *this;
+ HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
+ if (rgn) {
+ HRGN dest = CreateRectRgn(0,0,0,0);
+ int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
+ if (result) {
+ DeleteObject(winRegion);
+ winRegion = dest;
+ }
+ DeleteObject(rgn);
}
-
- detach();
-
- int result;
- result = CombineRgn(d->rgn, d->rgn, r.d->rgn, RGN_OR);
- if (result == NULLREGION || result == ERROR)
- *this = QRegion();
-
- return *this;
-}
-
-QRegion& QRegion::operator-=(const QRegion &r)
-{
- if (!r.d->rgn || !d->rgn)
- return *this;
-
- detach();
-
- int result;
- result = CombineRgn(d->rgn, d->rgn, r.d->rgn, RGN_DIFF);
- if (result == NULLREGION || result == ERROR)
- *this = QRegion();
-
- return *this;
}
-QRegion& QRegion::operator&=(const QRegion &r)
+void QRegion::ensureHandle() const
{
- if (!d->rgn)
- return *this;
-
- if (!r.d->rgn) {
- *this = QRegion();
- return *this;
+ if (d->rgn)
+ DeleteObject(d->rgn);
+ d->rgn = CreateRectRgn(0,0,0,0);
+ if (d->qt_rgn) {
+ if (d->qt_rgn->numRects == 1) {
+ QRect r = d->qt_rgn->extents;
+ qt_add_rect(d->rgn, r);
+ return;
+ }
+ for (int i = 0;i < d->qt_rgn->numRects;i++) {
+ QRect r = d->qt_rgn->rects.at(i);
+ qt_add_rect(d->rgn, r);
+ }
}
-
- detach();
-
- int result;
- result = CombineRgn(d->rgn, d->rgn, r.d->rgn, RGN_AND);
- if (result == NULLREGION || result == ERROR)
- *this = QRegion();
-
- return *this;
-}
-
-bool qt_region_strictContains(const QRegion &region, const QRect &rect)
-{
- Q_UNUSED(region);
- Q_UNUSED(rect);
- return false;
}
-void QRegion::ensureHandle() const
-{
-}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp
index d8b0d9e..95f6ce3 100644
--- a/src/gui/painting/qwindowsurface_x11.cpp
+++ b/src/gui/painting/qwindowsurface_x11.cpp
@@ -154,7 +154,7 @@ void QX11WindowSurface::setGeometry(const QRect &rect)
QX11PixmapData *oldData = static_cast<QX11PixmapData *>(d_ptr->device.pixmapData());
Q_ASSERT(oldData);
- if (!oldData->uninit && hasStaticContents()) {
+ if (!(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) {
// Copy the content of the old pixmap into the new one.
QX11PixmapData *newData = new QX11PixmapData(QPixmapData::PixmapType);
newData->resize(size.width(), size.height());
@@ -175,7 +175,7 @@ void QX11WindowSurface::setGeometry(const QRect &rect)
dx, dy, qMin(boundingRect.width(), size.width()),
qMin(boundingRect.height(), size.height()), dx, dy);
XFreeGC(X11->display, tmpGc);
- newData->uninit = false;
+ newData->flags &= ~QX11PixmapData::Uninitialized;
d_ptr->device = QPixmap(newData);
} else {
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 9560c4b..ad87354 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -134,6 +134,7 @@ static const int windowsRightBorder = 12; // right border on windows
// External function calls
extern Q_GUI_EXPORT HDC qt_win_display_dc();
+extern QRegion qt_region_from_HRGN(HRGN rgn);
@@ -445,6 +446,7 @@ bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData)
themeData.stateId);
}
+
/*! \internal
Returns a QRegion of the region of the part
*/
@@ -456,12 +458,18 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
themeData.stateId, &rect, &hRgn)))
return QRegion();
- QRegion rgn = QRegion(0,0,1,1);
- const bool success = CombineRgn(rgn.handle(), hRgn, 0, RGN_COPY) != ERROR;
- DeleteObject(hRgn);
+ HRGN dest = CreateRectRgn(0, 0, 0, 0);
+ const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR;
+
+ QRegion region;
+
if (success)
- return rgn;
- return QRegion();
+ region = qt_region_from_HRGN(dest);
+
+ DeleteObject(hRgn);
+ DeleteObject(dest);
+
+ return region;
}
/*! \internal
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index a0b6f0c..d210cb4 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1378,8 +1378,8 @@ bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, G
FT_Face face = 0;
for (int i = 0; i < num_glyphs; ++i) {
- if (!gs->glyph_data.contains(glyphs[i])
- || gs->glyph_data.value(glyphs[i])->format != format) {
+ Glyph *glyph = gs->glyph_data.value(glyphs[i]);
+ if (glyph == 0 || glyph->format != format) {
if (!face) {
face = lockFace();
FT_Matrix m = matrix;
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index bf1fa6a..a0a3756 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -824,6 +824,9 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)
Q_Q(QCompleter);
QString completion;
+ if (!(index.flags() & Qt::ItemIsEnabled))
+ return;
+
if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
completion = prefix;
} else {
@@ -1102,7 +1105,8 @@ void QCompleter::setPopup(QAbstractItemView *popup)
QObject::connect(popup, SIGNAL(clicked(QModelIndex)),
this, SLOT(_q_complete(QModelIndex)));
- QObject::connect(popup, SIGNAL(clicked(QModelIndex)), popup, SLOT(hide()));
+ QObject::connect(this, SIGNAL(activated(QModelIndex)),
+ popup, SLOT(hide()));
QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(_q_completionSelected(QItemSelection)));
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index a3964f7..4a900d6 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -716,7 +716,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
application examples} also provide menus using these classes.
\sa QMenu, QShortcut, QAction,
- {http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html}{Introduction to Apple Human Interface Guidelines},
+ {http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIntro/XHIGIntro.html}{Introduction to Apple Human Interface Guidelines},
{fowler}{GUI Design Handbook: Menu Bar}, {Menus Example}
*/
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index f6bfcbe..48d09ce 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -86,6 +86,7 @@
#include <private/qpixmapdata_gl_p.h>
#include <private/qglpixelbuffer_p.h>
#include <private/qwindowsurface_gl_p.h>
+#include <private/qimagepixmapcleanuphooks_p.h>
#include "qcolormap.h"
#include "qfile.h"
#include "qlibrary.h"
@@ -1407,15 +1408,17 @@ QGLTextureCache::QGLTextureCache()
{
Q_ASSERT(qt_gl_texture_cache == 0);
qt_gl_texture_cache = this;
- qt_pixmap_cleanup_hook_64 = cleanupHook;
- qt_image_cleanup_hook_64 = cleanupHook;
+
+ QImagePixmapCleanupHooks::instance()->addPixmapHook(pixmapCleanupHook);
+ QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook);
}
QGLTextureCache::~QGLTextureCache()
{
qt_gl_texture_cache = 0;
- qt_pixmap_cleanup_hook_64 = 0;
- qt_image_cleanup_hook_64 = 0;
+
+ QImagePixmapCleanupHooks::instance()->removePixmapHook(pixmapCleanupHook);
+ QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook);
}
void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost)
@@ -1471,7 +1474,7 @@ QGLTextureCache* QGLTextureCache::instance()
a hook that removes textures from the cache when a pixmap/image
is deref'ed
*/
-void QGLTextureCache::cleanupHook(qint64 cacheKey)
+void QGLTextureCache::imageCleanupHook(qint64 cacheKey)
{
// ### remove when the GL texture cache becomes thread-safe
if (qApp->thread() != QThread::currentThread())
@@ -1481,6 +1484,24 @@ void QGLTextureCache::cleanupHook(qint64 cacheKey)
instance()->remove(cacheKey);
}
+
+void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap)
+{
+ // ### remove when the GL texture cache becomes thread-safe
+ if (qApp->thread() == QThread::currentThread()) {
+ const qint64 cacheKey = pixmap->cacheKey();
+ QGLTexture *texture = instance()->getTexture(cacheKey);
+ if (texture && texture->clean)
+ instance()->remove(cacheKey);
+ }
+#if defined(Q_WS_X11)
+ QPixmapData *pd = pixmap->data_ptr();
+ // Only need to delete the gl surface if the pixmap is about to be deleted
+ if (pd->ref == 0)
+ QGLContextPrivate::destroyGlSurfaceForPixmap(pd);
+#endif
+}
+
void QGLTextureCache::deleteIfEmpty()
{
if (instance()->size() == 0)
@@ -2021,11 +2042,11 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
#if defined(Q_WS_X11)
// Try to use texture_from_pixmap
if (pd->classId() == QPixmapData::X11Class) {
- QPixmap *thatPixmap = const_cast<QPixmap*>(&pixmap);
- texture = bindTextureFromNativePixmap(thatPixmap, key, canInvert);
+ texture = bindTextureFromNativePixmap(pd, key, canInvert);
if (texture) {
texture->clean = clean;
- boundPixmaps.insert(thatPixmap->data_ptr(), QPixmap(pixmap));
+ texture->boundPixmap = pd;
+ boundPixmaps.insert(pd, QPixmap(pixmap));
}
}
#endif
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 85dae0d..f21ab93 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -241,7 +241,9 @@ public:
quint32 gpm;
int screen;
QHash<QPixmapData*, QPixmap> boundPixmaps;
- QGLTexture *bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool internal);
+ QGLTexture *bindTextureFromNativePixmap(QPixmapData*, const qint64 key, bool canInvert);
+ static void destroyGlSurfaceForPixmap(QPixmapData*);
+ static void unbindPixmapFromTexture(QPixmapData*);
#endif
#if defined(Q_WS_MAC)
bool update;
@@ -423,7 +425,8 @@ public:
// is a current context - the context the pixmap was bound to a texture in.
// Otherwise the release doesn't do anything and you get BadDrawable errors
// when you come to delete the context.
- deleteBoundPixmap();
+ if (boundPixmap)
+ QGLContextPrivate::unbindPixmapFromTexture(boundPixmap);
#endif
glDeleteTextures(1, &id);
if (switch_context && current)
@@ -437,9 +440,9 @@ public:
bool clean;
bool yInverted; // NOTE: Y-Inverted textures are for internal use only!
#if defined(Q_WS_X11)
- Qt::HANDLE boundPixmap;
- void deleteBoundPixmap(); // in qgl_x11.cpp/qgl_x11egl.cpp
+ QPixmapData* boundPixmap;
#endif
+
};
class QGLTextureCache {
@@ -458,7 +461,8 @@ public:
static QGLTextureCache *instance();
static void deleteIfEmpty();
- static void cleanupHook(qint64 cacheKey);
+ static void imageCleanupHook(qint64 cacheKey);
+ static void pixmapCleanupHook(QPixmap* pixmap);
private:
QCache<qint64, QGLTexture> m_cache;
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index cf70991..4509a64 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -58,11 +58,16 @@
#include <private/qglpixelbuffer_p.h>
#endif
+// We always define GLX_EXT_texture_from_pixmap ourselves because
+// we can't trust system headers to do it properly
+#define GLX_EXT_texture_from_pixmap 1
+
#define INT8 dummy_INT8
#define INT32 dummy_INT32
#include <GL/glx.h>
#undef INT8
#undef INT32
+
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
@@ -90,7 +95,7 @@ extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
#define GLX_SAMPLES_ARB 100001
#endif
-#ifndef GLX_EXT_texture_from_pixmap
+#ifndef GLX_TEXTURE_2D_BIT_EXT
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
@@ -1548,38 +1553,26 @@ void QGLExtensions::init()
}
}
-#if !defined(glXBindTexImageEXT)
+// Solaris defines glXBindTexImageEXT as part of the GL library
+#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
typedef void (*qt_glXBindTexImageEXT)(Display*, GLXDrawable, int, const int*);
-static qt_glXBindTexImageEXT glXBindTexImageEXT = 0;
-#endif
-#if !defined(glXReleaseTexImageEXT)
typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int);
+static qt_glXBindTexImageEXT glXBindTexImageEXT = 0;
static qt_glXReleaseTexImageEXT glXReleaseTexImageEXT = 0;
-#endif
-static bool qt_resolved_texture_from_pixmap = false;
-QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool canInvert)
+bool qt_resolveTextureFromPixmap()
{
-#if !defined(Q_OS_LINUX)
- return 0;
-#else
- Q_Q(QGLContext);
-
- if (pm->data_ptr()->classId() != QPixmapData::X11Class)
- return 0;
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pm->data_ptr());
- const QX11Info *x11Info = qt_x11Info(pm);
+ static bool resolvedTextureFromPixmap = false;
+ if (!resolvedTextureFromPixmap) {
+ resolvedTextureFromPixmap = true;
- // Check to see if we have NPOT texture support
- // TODO: Use GLX_TEXTURE_RECTANGLE_EXT texture target on systems without npot textures
- if ( !(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures) &&
- !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0))
- return 0;
-
-
- if (!qt_resolved_texture_from_pixmap) {
- qt_resolved_texture_from_pixmap = true;
+ // Check to see if we have NPOT texture support
+ if ( !(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures) &&
+ !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0))
+ {
+ return false; // Can't use TFP without NPOT
+ }
QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS));
if (glxExt.contains(QLatin1String("GLX_EXT_texture_from_pixmap"))) {
@@ -1601,81 +1594,139 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qi
}
}
- if (!glXBindTexImageEXT)
- return 0;
+ return glXBindTexImageEXT && glXReleaseTexImageEXT;
+}
+#endif //defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
+
+QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, const qint64 key, bool canInvert)
+{
#if !defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX)
return 0;
#else
- GLXFBConfig *configList = 0;
- GLXFBConfig glxPixmapConfig;
- int configCount = 0;
- bool hasAlpha = pixmapData->hasAlphaChannel();
-
- int configAttribs[] = {
- hasAlpha ? GLX_BIND_TO_TEXTURE_RGBA_EXT : GLX_BIND_TO_TEXTURE_RGB_EXT, True,
- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
- GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
- // QGLContext::bindTexture() can't return an inverted texture, but QPainter::drawPixmap() can:
- GLX_Y_INVERTED_EXT, canInvert ? GLX_DONT_CARE : False,
- XNone
-// GLX_BIND_TO_MIPMAP_TEXTURE_EXT, False,
-// GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_1D_BIT_EXT or GLX_TEXTURE_2D_BIT_EXT or GLX_TEXTURE_RECTANGLE_BIT_EXT
- };
- configList = glXChooseFBConfig(x11Info->display(), x11Info->screen(), configAttribs, &configCount);
- if (!configList)
- return 0;
- glxPixmapConfig = configList[0];
- XFree(configList);
-
- GLXPixmap glxPixmap;
- int pixmapAttribs[] = {
- GLX_TEXTURE_FORMAT_EXT, hasAlpha ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT,
- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
- GLX_MIPMAP_TEXTURE_EXT, False,
- XNone
-// GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT or GLX_TEXTURE_FORMAT_RGB_EXT or GLX_TEXTURE_FORMAT_NONE_EXT,
-// GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT or GLX_TEXTURE_RECTANGLE_EXT,
-// GLX_MIPMAP_TEXTURE_EXT, True or False,
- };
+ Q_Q(QGLContext);
- // Wrap the X Pixmap into a GLXPixmap:
- glxPixmap = glXCreatePixmap(x11Info->display(), glxPixmapConfig, pixmapData->handle(), pixmapAttribs);
+ Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- if (!glxPixmap)
+ if (!qt_resolveTextureFromPixmap())
return 0;
- int yInverted;
- glXGetFBConfigAttrib(x11Info->display(), glxPixmapConfig, GLX_Y_INVERTED_EXT, &yInverted);
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
+ const QX11Info &x11Info = pixmapData->xinfo;
+
+ // Store the configs (Can be static because configs aren't dependent on current context)
+ static GLXFBConfig glxRGBPixmapConfig = 0;
+ static bool RGBConfigInverted = false;
+ static GLXFBConfig glxRGBAPixmapConfig = 0;
+ static bool RGBAConfigInverted = false;
+
+ bool hasAlpha = pixmapData->hasAlphaChannel();
+
+ // Check to see if we need a config
+ if ( (hasAlpha && !glxRGBAPixmapConfig) || (!hasAlpha && !glxRGBPixmapConfig) ) {
+ GLXFBConfig *configList = 0;
+ int configCount = 0;
+
+ int configAttribs[] = {
+ hasAlpha ? GLX_BIND_TO_TEXTURE_RGBA_EXT : GLX_BIND_TO_TEXTURE_RGB_EXT, True,
+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
+ GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
+ // QGLContext::bindTexture() can't return an inverted texture, but QPainter::drawPixmap() can:
+ GLX_Y_INVERTED_EXT, canInvert ? GLX_DONT_CARE : False,
+ XNone
+ };
+ configList = glXChooseFBConfig(x11Info.display(), x11Info.screen(), configAttribs, &configCount);
+ if (!configList)
+ return 0;
+
+ int yInv;
+ glXGetFBConfigAttrib(x11Info.display(), configList[0], GLX_Y_INVERTED_EXT, &yInv);
+
+ if (hasAlpha) {
+ glxRGBAPixmapConfig = configList[0];
+ RGBAConfigInverted = yInv;
+ }
+ else {
+ glxRGBPixmapConfig = configList[0];
+ RGBConfigInverted = yInv;
+ }
+
+ XFree(configList);
+ }
+
+ // Check to see if the surface is still valid
+ if (pixmapData->gl_surface &&
+ hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
+ {
+ // Surface is invalid!
+ destroyGlSurfaceForPixmap(pixmapData);
+ }
+
+ // Check to see if we need a surface
+ if (!pixmapData->gl_surface) {
+ GLXPixmap glxPixmap;
+ int pixmapAttribs[] = {
+ GLX_TEXTURE_FORMAT_EXT, hasAlpha ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT,
+ GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
+ GLX_MIPMAP_TEXTURE_EXT, False, // Maybe needs to be don't care
+ XNone
+ };
+
+ // Wrap the X Pixmap into a GLXPixmap:
+ glxPixmap = glXCreatePixmap(x11Info.display(),
+ hasAlpha ? glxRGBAPixmapConfig : glxRGBPixmapConfig,
+ pixmapData->handle(), pixmapAttribs);
+
+ if (!glxPixmap)
+ return 0;
+
+ pixmapData->gl_surface = (Qt::HANDLE)glxPixmap;
+
+ // Make sure the cleanup hook gets called so we can delete the glx pixmap
+ pixmapData->is_cached = true;
+ }
GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
- glXBindTexImageEXT(x11Info->display(), glxPixmap, GLX_FRONT_LEFT_EXT, 0);
+ glXBindTexImageEXT(x11Info.display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT, 0);
glBindTexture(GL_TEXTURE_2D, textureId);
- QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, yInverted);
- texture->boundPixmap = glxPixmap;
+ QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, false);
+ texture->yInverted = (hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted);
+ if (texture->yInverted)
+ pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture;
// We assume the cost of bound pixmaps is zero
QGLTextureCache::instance()->insert(q, key, texture, 0);
return texture;
#endif //!defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX)
-#endif //!defined(Q_OS_LINUX
}
-void QGLTexture::deleteBoundPixmap()
+
+void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd)
{
-#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && defined(Q_OS_LINUX)
- if (boundPixmap) {
- glXReleaseTexImageEXT(QX11Info::display(), boundPixmap, GLX_FRONT_LEFT_EXT);
- glXDestroyPixmap(QX11Info::display(), boundPixmap);
- boundPixmap = 0;
+#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
+ Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
+ if (pixmapData->gl_surface) {
+ glXDestroyPixmap(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface);
+ pixmapData->gl_surface = 0;
}
#endif
}
+void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd)
+{
+#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
+ Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
+ Q_ASSERT(QGLContext::currentContext());
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
+ if (pixmapData->gl_surface)
+ glXReleaseTexImageEXT(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT);
+#endif
+}
QT_END_NAMESPACE
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index c6904fe..5ab3647 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -41,15 +41,16 @@
#include "qgl.h"
#include <private/qt_x11_p.h>
+#include <private/qpixmap_x11_p.h>
#include <private/qgl_p.h>
#include <private/qpaintengine_opengl_p.h>
#include "qgl_egl_p.h"
#include "qcolormap.h"
+#include <QDebug>
QT_BEGIN_NAMESPACE
-
bool QGLFormat::hasOpenGL()
{
return true;
@@ -486,15 +487,175 @@ void QGLWidgetPrivate::recreateEglSurface(bool force)
}
}
-QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool canInvert)
+
+QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, const qint64 key, bool canInvert)
{
- // TODO
- return 0;
+ Q_Q(QGLContext);
+
+ Q_ASSERT(pd->classId() == QPixmapData::X11Class);
+
+ static bool checkedForTFP = false;
+ static bool haveTFP = false;
+
+ if (!checkedForTFP) {
+ // Check for texture_from_pixmap egl extension
+ checkedForTFP = true;
+ if (eglContext->hasExtension("EGL_NOKIA_texture_from_pixmap") ||
+ eglContext->hasExtension("EGL_EXT_texture_from_pixmap"))
+ {
+ qDebug("Found texture_from_pixmap EGL extension!");
+ haveTFP = true;
+ }
+ }
+
+ if (!haveTFP)
+ return 0;
+
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pd);
+
+ bool hasAlpha = pixmapData->hasAlphaChannel();
+
+ // Check to see if the surface is still valid
+ if (pixmapData->gl_surface &&
+ hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
+ {
+ // Surface is invalid!
+ destroyGlSurfaceForPixmap(pixmapData);
+ }
+
+ EGLint pixmapAttribs[] = {
+ EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
+ EGL_TEXTURE_FORMAT, hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB,
+ EGL_NONE
+ };
+ Q_ASSERT(sizeof(Qt::HANDLE) >= sizeof(EGLSurface)); // Just to make totally sure!
+ if (pixmapData->gl_surface == 0)
+ pixmapData->gl_surface = (Qt::HANDLE)EGL_NO_SURFACE;
+ EGLSurface pixmapSurface = (EGLSurface)pixmapData->gl_surface;
+ static EGLConfig pixmapRGBConfig = 0;
+ static EGLConfig pixmapRGBAConfig = 0;
+
+ // Check to see if we need to find a config
+ if ((hasAlpha && !pixmapRGBAConfig) || (!hasAlpha && !pixmapRGBConfig) ) {
+ const EGLint configAttribs[] = {
+ EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_DEPTH_SIZE, 0,
+ hasAlpha ? EGL_BIND_TO_TEXTURE_RGBA : EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
+ EGL_NONE
+ };
+
+ EGLint configCount = 0;
+ eglChooseConfig(eglContext->display(), configAttribs, 0, 256, &configCount);
+ if (configCount == 0) {
+ haveTFP = false;
+ qWarning("bindTextureFromNativePixmap() - Couldn't find a suitable config");
+ return 0;
+ }
+
+ EGLConfig *configList = new EGLConfig[configCount];
+ eglChooseConfig(eglContext->display(), configAttribs, configList, configCount, &configCount);
+ Q_ASSERT(configCount);
+
+ // Try to create a pixmap surface for each config until one works
+ for (int i = 0; i < configCount; ++i) {
+ pixmapSurface = eglCreatePixmapSurface(eglContext->display(), configList[i],
+ (EGLNativePixmapType) pixmapData->handle(),
+ pixmapAttribs);
+ if (pixmapSurface != EGL_NO_SURFACE) {
+ // Got one!
+ qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB")
+ << "config (" << int(configList[i]) << ") to create a pixmap surface";
+ if (hasAlpha)
+ pixmapRGBAConfig = configList[i];
+ else
+ pixmapRGBConfig = configList[i];
+ pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface;
+ break;
+ }
+ }
+ delete configList;
+
+ if ((hasAlpha && !pixmapRGBAConfig) || (!hasAlpha && !pixmapRGBConfig) ) {
+ qDebug("Couldn't create a pixmap surface with any of the provided configs");
+ haveTFP = false;
+ return 0;
+ }
+ }
+
+ if (pixmapSurface == EGL_NO_SURFACE) {
+ pixmapSurface = eglCreatePixmapSurface(eglContext->display(),
+ hasAlpha? pixmapRGBAConfig : pixmapRGBConfig,
+ (EGLNativePixmapType) pixmapData->handle(),
+ pixmapAttribs);
+ if (pixmapSurface == EGL_NO_SURFACE) {
+ qWarning("Failed to create a pixmap surface using config %d",
+ (int)(hasAlpha? pixmapRGBAConfig : pixmapRGBConfig));
+ haveTFP = false;
+ return 0;
+ }
+ pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface;
+ }
+
+ // Make sure the cleanup hook gets called so we can delete the glx pixmap
+ pixmapData->is_cached = true;
+ Q_ASSERT(pixmapData->gl_surface);
+
+ GLuint textureId;
+ glGenTextures(1, &textureId);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+
+ // bind the egl pixmap surface to a texture
+ EGLBoolean success;
+ success = eglBindTexImage(eglContext->display(), pixmapSurface, EGL_BACK_BUFFER);
+ if (success == EGL_FALSE) {
+ qWarning() << "eglBindTexImage() failed:" << eglContext->errorString(eglGetError());
+ eglDestroySurface(eglContext->display(), pixmapSurface);
+ pixmapData->gl_surface = (Qt::HANDLE)EGL_NO_SURFACE;
+ haveTFP = false;
+ return 0;
+ }
+
+ QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, true);
+ pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture;
+
+ // We assume the cost of bound pixmaps is zero
+ QGLTextureCache::instance()->insert(q, key, texture, 0);
+
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ return texture;
}
-void QGLTexture::deleteBoundPixmap()
+void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd)
{
- //TODO
+ Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
+ if (pixmapData->gl_surface) {
+ EGLBoolean success;
+ success = eglDestroySurface(QEglContext::defaultDisplay(0), (EGLSurface)pixmapData->gl_surface);
+ if (success == EGL_FALSE) {
+ qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: "
+ << QEglContext::errorString(eglGetError());
+ }
+ pixmapData->gl_surface = 0;
+ }
+}
+
+void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd)
+{
+ Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
+ if (pixmapData->gl_surface) {
+ EGLBoolean success;
+ success = eglReleaseTexImage(QEglContext::defaultDisplay(0),
+ (EGLSurface)pixmapData->gl_surface,
+ EGL_BACK_BUFFER);
+ if (success == EGL_FALSE) {
+ qWarning() << "unbindPixmapFromTexture() - Unable to release bound texture: "
+ << QEglContext::errorString(eglGetError());
+ }
+ }
}
QT_END_NAMESPACE
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index b264ac0..2ed890b 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -53,6 +53,7 @@
#include <qmath.h>
#include <private/qpixmapdata_p.h>
#include <private/qpixmap_raster_p.h>
+#include <private/qimagepixmapcleanuphooks_p.h>
class SurfaceCache;
class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate
@@ -699,9 +700,7 @@ void QDirectFBPaintEngine::initImageCache(int size)
{
Q_ASSERT(size >= 0);
imageCache.setMaxCost(size);
- typedef void (*_qt_image_cleanup_hook_64)(qint64);
- extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64;
- qt_image_cleanup_hook_64 = ::cachedImageCleanupHook;
+ QImagePixmapCleanupHooks::instance()->addImageHook(cachedImageCleanupHook);
}
#endif // QT_DIRECTFB_IMAGECACHE
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index e09f382..2be7559 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -266,21 +266,23 @@ void QSvgRect::draw(QPainter *p, QSvgExtraStates &states)
}
}
+QSvgTspan * const QSvgText::LINEBREAK = 0;
+
QSvgText::QSvgText(QSvgNode *parent, const QPointF &coord)
: QSvgNode(parent)
, m_coord(coord)
- , m_textAlignment(Qt::AlignLeft)
- , m_scale(1)
- , m_appendSpace(false)
, m_type(TEXT)
, m_size(0, 0)
+ , m_mode(Default)
{
- m_paragraphs.push_back(QString());
- m_formatRanges.push_back(QList<QTextLayout::FormatRange>());
}
QSvgText::~QSvgText()
{
+ for (int i = 0; i < m_tspans.size(); ++i) {
+ if (m_tspans[i] != LINEBREAK)
+ delete m_tspans[i];
+ }
}
void QSvgText::setTextArea(const QSizeF &size)
@@ -295,175 +297,173 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
{
applyStyle(p, states);
- QSvgFontStyle *fontStyle = static_cast<QSvgFontStyle*>(
- styleProperty(QSvgStyleProperty::FONT));
- if (fontStyle && fontStyle->svgFont()) {
- // SVG fonts not fully supported...
- QString text = m_paragraphs.front();
- for (int i = 1; i < m_paragraphs.size(); ++i) {
- text.append(QLatin1Char('\n'));
- text.append(m_paragraphs[i]);
- }
- fontStyle->svgFont()->draw(p, m_coord, text, fontStyle->pointSize(), m_textAlignment);
- revertStyle(p, states);
- return;
- }
+ // Force the font to have a size of 100 pixels to avoid truncation problems
+ // when the font is very small.
+ qreal scale = 100.0 / p->font().pointSizeF();
+ Qt::Alignment alignment = states.textAnchor;
- // Scale the font to its correct size.
QTransform oldTransform = p->worldTransform();
- p->scale(1 / m_scale, 1 / m_scale);
+ p->scale(1 / scale, 1 / scale);
qreal y = 0;
bool initial = true;
- qreal px = m_coord.x() * m_scale;
- qreal py = m_coord.y() * m_scale;
- QSizeF scaledSize = m_size * m_scale;
+ qreal px = m_coord.x() * scale;
+ qreal py = m_coord.y() * scale;
+ QSizeF scaledSize = m_size * scale;
if (m_type == TEXTAREA) {
- if (m_textAlignment == Qt::AlignHCenter)
+ if (alignment == Qt::AlignHCenter)
px += scaledSize.width() / 2;
- else if (m_textAlignment == Qt::AlignRight)
+ else if (alignment == Qt::AlignRight)
px += scaledSize.width();
}
QRectF bounds;
if (m_size.height() != 0)
- bounds = QRectF(0, 0, 1, scaledSize.height());
-
- for (int i = 0; i < m_paragraphs.size(); ++i) {
- QTextLayout tl(m_paragraphs[i]);
- QTextOption op = tl.textOption();
- op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
- tl.setTextOption(op);
- tl.setAdditionalFormats(m_formatRanges[i]);
- tl.beginLayout();
- forever {
- QTextLine line = tl.createLine();
- if (!line.isValid())
- break;
-
- if (m_size.width() != 0)
- line.setLineWidth(scaledSize.width());
- }
- tl.endLayout();
-
- bool endOfBoundsReached = false;
- for (int i = 0; i < tl.lineCount(); ++i) {
- QTextLine line = tl.lineAt(i);
-
- qreal x = 0;
- if (m_textAlignment == Qt::AlignHCenter)
- x -= line.naturalTextWidth() / 2;
- else if (m_textAlignment == Qt::AlignRight)
- x -= line.naturalTextWidth();
-
- if (initial && m_type == TEXT)
- y -= line.ascent();
- initial = false;
-
- line.setPosition(QPointF(x, y));
- if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width())
- || (m_size.height() != 0 && y + line.height() > scaledSize.height())) {
- bounds.setHeight(y);
- endOfBoundsReached = true;
- break;
+ bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used.
+
+ bool appendSpace = false;
+ QVector<QString> paragraphs;
+ QStack<QTextCharFormat> formats;
+ QVector<QList<QTextLayout::FormatRange> > formatRanges;
+ paragraphs.push_back(QString());
+ formatRanges.push_back(QList<QTextLayout::FormatRange>());
+
+ for (int i = 0; i < m_tspans.size(); ++i) {
+ if (m_tspans[i] == LINEBREAK) {
+ if (m_type == TEXTAREA) {
+ if (paragraphs.back().isEmpty()) {
+ QFont font = p->font();
+ font.setPixelSize(font.pointSizeF() * scale);
+
+ QTextLayout::FormatRange range;
+ range.start = 0;
+ range.length = 1;
+ range.format.setFont(font);
+ formatRanges.back().append(range);
+
+ paragraphs.back().append(QLatin1Char(' '));;
+ }
+ appendSpace = false;
+ paragraphs.push_back(QString());
+ formatRanges.push_back(QList<QTextLayout::FormatRange>());
}
+ } else {
+ WhitespaceMode mode = m_tspans[i]->whitespaceMode();
+ m_tspans[i]->applyStyle(p, states);
- y += 1.1 * line.height();
- }
- tl.draw(p, QPointF(px, py), QVector<QTextLayout::FormatRange>(), bounds);
+ QFont font = p->font();
+ font.setPixelSize(font.pointSizeF() * scale);
- if (endOfBoundsReached)
- break;
- }
+ QString newText(m_tspans[i]->text());
+ newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
+ newText.replace(QLatin1Char('\n'), QLatin1Char(' '));
- p->setWorldTransform(oldTransform, false);
- revertStyle(p, states);
-}
+ bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
+ if (appendSpace || prependSpace)
+ paragraphs.back().append(QLatin1Char(' '));
-void QSvgText::insertText(const QString &text, WhitespaceMode mode)
-{
- bool isTSpan = (m_formats.count() == 2);
- QString newText(text);
- newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
- newText.replace(QLatin1Char('\n'), QLatin1Char(' '));
+ bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' ')));
- bool prependSpace = !m_appendSpace && !isTSpan && (mode == Default) && !m_paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
- if (m_appendSpace || prependSpace)
- m_paragraphs.back().append(QLatin1Char(' '));
+ if (mode == Default) {
+ newText = newText.simplified();
+ if (newText.isEmpty())
+ appendSpaceNext = false;
+ }
- bool appendSpaceNext = (!isTSpan && (mode == Default) && newText.endsWith(QLatin1Char(' ')));
+ QTextLayout::FormatRange range;
+ range.start = paragraphs.back().length();
+ range.length = newText.length();
+ range.format.setFont(font);
+ range.format.setTextOutline(p->pen());
+ range.format.setForeground(p->brush());
+
+ if (appendSpace) {
+ Q_ASSERT(!formatRanges.back().isEmpty());
+ ++formatRanges.back().back().length;
+ } else if (prependSpace) {
+ --range.start;
+ ++range.length;
+ }
+ formatRanges.back().append(range);
- if (mode == Default) {
- newText = newText.simplified();
- if (newText.isEmpty())
- appendSpaceNext = false;
- }
+ appendSpace = appendSpaceNext;
+ paragraphs.back() += newText;
- if (!m_formats.isEmpty()) {
- QTextLayout::FormatRange range;
- range.start = m_paragraphs.back().length();
- range.length = newText.length();
- range.format = m_formats.top();
- if (m_appendSpace) {
- Q_ASSERT(!m_formatRanges.back().isEmpty());
- ++m_formatRanges.back().back().length;
- } else if (prependSpace) {
- --range.start;
- ++range.length;
+ m_tspans[i]->revertStyle(p, states);
}
- m_formatRanges.back().append(range);
}
- m_appendSpace = appendSpaceNext;
- m_paragraphs.back() += newText;
-}
-
-void QSvgText::insertFormat(const QTextCharFormat &format)
-{
- QTextCharFormat mergedFormat = format;
- if (!m_formats.isEmpty()) {
- mergedFormat = m_formats.top();
- mergedFormat.merge(format);
- }
- m_formats.push(mergedFormat);
-}
+ if (states.svgFont) {
+ // SVG fonts not fully supported...
+ QString text = paragraphs.front();
+ for (int i = 1; i < paragraphs.size(); ++i) {
+ text.append(QLatin1Char('\n'));
+ text.append(paragraphs[i]);
+ }
+ states.svgFont->draw(p, m_coord, text, p->font().pointSizeF() * scale, states.textAnchor);
+ } else {
+ for (int i = 0; i < paragraphs.size(); ++i) {
+ QTextLayout tl(paragraphs[i]);
+ QTextOption op = tl.textOption();
+ op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
+ tl.setTextOption(op);
+ tl.setAdditionalFormats(formatRanges[i]);
+ tl.beginLayout();
+
+ forever {
+ QTextLine line = tl.createLine();
+ if (!line.isValid())
+ break;
+ if (m_size.width() != 0)
+ line.setLineWidth(scaledSize.width());
+ }
+ tl.endLayout();
+
+ bool endOfBoundsReached = false;
+ for (int i = 0; i < tl.lineCount(); ++i) {
+ QTextLine line = tl.lineAt(i);
+
+ qreal x = 0;
+ if (alignment == Qt::AlignHCenter)
+ x -= 0.5 * line.naturalTextWidth();
+ else if (alignment == Qt::AlignRight)
+ x -= line.naturalTextWidth();
+
+ if (initial && m_type == TEXT)
+ y -= line.ascent();
+ initial = false;
+
+ line.setPosition(QPointF(x, y));
+
+ // Check if the current line fits into the bounding rectangle.
+ if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width())
+ || (m_size.height() != 0 && y + line.height() > scaledSize.height())) {
+ // I need to set the bounds height to 'y-epsilon' to avoid drawing the current
+ // line. Since the font is scaled to 100 units, 1 should be a safe epsilon.
+ bounds.setHeight(y - 1);
+ endOfBoundsReached = true;
+ break;
+ }
+
+ y += 1.1 * line.height();
+ }
+ tl.draw(p, QPointF(px, py), QVector<QTextLayout::FormatRange>(), bounds);
-void QSvgText::insertLineBreak()
-{
- if (m_type == TEXTAREA) {
- if (m_paragraphs.back().isEmpty())
- insertText(QLatin1String(" "), Preserve);
- m_appendSpace = false;
- m_paragraphs.push_back(QString());
- m_formatRanges.push_back(QList<QTextLayout::FormatRange>());
+ if (endOfBoundsReached)
+ break;
+ }
}
-}
-void QSvgText::popFormat()
-{
- if (m_formats.count() > 1)
- m_formats.pop();
-}
-
-qreal QSvgText::scale() const
-{
- return m_scale;
-}
-
-void QSvgText::setScale(qreal scale)
-{
- m_scale = scale;
-}
-
-const QTextCharFormat &QSvgText::topFormat() const
-{
- return m_formats.top();
+ p->setWorldTransform(oldTransform, false);
+ revertStyle(p, states);
}
-void QSvgText::setTextAlignment(const Qt::Alignment &alignment)
+void QSvgText::addText(const QString &text)
{
- m_textAlignment = alignment;
+ m_tspans.append(new QSvgTspan(this, false));
+ m_tspans.back()->setWhitespaceMode(m_mode);
+ m_tspans.back()->addText(text);
}
QSvgUse::QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *node)
diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h
index 4a19c7e..345b90b 100644
--- a/src/svg/qsvggraphics_p.h
+++ b/src/svg/qsvggraphics_p.h
@@ -187,6 +187,8 @@ private:
int m_rx, m_ry;
};
+class QSvgTspan;
+
class QSvgText : public QSvgNode
{
public:
@@ -202,26 +204,47 @@ public:
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- void insertText(const QString &text, WhitespaceMode mode);
- void insertFormat(const QTextCharFormat &format);
- void insertLineBreak();
- void popFormat();
- void setTextAlignment(const Qt::Alignment &alignment);
- const QTextCharFormat &topFormat() const;
- qreal scale() const;
- void setScale(qreal scale);
+
+ void addTspan(QSvgTspan *tspan) {m_tspans.append(tspan);}
+ void addText(const QString &text);
+ void addLineBreak() {m_tspans.append(LINEBREAK);}
+ void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;}
+
//virtual QRectF bounds() const;
private:
+ static QSvgTspan * const LINEBREAK;
+
QPointF m_coord;
- QVector<QString> m_paragraphs;
- QStack<QTextCharFormat> m_formats;
- Qt::Alignment m_textAlignment;
- QVector<QList<QTextLayout::FormatRange> > m_formatRanges;
- qreal m_scale;
- bool m_appendSpace;
+ // 'm_tspans' is also used to store characters outside tspans and line breaks.
+ // If a 'm_tspan' item is null, it indicates a line break.
+ QVector<QSvgTspan *> m_tspans;
+
Type m_type;
QSizeF m_size;
+ WhitespaceMode m_mode;
+};
+
+class QSvgTspan : public QSvgNode
+{
+public:
+ // tspans are also used to store normal text, so the 'isProperTspan' is used to separate text from tspan.
+ QSvgTspan(QSvgNode *parent, bool isProperTspan = true)
+ : QSvgNode(parent), m_mode(QSvgText::Default), m_isTspan(isProperTspan)
+ {
+ }
+ ~QSvgTspan() { };
+ virtual Type type() const {return TSPAN;}
+ virtual void draw(QPainter *, QSvgExtraStates &) {Q_ASSERT(!"Tspans should be drawn through QSvgText::draw().");}
+ void addText(const QString &text) {m_text += text;}
+ const QString &text() const {return m_text;}
+ bool isTspan() const {return m_isTspan;}
+ void setWhitespaceMode(QSvgText::WhitespaceMode mode) {m_mode = mode;}
+ QSvgText::WhitespaceMode whitespaceMode() const {return m_mode;}
+private:
+ QString m_text;
+ QSvgText::WhitespaceMode m_mode;
+ bool m_isTspan;
};
class QSvgUse : public QSvgNode
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index f10b26f..73c8b01 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -70,6 +70,8 @@
QT_BEGIN_NAMESPACE
+static const char *qt_inherit_text = "inherit";
+#define QT_INHERIT QLatin1String(qt_inherit_text)
double qstrtod(const char *s00, char const **se, bool *ok);
@@ -492,7 +494,7 @@ static bool resolveColor(const QString &colorStr, QColor &color, QSvgHandler *ha
int(compo[2]));
return true;
} else if (colorStr == QLatin1String("inherited") ||
- colorStr == QLatin1String("inherit")) {
+ colorStr == QT_INHERIT) {
return false;
} else if (colorStr == QLatin1String("currentColor")) {
color = handler->currentColor();
@@ -646,138 +648,48 @@ static void parseBrush(QSvgNode *node,
QString opacity = attributes.value(QLatin1String("fill-opacity")).toString();
QString myId = someId(attributes);
- QSvgFillStyle *prop = new QSvgFillStyle(0);
+ if (!value.isEmpty() || !fillRule.isEmpty() || !opacity.isEmpty()) {
+ QSvgFillStyle *prop = new QSvgFillStyle(0);
- //fill-rule attribute handling
- if (!fillRule.isEmpty() && fillRule != QLatin1String("inherit")) {
- if (fillRule == QLatin1String("evenodd"))
- prop->setFillRule(Qt::OddEvenFill);
- else if (fillRule == QLatin1String("nonzero"))
- prop->setFillRule(Qt::WindingFill);
- }
-
- //fill-opacity atttribute handling
- if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) {
- prop->setFillOpacity(qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))));
- }
-
- //fill attribute handling
- if ((!value.isEmpty()) && (value != QLatin1String("inherit")) ) {
- if (value.startsWith(QLatin1String("url"))) {
- value = value.remove(0, 3);
- QSvgStyleProperty *style = styleFromUrl(node, value);
- if (style) {
- prop->setFillStyle(style);
- } else {
- QString id = idFromUrl(value);
- prop->setGradientId(id);
- prop->setGradientResolved(false);
- }
- } else if (value != QLatin1String("none")) {
- QColor color;
- if (resolveColor(value, color, handler))
- prop->setBrush(QBrush(color));
- } else {
- prop->setBrush(QBrush(Qt::NoBrush));
+ //fill-rule attribute handling
+ if (!fillRule.isEmpty() && fillRule != QT_INHERIT) {
+ if (fillRule == QLatin1String("evenodd"))
+ prop->setFillRule(Qt::OddEvenFill);
+ else if (fillRule == QLatin1String("nonzero"))
+ prop->setFillRule(Qt::WindingFill);
}
- }
- node->appendStyleProperty(prop,myId);
-}
-
-static void parseQPen(QPen &pen, QSvgNode *node,
- const QSvgAttributes &attributes,
- QSvgHandler *handler)
-{
- QString value = attributes.value(QLatin1String("stroke")).toString();
- QString dashArray = attributes.value(QLatin1String("stroke-dasharray")).toString();
- QString dashOffset = attributes.value(QLatin1String("stroke-dashoffset")).toString();
- QString linecap = attributes.value(QLatin1String("stroke-linecap")).toString();
- QString linejoin = attributes.value(QLatin1String("stroke-linejoin")).toString();
- QString miterlimit = attributes.value(QLatin1String("stroke-miterlimit")).toString();
- QString opacity = attributes.value(QLatin1String("stroke-opacity")).toString();
- QString width = attributes.value(QLatin1String("stroke-width")).toString();
- QString myId = someId(attributes);
+ //fill-opacity atttribute handling
+ if (!opacity.isEmpty() && opacity != QT_INHERIT) {
+ prop->setFillOpacity(qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))));
+ }
- if (!value.isEmpty() || !width.isEmpty()) {
- if (value != QLatin1String("none")) {
- if (!value.isEmpty()) {
- if (node && value.startsWith(QLatin1String("url"))) {
- value = value.remove(0, 3);
- QSvgStyleProperty *style = styleFromUrl(node, value);
- if (style) {
- if (style->type() == QSvgStyleProperty::GRADIENT) {
- QBrush b(*((QSvgGradientStyle*)style)->qgradient());
- pen.setBrush(b);
- } else if (style->type() == QSvgStyleProperty::SOLID_COLOR) {
- pen.setColor(
- ((QSvgSolidColorStyle*)style)->qcolor());
- }
- } else {
- qWarning()<<"QSvgHandler::parsePen could not resolve property" << idFromUrl(value);
- }
+ //fill attribute handling
+ if ((!value.isEmpty()) && (value != QT_INHERIT) ) {
+ if (value.startsWith(QLatin1String("url"))) {
+ value = value.remove(0, 3);
+ QSvgStyleProperty *style = styleFromUrl(node, value);
+ if (style) {
+ prop->setFillStyle(style);
} else {
- QColor color;
- if (constructColor(value, opacity, color, handler))
- pen.setColor(color);
+ QString id = idFromUrl(value);
+ prop->setGradientId(id);
+ prop->setGradientResolved(false);
}
- //since we could inherit stroke="none"
- //we need to reset the style of our stroke to something
- pen.setStyle(Qt::SolidLine);
- }
- if (!width.isEmpty()) {
- QSvgHandler::LengthType lt;
- qreal widthF = parseLength(width, lt, handler);
- //### fixme
- if (!widthF) {
- pen.setStyle(Qt::NoPen);
- return;
- }
- pen.setWidthF(widthF);
- }
- qreal penw = pen.widthF();
-
- if (!linejoin.isEmpty()) {
- if (linejoin == QLatin1String("miter"))
- pen.setJoinStyle(Qt::SvgMiterJoin);
- else if (linejoin == QLatin1String("round"))
- pen.setJoinStyle(Qt::RoundJoin);
- else if (linejoin == QLatin1String("bevel"))
- pen.setJoinStyle(Qt::BevelJoin);
- }
- if (!miterlimit.isEmpty())
- pen.setMiterLimit(toDouble(miterlimit));
-
- if (!linecap.isEmpty()) {
- if (linecap == QLatin1String("butt"))
- pen.setCapStyle(Qt::FlatCap);
- else if (linecap == QLatin1String("round"))
- pen.setCapStyle(Qt::RoundCap);
- else if (linecap == QLatin1String("square"))
- pen.setCapStyle(Qt::SquareCap);
- }
-
- if (!dashArray.isEmpty()) {
- const QChar *s = dashArray.constData();
- QVector<qreal> dashes = parseNumbersList(s);
- qreal *d = dashes.data();
- if (penw != 0)
- for (int i = 0; i < dashes.size(); ++i) {
- *d /= penw;
- ++d;
- }
- pen.setDashPattern(dashes);
- }
- if (!dashOffset.isEmpty()) {
- pen.setDashOffset(toDouble(dashOffset));
+ } else if (value != QLatin1String("none")) {
+ QColor color;
+ if (resolveColor(value, color, handler))
+ prop->setBrush(QBrush(color));
+ } else {
+ prop->setBrush(QBrush(Qt::NoBrush));
}
-
- } else {
- pen.setStyle(Qt::NoPen);
}
+ node->appendStyleProperty(prop, myId);
}
}
+
+
static QMatrix parseTransformationMatrix(const QString &value)
{
QMatrix matrix;
@@ -917,18 +829,15 @@ static void parsePen(QSvgNode *node,
QString miterlimit = attributes.value(QLatin1String("stroke-miterlimit")).toString();
QString opacity = attributes.value(QLatin1String("stroke-opacity")).toString();
QString width = attributes.value(QLatin1String("stroke-width")).toString();
+ QString vectorEffect = attributes.value(QLatin1String("vector-effect")).toString();
QString myId = someId(attributes);
//qDebug()<<"Node "<<node->type()<<", attrs are "<<value<<width;
- /* All the below checks needed because g (or any container element) can have only one of these attributes.
- * If it doesn't has any one of these, then processing below not needed */
-
if (!value.isEmpty() || !width.isEmpty() || !dashArray.isEmpty() || !linecap.isEmpty() ||
- !linejoin.isEmpty() || !miterlimit.isEmpty() || !opacity.isEmpty() || !dashOffset.isEmpty() ) {
- //if (value != QLatin1String("none")) {
- /* If stroke = "none" then also, we need to parse below, because elements like 'g' may
- have other defined stroke attributes, which will be inherited by its children */
+ !linejoin.isEmpty() || !miterlimit.isEmpty() || !opacity.isEmpty() ||
+ !dashOffset.isEmpty() || !vectorEffect.isEmpty()) {
+
QSvgStrokeStyle *inherited =
static_cast<QSvgStrokeStyle*>(node->parent()->styleProperty(
QSvgStyleProperty::STROKE));
@@ -942,14 +851,14 @@ static void parsePen(QSvgNode *node,
// stroke-opacity attribute handling
qreal strokeAlpha;
- if (!opacity.isEmpty() && opacity != QLatin1String("inherit")) {
+ if (!opacity.isEmpty() && opacity != QT_INHERIT) {
strokeAlpha = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity)));
} else {
strokeAlpha = pen.color().alphaF();
}
//stroke attribute handling
- if (!value.isEmpty() && value != QLatin1String("inherit")) {
+ if (!value.isEmpty() && value != QT_INHERIT) {
if (value.startsWith(QLatin1String("url"))) {
value = value.remove(0, 3);
QSvgStyleProperty *style = styleFromUrl(node, value);
@@ -961,8 +870,7 @@ static void parsePen(QSvgNode *node,
pen.setColor(
((QSvgSolidColorStyle*)style)->qcolor());
}
- pen.setStyle(Qt::SolidLine);
- stroke = true;
+ stroke = true;
} else {
qWarning() << "QSvgHandler::parsePen could not resolve property" << idFromUrl(value);
}
@@ -986,14 +894,11 @@ static void parsePen(QSvgNode *node,
}
//stroke-width handling
- if (!width.isEmpty() && width != QLatin1String("inherit")) {
+ if (!width.isEmpty() && width != QT_INHERIT) {
qreal widthF;
QSvgHandler::LengthType lt;
widthF = parseLength(width, lt, handler);
pen.setWidthF(widthF);
- } else if (inherited){
- qreal widthF = inherited->qpen().widthF();
- pen.setWidthF(widthF);
}
//stroke-linejoin attribute handling
@@ -1018,7 +923,7 @@ static void parsePen(QSvgNode *node,
//strok-dasharray attribute handling
qreal penw = pen.widthF();
- if (!dashArray.isEmpty() && dashArray != QLatin1String("inherit")) {
+ if (!dashArray.isEmpty() && dashArray != QT_INHERIT) {
const QChar *s = dashArray.constData();
QVector<qreal> dashes = parseNumbersList(s);
qreal *d = dashes.data();
@@ -1048,7 +953,7 @@ static void parsePen(QSvgNode *node,
//stroke-dashoffset attribute handling
- if (!dashOffset.isEmpty() && dashOffset != QLatin1String("inherit")) {
+ if (!dashOffset.isEmpty() && dashOffset != QT_INHERIT) {
qreal doffset = toDouble(dashOffset);
if (penw != 0)
doffset /= penw;
@@ -1064,7 +969,15 @@ static void parsePen(QSvgNode *node,
pen.setDashOffset(doffset);
}
- if (!miterlimit.isEmpty() && miterlimit != QLatin1String("inherit"))
+ //vector-effect attribute handling
+ if (!vectorEffect.isEmpty()) {
+ if (vectorEffect == QLatin1String("non-scaling-stroke"))
+ pen.setCosmetic(true);
+ else if (vectorEffect == QLatin1String("none"))
+ pen.setCosmetic(false);
+ }
+
+ if (!miterlimit.isEmpty() && miterlimit != QT_INHERIT)
pen.setMiterLimit(toDouble(miterlimit));
QSvgStrokeStyle *prop = new QSvgStrokeStyle(pen);
@@ -1073,182 +986,84 @@ static void parsePen(QSvgNode *node,
}
}
-
-static bool parseQBrush(const QSvgAttributes &attributes, QSvgNode *node,
- QBrush &brush, QSvgHandler *handler)
-{
- QString value = attributes.value(QLatin1String("fill")).toString();
- QString opacity = attributes.value(QLatin1String("fill-opacity")).toString();
-
- QColor color;
- if (!value.isEmpty() || !opacity.isEmpty()) {
- if (value.startsWith(QLatin1String("url"))) {
- value = value.remove(0, 3);
- QSvgStyleProperty *style = styleFromUrl(node, value);
- if (style) {
- switch (style->type()) {
- case QSvgStyleProperty::FILL:
- {
- brush = static_cast<QSvgFillStyle*>(style)->qbrush();
- break;
- }
- case QSvgStyleProperty::SOLID_COLOR:
- {
- brush = QBrush(static_cast<QSvgSolidColorStyle*>(style)->qcolor());
- break;
- }
- case QSvgStyleProperty::GRADIENT:
- {
- brush = QBrush(*static_cast<QSvgGradientStyle*>(style)->qgradient());
- break;
- }
- default:
- qWarning("Cannot use property \"%s\" as brush.", qPrintable(idFromUrl(value)));
- }
- } else {
- qWarning("Couldn't resolve property: %s", qPrintable(idFromUrl(value)));
- }
- } else if (value != QLatin1String("none")) {
- if (constructColor(value, opacity, color, handler)) {
- brush.setStyle(Qt::SolidPattern);
- brush.setColor(color);
- }
- } else {
- brush = QBrush(Qt::NoBrush);
- }
- return true;
- }
- return false;
-}
-
-static bool parseQFont(const QSvgAttributes &attributes,
- QFont &font, qreal &fontSize, QSvgHandler *handler)
+static void parseFont(QSvgNode *node,
+ const QSvgAttributes &attributes,
+ QSvgHandler *handler)
{
QString family = attributes.value(QLatin1String("font-family")).toString();
QString size = attributes.value(QLatin1String("font-size")).toString();
QString style = attributes.value(QLatin1String("font-style")).toString();
QString weight = attributes.value(QLatin1String("font-weight")).toString();
+ QString variant = attributes.value(QLatin1String("font-variant")).toString();
+ QString anchor = attributes.value(QLatin1String("text-anchor")).toString();
- if (!family.isEmpty() || !size.isEmpty() ||
- !style.isEmpty() || !weight.isEmpty()) {
+ if (family.isEmpty() && size.isEmpty() && style.isEmpty() && weight.isEmpty() && variant.isEmpty() && anchor.isEmpty())
+ return;
- if (!family.isEmpty()) {
- font.setFamily(family.trimmed());
- }
- if (!size.isEmpty()) {
- if (size == QLatin1String("inherit")) {
- //inherited already
- } else {
- QSvgHandler::LengthType dummy; // should always be pixel size
- fontSize = parseLength(size, dummy, handler);
- if (fontSize <= 0)
- fontSize = 1;
- }
- font.setPixelSize(qMax(1, int(fontSize)));
- }
- if (!style.isEmpty()) {
- if (style == QLatin1String("normal")) {
- font.setStyle(QFont::StyleNormal);
- } else if (style == QLatin1String("italic")) {
- font.setStyle(QFont::StyleItalic);
- } else if (style == QLatin1String("oblique")) {
- font.setStyle(QFont::StyleOblique);
- } else if (style == QLatin1String("inherit")) {
- //inherited already
- }
- }
- if (!weight.isEmpty()) {
- bool ok = false;
- int weightNum = weight.toInt(&ok);
- if (ok) {
- switch (weightNum) {
- case 100:
- case 200:
- font.setWeight(QFont::Light);
- break;
- case 300:
- case 400:
- font.setWeight(QFont::Normal);
- break;
- case 500:
- case 600:
- font.setWeight(QFont::DemiBold);
- break;
- case 700:
- case 800:
- font.setWeight(QFont::Bold);
- break;
- case 900:
- font.setWeight(QFont::Black);
- break;
- default:
- break;
- }
- } else {
- if (weight == QLatin1String("normal")) {
- font.setWeight(QFont::Normal);
- } else if (weight == QLatin1String("bold")) {
- font.setWeight(QFont::Bold);
- } else if (weight == QLatin1String("bolder")) {
- font.setWeight(QFont::DemiBold);
- } else if (weight == QLatin1String("lighter")) {
- font.setWeight(QFont::Light);
- }
- }
- }
- // QFontInfo fi(font);
- // font.setPointSize(fi.pointSize());
- return true;
+ QString id = someId(attributes);
+ QSvgTinyDocument *doc = node->document();
+ QSvgFontStyle *fontStyle = 0;
+ if (!family.isEmpty()) {
+ QSvgFont *svgFont = doc->svgFont(family);
+ if (svgFont)
+ fontStyle = new QSvgFontStyle(svgFont, doc);
}
+ if (!fontStyle)
+ fontStyle = new QSvgFontStyle;
- return false;
-}
+ if (!family.isEmpty() && family != QT_INHERIT)
+ fontStyle->setFamily(family.trimmed());
-static void parseFont(QSvgNode *node,
- const QSvgAttributes &attributes,
- QSvgHandler *handler)
-{
- QFont font;
- font.setPixelSize(12);
- qreal fontSize = font.pixelSize();
-
- QSvgFontStyle *inherited =
- static_cast<QSvgFontStyle*>(node->styleProperty(
- QSvgStyleProperty::FONT));
- if (!inherited)
- inherited =
- static_cast<QSvgFontStyle*>(node->parent()->styleProperty(
- QSvgStyleProperty::FONT));
- if (inherited) {
- font = inherited->qfont();
- fontSize = inherited->pointSize();
- }
- // group or any container element can have only text-anchor and should
- // be processed, because its children can inherit from it.
- // So checking for text-anchor before parseQfont()
- QString anchor = attributes.value(QLatin1String("text-anchor")).toString();
- if (parseQFont(attributes, font, fontSize, handler) || (!anchor.isEmpty())) {
- QString myId = someId(attributes);
- //QString anchor = attributes.value(QLatin1String("text-anchor")).toString();
- QSvgTinyDocument *doc = node->document();
- QSvgFontStyle *fontStyle = 0;
- QString family = (font.family().isEmpty())?myId:font.family();
- if (!family.isEmpty()) {
- QSvgFont *svgFont = doc->svgFont(family);
- if (svgFont) {
- fontStyle = new QSvgFontStyle(svgFont, doc);
- fontStyle->setPointSize(fontSize);
- }
+ if (!size.isEmpty() && size != QT_INHERIT) {
+ QSvgHandler::LengthType dummy; // should always be pixel size
+ fontStyle->setSize(parseLength(size, dummy, handler));
+ }
+
+ if (!style.isEmpty() && style != QT_INHERIT) {
+ if (style == QLatin1String("normal")) {
+ fontStyle->setStyle(QFont::StyleNormal);
+ } else if (style == QLatin1String("italic")) {
+ fontStyle->setStyle(QFont::StyleItalic);
+ } else if (style == QLatin1String("oblique")) {
+ fontStyle->setStyle(QFont::StyleOblique);
}
- if (!fontStyle) {
- fontStyle = new QSvgFontStyle(font, node->document());
- fontStyle->setPointSize(fontSize);
+ }
+
+ if (!weight.isEmpty() && weight != QT_INHERIT) {
+ bool ok = false;
+ int weightNum = weight.toInt(&ok);
+ if (ok) {
+ fontStyle->setWeight(weightNum);
+ } else {
+ if (weight == QLatin1String("normal")) {
+ fontStyle->setWeight(400);
+ } else if (weight == QLatin1String("bold")) {
+ fontStyle->setWeight(700);
+ } else if (weight == QLatin1String("bolder")) {
+ fontStyle->setWeight(QSvgFontStyle::BOLDER);
+ } else if (weight == QLatin1String("lighter")) {
+ fontStyle->setWeight(QSvgFontStyle::LIGHTER);
+ }
}
- if (!anchor.isEmpty())
- fontStyle->setTextAnchor(anchor);
+ }
- node->appendStyleProperty(fontStyle, myId);
+ if (!variant.isEmpty() && variant != QT_INHERIT) {
+ if (variant == QLatin1String("normal"))
+ fontStyle->setVariant(QFont::MixedCase);
+ else if (variant == QLatin1String("small-caps"))
+ fontStyle->setVariant(QFont::SmallCaps);
}
+
+ if (!anchor.isEmpty() && anchor != QT_INHERIT) {
+ if (anchor == QLatin1String("start"))
+ fontStyle->setTextAnchor(Qt::AlignLeft);
+ if (anchor == QLatin1String("middle"))
+ fontStyle->setTextAnchor(Qt::AlignHCenter);
+ else if (anchor == QLatin1String("end"))
+ fontStyle->setTextAnchor(Qt::AlignRight);
+ }
+
+ node->appendStyleProperty(fontStyle, id);
}
static void parseTransform(QSvgNode *node,
@@ -1275,7 +1090,7 @@ static void parseVisibility(QSvgNode *node,
QString value = attributes.value(QLatin1String("visibility")).toString();
QSvgNode *parent = node->parent();
- if (parent && (value.isEmpty() || value == QLatin1String("inherit")))
+ if (parent && (value.isEmpty() || value == QT_INHERIT))
node->setVisible(parent->isVisible());
else if (value == QLatin1String("hidden") || value == QLatin1String("collapse")) {
node->setVisible(false);
@@ -1886,105 +1701,6 @@ static void cssStyleLookup(QSvgNode *node,
parseStyle(node, attributes, handler);
}
-static bool parseDefaultTextStyle(QSvgNode *node,
- const QXmlStreamAttributes &attributes,
- bool initial,
- QSvgHandler *handler)
-{
- Q_ASSERT(node->type() == QSvgText::TEXT || node->type() == QSvgNode::TEXTAREA);
- QSvgText *textNode = static_cast<QSvgText*>(node);
-
- QSvgAttributes attrs(attributes, handler);
-
- QString fontFamily = attrs.value(QString(), QLatin1String("font-family")).toString();
-
- QString anchor = attrs.value(QString(), QLatin1String("text-anchor")).toString();
-
- QSvgFontStyle *fontStyle = static_cast<QSvgFontStyle*>(
- node->styleProperty(QSvgStyleProperty::FONT));
- if (fontStyle) {
- QSvgTinyDocument *doc = fontStyle->doc();
- if (doc && fontStyle->svgFont()) {
- cssStyleLookup(node, handler, handler->selector());
- parseStyle(node, attrs, handler);
- return true;
- }
- } else if (!fontFamily.isEmpty()) {
- QSvgTinyDocument *doc = node->document();
- QSvgFont *svgFont = doc->svgFont(fontFamily);
- if (svgFont) {
- cssStyleLookup(node, handler, handler->selector());
- parseStyle(node, attrs, handler);
- return true;
- }
- }
-
- QTextCharFormat format;
- QBrush brush(QColor(0, 0, 0));
- QFont font;
- font.setPixelSize(12);
- qreal fontSize = font.pixelSize();
-
- if (!initial) {
- font = textNode->topFormat().font();
- fontSize = font.pixelSize() / textNode->scale();
- brush = textNode->topFormat().foreground();
- } else {
- QSvgFontStyle *fontStyle = static_cast<QSvgFontStyle*>(
- node->styleProperty(QSvgStyleProperty::FONT));
- if (!fontStyle)
- fontStyle = static_cast<QSvgFontStyle*>(
- node->parent()->styleProperty(QSvgStyleProperty::FONT));
- if (fontStyle) {
- font = fontStyle->qfont();
- fontSize = fontStyle->pointSize();
- if (anchor.isEmpty() || anchor == QLatin1String("inherit"))
- anchor = fontStyle->textAnchor();
- }
-
- Qt::Alignment align = Qt::AlignLeft;
- if (anchor == QLatin1String("middle"))
- align = Qt::AlignHCenter;
- else if (anchor == QLatin1String("end"))
- align = Qt::AlignRight;
- textNode->setTextAlignment(align);
-
- QSvgFillStyle *fillStyle = static_cast<QSvgFillStyle*>(
- node->styleProperty(QSvgStyleProperty::FILL));
- if (fillStyle)
- brush = fillStyle->qbrush();
- }
-
- if (parseQFont(attrs, font, fontSize, handler) || initial) {
- if (initial)
- textNode->setScale(100 / fontSize);
- font.setPixelSize(qMax(1, int(fontSize * textNode->scale())));
- format.setFont(font);
- }
-
- if (parseQBrush(attrs, node, brush, handler) || initial) {
- if (brush.style() != Qt::NoBrush || initial)
- format.setForeground(brush);
- }
-
- QPen pen(Qt::NoPen);
-// QSvgStrokeStyle *inherited =
-// static_cast<QSvgStrokeStyle*>(node->parent()->styleProperty(
-// QSvgStyleProperty::STROKE));
-// if (inherited)
-// pen = inherited->qpen();
- parseQPen(pen, node, attrs, handler);
- if (pen.style() != Qt::NoPen) {
- format.setTextOutline(pen);
- }
-
- parseTransform(node, attrs, handler);
-
- textNode->insertFormat(format);
-
- return true;
-}
-
static inline QStringList stringToList(const QString &str)
{
QStringList lst = str.split(QLatin1Char(','), QString::SkipEmptyParts);
@@ -2143,7 +1859,7 @@ static inline QSvgNode::DisplayMode displayStringToEnum(const QString &str)
return QSvgNode::TableCaptionMode;
} else if (str == QLatin1String("none")) {
return QSvgNode::NoneMode;
- } else if (str == QLatin1String("inherit")) {
+ } else if (str == QT_INHERIT) {
return QSvgNode::InheritMode;
}
return QSvgNode::BlockMode;
@@ -3107,7 +2823,6 @@ static QSvgNode *createSvgNode(QSvgNode *parent,
node->setHeight(int(height), type == QSvgHandler::LT_PERCENT);
}
-
if (!viewBoxStr.isEmpty()) {
QStringList lst = viewBoxStr.split(QLatin1Char(' '), QString::SkipEmptyParts);
if (lst.count() != 4)
@@ -3157,7 +2872,7 @@ static bool parseTbreakNode(QSvgNode *parent,
{
if (parent->type() != QSvgNode::TEXTAREA)
return false;
- static_cast<QSvgText*>(parent)->insertLineBreak();
+ static_cast<QSvgText*>(parent)->addLineBreak();
return true;
}
@@ -3172,12 +2887,6 @@ static QSvgNode *createTextNode(QSvgNode *parent,
qreal nx = parseLength(x, type, handler);
qreal ny = parseLength(y, type, handler);
- //### not to pixels but to the default coordinate system
- // and text should be already in the correct coordinate
- // system here
- //nx = convertToPixels(nx, true, type);
- //ny = convertToPixels(ny, true, type);
-
QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
return text;
}
@@ -3196,6 +2905,13 @@ static QSvgNode *createTextAreaNode(QSvgNode *parent,
return node;
}
+static QSvgNode *createTspanNode(QSvgNode *parent,
+ const QXmlStreamAttributes &,
+ QSvgHandler *)
+{
+ return new QSvgTspan(parent);
+}
+
static bool parseTitleNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *)
@@ -3204,15 +2920,6 @@ static bool parseTitleNode(QSvgNode *parent,
return true;
}
-static bool parseTspanNode(QSvgNode *parent,
- const QXmlStreamAttributes &attributes,
- QSvgHandler *handler)
-{
-
- cssStyleLookup(parent, handler, handler->selector());
- return parseDefaultTextStyle(parent, attributes, false, handler);
-}
-
static QSvgNode *createUseNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
@@ -3326,6 +3033,7 @@ static FactoryMethod findGraphicsFactory(const QString &name)
case 't':
if (ref == QLatin1String("ext")) return createTextNode;
if (ref == QLatin1String("extArea")) return createTextAreaNode;
+ if (ref == QLatin1String("span")) return createTspanNode;
break;
case 'u':
if (ref == QLatin1String("se")) return createUseNode;
@@ -3382,7 +3090,6 @@ static ParseMethod findUtilFactory(const QString &name)
case 't':
if (ref == QLatin1String("break")) return parseTbreakNode;
if (ref == QLatin1String("itle")) return parseTitleNode;
- if (ref == QLatin1String("span")) return parseTspanNode;
break;
default:
break;
@@ -3591,16 +3298,33 @@ bool QSvgHandler::startElement(const QString &localName,
group->addChild(node, someId(attributes));
}
break;
+ case QSvgNode::TEXT:
+ case QSvgNode::TEXTAREA:
+ if (node->type() == QSvgNode::TSPAN) {
+ static_cast<QSvgText *>(m_nodes.top())->addTspan(static_cast<QSvgTspan *>(node));
+ } else {
+ qWarning("\'text\' or \'textArea\' element contains invalid element type.");
+ delete node;
+ node = 0;
+ }
+ break;
default:
- Q_ASSERT(!"not a grouping element is the parent");
+ qWarning("Could not add child element to parent element because the types are incorrect.");
+ delete node;
+ node = 0;
+ break;
}
- parseCoreNode(node, attributes);
- cssStyleLookup(node, this, m_selector);
- if (node->type() != QSvgNode::TEXT && node->type() != QSvgNode::TEXTAREA)
+ if (node) {
+ parseCoreNode(node, attributes);
+ cssStyleLookup(node, this, m_selector);
parseStyle(node, attributes, this);
- else
- parseDefaultTextStyle(node, attributes, true, this);
+ if (node->type() == QSvgNode::TEXT || node->type() == QSvgNode::TEXTAREA) {
+ static_cast<QSvgText *>(node)->setWhitespaceMode(m_whitespaceMode.top());
+ } else if (node->type() == QSvgNode::TSPAN) {
+ static_cast<QSvgTspan *>(node)->setWhitespaceMode(m_whitespaceMode.top());
+ }
+ }
}
} else if (ParseMethod method = findUtilFactory(localName)) {
Q_ASSERT(!m_nodes.isEmpty());
@@ -3657,13 +3381,8 @@ bool QSvgHandler::endElement(const QStringRef &localName)
return true;
}
- if (m_inStyle && localName == QLatin1String("style")) {
+ if (m_inStyle && localName == QLatin1String("style"))
m_inStyle = false;
- } else if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) {
- QSvgText *node = static_cast<QSvgText*>(m_nodes.top());
- if (localName == QLatin1String("tspan"))
- node->popFormat();
- }
if (node == Graphics) {
// Iterate through the m_renderers to resolve any unresolved gradients.
@@ -3711,8 +3430,9 @@ bool QSvgHandler::characters(const QStringRef &str)
return true;
if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) {
- QSvgText *node = static_cast<QSvgText*>(m_nodes.top());
- node->insertText(str.toString(), m_whitespaceMode.top());
+ static_cast<QSvgText*>(m_nodes.top())->addText(str.toString());
+ } else if (m_nodes.top()->type() == QSvgNode::TSPAN) {
+ static_cast<QSvgTspan*>(m_nodes.top())->addText(str.toString());
}
return true;
diff --git a/src/svg/qsvgnode_p.h b/src/svg/qsvgnode_p.h
index f203ea7..315f228 100644
--- a/src/svg/qsvgnode_p.h
+++ b/src/svg/qsvgnode_p.h
@@ -86,6 +86,7 @@ public:
RECT,
TEXT,
TEXTAREA,
+ TSPAN,
USE,
VIDEO
};
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index c3c0a68..3682f47 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE
QSvgExtraStates::QSvgExtraStates()
: fillOpacity(1.0)
+ , svgFont(0)
+ , textAnchor(Qt::AlignLeft)
+ , fontWeight(400)
{
}
@@ -191,39 +194,94 @@ void QSvgViewportFillStyle::revert(QPainter *p, QSvgExtraStates &)
}
QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc)
- : m_font(font), m_pointSize(24), m_doc(doc)
-{
-}
-
-QSvgFontStyle::QSvgFontStyle(const QFont &font, QSvgTinyDocument *doc)
- : m_font(0), m_pointSize(24), m_doc(doc), m_qfont(font)
-{
-}
-
-
-void QSvgFontStyle::setPointSize(qreal size)
-{
- m_pointSize = size;
-}
-
-qreal QSvgFontStyle::pointSize() const
-{
- return m_pointSize;
-}
-
-void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
-{
- if (!m_font) {
- m_oldFont = p->font();
- p->setFont(m_qfont);
+ : m_svgFont(font)
+ , m_doc(doc)
+ , m_familySet(0)
+ , m_sizeSet(0)
+ , m_styleSet(0)
+ , m_variantSet(0)
+ , m_weightSet(0)
+ , m_textAnchorSet(0)
+{
+}
+
+QSvgFontStyle::QSvgFontStyle()
+ : m_doc(0)
+ , m_svgFont(0)
+ , m_familySet(0)
+ , m_sizeSet(0)
+ , m_styleSet(0)
+ , m_variantSet(0)
+ , m_weightSet(0)
+ , m_textAnchorSet(0)
+{
+}
+
+int QSvgFontStyle::SVGToQtWeight(int weight) {
+ switch (weight) {
+ case 100:
+ case 200:
+ return QFont::Light;
+ case 300:
+ case 400:
+ return QFont::Normal;
+ case 500:
+ case 600:
+ return QFont::DemiBold;
+ case 700:
+ case 800:
+ return QFont::Bold;
+ case 900:
+ return QFont::Black;
+ }
+ return QFont::Normal;
+}
+
+void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
+{
+ m_oldQFont = p->font();
+ m_oldSvgFont = states.svgFont;
+ m_oldTextAnchor = states.textAnchor;
+ m_oldWeight = states.fontWeight;
+
+ if (m_textAnchorSet)
+ states.textAnchor = m_textAnchor;
+
+ QFont font = m_oldQFont;
+ if (m_familySet) {
+ states.svgFont = m_svgFont;
+ font.setFamily(m_qfont.family());
+ }
+
+ if (m_sizeSet)
+ font.setPointSize(m_qfont.pointSizeF());
+
+ if (m_styleSet)
+ font.setStyle(m_qfont.style());
+
+ if (m_variantSet)
+ font.setCapitalization(m_qfont.capitalization());
+
+ if (m_weightSet) {
+ if (m_weight == BOLDER) {
+ states.fontWeight = qMin(states.fontWeight + 100, 900);
+ } else if (m_weight == LIGHTER) {
+ states.fontWeight = qMax(states.fontWeight - 100, 100);
+ } else {
+ states.fontWeight = m_weight;
+ }
+ font.setWeight(SVGToQtWeight(states.fontWeight));
}
+
+ p->setFont(font);
}
-void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &)
+void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &states)
{
- if (!m_font) {
- p->setFont(m_oldFont);
- }
+ p->setFont(m_oldQFont);
+ states.svgFont = m_oldSvgFont;
+ states.textAnchor = m_oldTextAnchor;
+ states.fontWeight = m_oldWeight;
}
QSvgStrokeStyle::QSvgStrokeStyle(const QPen &pen)
@@ -799,16 +857,6 @@ QSvgStyleProperty::Type QSvgAnimateColor::type() const
return ANIMATE_COLOR;
}
-QString QSvgFontStyle::textAnchor() const
-{
- return m_textAnchor;
-}
-
-void QSvgFontStyle::setTextAnchor(const QString &anchor)
-{
- m_textAnchor = anchor;
-}
-
QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity)
: m_opacity(opacity)
{
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index 70ecf5b..bd28bb6 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -141,7 +141,11 @@ private:
struct QSvgExtraStates
{
QSvgExtraStates();
+
qreal fillOpacity;
+ QSvgFont *svgFont;
+ Qt::Alignment textAnchor;
+ int fontWeight;
};
class QSvgStyleProperty : public QSvgRefCounted
@@ -307,41 +311,85 @@ private:
class QSvgFontStyle : public QSvgStyleProperty
{
public:
+ static const int LIGHTER = -1;
+ static const int BOLDER = 1;
+
QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc);
- QSvgFontStyle(const QFont &font, QSvgTinyDocument *doc);
+ QSvgFontStyle();
virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- void setPointSize(qreal size);
- qreal pointSize() const;
+ void setSize(qreal size)
+ {
+ // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call
+ // QFont::SetPointSize() instead. Set proper font size just before rendering.
+ m_qfont.setPointSize(size);
+ m_sizeSet = 1;
+ }
- //### hack to avoid having a separate style element for text-anchor
- QString textAnchor() const;
- void setTextAnchor(const QString &anchor);
+ void setTextAnchor(Qt::Alignment anchor)
+ {
+ m_textAnchor = anchor;
+ m_textAnchorSet = 1;
+ }
- QSvgFont * svgFont() const
+ void setFamily(const QString &family)
{
- return m_font;
+ m_qfont.setFamily(family);
+ m_familySet = 1;
+ }
+
+ void setStyle(QFont::Style fontStyle) {
+ m_qfont.setStyle(fontStyle);
+ m_styleSet = 1;
}
- QSvgTinyDocument *doc() const
+
+ void setVariant(QFont::Capitalization fontVariant)
{
- return m_doc;
+ m_qfont.setCapitalization(fontVariant);
+ m_variantSet = 1;
}
- const QFont & qfont() const
+ static int SVGToQtWeight(int weight);
+
+ void setWeight(int weight)
+ {
+ m_weight = weight;
+ m_weightSet = 1;
+ }
+
+ QSvgFont * svgFont() const
+ {
+ return m_svgFont;
+ }
+
+ const QFont &qfont() const
{
return m_qfont;
}
+
+ QSvgTinyDocument *doc() const {return m_doc;}
+
private:
- QSvgFont *m_font;
- qreal m_pointSize;
+ QSvgFont *m_svgFont;
QSvgTinyDocument *m_doc;
+ QFont m_qfont;
- QString m_textAnchor;
+ int m_weight;
+ Qt::Alignment m_textAnchor;
- QFont m_qfont;
- QFont m_oldFont;
+ QSvgFont *m_oldSvgFont;
+ QFont m_oldQFont;
+ Qt::Alignment m_oldTextAnchor;
+ int m_oldWeight;
+
+ unsigned m_familySet : 1;
+ unsigned m_sizeSet : 1;
+ unsigned m_styleSet : 1;
+ unsigned m_variantSet : 1;
+ unsigned m_weightSet : 1;
+ unsigned m_textAnchorSet : 1;
};
class QSvgStrokeStyle : public QSvgStyleProperty
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index e44be9c..1dae828 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -834,11 +834,12 @@ int qt_asprintf(char **str, const char *format, ...)
res = qvsnprintf(*str, size, format, ap);
va_end(ap);
(*str)[size - 1] = '\0';
- if (res < size) {
- // We succeeded or fatally failed
+ if (res >= 0 && res < size) {
+ // We succeeded
break;
}
- // buffer wasn't big enough, try again
+ // buffer wasn't big enough, try again.
+ // Note, we're assuming that a result of -1 is always due to running out of space.
size *= 2;
if (size > MAXSIZE) {
break;
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index aa11d0e..74b1a67 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -429,7 +429,7 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
{
def->isVirtual = false;
//skip modifiers and attributes
- while (test(INLINE) || test(STATIC) ||
+ while (test(EXPLICIT) || test(INLINE) || test(STATIC) ||
(test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
|| testFunctionAttribute(def)) {}
bool tilde = test(TILDE);
diff --git a/tests/arthur/data/1.2/textArea01.svg b/tests/arthur/data/1.2/textArea01.svg
index 79fcd0a..945c34c 100644
--- a/tests/arthur/data/1.2/textArea01.svg
+++ b/tests/arthur/data/1.2/textArea01.svg
@@ -6,5 +6,5 @@
height="300">Tomorrow, and tomorrow, and
tomorrow; creeps in this petty pace from day to day, until the last syll&#xAD;able of recorded
time. And all our yesterdays have lighted fools the way to dusty death.</textArea>
- <rect x="5" y="5" width="210" height="310" stroke-width="3" stroke="#777"/>
+ <rect x="5" y="5" width="210" height="310" stroke-width="3" stroke="#777" fill="none"/>
</svg>
diff --git a/tests/arthur/data/qps/linear_gradients_perspectives_qps.png b/tests/arthur/data/qps/linear_gradients_perspectives_qps.png
index 42ba872..3315ebe 100644
--- a/tests/arthur/data/qps/linear_gradients_perspectives_qps.png
+++ b/tests/arthur/data/qps/linear_gradients_perspectives_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/linear_gradients_qps.png b/tests/arthur/data/qps/linear_gradients_qps.png
index dc5223b..a4cdc43 100644
--- a/tests/arthur/data/qps/linear_gradients_qps.png
+++ b/tests/arthur/data/qps/linear_gradients_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/lineconsistency_qps.png b/tests/arthur/data/qps/lineconsistency_qps.png
index 48768ef..9d19a5d 100644
--- a/tests/arthur/data/qps/lineconsistency_qps.png
+++ b/tests/arthur/data/qps/lineconsistency_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/linedashes2_aa_qps.png b/tests/arthur/data/qps/linedashes2_aa_qps.png
index 0cb5b40..54c84b3 100644
--- a/tests/arthur/data/qps/linedashes2_aa_qps.png
+++ b/tests/arthur/data/qps/linedashes2_aa_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/paths_aa_qps.png b/tests/arthur/data/qps/paths_aa_qps.png
index 45b4b74..e51a4ac 100644
--- a/tests/arthur/data/qps/paths_aa_qps.png
+++ b/tests/arthur/data/qps/paths_aa_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/paths_qps.png b/tests/arthur/data/qps/paths_qps.png
index a9a8743..094a84f 100644
--- a/tests/arthur/data/qps/paths_qps.png
+++ b/tests/arthur/data/qps/paths_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/radial_gradients_perspectives_qps.png b/tests/arthur/data/qps/radial_gradients_perspectives_qps.png
index 0e28aae..d833250 100644
--- a/tests/arthur/data/qps/radial_gradients_perspectives_qps.png
+++ b/tests/arthur/data/qps/radial_gradients_perspectives_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/radial_gradients_qps.png b/tests/arthur/data/qps/radial_gradients_qps.png
index 66fcfc4..11043e8 100644
--- a/tests/arthur/data/qps/radial_gradients_qps.png
+++ b/tests/arthur/data/qps/radial_gradients_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/rasterops.qps b/tests/arthur/data/qps/rasterops.qps
index b79ec0d..ee3deca 100644
--- a/tests/arthur/data/qps/rasterops.qps
+++ b/tests/arthur/data/qps/rasterops.qps
@@ -1,83 +1,84 @@
-setPen NoPen
-
-setBrush black
-drawRect 10 10 1200 140
-
-setCompositionMode SourceOrDestination
-translate 20 20
-begin_block drawShape
-setBrush 0xffff0000
-drawEllipse 10 10 80 80
-setBrush 0xff00ff00
-drawRect 0 0 50 50
-setBrush 0xff0000ff
-drawRect 50 50 50 50
-end_block
-
-begin_block loop
-setCompositionMode SourceAndDestination
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode SourceXorDestination
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode NotSourceAndNotDestination
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode NotSourceOrNotDestination
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode NotSourceXorDestination
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode NotSource
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode NotSourceAndDestination
-translate 120 0
-repeat_block drawShape
-
-setCompositionMode SourceAndNotDestination
-translate 120 0
-repeat_block drawShape
-end_block
-
-resetMatrix
-setCompositionMode Source
-setBrush white
-drawRect 10 160 1200 140
-translate 20 170
-repeat_block loop
-
-resetMatrix
-setCompositionMode Source
-translate 20 320
-repeat_block loop
-
-resetMatrix
-setPen black
-setCompositionMode SourceOver
-translate 20 470
-drawText 20 0 "Or ROP"
-translate 120 0
-drawText 20 0 "And ROP"
-translate 120 0
-drawText 20 0 "Xor ROP"
-translate 120 0
-drawText 20 0 "Nor ROP"
-translate 120 0
-drawText 20 0 "Nand ROP"
-translate 120 0
-drawText 0 0 "NSrcXorDst ROP"
-translate 120 0
-drawText 20 0 "NSrc ROP"
-translate 120 0
-drawText 0 0 "NSrcAndDst ROP"
-translate 120 0
-drawText 0 0 "SrcAndNDst ROP"
+setPen NoPen
+
+setBrush black
+drawRect 10 10 60 500
+
+setCompositionMode SourceOrDestination
+translate 20 20
+
+begin_block drawShape
+ setBrush 0xffff0000
+ drawEllipse 5 5 30 30
+ setBrush 0xff00ff00
+ drawRect 0 0 20 20
+ setBrush 0xff0000ff
+ drawRect 20 20 20 20
+end_block
+
+begin_block loop
+ setCompositionMode SourceAndDestination
+ translate 0 50
+repeat_block drawShape
+
+setCompositionMode SourceXorDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceAndNotDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceOrNotDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceXorDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSource
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceAndDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode SourceAndNotDestination
+translate 0 50
+repeat_block drawShape
+end_block
+
+resetMatrix
+setCompositionMode Source
+setBrush white
+drawRect 100 10 60 500
+translate 110 20
+repeat_block loop
+
+resetMatrix
+setCompositionMode Source
+translate 190 20
+repeat_block loop
+
+resetMatrix
+setPen black
+setCompositionMode SourceOver
+translate 250 45
+drawText 20 0 "Or ROP"
+translate 0 50
+drawText 20 0 "And ROP"
+translate 0 50
+drawText 20 0 "Xor ROP"
+translate 0 50
+drawText 20 0 "Nor ROP"
+translate 0 50
+drawText 20 0 "Nand ROP"
+translate 0 50
+drawText 0 0 "NSrcXorDst ROP"
+translate 0 50
+drawText 20 0 "NSrc ROP"
+translate 0 50
+drawText 0 0 "NSrcAndDst ROP"
+translate 0 50
+drawText 0 0 "SrcAndNDst ROP"
diff --git a/tests/arthur/data/qps/rasterops_qps.png b/tests/arthur/data/qps/rasterops_qps.png
index 80ca8ae..7b93001 100644
--- a/tests/arthur/data/qps/rasterops_qps.png
+++ b/tests/arthur/data/qps/rasterops_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/text_perspectives_qps.png b/tests/arthur/data/qps/text_perspectives_qps.png
index 483ccc0..183ad6f 100644
--- a/tests/arthur/data/qps/text_perspectives_qps.png
+++ b/tests/arthur/data/qps/text_perspectives_qps.png
Binary files differ
diff --git a/tests/arthur/data/qps/text_qps.png b/tests/arthur/data/qps/text_qps.png
index 2c2ebf2..9a95493 100644
--- a/tests/arthur/data/qps/text_qps.png
+++ b/tests/arthur/data/qps/text_qps.png
Binary files differ
diff --git a/tests/arthur/lance/interactivewidget.cpp b/tests/arthur/lance/interactivewidget.cpp
index 0febbed..0c2c7a6 100644
--- a/tests/arthur/lance/interactivewidget.cpp
+++ b/tests/arthur/lance/interactivewidget.cpp
@@ -43,7 +43,7 @@
InteractiveWidget::InteractiveWidget()
{
- m_onScreenWidget = new OnScreenWidget<QWidget>();
+ m_onScreenWidget = new OnScreenWidget<QWidget>("");
m_onScreenWidget->setMinimumSize(320, 240);
setCentralWidget(m_onScreenWidget);
diff --git a/tests/arthur/lance/lance.pro b/tests/arthur/lance/lance.pro
index 193dbd2..ee9e08b 100644
--- a/tests/arthur/lance/lance.pro
+++ b/tests/arthur/lance/lance.pro
@@ -6,7 +6,7 @@ INCLUDEPATH += .
# Input
HEADERS += widgets.h interactivewidget.h
-SOURCES += interactivewidget.cpp main.cpp
+SOURCES += interactivewidget.cpp main.cpp
RESOURCES += icons.qrc
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
diff --git a/tests/arthur/lance/main.cpp b/tests/arthur/lance/main.cpp
index 07e5180..f95b426 100644
--- a/tests/arthur/lance/main.cpp
+++ b/tests/arthur/lance/main.cpp
@@ -66,7 +66,7 @@ extern bool qt_show_painter_debug_output = false;
//#define CONSOLE_APPLICATION
-static const struct {
+static const struct {
const char *name;
QImage::Format format;
} imageFormats[] = {
@@ -282,7 +282,7 @@ int main(int argc, char **argv)
if (imageFormat == QImage::Format_Invalid) {
printf("Invalid image format. Available formats are:\n");
- for (int ff = 0; ff < formatCount; ++ff)
+ for (int ff = 0; ff < formatCount; ++ff)
printf("\t%s\n", imageFormats[ff].name);
return -1;
}
@@ -403,12 +403,10 @@ int main(int argc, char **argv)
case WidgetType:
{
OnScreenWidget<QWidget> *qWidget =
- new OnScreenWidget<QWidget>;
+ new OnScreenWidget<QWidget>(files.at(j));
qWidget->setVerboseMode(verboseMode);
qWidget->setType(type);
qWidget->setCheckersBackground(checkers_background);
- qWidget->m_filename = files.at(j);
- qWidget->setWindowTitle(fileinfo.filePath());
qWidget->m_commands = content;
qWidget->resize(width, height);
qWidget->show();
@@ -418,12 +416,10 @@ int main(int argc, char **argv)
case ImageWidgetType:
{
- OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>;
+ OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>(files.at(j));
qWidget->setVerboseMode(verboseMode);
qWidget->setType(type);
qWidget->setCheckersBackground(checkers_background);
- qWidget->m_filename = files.at(j);
- qWidget->setWindowTitle(fileinfo.filePath());
qWidget->m_commands = content;
qWidget->resize(width, height);
qWidget->show();
@@ -452,12 +448,10 @@ int main(int argc, char **argv)
}
case OpenGLType:
{
- OnScreenWidget<QGLWidget> *qGLWidget = new OnScreenWidget<QGLWidget>;
+ OnScreenWidget<QGLWidget> *qGLWidget = new OnScreenWidget<QGLWidget>(files.at(j));
qGLWidget->setVerboseMode(verboseMode);
qGLWidget->setType(type);
qGLWidget->setCheckersBackground(checkers_background);
- qGLWidget->m_filename = files.at(j);
- qGLWidget->setWindowTitle(fileinfo.filePath());
qGLWidget->m_commands = content;
qGLWidget->resize(width, height);
qGLWidget->show();
diff --git a/tests/arthur/lance/widgets.h b/tests/arthur/lance/widgets.h
index 271c18a..7247608 100644
--- a/tests/arthur/lance/widgets.h
+++ b/tests/arthur/lance/widgets.h
@@ -57,15 +57,47 @@
#include <QTextStream>
#include <QPaintEngine>
+#include <private/qwindowsurface_p.h>
+
#include <qmath.h>
const int CP_RADIUS = 10;
+class StupidWorkaround : public QObject
+{
+ Q_OBJECT
+public:
+ StupidWorkaround(QWidget *widget, int *value)
+ : QObject(widget), w(widget), mode(value)
+ {
+ }
+
+public slots:
+ void setViewMode(int m) {
+ *mode = m;
+ w->update();
+ }
+
+private:
+ QWidget *w;
+ int *mode;
+};
+
template <class T>
class OnScreenWidget : public T
{
public:
- OnScreenWidget(QWidget *parent = 0) : T(parent)
+
+ enum ViewMode {
+ RenderView,
+ BaselineView,
+ DifferenceView
+ };
+
+ OnScreenWidget(const QString &file, QWidget *parent = 0)
+ : T(parent),
+ m_view_mode(RenderView),
+ m_filename(file)
{
QSettings settings("Trolltech", "lance");
for (int i=0; i<10; ++i) {
@@ -78,11 +110,47 @@ public:
m_deviceType = WidgetType;
m_checkersBackground = true;
m_verboseMode = false;
- }
- void setVerboseMode(bool v) { m_verboseMode = v; }
- void setCheckersBackground(bool b) { m_checkersBackground = b; }
- void setType(DeviceType t) { m_deviceType = t; }
+ m_baseline_name = QString(m_filename).replace(".qps", "_qps") + ".png";
+ if (QFileInfo(m_baseline_name).exists()) {
+ m_baseline = QPixmap(m_baseline_name);
+ }
+
+ if (m_baseline.isNull()) {
+ setWindowTitle("Rendering: '" + file + "'. No baseline available");
+ } else {
+ setWindowTitle("Rendering: '" + file + "'. Shortcuts: 1=render, 2=baseline, 3=difference");
+
+ StupidWorkaround *workaround = new StupidWorkaround(this, &m_view_mode);
+
+ QSignalMapper *mapper = new QSignalMapper(this);
+ connect(mapper, SIGNAL(mapped(int)), workaround, SLOT(setViewMode(int)));
+ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setWindowTitle(QString)));
+
+ QAction *renderViewAction = new QAction("Render View", this);
+ renderViewAction->setShortcut(Qt::Key_1);
+ connect(renderViewAction, SIGNAL(triggered()), mapper, SLOT(map()));
+ mapper->setMapping(renderViewAction, RenderView);
+ mapper->setMapping(renderViewAction, "Render View: " + file);
+ addAction(renderViewAction);
+
+ QAction *baselineAction = new QAction("Baseline", this);
+ baselineAction->setShortcut(Qt::Key_2);
+ connect(baselineAction, SIGNAL(triggered()), mapper, SLOT(map()));
+ mapper->setMapping(baselineAction, BaselineView);
+ mapper->setMapping(baselineAction, "Baseline View: " + file);
+ addAction(baselineAction);
+
+ QAction *differenceAction = new QAction("Differenfe View", this);
+ differenceAction->setShortcut(Qt::Key_3);
+ connect(differenceAction, SIGNAL(triggered()), mapper, SLOT(map()));
+ mapper->setMapping(differenceAction, DifferenceView);
+ mapper->setMapping(differenceAction, "Difference View" + file);
+ addAction(differenceAction);
+
+ }
+
+ }
~OnScreenWidget()
{
@@ -93,12 +161,24 @@ public:
settings.sync();
}
+ void setVerboseMode(bool v) { m_verboseMode = v; }
+ void setCheckersBackground(bool b) { m_checkersBackground = b; }
+ void setType(DeviceType t) { m_deviceType = t; }
+
void resizeEvent(QResizeEvent *e) {
m_image = QImage();
T::resizeEvent(e);
}
- void paintEvent(QPaintEvent *)
+ void paintEvent(QPaintEvent *) {
+ switch (m_view_mode) {
+ case RenderView: paintRenderView(); break;
+ case BaselineView: paintBaselineView(); break;
+ case DifferenceView: paintDifferenceView(); break;
+ }
+ }
+
+ void OnScreenWidget<T>::paintRenderView()
{
QPainter pt;
QPaintDevice *dev = this;
@@ -152,6 +232,57 @@ public:
}
}
+ if (m_render_view.isNull()) {
+ m_render_view = window()->windowSurface()->grabWidget(this);
+ m_render_view.save("renderView.png");
+ }
+ }
+
+ void paintBaselineView() {
+ QPainter p(this);
+
+ if (m_baseline.isNull()) {
+ p.drawText(rect(), Qt::AlignCenter,
+ "No baseline found\n"
+ "file '" + m_baseline_name + "' does not exist...");
+ return;
+ }
+
+ p.drawPixmap(0, 0, m_baseline);
+
+ p.setPen(QColor::fromRgb(0, 0, 0, 0.1));
+ p.setFont(QFont("Arial", 128));
+ p.rotate(45);
+ p.drawText(100, 0, "BASELINE");
+ }
+
+ QPixmap generateDifference()
+ {
+ QImage img(size(), QImage::Format_RGB32);
+ img.fill(0);
+
+ QPainter p(&img);
+ p.drawPixmap(0, 0, m_render_view);
+
+ p.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
+ p.drawPixmap(0, 0, m_baseline);
+
+ p.end();
+
+ return QPixmap::fromImage(img);
+ }
+
+ void paintDifferenceView() {
+ QPainter p(this);
+ if (m_baseline.isNull()) {
+ p.drawText(rect(), Qt::AlignCenter,
+ "No baseline found\n"
+ "file '" + m_baseline_name + "' does not exist...");
+ return;
+ }
+
+ p.fillRect(rect(), Qt::black);
+ p.drawPixmap(0, 0, generateDifference());
}
@@ -190,8 +321,6 @@ public:
T::update();
}
-
-
QSize sizeHint() const { return QSize(800, 800); }
QVector<QPointF> m_controlPoints;
@@ -200,12 +329,18 @@ public:
QStringList m_commands;
QString m_filename;
+ QString m_baseline_name;
bool m_verboseMode;
bool m_checkersBackground;
DeviceType m_deviceType;
+ int m_view_mode;
+
QImage m_image;
+
+ QPixmap m_baseline;
+ QPixmap m_render_view;
};
#endif
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 6f10922..b4a6600 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -159,9 +159,9 @@ SUBDIRS += _networkselftest \
qhash \
qheaderview \
qhelpcontentmodel \
-# qhelpenginecore \
+ qhelpenginecore \
qhelpgenerator \
-# qhelpindexmodel \
+ qhelpindexmodel \
qhelpprojectdata \
qhostaddress \
qhostinfo \
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index d66791f..488f068 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -1157,6 +1157,13 @@ void tst_Moc::constructors()
QObject *o3 = mo->newInstance(Q_ARG(QString, str));
QVERIFY(o3 != 0);
QCOMPARE(qobject_cast<CtorTestClass*>(o3)->m_str, str);
+
+ {
+ //explicit constructor
+ QObject *o = QObject::staticMetaObject.newInstance();
+ QVERIFY(o);
+ delete o;
+ }
}
#include "task234909.h"
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 0a9c16a..a65490d 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -138,6 +138,7 @@ private slots:
void setters();
void dynamicSortOrder();
+ void disabledItems();
// task-specific tests below me
void task178797_activatedOnReturn();
@@ -147,7 +148,6 @@ private slots:
void task253125_lineEditCompletion_data();
void task253125_lineEditCompletion();
-
void task247560_keyboardNavigation();
private:
@@ -1106,6 +1106,31 @@ void tst_QCompleter::dynamicSortOrder()
QCOMPARE(completer.completionCount(), 12);
}
+void tst_QCompleter::disabledItems()
+{
+ QLineEdit lineEdit;
+ QStandardItemModel *model = new QStandardItemModel(&lineEdit);
+ QStandardItem *suggestions = new QStandardItem("suggestions");
+ suggestions->setEnabled(false);
+ model->appendRow(suggestions);
+ model->appendRow(new QStandardItem("suggestions Enabled"));
+ QCompleter *completer = new QCompleter(model, &lineEdit);
+ QSignalSpy spy(completer, SIGNAL(activated(const QString &)));
+ lineEdit.setCompleter(completer);
+ lineEdit.show();
+
+ QTest::keyPress(&lineEdit, Qt::Key_S);
+ QTest::keyPress(&lineEdit, Qt::Key_U);
+ QAbstractItemView *view = lineEdit.completer()->popup();
+ QVERIFY(view->isVisible());
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(0, 0)).center());
+ QCOMPARE(spy.count(), 0);
+ QVERIFY(view->isVisible());
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(1, 0)).center());
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(!view->isVisible());
+}
+
void tst_QCompleter::task178797_activatedOnReturn()
{
QStringList words;
diff --git a/tests/auto/qhelpenginecore/data/collection.qhc b/tests/auto/qhelpenginecore/data/collection.qhc
index 6fb8abb..bd2f37c 100644
--- a/tests/auto/qhelpenginecore/data/collection.qhc
+++ b/tests/auto/qhelpenginecore/data/collection.qhc
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/collection1.qhc b/tests/auto/qhelpenginecore/data/collection1.qhc
index 45acf33..de310ea 100644
--- a/tests/auto/qhelpenginecore/data/collection1.qhc
+++ b/tests/auto/qhelpenginecore/data/collection1.qhc
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch
index 0b53cd8..ed9a89c 100644
--- a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch
+++ b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch
index a3ca18a..0e95c14 100644
--- a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch
+++ b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch
index 8f76134..337d7a1 100644
--- a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch
+++ b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/test.qch b/tests/auto/qhelpenginecore/data/test.qch
index 8a8f7a1..06b789a 100644
--- a/tests/auto/qhelpenginecore/data/test.qch
+++ b/tests/auto/qhelpenginecore/data/test.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
index d62c8e5..f9aa653 100644
--- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
+++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
@@ -130,7 +130,7 @@ void tst_QHelpEngineCore::setCollectionFile()
QStringList docs = help.registeredDocumentations();
QCOMPARE(docs.count(), 1);
- QCOMPARE(docs.first(), QLatin1String("trolltech.com.1_0_0.test"));
+ QCOMPARE(docs.first(), QLatin1String("trolltech.com.1-0-0.test"));
}
void tst_QHelpEngineCore::copyCollectionFile()
@@ -177,7 +177,7 @@ void tst_QHelpEngineCore::copyCollectionFile()
i = 0;
while (m_query->next()) {
if (i == 0) {
- QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3_3_8.qmake"));
+ QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3-3-8.qmake"));
QCOMPARE(m_query->value(1).toString(), QString("data/qmake-3.3.8.qch"));
}
++i;
@@ -193,9 +193,9 @@ void tst_QHelpEngineCore::copyCollectionFile()
void tst_QHelpEngineCore::namespaceName()
{
QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/qmake-3.3.8.qch"),
- QString("trolltech.com.3_3_8.qmake"));
+ QString("trolltech.com.3-3-8.qmake"));
QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/linguist-3.3.8.qch"),
- QString("trolltech.com.3_3_8.linguist"));
+ QString("trolltech.com.3-3-8.linguist"));
}
void tst_QHelpEngineCore::registeredDocumentations()
@@ -205,8 +205,8 @@ void tst_QHelpEngineCore::registeredDocumentations()
QStringList docs = help.registeredDocumentations();
QCOMPARE(docs.count(), 3);
QStringList lst;
- lst << "trolltech.com.3_3_8.qmake" << "trolltech.com.4_3_0.qmake"
- << "trolltech.com.1_0_0.test";
+ lst << "trolltech.com.3-3-8.qmake" << "trolltech.com.4-3-0.qmake"
+ << "trolltech.com.1-0-0.test";
foreach (QString s, docs)
lst.removeAll(s);
QCOMPARE(lst.isEmpty(), true);
@@ -236,7 +236,7 @@ void tst_QHelpEngineCore::registerDocumentation()
}
QSqlQuery query(db);
query.exec("SELECT FilePath FROM NamespaceTable WHERE "
- "Name=\'trolltech.com.3_3_8.linguist\'");
+ "Name=\'trolltech.com.3-3-8.linguist\'");
if (query.next())
QCOMPARE(query.value(0).toString(),
QString("linguist-3.3.8.qch"));
@@ -251,7 +251,7 @@ void tst_QHelpEngineCore::unregisterDocumentation()
QHelpEngineCore c(m_colFile);
QCOMPARE(c.setupData(), true);
QCOMPARE(c.registeredDocumentations().count(), 3);
- c.unregisterDocumentation("trolltech.com.3_3_8.qmake");
+ c.unregisterDocumentation("trolltech.com.3-3-8.qmake");
QCOMPARE(c.registeredDocumentations().count(), 2);
QCOMPARE(c.unregisterDocumentation("noexisting"), false);
}
@@ -260,9 +260,9 @@ void tst_QHelpEngineCore::documentationFileName()
{
QHelpEngineCore c(m_colFile);
QCOMPARE(c.setupData(), true);
- QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3_3_8.qmake")),
+ QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3-3-8.qmake")),
QString(m_path + "/data/qmake-3.3.8.qch"));
- QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1_0_0.test")),
+ QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1-0-0.test")),
QString(m_path + "/data/test.qch"));
QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.empty")),
QString());
@@ -337,7 +337,7 @@ void tst_QHelpEngineCore::filterAttributeSets()
{
QHelpEngineCore help(m_colFile, 0);
QCOMPARE(help.setupData(), true);
- QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1_0_0.test");
+ QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1-0-0.test");
QCOMPARE(lst.count(), 2);
QCOMPARE(lst.first().count(), 2);
QCOMPARE((bool)lst.first().contains("filter1"), true);
@@ -348,22 +348,22 @@ void tst_QHelpEngineCore::files()
{
QHelpEngineCore help(m_colFile, 0);
QCOMPARE(help.setupData(), true);
- QList<QUrl> lst = help.files("trolltech.com.4_3_0.qmake",
+ QList<QUrl> lst = help.files("trolltech.com.4-3-0.qmake",
QStringList());
QCOMPARE(lst.count(), 16);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList(), "png");
QCOMPARE(lst.count(), 2);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt", "html");
QCOMPARE(lst.count(), 13);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt" << "qmake", "html");
QCOMPARE(lst.count(), 13);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt" << "qmake" << "bla", "html");
QCOMPARE(lst.count(), 0);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt" << "qmake", "foo");
QCOMPARE(lst.count(), 0);
@@ -378,7 +378,7 @@ void tst_QHelpEngineCore::fileData()
QCOMPARE(help.setupData(), true);
QByteArray ba = help.fileData(QUrl("NotExisting"));
QCOMPARE(ba.size(), 0);
- ba = help.fileData(QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html"));
+ ba = help.fileData(QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html"));
QTextStream s(ba, QIODevice::ReadOnly|QIODevice::Text);
QFile f(m_path + "/data/test.html");
if (!f.open(QIODevice::ReadOnly|QIODevice::Text))
@@ -396,7 +396,7 @@ void tst_QHelpEngineCore::linksForIdentifier()
QCOMPARE(map.contains("Test Manual"), true);
QCOMPARE(map.count(), 1);
QCOMPARE(map.value("Test Manual"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo"));
help.setCurrentFilter("Custom Filter 2");
map = help.linksForIdentifier("People::newton");
@@ -405,7 +405,7 @@ void tst_QHelpEngineCore::linksForIdentifier()
QCOMPARE(map.contains("Fancy"), true);
QCOMPARE(map.count(), 1);
QCOMPARE(map.value("Fancy"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foobar"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foobar"));
}
void tst_QHelpEngineCore::customValue()
diff --git a/tests/auto/qhelpindexmodel/data/collection.qhc b/tests/auto/qhelpindexmodel/data/collection.qhc
index 6fb8abb..bd2f37c 100644
--- a/tests/auto/qhelpindexmodel/data/collection.qhc
+++ b/tests/auto/qhelpindexmodel/data/collection.qhc
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/collection1.qhc b/tests/auto/qhelpindexmodel/data/collection1.qhc
index 45acf33..de310ea 100644
--- a/tests/auto/qhelpindexmodel/data/collection1.qhc
+++ b/tests/auto/qhelpindexmodel/data/collection1.qhc
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch
index 0b53cd8..ed9a89c 100644
--- a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch
+++ b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch
index a3ca18a..0e95c14 100644
--- a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch
+++ b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch
index 8f76134..337d7a1 100644
--- a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch
+++ b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/test.qch b/tests/auto/qhelpindexmodel/data/test.qch
index 1d6c1a8..4ea9847 100644
--- a/tests/auto/qhelpindexmodel/data/test.qch
+++ b/tests/auto/qhelpindexmodel/data/test.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
index 9482def..3adb894 100644
--- a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
+++ b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
@@ -185,11 +185,11 @@ void tst_QHelpIndexModel::linksForIndex()
QCOMPARE(map.count(), 2);
QCOMPARE(map.contains("Test Manual"), true);
QCOMPARE(map.value("Test Manual"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo"));
QCOMPARE(map.contains("Fancy"), true);
QCOMPARE(map.value("Fancy"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foo"));
map = m->linksForKeyword("foobar");
QCOMPARE(map.count(), 1);
@@ -208,7 +208,7 @@ void tst_QHelpIndexModel::linksForIndex()
QCOMPARE(map.count(), 1);
QCOMPARE(map.contains("Test Manual"), true);
QCOMPARE(map.value("Test Manual"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo"));
}
QTEST_MAIN(tst_QHelpIndexModel)
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 03b1474..cfd3dd0 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -223,8 +223,10 @@ private Q_SLOTS:
void rateControl();
void downloadPerformance();
void uploadPerformance();
- void httpUploadPerformance();
void performanceControlRate();
+ void httpUploadPerformance();
+ void httpDownloadPerformance_data();
+ void httpDownloadPerformance();
void downloadProgress_data();
void downloadProgress();
@@ -248,8 +250,6 @@ private Q_SLOTS:
void authorizationError();
void httpConnectionCount();
- void httpDownloadPerformance_data();
- void httpDownloadPerformance();
#ifndef QT_NO_OPENSSL
void ignoreSslErrorsList_data();
@@ -513,10 +513,10 @@ public:
QTcpSocket *active = new QTcpSocket(this);
active->connectToHost("127.0.0.1", server.serverPort());
- if (!active->waitForConnected(10))
+ if (!active->waitForConnected(100))
return false;
- if (!server.waitForNewConnection(10))
+ if (!server.waitForNewConnection(100))
return false;
QTcpSocket *passive = server.nextPendingConnection();
passive->setParent(this);
@@ -836,6 +836,92 @@ protected:
}
};
+class HttpDownloadPerformanceClient : QObject {
+ Q_OBJECT;
+ QIODevice *device;
+ public:
+ HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){
+ connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ }
+
+ public slots:
+ void readyReadSlot() {
+ device->readAll();
+ }
+
+};
+
+class HttpDownloadPerformanceServer : QObject {
+ Q_OBJECT;
+ qint64 dataSize;
+ qint64 dataSent;
+ QTcpServer server;
+ QTcpSocket *client;
+ bool serverSendsContentLength;
+ bool chunkedEncoding;
+
+public:
+ HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
+ client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
+ server.listen();
+ connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
+ }
+
+ int serverPort() {
+ return server.serverPort();
+ }
+
+public slots:
+
+ void newConnectionSlot() {
+ client = server.nextPendingConnection();
+ client->setParent(this);
+ connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
+ }
+
+ void readyReadSlot() {
+ client->readAll();
+ client->write("HTTP/1.0 200 OK\n");
+ if (serverSendsContentLength)
+ client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii());
+ if (chunkedEncoding)
+ client->write(QString("Transfer-Encoding: chunked\n").toAscii());
+ client->write("Connection: close\n\n");
+ }
+
+ void bytesWrittenSlot(qint64 amount) {
+ Q_UNUSED(amount);
+ if (dataSent == dataSize && client) {
+ // close eventually
+
+ // chunked encoding: we have to send a last "empty" chunk
+ if (chunkedEncoding)
+ client->write(QString("0\r\n\r\n").toAscii());
+
+ client->disconnectFromHost();
+ server.close();
+ client = 0;
+ return;
+ }
+
+ // send data
+ if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) {
+ qint64 amount = qMin(qint64(16*1024), dataSize - dataSent);
+ QByteArray data(amount, '@');
+
+ if (chunkedEncoding) {
+ client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii());
+ client->write(data.constData(), amount);
+ client->write(QString("\r\n").toAscii());
+ } else {
+ client->write(data.constData(), amount);
+ }
+
+ dataSent += amount;
+ }
+ }
+};
tst_QNetworkReply::tst_QNetworkReply()
@@ -2642,8 +2728,6 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
QCOMPARE(file.size(), qint64(data.size()));
QByteArray contents = file.readAll();
QCOMPARE(contents, data);
-
- delete reply;
#endif
}
@@ -3183,7 +3267,7 @@ void tst_QNetworkReply::uploadPerformance()
void tst_QNetworkReply::httpUploadPerformance()
{
- enum {UploadSize = 1000*1024*1024}; // 1000 MB
+ enum {UploadSize = 128*1024*1024}; // 128 MB
ThreadedDataReaderHttpServer reader;
FixedSizeDataGenerator generator(UploadSize);
@@ -3205,7 +3289,7 @@ void tst_QNetworkReply::httpUploadPerformance()
<< ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
reader.exit();
- reader.wait(3000);
+ reader.wait();
}
@@ -3233,6 +3317,41 @@ void tst_QNetworkReply::performanceControlRate()
<< elapsedTime << "ms";
}
+void tst_QNetworkReply::httpDownloadPerformance_data()
+{
+ QTest::addColumn<bool>("serverSendsContentLength");
+ QTest::addColumn<bool>("chunkedEncoding");
+
+ QTest::newRow("Server sends no Content-Length") << false << false;
+ QTest::newRow("Server sends Content-Length") << true << false;
+ QTest::newRow("Server uses chunked encoding") << false << true;
+
+}
+
+void tst_QNetworkReply::httpDownloadPerformance()
+{
+ QFETCH(bool, serverSendsContentLength);
+ QFETCH(bool, chunkedEncoding);
+
+ enum {UploadSize = 128*1024*1024}; // 128 MB
+ HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
+
+ QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1"));
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ HttpDownloadPerformanceClient client(reply);
+
+ QTime time;
+ time.start();
+ QTestEventLoop::instance().enterLoop(40);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ qint64 elapsed = time.elapsed();
+ qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, "
+ << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
+}
+
void tst_QNetworkReply::downloadProgress_data()
{
QTest::addColumn<int>("loopCount");
@@ -3720,130 +3839,6 @@ void tst_QNetworkReply::httpConnectionCount()
QCOMPARE(pendingConnectionCount, 6);
}
-class HttpDownloadPerformanceClient : QObject {
- Q_OBJECT;
- QIODevice *device;
- public:
- HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){
- connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
- }
-
- public slots:
- void readyReadSlot() {
- device->readAll();
- }
-
-};
-
-class HttpDownloadPerformanceServer : QObject {
- Q_OBJECT;
- qint64 dataSize;
- qint64 dataSent;
- QTcpServer server;
- QTcpSocket *client;
- bool serverSendsContentLength;
- bool chunkedEncoding;
-
-public:
- HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
- client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
- server.listen();
- connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
- }
-
- int serverPort() {
- return server.serverPort();
- }
-
-public slots:
-
- void newConnectionSlot() {
- client = server.nextPendingConnection();
- client->setParent(this);
- connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
- connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
- }
-
- void readyReadSlot() {
- client->readAll();
- client->write("HTTP/1.0 200 OK\n");
- if (serverSendsContentLength)
- client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii());
- if (chunkedEncoding)
- client->write(QString("Transfer-Encoding: chunked\n").toAscii());
- client->write("Connection: close\n\n");
- }
-
- void bytesWrittenSlot(qint64 amount) {
- Q_UNUSED(amount);
- if (dataSent == dataSize && client) {
- // close eventually
-
- // chunked encoding: we have to send a last "empty" chunk
- if (chunkedEncoding)
- client->write(QString("0\r\n\r\n").toAscii());
-
- client->disconnectFromHost();
- server.close();
- client = 0;
- return;
- }
-
- // send data
- if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) {
- qint64 amount = qMin(qint64(16*1024), dataSize - dataSent);
- QByteArray data(amount, '@');
-
- if (chunkedEncoding) {
- client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii());
- client->write(data.constData(), amount);
- client->write(QString("\r\n").toAscii());
- } else {
- client->write(data.constData(), amount);
- }
-
- dataSent += amount;
- }
- }
-};
-
-void tst_QNetworkReply::httpDownloadPerformance_data()
-{
- QTest::addColumn<bool>("serverSendsContentLength");
- QTest::addColumn<bool>("chunkedEncoding");
-
- QTest::newRow("Server sends no Content-Length") << false << false;
- QTest::newRow("Server sends Content-Length") << true << false;
- QTest::newRow("Server uses chunked encoding") << false << true;
-
-}
-
-void tst_QNetworkReply::httpDownloadPerformance()
-{
- QFETCH(bool, serverSendsContentLength);
- QFETCH(bool, chunkedEncoding);
-
- enum {UploadSize = 1000*1024*1024}; // 1000 MB
- HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
-
- QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1"));
- QNetworkReply* reply = manager.get(request);
-
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- HttpDownloadPerformanceClient client(reply);
-
- QTime time;
- time.start();
- QTestEventLoop::instance().enterLoop(40);
- QVERIFY(!QTestEventLoop::instance().timeout());
-
- qint64 elapsed = time.elapsed();
- qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, "
- << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
-
- delete reply;
-}
-
#ifndef QT_NO_OPENSSL
void tst_QNetworkReply::ignoreSslErrorsList_data()
{
@@ -3872,7 +3867,7 @@ void tst_QNetworkReply::ignoreSslErrorsList()
{
QFETCH(QString, url);
QNetworkRequest request(url);
- QNetworkReply *reply = manager.get(request);
+ QNetworkReplyPtr reply = manager.get(request);
QFETCH(QList<QSslError>, expectedSslErrors);
reply->ignoreSslErrors(expectedSslErrors);
@@ -3901,7 +3896,7 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot()
{
QFETCH(QString, url);
QNetworkRequest request(url);
- QNetworkReply *reply = manager.get(request);
+ QNetworkReplyPtr reply = manager.get(request);
QFETCH(QList<QSslError>, expectedSslErrors);
// store the errors to ignore them later in the slot connected below
diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp
new file mode 100644
index 0000000..055ff40
--- /dev/null
+++ b/tests/manual/windowflags/controllerwindow.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "controllerwindow.h"
+
+//! [0]
+ControllerWindow::ControllerWindow()
+{
+ parentWindow = new QMainWindow;
+ parentWindow->setWindowTitle(tr("Preview parent window"));
+ QLabel *label = new QLabel(tr("Parent window"));
+ parentWindow->setCentralWidget(label);
+
+ previewWindow = new PreviewWindow;
+ previewDialog = new PreviewDialog;
+
+ createTypeGroupBox();
+ createHintsGroupBox();
+
+ quitButton = new QPushButton(tr("&Quit"));
+ connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ bottomLayout->addStretch();
+ bottomLayout->addWidget(quitButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(widgetTypeGroupBox);
+ mainLayout->addWidget(additionalOptionsGroupBox);
+ mainLayout->addWidget(typeGroupBox);
+ mainLayout->addWidget(hintsGroupBox);
+ mainLayout->addLayout(bottomLayout);
+ setLayout(mainLayout);
+
+ setWindowTitle(tr("Window Flags"));
+ updatePreview();
+}
+
+void ControllerWindow::updatePreview()
+{
+ Qt::WindowFlags flags = 0;
+
+ if (windowRadioButton->isChecked()) {
+ flags = Qt::Window;
+ } else if (dialogRadioButton->isChecked()) {
+ flags = Qt::Dialog;
+ } else if (sheetRadioButton->isChecked()) {
+ flags = Qt::Sheet;
+ } else if (drawerRadioButton->isChecked()) {
+ flags = Qt::Drawer;
+ } else if (popupRadioButton->isChecked()) {
+ flags = Qt::Popup;
+ } else if (toolRadioButton->isChecked()) {
+ flags = Qt::Tool;
+ } else if (toolTipRadioButton->isChecked()) {
+ flags = Qt::ToolTip;
+ } else if (splashScreenRadioButton->isChecked()) {
+ flags = Qt::SplashScreen;
+ }
+
+ if (msWindowsFixedSizeDialogCheckBox->isChecked())
+ flags |= Qt::MSWindowsFixedSizeDialogHint;
+ if (x11BypassWindowManagerCheckBox->isChecked())
+ flags |= Qt::X11BypassWindowManagerHint;
+ if (framelessWindowCheckBox->isChecked())
+ flags |= Qt::FramelessWindowHint;
+ if (windowTitleCheckBox->isChecked())
+ flags |= Qt::WindowTitleHint;
+ if (windowSystemMenuCheckBox->isChecked())
+ flags |= Qt::WindowSystemMenuHint;
+ if (windowMinimizeButtonCheckBox->isChecked())
+ flags |= Qt::WindowMinimizeButtonHint;
+ if (windowMaximizeButtonCheckBox->isChecked())
+ flags |= Qt::WindowMaximizeButtonHint;
+ if (windowCloseButtonCheckBox->isChecked())
+ flags |= Qt::WindowCloseButtonHint;
+ if (windowContextHelpButtonCheckBox->isChecked())
+ flags |= Qt::WindowContextHelpButtonHint;
+ if (windowShadeButtonCheckBox->isChecked())
+ flags |= Qt::WindowShadeButtonHint;
+ if (windowStaysOnTopCheckBox->isChecked())
+ flags |= Qt::WindowStaysOnTopHint;
+ if (windowStaysOnBottomCheckBox->isChecked())
+ flags |= Qt::WindowStaysOnBottomHint;
+ if (customizeWindowHintCheckBox->isChecked())
+ flags |= Qt::CustomizeWindowHint;
+
+ previewWindow->hide();
+ previewDialog->hide();
+ QWidget *widget = 0;
+ if (previewWidgetButton->isChecked())
+ widget = previewWindow;
+ else
+ widget = previewDialog;
+
+ if (modalWindowCheckBox->isChecked()) {
+ parentWindow->show();
+ widget->setWindowModality(Qt::WindowModal);
+ widget->setParent(parentWindow);
+ } else {
+ widget->setWindowModality(Qt::NonModal);
+ widget->setParent(0);
+ parentWindow->hide();
+ }
+
+ widget->setWindowFlags(flags);
+
+ if (fixedSizeWindowCheckBox->isChecked()) {
+ widget->setFixedSize(300, 300);
+ } else {
+ widget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+ }
+
+ QPoint pos = widget->pos();
+ if (pos.x() < 0)
+ pos.setX(0);
+ if (pos.y() < 0)
+ pos.setY(0);
+ widget->move(pos);
+ widget->show();
+}
+
+void ControllerWindow::createTypeGroupBox()
+{
+ widgetTypeGroupBox = new QGroupBox(tr("Widget Type"));
+ previewWidgetButton = createRadioButton(tr("QWidget"));
+ previewWidgetButton->setChecked(true);
+ previewDialogButton = createRadioButton(tr("QDialog"));
+ QHBoxLayout *l = new QHBoxLayout;
+ l->addWidget(previewWidgetButton);
+ l->addWidget(previewDialogButton);
+ widgetTypeGroupBox->setLayout(l);
+
+ additionalOptionsGroupBox = new QGroupBox(tr("Additional options"));
+ l = new QHBoxLayout;
+ modalWindowCheckBox = createCheckBox(tr("Modal window"));
+ fixedSizeWindowCheckBox = createCheckBox(tr("Fixed size window"));
+ l->addWidget(modalWindowCheckBox);
+ l->addWidget(fixedSizeWindowCheckBox);
+ additionalOptionsGroupBox->setLayout(l);
+
+ typeGroupBox = new QGroupBox(tr("Type"));
+
+ windowRadioButton = createRadioButton(tr("Window"));
+ dialogRadioButton = createRadioButton(tr("Dialog"));
+ sheetRadioButton = createRadioButton(tr("Sheet"));
+ drawerRadioButton = createRadioButton(tr("Drawer"));
+ popupRadioButton = createRadioButton(tr("Popup"));
+ toolRadioButton = createRadioButton(tr("Tool"));
+ toolTipRadioButton = createRadioButton(tr("Tooltip"));
+ splashScreenRadioButton = createRadioButton(tr("Splash screen"));
+ windowRadioButton->setChecked(true);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(windowRadioButton, 0, 0);
+ layout->addWidget(dialogRadioButton, 1, 0);
+ layout->addWidget(sheetRadioButton, 2, 0);
+ layout->addWidget(drawerRadioButton, 3, 0);
+ layout->addWidget(popupRadioButton, 0, 1);
+ layout->addWidget(toolRadioButton, 1, 1);
+ layout->addWidget(toolTipRadioButton, 2, 1);
+ layout->addWidget(splashScreenRadioButton, 3, 1);
+ typeGroupBox->setLayout(layout);
+}
+//! [5]
+
+//! [6]
+void ControllerWindow::createHintsGroupBox()
+{
+ hintsGroupBox = new QGroupBox(tr("Hints"));
+
+ msWindowsFixedSizeDialogCheckBox =
+ createCheckBox(tr("MS Windows fixed size dialog"));
+ x11BypassWindowManagerCheckBox =
+ createCheckBox(tr("X11 bypass window manager"));
+ framelessWindowCheckBox = createCheckBox(tr("Frameless window"));
+ windowTitleCheckBox = createCheckBox(tr("Window title"));
+ windowSystemMenuCheckBox = createCheckBox(tr("Window system menu"));
+ windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button"));
+ windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button"));
+ windowCloseButtonCheckBox = createCheckBox(tr("Window close button"));
+ windowContextHelpButtonCheckBox =
+ createCheckBox(tr("Window context help button"));
+ windowShadeButtonCheckBox = createCheckBox(tr("Window shade button"));
+ windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top"));
+ windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom"));
+ customizeWindowHintCheckBox= createCheckBox(tr("Customize window"));
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0);
+ layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0);
+ layout->addWidget(framelessWindowCheckBox, 2, 0);
+ layout->addWidget(windowTitleCheckBox, 3, 0);
+ layout->addWidget(windowSystemMenuCheckBox, 4, 0);
+ layout->addWidget(windowMinimizeButtonCheckBox, 0, 1);
+ layout->addWidget(windowMaximizeButtonCheckBox, 1, 1);
+ layout->addWidget(windowCloseButtonCheckBox, 2, 1);
+ layout->addWidget(windowContextHelpButtonCheckBox, 3, 1);
+ layout->addWidget(windowShadeButtonCheckBox, 4, 1);
+ layout->addWidget(windowStaysOnTopCheckBox, 5, 1);
+ layout->addWidget(windowStaysOnBottomCheckBox, 6, 1);
+ layout->addWidget(customizeWindowHintCheckBox, 5, 0);
+ hintsGroupBox->setLayout(layout);
+}
+//! [6]
+
+//! [7]
+QCheckBox *ControllerWindow::createCheckBox(const QString &text)
+{
+ QCheckBox *checkBox = new QCheckBox(text);
+ connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview()));
+ return checkBox;
+}
+//! [7]
+
+//! [8]
+QRadioButton *ControllerWindow::createRadioButton(const QString &text)
+{
+ QRadioButton *button = new QRadioButton(text);
+ connect(button, SIGNAL(clicked()), this, SLOT(updatePreview()));
+ return button;
+}
+//! [8]
diff --git a/src/gui/painting/qregion_wince.cpp b/tests/manual/windowflags/controllerwindow.h
index 9c33123..3d315be 100644
--- a/src/gui/painting/qregion_wince.cpp
+++ b/tests/manual/windowflags/controllerwindow.h
@@ -3,7 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,81 +39,77 @@
**
****************************************************************************/
-#include "qatomic.h"
-#include "qbitmap.h"
-#include "qbuffer.h"
-#include "qimage.h"
-#include "qpolygon.h"
-#include "qregion.h"
-#include "qt_windows.h"
-#include "qpainterpath.h"
-#include "qguifunctions_wince.h"
+#ifndef CONTROLLERWINDOW_H
+#define CONTROLLERWINDOW_H
-QT_BEGIN_NAMESPACE
+#include <QWidget>
-QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 };
+#include "previewwindow.h"
-HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom)
-{
- const int tries = 10;
- for (int i = 0; i < tries; ++i) {
- HRGN region;
- switch (type) {
- case QRegion::Rectangle:
- region = CreateRectRgn(left, top, right, bottom);
- break;
- case QRegion::Ellipse:
-#ifndef Q_OS_WINCE
- region = CreateEllipticRgn(left, top, right, bottom);
-#endif
- break;
- }
- if (region) {
- if (GetRegionData(region, 0, 0))
- return region;
- else
- DeleteObject(region);
- }
- }
- return 0;
-}
+QT_BEGIN_NAMESPACE
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QPushButton;
+class QRadioButton;
+class QMainWindow;
+QT_END_NAMESPACE
-void qt_win_dispose_rgn(HRGN r)
+//! [0]
+class ControllerWindow : public QWidget
{
- if (r)
- DeleteObject(r);
-}
+ Q_OBJECT
-static void qt_add_rect(HRGN &winRegion, QRect r)
-{
- HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
- if (rgn) {
- HRGN dest = CreateRectRgn(0,0,0,0);
- int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
- if (result) {
- DeleteObject(winRegion);
- winRegion = dest;
- }
- }
-}
+public:
+ ControllerWindow();
-void QRegion::ensureHandle() const
-{
- if (d->rgn)
- DeleteObject(d->rgn);
- d->rgn = CreateRectRgn(0,0,0,0);
- if (d->qt_rgn) {
- if (d->qt_rgn->numRects == 1) {
- QRect r = d->qt_rgn->extents;
- qt_add_rect(d->rgn, r);
- return;
- }
- for (int i = 0;i < d->qt_rgn->numRects;i++) {
- QRect r = d->qt_rgn->rects.at(i);
- qt_add_rect(d->rgn, r);
- }
- }
-}
+private slots:
+ void updatePreview();
+private:
+ void createTypeGroupBox();
+ void createHintsGroupBox();
+ QCheckBox *createCheckBox(const QString &text);
+ QRadioButton *createRadioButton(const QString &text);
-QT_END_NAMESPACE
+ QMainWindow *parentWindow;
+ PreviewWindow *previewWindow;
+ PreviewDialog *previewDialog;
+
+ QGroupBox *widgetTypeGroupBox;
+ QGroupBox *additionalOptionsGroupBox;
+ QGroupBox *typeGroupBox;
+ QGroupBox *hintsGroupBox;
+ QPushButton *quitButton;
+
+ QRadioButton *previewWidgetButton;
+ QRadioButton *previewDialogButton;
+ QCheckBox *modalWindowCheckBox;
+ QCheckBox *fixedSizeWindowCheckBox;
+
+ QRadioButton *windowRadioButton;
+ QRadioButton *dialogRadioButton;
+ QRadioButton *sheetRadioButton;
+ QRadioButton *drawerRadioButton;
+ QRadioButton *popupRadioButton;
+ QRadioButton *toolRadioButton;
+ QRadioButton *toolTipRadioButton;
+ QRadioButton *splashScreenRadioButton;
+
+ QCheckBox *msWindowsFixedSizeDialogCheckBox;
+ QCheckBox *x11BypassWindowManagerCheckBox;
+ QCheckBox *framelessWindowCheckBox;
+ QCheckBox *windowTitleCheckBox;
+ QCheckBox *windowSystemMenuCheckBox;
+ QCheckBox *windowMinimizeButtonCheckBox;
+ QCheckBox *windowMaximizeButtonCheckBox;
+ QCheckBox *windowCloseButtonCheckBox;
+ QCheckBox *windowContextHelpButtonCheckBox;
+ QCheckBox *windowShadeButtonCheckBox;
+ QCheckBox *windowStaysOnTopCheckBox;
+ QCheckBox *windowStaysOnBottomCheckBox;
+ QCheckBox *customizeWindowHintCheckBox;
+};
+//! [0]
+
+#endif
diff --git a/tests/manual/windowflags/main.cpp b/tests/manual/windowflags/main.cpp
new file mode 100644
index 0000000..011ca3f
--- /dev/null
+++ b/tests/manual/windowflags/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "controllerwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ControllerWindow controller;
+ controller.show();
+ return app.exec();
+}
diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp
new file mode 100644
index 0000000..796bdb9
--- /dev/null
+++ b/tests/manual/windowflags/previewwindow.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "previewwindow.h"
+
+static QString windowFlagsToString(Qt::WindowFlags flags)
+{
+ QString text;
+
+ Qt::WindowFlags type = (flags & Qt::WindowType_Mask);
+ if (type == Qt::Window) {
+ text = "Qt::Window";
+ } else if (type == Qt::Dialog) {
+ text = "Qt::Dialog";
+ } else if (type == Qt::Sheet) {
+ text = "Qt::Sheet";
+ } else if (type == Qt::Drawer) {
+ text = "Qt::Drawer";
+ } else if (type == Qt::Popup) {
+ text = "Qt::Popup";
+ } else if (type == Qt::Tool) {
+ text = "Qt::Tool";
+ } else if (type == Qt::ToolTip) {
+ text = "Qt::ToolTip";
+ } else if (type == Qt::SplashScreen) {
+ text = "Qt::SplashScreen";
+ }
+
+ if (flags & Qt::MSWindowsFixedSizeDialogHint)
+ text += "\n| Qt::MSWindowsFixedSizeDialogHint";
+ if (flags & Qt::X11BypassWindowManagerHint)
+ text += "\n| Qt::X11BypassWindowManagerHint";
+ if (flags & Qt::FramelessWindowHint)
+ text += "\n| Qt::FramelessWindowHint";
+ if (flags & Qt::WindowTitleHint)
+ text += "\n| Qt::WindowTitleHint";
+ if (flags & Qt::WindowSystemMenuHint)
+ text += "\n| Qt::WindowSystemMenuHint";
+ if (flags & Qt::WindowMinimizeButtonHint)
+ text += "\n| Qt::WindowMinimizeButtonHint";
+ if (flags & Qt::WindowMaximizeButtonHint)
+ text += "\n| Qt::WindowMaximizeButtonHint";
+ if (flags & Qt::WindowCloseButtonHint)
+ text += "\n| Qt::WindowCloseButtonHint";
+ if (flags & Qt::WindowContextHelpButtonHint)
+ text += "\n| Qt::WindowContextHelpButtonHint";
+ if (flags & Qt::WindowShadeButtonHint)
+ text += "\n| Qt::WindowShadeButtonHint";
+ if (flags & Qt::WindowStaysOnTopHint)
+ text += "\n| Qt::WindowStaysOnTopHint";
+ if (flags & Qt::CustomizeWindowHint)
+ text += "\n| Qt::CustomizeWindowHint";
+ return text;
+}
+
+PreviewWindow::PreviewWindow(QWidget *parent)
+ : QWidget(parent)
+{
+ textEdit = new QTextEdit;
+ textEdit->setReadOnly(true);
+ textEdit->setLineWrapMode(QTextEdit::NoWrap);
+
+ closeButton = new QPushButton(tr("&Close"));
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(textEdit);
+ layout->addWidget(closeButton);
+ setLayout(layout);
+
+ setWindowTitle(tr("Preview <QWidget>"));
+}
+
+void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ QWidget::setWindowFlags(flags);
+
+ QString text = windowFlagsToString(flags);
+ textEdit->setPlainText(text);
+}
+
+PreviewDialog::PreviewDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ textEdit = new QTextEdit;
+ textEdit->setReadOnly(true);
+ textEdit->setLineWrapMode(QTextEdit::NoWrap);
+
+ closeButton = new QPushButton(tr("&Close"));
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(textEdit);
+ layout->addWidget(closeButton);
+ setLayout(layout);
+
+ setWindowTitle(tr("Preview <QDialog>"));
+}
+
+void PreviewDialog::setWindowFlags(Qt::WindowFlags flags)
+{
+ QWidget::setWindowFlags(flags);
+
+ QString text = windowFlagsToString(flags);
+ textEdit->setPlainText(text);
+}
diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h
new file mode 100644
index 0000000..90ed8ba
--- /dev/null
+++ b/tests/manual/windowflags/previewwindow.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PREVIEWWINDOW_H
+#define PREVIEWWINDOW_H
+
+#include <QWidget>
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QPushButton;
+class QTextEdit;
+QT_END_NAMESPACE
+
+class PreviewWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ PreviewWindow(QWidget *parent = 0);
+
+ void setWindowFlags(Qt::WindowFlags flags);
+
+private:
+ QTextEdit *textEdit;
+ QPushButton *closeButton;
+};
+
+class PreviewDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ PreviewDialog(QWidget *parent = 0);
+
+ void setWindowFlags(Qt::WindowFlags flags);
+
+private:
+ QTextEdit *textEdit;
+ QPushButton *closeButton;
+};
+
+#endif
diff --git a/tests/manual/windowflags/windowflags.pro b/tests/manual/windowflags/windowflags.pro
new file mode 100644
index 0000000..1b45d0d
--- /dev/null
+++ b/tests/manual/windowflags/windowflags.pro
@@ -0,0 +1,5 @@
+HEADERS = controllerwindow.h \
+ previewwindow.h
+SOURCES = controllerwindow.cpp \
+ previewwindow.cpp \
+ main.cpp
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 58e094b..21b230e 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -1676,7 +1676,9 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
case Tok_trid:
if (!results->tor)
goto case_default;
- if (!sourcetext.isEmpty()) {
+ if (sourcetext.isEmpty()) {
+ yyTok = getToken();
+ } else {
if (!msgid.isEmpty())
qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n",
qPrintable(yyFileName), yyLineNo);
diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp
index 638e997..dc681f5 100644
--- a/tools/linguist/shared/qm.cpp
+++ b/tools/linguist/shared/qm.cpp
@@ -553,7 +553,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd)
//qDebug() << "NUMITEMS: " << numItems;
QTextCodec *codec = QTextCodec::codecForName(
- cd.m_codecForSource.isEmpty() ? "Latin1" : cd.m_codecForSource);
+ cd.m_codecForSource.isEmpty() ? QByteArray("Latin1") : cd.m_codecForSource);
QTextCodec *utf8Codec = 0;
if (codec->name() != "UTF-8")
utf8Codec = QTextCodec::codecForName("UTF-8");