summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/baselineexample/baselineexample.pro2
-rw-r--r--tests/auto/gui.pro1
-rw-r--r--tests/auto/guiapplauncher/demos.txt14
-rw-r--r--tests/auto/guiapplauncher/examples.txt14
-rw-r--r--tests/auto/lancelot/images.qrc34
-rw-r--r--tests/auto/lancelot/images/alpha.pngbin0 -> 2422 bytes
-rw-r--r--tests/auto/lancelot/images/alpha2x2.pngbin0 -> 169 bytes
-rw-r--r--tests/auto/lancelot/images/bitmap.pngbin0 -> 254 bytes
-rw-r--r--tests/auto/lancelot/images/border.pngbin0 -> 182 bytes
-rw-r--r--tests/auto/lancelot/images/borderimage.pngbin0 -> 826 bytes
-rw-r--r--tests/auto/lancelot/images/dome_argb32.pngbin0 -> 18234 bytes
-rw-r--r--tests/auto/lancelot/images/dome_indexed.pngbin0 -> 7946 bytes
-rw-r--r--tests/auto/lancelot/images/dome_indexed_mask.pngbin0 -> 5411 bytes
-rw-r--r--tests/auto/lancelot/images/dome_mono.pngbin0 -> 1391 bytes
-rw-r--r--tests/auto/lancelot/images/dome_mono_128.pngbin0 -> 2649 bytes
-rw-r--r--tests/auto/lancelot/images/dome_mono_palette.pngbin0 -> 1404 bytes
-rw-r--r--tests/auto/lancelot/images/dome_rgb32.pngbin0 -> 17890 bytes
-rw-r--r--tests/auto/lancelot/images/dot.pngbin0 -> 287 bytes
-rw-r--r--tests/auto/lancelot/images/face.pngbin0 -> 2414 bytes
-rw-r--r--tests/auto/lancelot/images/gam030.pngbin0 -> 213 bytes
-rw-r--r--tests/auto/lancelot/images/gam045.pngbin0 -> 216 bytes
-rw-r--r--tests/auto/lancelot/images/gam056.pngbin0 -> 216 bytes
-rw-r--r--tests/auto/lancelot/images/gam100.pngbin0 -> 205 bytes
-rw-r--r--tests/auto/lancelot/images/gam200.pngbin0 -> 187 bytes
-rw-r--r--tests/auto/lancelot/images/image.pngbin0 -> 169554 bytes
-rw-r--r--tests/auto/lancelot/images/mask.pngbin0 -> 274 bytes
-rw-r--r--tests/auto/lancelot/images/mask_100.pngbin0 -> 319 bytes
-rw-r--r--tests/auto/lancelot/images/masked.pngbin0 -> 788 bytes
-rw-r--r--tests/auto/lancelot/images/sign.pngbin0 -> 10647 bytes
-rw-r--r--tests/auto/lancelot/images/solid.pngbin0 -> 607 bytes
-rw-r--r--tests/auto/lancelot/images/solid2x2.pngbin0 -> 169 bytes
-rw-r--r--tests/auto/lancelot/images/struct-image-01.jpgbin0 -> 4751 bytes
-rw-r--r--tests/auto/lancelot/images/struct-image-01.pngbin0 -> 63238 bytes
-rw-r--r--tests/auto/lancelot/images/zebra.pngbin0 -> 426 bytes
-rw-r--r--tests/auto/lancelot/lancelot.pro8
-rw-r--r--tests/auto/lancelot/paintcommands.cpp2586
-rw-r--r--tests/auto/lancelot/paintcommands.h334
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp2
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp2
-rw-r--r--tests/auto/qclipboard/tst_qclipboard.cpp6
-rw-r--r--tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp2
-rw-r--r--tests/auto/qeventloop/tst_qeventloop.cpp77
-rw-r--r--tests/auto/qftp/tst_qftp.cpp2
-rw-r--r--tests/auto/qgl/tst_qgl.cpp17
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp2
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp4
-rw-r--r--tests/auto/qhostinfo/tst_qhostinfo.cpp2
-rw-r--r--tests/auto/qitemmodel/tst_qitemmodel.cpp30
-rw-r--r--tests/auto/qitemview/tst_qitemview.cpp4
-rw-r--r--tests/auto/qkeysequence/tst_qkeysequence.cpp2
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp2
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp2
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp28
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp57
-rw-r--r--tests/auto/qprinterinfo/tst_qprinterinfo.cpp2
-rw-r--r--tests/auto/qpushbutton/tst_qpushbutton.cpp2
-rw-r--r--tests/auto/qscopedpointer/tst_qscopedpointer.cpp22
-rw-r--r--tests/auto/qshortcut/tst_qshortcut.cpp2
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp2
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp2
-rw-r--r--tests/auto/qsslcertificate/more-certificates/test-cn-two-cns-cert.pem67
-rw-r--r--tests/auto/qsslcertificate/tst_qsslcertificate.cpp84
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp4
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp40
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp12
-rw-r--r--tests/auto/qtcpserver/tst_qtcpserver.cpp4
-rw-r--r--tests/auto/qtextformat/tst_qtextformat.cpp4
-rw-r--r--tests/auto/qtipc/qsharedmemory/src/qsystemlock.cpp2
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp5
-rw-r--r--tests/auto/qurl/tst_qurl.cpp25
71 files changed, 3339 insertions, 176 deletions
diff --git a/tests/auto/baselineexample/baselineexample.pro b/tests/auto/baselineexample/baselineexample.pro
index 13f03b8f36..3d3d42e8cc 100644
--- a/tests/auto/baselineexample/baselineexample.pro
+++ b/tests/auto/baselineexample/baselineexample.pro
@@ -15,4 +15,4 @@ TEMPLATE = app
SOURCES += tst_baselineexample.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
-include($$PWD/../../arthur/common/qbaselinetest.pri)
+include($$PWD/../../baselineserver/shared/qbaselinetest.pri)
diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro
index df161f1fb2..cf7db60c6d 100644
--- a/tests/auto/gui.pro
+++ b/tests/auto/gui.pro
@@ -227,6 +227,7 @@ win32:SUBDIRS -= qtextpiecetable
qtextpiecetable \
qtipc \
qtoolbar \
+ qstatictext \
symbian:SUBDIRS -= \
qsystemtrayicon \
diff --git a/tests/auto/guiapplauncher/demos.txt b/tests/auto/guiapplauncher/demos.txt
index 2835f09477..e69de29bb2 100644
--- a/tests/auto/guiapplauncher/demos.txt
+++ b/tests/auto/guiapplauncher/demos.txt
@@ -1,14 +0,0 @@
-"Affine Demo", "demos/affine", "affine", 0, -1
-"Books Demo", "demos/books", "books", 0, -1
-"Chip Demo", "demos/chip", "chip", 0, -1
-"Composition Demo", "demos/composition", "composition", 0, -1
-"Deform Demo", "demos/deform", "deform", 0, -1
-"Embeddeddialogs Demo", "demos/embeddeddialogs", "embeddeddialogs", 0, -1
-"Gradients Demo", "demos/gradients", "gradients", 0, -1
-"Interview Demo", "demos/interview", "interview", 0, -1
-"Mainwindow Demo", "demos/mainwindow", "mainwindow", 0, -1
-"PathStroke Demo", "demos/pathstroke", "pathstroke", 0, -1
-"Spreadsheet Demo", "demos/spreadsheet", "spreadsheet", 0, -1
-"Sub-Attac Demo", "demos/sub-attaq", "sub-attaq", 0, -1
-"TextEdit Demo", "demos/textedit", "textedit", 0, -1
-"Undo Demo", "demos/undo", "undo", 0, -1
diff --git a/tests/auto/guiapplauncher/examples.txt b/tests/auto/guiapplauncher/examples.txt
index fea7e543f0..65993fae1a 100644
--- a/tests/auto/guiapplauncher/examples.txt
+++ b/tests/auto/guiapplauncher/examples.txt
@@ -4,6 +4,7 @@
"animation/moveblocks Example", "examples/animation/moveblocks", "moveblocks", 10, -1
"animation/states Example", "examples/animation/states", "states", 10, -1
"animation/stickman Example", "examples/animation/stickman", "stickman", 10, -1
+"animation/sub-attaq Example", "examples/animation/sub-attaq", "sub-attaq", 0, -1
"designer/calculatorbuilder Example", "examples/designer/calculatorbuilder", "calculatorbuilder", 10, -1
"dialogs/standarddialogs Example", "examples/dialogs/standarddialogs", "standarddialogs", 10, -1
"draganddrop/dropsite Example", "examples/draganddrop/dropsite", "dropsite", 10, -1
@@ -15,10 +16,12 @@
"effects/lighting Example", "examples/effects/lighting", "lighting", 10, -1
"graphicsview/anchorlayout Example", "examples/graphicsview/anchorlayout", "anchorlayout", 10, -1
"graphicsview/basicgraphicslayouts Example", "examples/graphicsview/basicgraphicslayouts", "basicgraphicslayouts", 0, -1
+"graphicsview/chip Example", "examples/graphicsview/chip", "chip", 0, -1
"graphicsview/collidingmice Example", "examples/graphicsview/collidingmice", "collidingmice", 10, -1
"graphicsview/diagramscene Example", "examples/graphicsview/diagramscene", "diagramscene", 10, -1
"graphicsview/dragdroprobot Example", "examples/graphicsview/dragdroprobot", "dragdroprobot", 10, -1
"graphicsview/elasticnodes Example", "examples/graphicsview/elasticnodes", "elasticnodes", 10, -1
+"graphicsview/embeddeddialogs Example", "examples/graphicsview/embeddeddialogs", "embeddeddialogs", 0, -1
"graphicsview/flowlayout Example", "examples/graphicsview/flowlayout", "flowlayout", 10, -1
"graphicsview/padnavigator Example", "examples/graphicsview/padnavigator", "padnavigator", 0, -1
"graphicsview/portedasteroids Example", "examples/graphicsview/portedasteroids", "portedasteroids", 10, -1
@@ -34,12 +37,14 @@
"itemviews/editabletreemodel Example", "examples/itemviews/editabletreemodel", "editabletreemodel", 0, -1
"itemviews/fetchmore Example", "examples/itemviews/fetchmore", "fetchmore", 10, -1
"itemviews/frozencolumn Example", "examples/itemviews/frozencolumn", "frozencolumn", 10, -1
+"itemviews/interview Example", "examples/itemviews/interview", "interview", 0, -1
"itemviews/pixelator Example", "examples/itemviews/pixelator", "pixelator", 10, -1
"itemviews/puzzle Example", "examples/itemviews/puzzle", "puzzle", 10, -1
"itemviews/simpledommodel Example", "examples/itemviews/simpledommodel", "simpledommodel", 10, -1
"itemviews/simpletreemodel Example", "examples/itemviews/simpletreemodel", "simpletreemodel", 10, -1
"itemviews/simplewidgetmapper Example", "examples/itemviews/simplewidgetmapper", "simplewidgetmapper", 10, -1
"itemviews/spinboxdelegate Example", "examples/itemviews/spinboxdelegate", "spinboxdelegate", 0, -1
+"itemviews/spreadsheet Example", "examples/itemviews/spreadsheet", "spreadsheet", 0, -1
"itemviews/stardelegate Example", "examples/itemviews/stardelegate", "stardelegate", 10, -1
"layouts/basiclayouts Example", "examples/layouts/basiclayouts", "basiclayouts", 0, -1
"layouts/borderlayout Example", "examples/layouts/borderlayout", "borderlayout", 10, -1
@@ -47,6 +52,7 @@
"layouts/flowlayout Example", "examples/layouts/flowlayout", "flowlayout", 10, -1
"mainwindows/application Example", "examples/mainwindows/application", "application", 6, -1
"mainwindows/dockwidgets Example", "examples/mainwindows/dockwidgets", "dockwidgets", 0, -1
+"mainwindows/mainwindow Example", "examples/mainwindows/mainwindow", "mainwindow", 0, -1
"mainwindows/mdi Example", "examples/mainwindows/mdi", "mdi", 0, -1
"mainwindows/menus Example", "examples/mainwindows/menus", "menus", 10, -1
"mainwindows/recentfiles Example", "examples/mainwindows/recentfiles", "recentfiles", 10, -1
@@ -61,21 +67,29 @@
"opengl/overpainting Example", "examples/opengl/overpainting", "overpainting", 10, -1
"opengl/samplebuffers Example", "examples/opengl/samplebuffers", "samplebuffers", 10, -1
"opengl/textures Example", "examples/opengl/textures", "textures", 10, -1
+"painting/affine Example", "examples/painting/affine", "affine", 0, -1
"painting/basicdrawing Example", "examples/painting/basicdrawing", "basicdrawing", 10, -1
+"painting/composition Example", "examples/painting/composition", "composition", 0, -1
"painting/concentriccircles Example", "examples/painting/concentriccircles", "concentriccircles", 0, -1
+"painting/deform Example", "examples/painting/deform", "deform", 0, -1
"painting/fontsampler Example", "examples/painting/fontsampler", "fontsampler", 0, -1
+"painting/gradients Example", "examples/painting/gradients", "gradients", 0, -1
"painting/imagecomposition Example", "examples/painting/imagecomposition", "imagecomposition", 10, -1
"painting/painterpaths Example", "examples/painting/painterpaths", "painterpaths", 10, -1
+"painting/pathstroke Example", "examples/painting/pathstroke", "pathstroke", 0, -1
"painting/transformations Example", "examples/painting/transformations", "transformations", 0, -1
"qtconcurrent/imagescaling Example", "examples/qtconcurrent/imagescaling", "imagescaling", 10, -1
"richtext/calendar Example", "examples/richtext/calendar", "calendar", 0, -1
"richtext/orderform Example", "examples/richtext/orderform", "orderform", 10, -1
"richtext/syntaxhighlighter Example", "examples/richtext/syntaxhighlighter", "syntaxhighlighter", 0, -1
+"richtext/textedit Example", "examples/richtext/textedit", "textedit", 0, -1
"richtext/textobject Example", "examples/richtext/textobject", "textobject", 10, -1
+"sql/books Example", "examples/sql/books", "books", 0, -1
"statemachine/eventtransitions Example", "examples/statemachine/eventtransitions", "eventtransitions", 10, -1
"statemachine/rogue Example", "examples/statemachine/rogue", "rogue", 10, -1
"statemachine/trafficlight Example", "examples/statemachine/trafficlight", "trafficlight", 0, -1
"statemachine/twowaybutton Example", "examples/statemachine/twowaybutton", "twowaybutton", 10, -1
+"tools/undo Example", "examples/tools/undo", "undo", 0, -1
"tutorials/addressbook/part7 Example", "examples/tutorials/addressbook/part7", "part7", 0, -1
"widgets/analogclock Example", "examples/widgets/analogclock", "analogclock", 6, -1
"widgets/calculator Example", "examples/widgets/calculator", "calculator", 6, -1
diff --git a/tests/auto/lancelot/images.qrc b/tests/auto/lancelot/images.qrc
new file mode 100644
index 0000000000..060b52c85a
--- /dev/null
+++ b/tests/auto/lancelot/images.qrc
@@ -0,0 +1,34 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+<qresource>
+ <file>images/alpha.png</file>
+ <file>images/border.png</file>
+ <file>images/borderimage.png</file>
+ <file>images/dome_argb32.png</file>
+ <file>images/dome_indexed.png</file>
+ <file>images/dome_mono_palette.png</file>
+ <file>images/dome_rgb32.png</file>
+ <file>images/face.png</file>
+ <file>images/gam045.png</file>
+ <file>images/gam100.png</file>
+ <file>images/image.png</file>
+ <file>images/masked.png</file>
+ <file>images/sign.png</file>
+ <file>images/struct-image-01.jpg</file>
+ <file>images/bitmap.png</file>
+ <file>images/dome_indexed_mask.png</file>
+ <file>images/dome_mono_128.png</file>
+ <file>images/dome_mono.png</file>
+ <file>images/dot.png</file>
+ <file>images/gam030.png</file>
+ <file>images/gam056.png</file>
+ <file>images/gam200.png</file>
+ <file>images/mask_100.png</file>
+ <file>images/mask.png</file>
+ <file>images/solid.png</file>
+ <file>images/struct-image-01.png</file>
+ <file>images/zebra.png</file>
+ <file>images/alpha2x2.png</file>
+ <file>images/solid2x2.png</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/lancelot/images/alpha.png b/tests/auto/lancelot/images/alpha.png
new file mode 100644
index 0000000000..e465b2586d
--- /dev/null
+++ b/tests/auto/lancelot/images/alpha.png
Binary files differ
diff --git a/tests/auto/lancelot/images/alpha2x2.png b/tests/auto/lancelot/images/alpha2x2.png
new file mode 100644
index 0000000000..67ecc04286
--- /dev/null
+++ b/tests/auto/lancelot/images/alpha2x2.png
Binary files differ
diff --git a/tests/auto/lancelot/images/bitmap.png b/tests/auto/lancelot/images/bitmap.png
new file mode 100644
index 0000000000..d21f8f51bb
--- /dev/null
+++ b/tests/auto/lancelot/images/bitmap.png
Binary files differ
diff --git a/tests/auto/lancelot/images/border.png b/tests/auto/lancelot/images/border.png
new file mode 100644
index 0000000000..a3d2fed0a3
--- /dev/null
+++ b/tests/auto/lancelot/images/border.png
Binary files differ
diff --git a/tests/auto/lancelot/images/borderimage.png b/tests/auto/lancelot/images/borderimage.png
new file mode 100644
index 0000000000..f7f6b66227
--- /dev/null
+++ b/tests/auto/lancelot/images/borderimage.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_argb32.png b/tests/auto/lancelot/images/dome_argb32.png
new file mode 100644
index 0000000000..e3ccba0c13
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_argb32.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_indexed.png b/tests/auto/lancelot/images/dome_indexed.png
new file mode 100644
index 0000000000..beefcd514e
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_indexed.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_indexed_mask.png b/tests/auto/lancelot/images/dome_indexed_mask.png
new file mode 100644
index 0000000000..a62f29f40e
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_indexed_mask.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_mono.png b/tests/auto/lancelot/images/dome_mono.png
new file mode 100644
index 0000000000..950c2a7494
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_mono.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_mono_128.png b/tests/auto/lancelot/images/dome_mono_128.png
new file mode 100644
index 0000000000..77e48aaab7
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_mono_128.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_mono_palette.png b/tests/auto/lancelot/images/dome_mono_palette.png
new file mode 100644
index 0000000000..dca3f59245
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_mono_palette.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dome_rgb32.png b/tests/auto/lancelot/images/dome_rgb32.png
new file mode 100644
index 0000000000..27bc02a545
--- /dev/null
+++ b/tests/auto/lancelot/images/dome_rgb32.png
Binary files differ
diff --git a/tests/auto/lancelot/images/dot.png b/tests/auto/lancelot/images/dot.png
new file mode 100644
index 0000000000..17a7b6a0ba
--- /dev/null
+++ b/tests/auto/lancelot/images/dot.png
Binary files differ
diff --git a/tests/auto/lancelot/images/face.png b/tests/auto/lancelot/images/face.png
new file mode 100644
index 0000000000..4f6172d83b
--- /dev/null
+++ b/tests/auto/lancelot/images/face.png
Binary files differ
diff --git a/tests/auto/lancelot/images/gam030.png b/tests/auto/lancelot/images/gam030.png
new file mode 100644
index 0000000000..904c9721bd
--- /dev/null
+++ b/tests/auto/lancelot/images/gam030.png
Binary files differ
diff --git a/tests/auto/lancelot/images/gam045.png b/tests/auto/lancelot/images/gam045.png
new file mode 100644
index 0000000000..b649a8a54f
--- /dev/null
+++ b/tests/auto/lancelot/images/gam045.png
Binary files differ
diff --git a/tests/auto/lancelot/images/gam056.png b/tests/auto/lancelot/images/gam056.png
new file mode 100644
index 0000000000..e5f959dc96
--- /dev/null
+++ b/tests/auto/lancelot/images/gam056.png
Binary files differ
diff --git a/tests/auto/lancelot/images/gam100.png b/tests/auto/lancelot/images/gam100.png
new file mode 100644
index 0000000000..6c7ba5f1ed
--- /dev/null
+++ b/tests/auto/lancelot/images/gam100.png
Binary files differ
diff --git a/tests/auto/lancelot/images/gam200.png b/tests/auto/lancelot/images/gam200.png
new file mode 100644
index 0000000000..daa20fcbc4
--- /dev/null
+++ b/tests/auto/lancelot/images/gam200.png
Binary files differ
diff --git a/tests/auto/lancelot/images/image.png b/tests/auto/lancelot/images/image.png
new file mode 100644
index 0000000000..85d486a790
--- /dev/null
+++ b/tests/auto/lancelot/images/image.png
Binary files differ
diff --git a/tests/auto/lancelot/images/mask.png b/tests/auto/lancelot/images/mask.png
new file mode 100644
index 0000000000..c3f3b1b6ca
--- /dev/null
+++ b/tests/auto/lancelot/images/mask.png
Binary files differ
diff --git a/tests/auto/lancelot/images/mask_100.png b/tests/auto/lancelot/images/mask_100.png
new file mode 100644
index 0000000000..fc950dc7ed
--- /dev/null
+++ b/tests/auto/lancelot/images/mask_100.png
Binary files differ
diff --git a/tests/auto/lancelot/images/masked.png b/tests/auto/lancelot/images/masked.png
new file mode 100644
index 0000000000..6debec534d
--- /dev/null
+++ b/tests/auto/lancelot/images/masked.png
Binary files differ
diff --git a/tests/auto/lancelot/images/sign.png b/tests/auto/lancelot/images/sign.png
new file mode 100644
index 0000000000..6aac7e150a
--- /dev/null
+++ b/tests/auto/lancelot/images/sign.png
Binary files differ
diff --git a/tests/auto/lancelot/images/solid.png b/tests/auto/lancelot/images/solid.png
new file mode 100644
index 0000000000..371e9c1aee
--- /dev/null
+++ b/tests/auto/lancelot/images/solid.png
Binary files differ
diff --git a/tests/auto/lancelot/images/solid2x2.png b/tests/auto/lancelot/images/solid2x2.png
new file mode 100644
index 0000000000..ad67cd3e12
--- /dev/null
+++ b/tests/auto/lancelot/images/solid2x2.png
Binary files differ
diff --git a/tests/auto/lancelot/images/struct-image-01.jpg b/tests/auto/lancelot/images/struct-image-01.jpg
new file mode 100644
index 0000000000..a74e07223b
--- /dev/null
+++ b/tests/auto/lancelot/images/struct-image-01.jpg
Binary files differ
diff --git a/tests/auto/lancelot/images/struct-image-01.png b/tests/auto/lancelot/images/struct-image-01.png
new file mode 100644
index 0000000000..4ed08406dc
--- /dev/null
+++ b/tests/auto/lancelot/images/struct-image-01.png
Binary files differ
diff --git a/tests/auto/lancelot/images/zebra.png b/tests/auto/lancelot/images/zebra.png
new file mode 100644
index 0000000000..ef35f20785
--- /dev/null
+++ b/tests/auto/lancelot/images/zebra.png
Binary files differ
diff --git a/tests/auto/lancelot/lancelot.pro b/tests/auto/lancelot/lancelot.pro
index c4eaaac6ab..67fff1b411 100644
--- a/tests/auto/lancelot/lancelot.pro
+++ b/tests/auto/lancelot/lancelot.pro
@@ -3,11 +3,11 @@ QT += xml
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl
SOURCES += tst_lancelot.cpp \
- $$PWD/../../arthur/common/paintcommands.cpp
-HEADERS += $$PWD/../../arthur/common/paintcommands.h
-RESOURCES += $$PWD/../../arthur/common/images.qrc
+ paintcommands.cpp
+HEADERS += paintcommands.h
+RESOURCES += images.qrc
-include($$PWD/../../arthur/common/qbaselinetest.pri)
+include($$PWD/../../baselineserver/shared/qbaselinetest.pri)
!symbian:!wince*:DEFINES += SRCDIR=\\\"$$PWD\\\"
linux-g++-maemo:DEFINES += USE_RUNTIME_DIR
diff --git a/tests/auto/lancelot/paintcommands.cpp b/tests/auto/lancelot/paintcommands.cpp
new file mode 100644
index 0000000000..8735baa3f0
--- /dev/null
+++ b/tests/auto/lancelot/paintcommands.cpp
@@ -0,0 +1,2586 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "paintcommands.h"
+
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qpainter.h>
+#include <qbitmap.h>
+#include <qtextstream.h>
+#include <qtextlayout.h>
+#include <qdebug.h>
+#include <QStaticText>
+
+#ifndef QT_NO_OPENGL
+#include <qglpixelbuffer.h>
+#endif
+
+/*********************************************************************************
+** everything to populate static tables
+**********************************************************************************/
+const char *PaintCommands::brushStyleTable[] = {
+ "NoBrush",
+ "SolidPattern",
+ "Dense1Pattern",
+ "Dense2Pattern",
+ "Dense3Pattern",
+ "Dense4Pattern",
+ "Dense5Pattern",
+ "Dense6Pattern",
+ "Dense7Pattern",
+ "HorPattern",
+ "VerPattern",
+ "CrossPattern",
+ "BDiagPattern",
+ "FDiagPattern",
+ "DiagCrossPattern",
+ "LinearGradientPattern"
+};
+
+const char *PaintCommands::penStyleTable[] = {
+ "NoPen",
+ "SolidLine",
+ "DashLine",
+ "DotLine",
+ "DashDotLine",
+ "DashDotDotLine"
+};
+
+const char *PaintCommands::fontWeightTable[] = {
+ "Light",
+ "Normal",
+ "DemiBold",
+ "Bold",
+ "Black"
+};
+
+const char *PaintCommands::fontHintingTable[] = {
+ "Default",
+ "None",
+ "Vertical",
+ "Full"
+};
+
+const char *PaintCommands::clipOperationTable[] = {
+ "NoClip",
+ "ReplaceClip",
+ "IntersectClip",
+ "UniteClip"
+};
+
+const char *PaintCommands::spreadMethodTable[] = {
+ "PadSpread",
+ "ReflectSpread",
+ "RepeatSpread"
+};
+
+const char *PaintCommands::coordinateMethodTable[] = {
+ "LogicalMode",
+ "StretchToDeviceMode",
+ "ObjectBoundingMode"
+};
+
+const char *PaintCommands::sizeModeTable[] = {
+ "AbsoluteSize",
+ "RelativeSize"
+};
+
+const char *PaintCommands::compositionModeTable[] = {
+ "SourceOver",
+ "DestinationOver",
+ "Clear",
+ "Source",
+ "Destination",
+ "SourceIn",
+ "DestinationIn",
+ "SourceOut",
+ "DestinationOut",
+ "SourceAtop",
+ "DestinationAtop",
+ "Xor",
+ "Plus",
+ "Multiply",
+ "Screen",
+ "Overlay",
+ "Darken",
+ "Lighten",
+ "ColorDodge",
+ "ColorBurn",
+ "HardLight",
+ "SoftLight",
+ "Difference",
+ "Exclusion",
+ "SourceOrDestination",
+ "SourceAndDestination",
+ "SourceXorDestination",
+ "NotSourceAndNotDestination",
+ "NotSourceOrNotDestination",
+ "NotSourceXorDestination",
+ "NotSource",
+ "NotSourceAndDestination",
+ "SourceAndNotDestination"
+};
+
+const char *PaintCommands::imageFormatTable[] = {
+ "Invalid",
+ "Mono",
+ "MonoLSB",
+ "Indexed8",
+ "RGB32",
+ "ARGB32",
+ "ARGB32_Premultiplied",
+ "Format_RGB16",
+ "Format_ARGB8565_Premultiplied",
+ "Format_RGB666",
+ "Format_ARGB6666_Premultiplied",
+ "Format_RGB555",
+ "Format_ARGB8555_Premultiplied",
+ "Format_RGB888",
+ "Format_RGB444",
+ "Format_ARGB4444_Premultiplied"
+};
+
+int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit)
+{
+ QByteArray p = pattern.toLatin1().toLower();
+ for (int i=0; i<limit; ++i)
+ if (p == QByteArray::fromRawData(table[i], qstrlen(table[i])).toLower())
+ return i;
+ return -1;
+}
+
+QList<PaintCommands::PaintCommandInfos> PaintCommands::s_commandInfoTable = QList<PaintCommands::PaintCommandInfos>();
+QList<QPair<QString,QStringList> > PaintCommands::s_enumsTable = QList<QPair<QString,QStringList> >();
+QMultiHash<QString, int> PaintCommands::s_commandHash;
+
+#define DECL_PAINTCOMMAND(identifier, method, regexp, syntax, sample) \
+ s_commandInfoTable << PaintCommandInfos(QLatin1String(identifier), &PaintCommands::method, QRegExp(regexp), \
+ QLatin1String(syntax), QLatin1String(sample) );
+
+#define DECL_PAINTCOMMANDSECTION(title) \
+ s_commandInfoTable << PaintCommandInfos(QLatin1String(title));
+
+#define ADD_ENUMLIST(listCaption, cStrArray) { \
+ QStringList list; \
+ for (int i=0; i<int(sizeof(cStrArray)/sizeof(char*)); i++) \
+ list << cStrArray[i]; \
+ s_enumsTable << qMakePair(QString(listCaption), list); \
+ }
+
+void PaintCommands::staticInit()
+{
+ // check if already done
+ if (!s_commandInfoTable.isEmpty()) return;
+
+ // populate the command list
+ DECL_PAINTCOMMANDSECTION("misc");
+ DECL_PAINTCOMMAND("comment", command_comment,
+ "^\\s*#",
+ "# this is some comments",
+ "# place your comments here");
+ DECL_PAINTCOMMAND("import", command_import,
+ "^import\\s+\"(.*)\"$",
+ "import <qrcFilename>",
+ "import \"myfile.qrc\"");
+ DECL_PAINTCOMMAND("begin_block", command_begin_block,
+ "^begin_block\\s+(\\w*)$",
+ "begin_block <blockName>",
+ "begin_block blockName");
+ DECL_PAINTCOMMAND("end_block", command_end_block,
+ "^end_block$",
+ "end_block",
+ "end_block");
+ DECL_PAINTCOMMAND("repeat_block", command_repeat_block,
+ "^repeat_block\\s+(\\w*)$",
+ "repeat_block <blockName>",
+ "repeat_block blockName");
+ DECL_PAINTCOMMAND("textlayout_draw", command_textlayout_draw,
+ "^textlayout_draw\\s+\"(.*)\"\\s+([0-9.]*)$",
+ "textlayout_draw <text> <width>",
+ "textlayout_draw \"your text\" 1.0");
+ DECL_PAINTCOMMAND("abort", command_abort,
+ "^abort$",
+ "abort",
+ "abort");
+ DECL_PAINTCOMMAND("noop", command_noop,
+ "^$",
+ "-",
+ "\n");
+
+ DECL_PAINTCOMMANDSECTION("setters");
+ DECL_PAINTCOMMAND("setBackgroundMode", command_setBgMode,
+ "^(setBackgroundMode|setBgMode)\\s+(\\w*)$",
+ "setBackgroundMode <OpaqueMode|TransparentMode>",
+ "setBackgroundMode TransparentMode");
+ DECL_PAINTCOMMAND("setBackground", command_setBackground,
+ "^setBackground\\s+#?(\\w*)\\s*(\\w*)?$",
+ "setBackground <color> [brush style enum]",
+ "setBackground black SolidPattern");
+ DECL_PAINTCOMMAND("setOpacity", command_setOpacity,
+ "^setOpacity\\s+(-?\\d*\\.?\\d*)$",
+ "setOpacity <opacity>\n - opacity is in [0,1]",
+ "setOpacity 1.0");
+ DECL_PAINTCOMMAND("path_setFillRule", command_path_setFillRule,
+ "^path_setFillRule\\s+(\\w*)\\s+(\\w*)$",
+ "path_setFillRule <pathName> [Winding|OddEven]",
+ "path_setFillRule pathName Winding");
+ DECL_PAINTCOMMAND("setBrush", command_setBrush,
+ "^setBrush\\s+(#?[\\w.:\\/]*)\\s*(\\w*)?$",
+ "setBrush <pixmapFileName>\nsetBrush noBrush\nsetBrush <color> <brush style enum>",
+ "setBrush white SolidPattern");
+ DECL_PAINTCOMMAND("setBrushOrigin", command_setBrushOrigin,
+ "^setBrushOrigin\\s*(-?\\w*)\\s+(-?\\w*)$",
+ "setBrushOrigin <dx> <dy>",
+ "setBrushOrigin 0 0");
+ DECL_PAINTCOMMAND("brushTranslate", command_brushTranslate,
+ "^brushTranslate\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "brushTranslate <tx> <ty>",
+ "brushTranslate 0.0 0.0");
+ DECL_PAINTCOMMAND("brushScale", command_brushScale,
+ "^brushScale\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "brushScale <kx> <ky>",
+ "brushScale 0.0 0.0");
+ DECL_PAINTCOMMAND("brushRotate", command_brushRotate,
+ "^brushRotate\\s+(-?[\\w.]*)$",
+ "brushRotate <angle>\n - angle in degrees",
+ "brushRotate 0.0");
+ DECL_PAINTCOMMAND("brushShear", command_brushShear,
+ "^brushShear\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "brushShear <sx> <sy>",
+ "brushShear 0.0 0.0");
+ DECL_PAINTCOMMAND("setCompositionMode", command_setCompositionMode,
+ "^setCompositionMode\\s+([\\w_0-9]*)$",
+ "setCompositionMode <composition mode enum>",
+ "setCompositionMode SourceOver");
+ DECL_PAINTCOMMAND("setFont", command_setFont,
+ "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$",
+ "setFont <fontFace> [size] [font weight|font weight enum] [italic] [hinting enum]\n - font weight is an integer between 0 and 99",
+ "setFont \"times\" 12");
+ DECL_PAINTCOMMAND("setPen", command_setPen,
+ "^setPen\\s+#?(\\w*)$",
+ "setPen <color>\nsetPen <pen style enum>\nsetPen brush",
+ "setPen black");
+ DECL_PAINTCOMMAND("setPen", command_setPen2,
+ "^setPen\\s+(#?\\w*)\\s+([\\w.]+)\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$",
+ "setPen brush|<color> [width] [pen style enum] [FlatCap|SquareCap|RoundCap] [MiterJoin|BevelJoin|RoundJoin]",
+ "setPen black 1 FlatCap MiterJoin");
+ DECL_PAINTCOMMAND("pen_setDashOffset", command_pen_setDashOffset,
+ "^pen_setDashOffset\\s+(-?[\\w.]+)$",
+ "pen_setDashOffset <offset>\n",
+ "pen_setDashOffset 1.0");
+ DECL_PAINTCOMMAND("pen_setDashPattern", command_pen_setDashPattern,
+ "^pen_setDashPattern\\s+\\[([\\w\\s.]*)\\]$",
+ "pen_setDashPattern <[ <dash_1> <space_1> ... <dash_n> <space_n> ]>",
+ "pen_setDashPattern [ 2 1 4 1 3 3 ]");
+ DECL_PAINTCOMMAND("pen_setCosmetic", command_pen_setCosmetic,
+ "^pen_setCosmetic\\s+(\\w*)$",
+ "pen_setCosmetic <true|false>",
+ "pen_setCosmetic true");
+ DECL_PAINTCOMMAND("setRenderHint", command_setRenderHint,
+ "^setRenderHint\\s+([\\w_0-9]*)\\s*(\\w*)$",
+ "setRenderHint <Antialiasing|SmoothPixmapTransform> <true|false>",
+ "setRenderHint Antialiasing true");
+ DECL_PAINTCOMMAND("clearRenderHint", command_clearRenderHint,
+ "^clearRenderHint$",
+ "clearRenderHint",
+ "clearRenderHint");
+
+ DECL_PAINTCOMMANDSECTION("gradients");
+ DECL_PAINTCOMMAND("gradient_appendStop", command_gradient_appendStop,
+ "^gradient_appendStop\\s+([\\w.]*)\\s+#?(\\w*)$",
+ "gradient_appendStop <pos> <color>",
+ "gradient_appendStop 1.0 red");
+ DECL_PAINTCOMMAND("gradient_clearStops", command_gradient_clearStops,
+ "^gradient_clearStops$",
+ "gradient_clearStops",
+ "gradient_clearStops");
+ DECL_PAINTCOMMAND("gradient_setConical", command_gradient_setConical,
+ "^gradient_setConical\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)$",
+ "gradient_setConical <cx> <cy> <angle>\n - angle in degrees",
+ "gradient_setConical 5.0 5.0 45.0");
+ DECL_PAINTCOMMAND("gradient_setLinear", command_gradient_setLinear,
+ "^gradient_setLinear\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)$",
+ "gradient_setLinear <x1> <y1> <x2> <y2>",
+ "gradient_setLinear 1.0 1.0 2.0 2.0");
+ DECL_PAINTCOMMAND("gradient_setRadial", command_gradient_setRadial,
+ "^gradient_setRadial\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)\\s?([\\w.]*)\\s?([\\w.]*)$",
+ "gradient_setRadial <cx> <cy> <rad> <fx> <fy>\n - C is the center\n - rad is the radius\n - F is the focal point",
+ "gradient_setRadial 1.0 1.0 45.0 2.0 2.0");
+ DECL_PAINTCOMMAND("gradient_setRadialExtended", command_gradient_setRadialExtended,
+ "^gradient_setRadialExtended\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)\\s?([\\w.]*)\\s?([\\w.]*)\\s?([\\w.]*)$",
+ "gradient_setRadialExtended <cx> <cy> <rad> <fx> <fy> <frad>\n - C is the center\n - rad is the center radius\n - F is the focal point\n - frad is the focal radius",
+ "gradient_setRadialExtended 1.0 1.0 45.0 2.0 2.0 45.0");
+ DECL_PAINTCOMMAND("gradient_setLinearPen", command_gradient_setLinearPen,
+ "^gradient_setLinearPen\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)\\s+([\\w.]*)$",
+ "gradient_setLinearPen <x1> <y1> <x2> <y2>",
+ "gradient_setLinearPen 1.0 1.0 2.0 2.0");
+ DECL_PAINTCOMMAND("gradient_setSpread", command_gradient_setSpread,
+ "^gradient_setSpread\\s+(\\w*)$",
+ "gradient_setSpread <spread method enum>",
+ "gradient_setSpread PadSpread");
+ DECL_PAINTCOMMAND("gradient_setCoordinateMode", command_gradient_setCoordinateMode,
+ "^gradient_setCoordinateMode\\s+(\\w*)$",
+ "gradient_setCoordinateMode <coordinate method enum>",
+ "gradient_setCoordinateMode ObjectBoundingMode");
+ DECL_PAINTCOMMANDSECTION("drawing ops");
+ DECL_PAINTCOMMAND("drawPoint", command_drawPoint,
+ "^drawPoint\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "drawPoint <x> <y>",
+ "drawPoint 10.0 10.0");
+ DECL_PAINTCOMMAND("drawLine", command_drawLine,
+ "^drawLine\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "drawLine <x1> <y1> <x2> <y2>",
+ "drawLine 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("drawRect", command_drawRect,
+ "^drawRect\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "drawRect <x> <y> <w> <h>",
+ "drawRect 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("drawRoundRect", command_drawRoundRect,
+ "^drawRoundRect\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w*)?\\s*(-?\\w*)?$",
+ "drawRoundRect <x> <y> <w> <h> [rx] [ry]",
+ "drawRoundRect 10 10 20 20 3 3");
+ DECL_PAINTCOMMAND("drawRoundedRect", command_drawRoundedRect,
+ "^drawRoundedRect\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s*(\\w*)?$",
+ "drawRoundedRect <x> <y> <w> <h> <rx> <ry> [SizeMode enum]",
+ "drawRoundedRect 10 10 20 20 4 4 AbsoluteSize");
+ DECL_PAINTCOMMAND("drawArc", command_drawArc,
+ "^drawArc\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
+ "drawArc <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in 1/16th of degree",
+ "drawArc 10 10 20 20 0 5760");
+ DECL_PAINTCOMMAND("drawChord", command_drawChord,
+ "^drawChord\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
+ "drawChord <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in 1/16th of degree",
+ "drawChord 10 10 20 20 0 5760");
+ DECL_PAINTCOMMAND("drawEllipse", command_drawEllipse,
+ "^drawEllipse\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "drawEllipse <x> <y> <w> <h>",
+ "drawEllipse 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("drawPath", command_drawPath,
+ "^drawPath\\s+(\\w*)$",
+ "drawPath <pathName>",
+ "drawPath mypath");
+ DECL_PAINTCOMMAND("drawPie", command_drawPie,
+ "^drawPie\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
+ "drawPie <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in 1/16th of degree",
+ "drawPie 10 10 20 20 0 5760");
+ DECL_PAINTCOMMAND("drawPixmap", command_drawPixmap,
+ "^drawPixmap\\s+([\\w.:\\-/]*)"
+ "\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?" // target rect
+ "\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?$", // source rect
+ "drawPixmap <filename> <tx> <ty> <tw> <th> <sx> <sy> <sw> <sh>"
+ "\n- where t means target and s means source"
+ "\n- a width or height of -1 means maximum space",
+ "drawPixmap :/images/face.png 0 0 -1 -1 0 0 -1 -1");
+ DECL_PAINTCOMMAND("drawImage", command_drawImage,
+ "^drawImage\\s+([\\w.:\\/]*)"
+ "\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?" // target rect
+ "\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?\\s*(-?[\\w.]*)?$", // source rect
+ "drawImage <filename> <tx> <ty> <tw> <th> <sx> <sy> <sw> <sh>"
+ "\n- where t means target and s means source"
+ "\n- a width or height of -1 means maximum space",
+ "drawImage :/images/face.png 0 0 -1 -1 0 0 -1 -1");
+ DECL_PAINTCOMMAND("drawPolygon", command_drawPolygon,
+ "^drawPolygon\\s+\\[([\\w\\s-.]*)\\]\\s*(\\w*)$",
+ "drawPolygon <[ <x1> <y1> ... <xn> <yn> ]> <Winding|OddEven>",
+ "drawPolygon [ 1 4 6 8 5 3 ] Winding");
+ DECL_PAINTCOMMAND("drawConvexPolygon", command_drawConvexPolygon,
+ "^drawConvexPolygon\\s+\\[([\\w\\s-.]*)\\]$",
+ "drawConvexPolygon <[ <x1> <y1> ... <xn> <yn> ]>",
+ "drawConvexPolygon [ 1 4 6 8 5 3 ]");
+ DECL_PAINTCOMMAND("drawPolyline", command_drawPolyline,
+ "^drawPolyline\\s+\\[([\\w\\s]*)\\]$",
+ "drawPolyline <[ <x1> <y1> ... <xn> <yn> ]>",
+ "drawPolyline [ 1 4 6 8 5 3 ]");
+ DECL_PAINTCOMMAND("drawText", command_drawText,
+ "^drawText\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
+ "drawText <x> <y> <text>",
+ "drawText 10 10 \"my text\"");
+ DECL_PAINTCOMMAND("drawStaticText", command_drawStaticText,
+ "^drawStaticText\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
+ "drawStaticText <x> <y> <text>",
+ "drawStaticText 10 10 \"my text\"");
+ DECL_PAINTCOMMAND("drawTiledPixmap", command_drawTiledPixmap,
+ "^drawTiledPixmap\\s+([\\w.:\\/]*)"
+ "\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w*)\\s*(-?\\w*)"
+ "\\s*(-?\\w*)\\s*(-?\\w*)$",
+ "drawTiledPixmap <tile image filename> <tx> <ty> <tx> <ty> <sx> <sy>"
+ "\n - where t means tile"
+ "\n - and s is an offset in the tile",
+ "drawTiledPixmap :/images/alpha.png ");
+
+ DECL_PAINTCOMMANDSECTION("painterPaths");
+ DECL_PAINTCOMMAND("path_moveTo", command_path_moveTo,
+ "^path_moveTo\\s+([.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "path_moveTo <pathName> <x> <y>",
+ "path_moveTo mypath 1.0 1.0");
+ DECL_PAINTCOMMAND("path_lineTo", command_path_lineTo,
+ "^path_lineTo\\s+([.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "path_lineTo <pathName> <x> <y>",
+ "path_lineTo mypath 1.0 1.0");
+ DECL_PAINTCOMMAND("path_addEllipse", command_path_addEllipse,
+ "^path_addEllipse\\s+(\\w*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "path_addEllipse <pathName> <x1> <y1> <x2> <y2>",
+ "path_addEllipse mypath 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("path_addPolygon", command_path_addPolygon,
+ "^path_addPolygon\\s+(\\w*)\\s+\\[([\\w\\s]*)\\]\\s*(\\w*)$",
+ "path_addPolygon <pathName> <[ <x1> <y1> ... <xn> <yn> ]>",
+ "path_addPolygon mypath [ 1 4 6 8 5 3 ]");
+ DECL_PAINTCOMMAND("path_addRect", command_path_addRect,
+ "^path_addRect\\s+(\\w*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "path_addRect <pathName> <x1> <y1> <x2> <y2>",
+ "path_addRect mypath 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("path_addText", command_path_addText,
+ "^path_addText\\s+(\\w*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+\"(.*)\"$",
+ "path_addText <pathName> <x> <y> <text>",
+ "path_addText mypath 10.0 20.0 \"some text\"");
+ DECL_PAINTCOMMAND("path_arcTo", command_path_arcTo,
+ "^path_arcTo\\s+(\\w*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "path_arcTo <pathName> <x> <y> <w> <h> <angleStart> <angleArc>\n - angles are expressed in degrees",
+ "path_arcTo mypath 0.0 0.0 10.0 10.0 0.0 360.0");
+ DECL_PAINTCOMMAND("path_cubicTo", command_path_cubicTo,
+ "^path_cubicTo\\s+(\\w*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "path_cubicTo <pathName> <x1> <y1> <x2> <y2> <x3> <y3>",
+ "path_cubicTo mypath 0.0 0.0 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("path_closeSubpath", command_path_closeSubpath,
+ "^path_closeSubpath\\s+(\\w*)$",
+ "path_closeSubpath <pathName>",
+ "path_closeSubpath mypath");
+ DECL_PAINTCOMMAND("path_createOutline", command_path_createOutline,
+ "^path_createOutline\\s+(\\w*)\\s+(\\w*)$",
+ "path_createOutline <pathName> <newName>",
+ "path_createOutline mypath myoutline");
+ DECL_PAINTCOMMAND("path_debugPrint", command_path_debugPrint,
+ "^path_debugPrint\\s+(\\w*)$",
+ "path_debugPrint <pathName>",
+ "path_debugPrint mypath");
+
+ DECL_PAINTCOMMANDSECTION("regions");
+ DECL_PAINTCOMMAND("region_addRect", command_region_addRect,
+ "^region_addRect\\s+(\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
+ "region_addRect <regionName> <x1> <y1> <x2> <y2>",
+ "region_addRect myregion 0.0 0.0 10.0 10.0");
+ DECL_PAINTCOMMAND("region_addEllipse", command_region_addEllipse,
+ "^region_addEllipse\\s+(\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)$",
+ "region_addEllipse <regionName> <x1> <y1> <x2> <y2>",
+ "region_addEllipse myregion 0.0 0.0 10.0 10.0");
+
+ DECL_PAINTCOMMANDSECTION("clipping");
+ DECL_PAINTCOMMAND("region_getClipRegion", command_region_getClipRegion,
+ "^region_getClipRegion\\s+(\\w*)$",
+ "region_getClipRegion <regionName>",
+ "region_getClipRegion myregion");
+ DECL_PAINTCOMMAND("setClipRegion", command_setClipRegion,
+ "^setClipRegion\\s+(\\w*)\\s*(\\w*)$",
+ "setClipRegion <regionName> <clip operation enum>",
+ "setClipRegion myregion ReplaceClip");
+ DECL_PAINTCOMMAND("path_getClipPath", command_path_getClipPath,
+ "^path_getClipPath\\s+([\\w0-9]*)$",
+ "path_getClipPath <pathName>",
+ "path_getClipPath mypath");
+ DECL_PAINTCOMMAND("setClipPath", command_setClipPath,
+ "^setClipPath\\s+(\\w*)\\s*(\\w*)$",
+ "setClipPath <pathName> <clip operation enum>",
+ "setClipPath mypath ReplaceClip");
+ DECL_PAINTCOMMAND("setClipRect", command_setClipRect,
+ "^setClipRect\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s+(-?\\w*)\\s*(\\w*)$",
+ "setClipRect <x1> <y1> <x2> <y2> <clip operation enum>",
+ "setClipRect 0.0 0.0 10.0 10.0 ReplaceClip");
+ DECL_PAINTCOMMAND("setClipping", command_setClipping,
+ "^setClipping\\s+(\\w*)$",
+ "setClipping <true|false>",
+ "setClipping true");
+
+ DECL_PAINTCOMMANDSECTION("surface");
+ DECL_PAINTCOMMAND("surface_begin", command_surface_begin,
+ "^surface_begin\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "surface_begin <x> <y> <w> <h>",
+ "surface_begin 0.0 0.0 10.0 10.0");
+ DECL_PAINTCOMMAND("surface_end", command_surface_end,
+ "^surface_end$",
+ "surface_end",
+ "surface_end");
+
+ DECL_PAINTCOMMANDSECTION("painter states");
+ DECL_PAINTCOMMAND("restore", command_restore,
+ "^restore$",
+ "restore",
+ "restore");
+ DECL_PAINTCOMMAND("save", command_save,
+ "^save$",
+ "save",
+ "save");
+
+ DECL_PAINTCOMMANDSECTION("pixmaps'n'images");
+ DECL_PAINTCOMMAND("pixmap_load", command_pixmap_load,
+ "^pixmap_load\\s+([\\w.:\\/]*)\\s*([\\w.:\\/]*)$",
+ "pixmap_load <image filename> <pixmapName>",
+ "pixmap_load :/images/face.png myPixmap");
+ DECL_PAINTCOMMAND("pixmap_setMask", command_pixmap_setMask,
+ "^pixmap_setMask\\s+([\\w.:\\/]*)\\s+([\\w.:\\/]*)$",
+ "pixmap_setMask <pixmapName> <bitmap filename>",
+ "pixmap_setMask myPixmap :/images/bitmap.png");
+ DECL_PAINTCOMMAND("bitmap_load", command_bitmap_load,
+ "^bitmap_load\\s+([\\w.:\\/]*)\\s*([\\w.:\\/]*)$",
+ "bitmap_load <bitmap filename> <bitmapName>\n - note that the image is stored as a pixmap",
+ "bitmap_load :/images/bitmap.png myBitmap");
+ DECL_PAINTCOMMAND("image_convertToFormat", command_image_convertToFormat,
+ "^image_convertToFormat\\s+([\\w.:\\/]*)\\s+([\\w.:\\/]+)\\s+([\\w0-9_]*)$",
+ "image_convertToFormat <sourceImageName> <destImageName> <image format enum>",
+ "image_convertToFormat myImage myNewImage Indexed8");
+ DECL_PAINTCOMMAND("image_load", command_image_load,
+ "^image_load\\s+([\\w.:\\/]*)\\s*([\\w.:\\/]*)$",
+ "image_load <filename> <imageName>",
+ "image_load :/images/face.png myImage");
+ DECL_PAINTCOMMAND("image_setColor", command_image_setColor,
+ "^image_setColor\\s+([\\w.:\\/]*)\\s+([0-9]*)\\s+#([0-9]*)$",
+ "image_setColor <imageName> <index> <color>",
+ "image_setColor myImage 0 black");
+ DECL_PAINTCOMMAND("image_setColorCount", command_image_setColorCount,
+ "^image_setColorCount\\s+([\\w.:\\/]*)\\s+([0-9]*)$",
+ "image_setColorCount <imageName> <nbColors>",
+ "image_setColorCount myImage 128");
+
+ DECL_PAINTCOMMANDSECTION("transformations");
+ DECL_PAINTCOMMAND("resetMatrix", command_resetMatrix,
+ "^resetMatrix$",
+ "resetMatrix",
+ "resetMatrix");
+ DECL_PAINTCOMMAND("setMatrix", command_setMatrix,
+ "^setMatrix\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "setMatrix <m11> <m12> <m13> <m21> <m22> <m23> <m31> <m32> <m33>",
+ "setMatrix 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0");
+ DECL_PAINTCOMMAND("translate", command_translate,
+ "^translate\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "translate <tx> <ty>",
+ "translate 10.0 10.0");
+ DECL_PAINTCOMMAND("rotate", command_rotate,
+ "^rotate\\s+(-?[\\w.]*)$",
+ "rotate <angle>\n - with angle in degrees",
+ "rotate 30.0");
+ DECL_PAINTCOMMAND("rotate_x", command_rotate_x,
+ "^rotate_x\\s+(-?[\\w.]*)$",
+ "rotate_x <angle>\n - with angle in degrees",
+ "rotate_x 30.0");
+ DECL_PAINTCOMMAND("rotate_y", command_rotate_y,
+ "^rotate_y\\s+(-?[\\w.]*)$",
+ "rotate_y <angle>\n - with angle in degrees",
+ "rotate_y 30.0");
+ DECL_PAINTCOMMAND("scale", command_scale,
+ "^scale\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
+ "scale <sx> <sy>",
+ "scale 2.0 1.0");
+ DECL_PAINTCOMMAND("mapQuadToQuad", command_mapQuadToQuad,
+ "^mapQuadToQuad\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)\\s+(-?[.\\w]*)$",
+ "mapQuadToQuad <x1> <y1> <x2> <y2> <x3> <y3> <x4> <y4> <x5> <y5> <x6> <y6> <x7> <y7> <x8> <y8>"
+ "\n - where vertices 1 to 4 defines the source quad and 5 to 8 the destination quad",
+ "mapQuadToQuad 0.0 0.0 1.0 1.0 0.0 0.0 -1.0 -1.0");
+
+ // populate the command lookup hash
+ for (int i=0; i<s_commandInfoTable.size(); i++) {
+ if (s_commandInfoTable.at(i).isSectionHeader() ||
+ s_commandInfoTable.at(i).identifier == QLatin1String("comment") ||
+ s_commandInfoTable.at(i).identifier == QLatin1String("noop"))
+ continue;
+ s_commandHash.insert(s_commandInfoTable.at(i).identifier, i);
+ }
+
+ // populate the enums list
+ ADD_ENUMLIST("brush styles", brushStyleTable);
+ ADD_ENUMLIST("pen styles", penStyleTable);
+ ADD_ENUMLIST("font weights", fontWeightTable);
+ ADD_ENUMLIST("font hintings", fontHintingTable);
+ ADD_ENUMLIST("clip operations", clipOperationTable);
+ ADD_ENUMLIST("spread methods", spreadMethodTable);
+ ADD_ENUMLIST("composition modes", compositionModeTable);
+ ADD_ENUMLIST("image formats", imageFormatTable);
+ ADD_ENUMLIST("coordinate modes", coordinateMethodTable);
+ ADD_ENUMLIST("size modes", sizeModeTable);
+}
+
+#undef DECL_PAINTCOMMAND
+#undef ADD_ENUMLIST
+/*********************************************************************************
+** utility
+**********************************************************************************/
+template <typename T> T PaintCommands::image_load(const QString &filepath)
+{
+ T t(filepath);
+
+ if (t.isNull())
+ t = T(":images/" + filepath);
+
+ if (t.isNull())
+ t = T("images/" + filepath);
+
+ if (t.isNull()) {
+ QFileInfo fi(filepath);
+ QDir dir = fi.absoluteDir();
+ dir.cdUp();
+ dir.cd("images");
+ QString fileName = QString("%1/%2").arg(dir.absolutePath()).arg(fi.fileName());
+ t = T(fileName);
+ if (t.isNull() && !fileName.endsWith(".png")) {
+ fileName.append(".png");
+ t = T(fileName);
+ }
+ }
+
+ return t;
+}
+
+/*********************************************************************************
+** setters
+**********************************************************************************/
+void PaintCommands::insertAt(int commandIndex, const QStringList &newCommands)
+{
+ int index = 0;
+ int left = newCommands.size();
+ while (left--)
+ m_commands.insert(++commandIndex, newCommands.at(index++));
+}
+
+/*********************************************************************************
+** run
+**********************************************************************************/
+void PaintCommands::runCommand(const QString &scriptLine)
+{
+ if (scriptLine.isEmpty()) {
+ command_noop(QRegExp());
+ return;
+ }
+ if (scriptLine.startsWith('#')) {
+ command_comment(QRegExp());
+ return;
+ }
+ QString firstWord = scriptLine.section(QRegExp("\\s"), 0, 0);
+ QList<int> indices = s_commandHash.values(firstWord);
+ foreach(int idx, indices) {
+ const PaintCommandInfos &command = s_commandInfoTable.at(idx);
+ if (command.regExp.indexIn(scriptLine) >= 0) {
+ (this->*(command.paintMethod))(command.regExp);
+ return;
+ }
+ }
+ qWarning("ERROR: unknown command or argument syntax error in \"%s\"", qPrintable(scriptLine));
+}
+
+void PaintCommands::runCommands()
+{
+ staticInit();
+ int width = m_painter->window().width();
+ int height = m_painter->window().height();
+
+ if (width <= 0)
+ width = 800;
+ if (height <= 0)
+ height = 800;
+
+ // paint background
+ if (m_checkers_background) {
+ QPixmap pm(20, 20);
+ pm.fill(Qt::white);
+ QPainter pt(&pm);
+ pt.fillRect(0, 0, 10, 10, QColor::fromRgba(0xffdfdfdf));
+ pt.fillRect(10, 10, 10, 10, QColor::fromRgba(0xffdfdfdf));
+ pt.end();
+ m_painter->drawTiledPixmap(0, 0, width, height, pm);
+ } else {
+ m_painter->fillRect(0, 0, width, height, Qt::white);
+ }
+
+ // run each command
+ m_abort = false;
+ for (int i=0; i<m_commands.size() && !m_abort; ++i) {
+ const QString &commandNow = m_commands.at(i);
+ m_currentCommand = commandNow;
+ m_currentCommandIndex = i;
+ runCommand(commandNow.trimmed());
+ }
+}
+
+/*********************************************************************************
+** conversions
+**********************************************************************************/
+int PaintCommands::convertToInt(const QString &str)
+{
+ return qRound(convertToDouble(str));
+}
+
+float PaintCommands::convertToFloat(const QString &str)
+{
+ return float(convertToDouble(str));
+}
+
+double PaintCommands::convertToDouble(const QString &str)
+{
+ static QRegExp re("cp([0-9])([xy])");
+ if (str.toLower() == "width") {
+ if (m_painter->device()->devType() == Qt::Widget)
+ return m_painter->window().width();
+ else
+ return 800;
+ }
+ if (str.toLower() == "height") {
+ if (m_painter->device()->devType() == Qt::Widget)
+ return m_painter->window().height();
+ else
+ return 800;
+ }
+ if (re.indexIn(str) >= 0) {
+ int index = re.cap(1).toInt();
+ bool is_it_x = re.cap(2) == "x";
+ if (index < 0 || index >= m_controlPoints.size()) {
+ qWarning("ERROR: control point index=%d is out of bounds", index);
+ return 0;
+ }
+ return is_it_x ? m_controlPoints.at(index).x() : m_controlPoints.at(index).y();
+ }
+ return str.toDouble();
+}
+
+QColor PaintCommands::convertToColor(const QString &str)
+{
+ static QRegExp alphaColor("#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})");
+ static QRegExp opaqueColor("#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})");
+
+ Q_ASSERT(alphaColor.isValid());
+ Q_ASSERT(opaqueColor.isValid());
+
+ if (alphaColor.indexIn(str) >= 0) {
+ return QColor(alphaColor.cap(2).toInt(0, 16),
+ alphaColor.cap(3).toInt(0, 16),
+ alphaColor.cap(4).toInt(0, 16),
+ alphaColor.cap(1).toInt(0, 16));
+ } else if (opaqueColor.indexIn(str) >= 0) {
+ return QColor(opaqueColor.cap(1).toInt(0, 16),
+ opaqueColor.cap(2).toInt(0, 16),
+ opaqueColor.cap(3).toInt(0, 16));
+ }
+ return QColor(str);
+}
+
+/*********************************************************************************
+** command implementations
+**********************************************************************************/
+void PaintCommands::command_comment(QRegExp)
+{
+ if (m_verboseMode)
+ printf(" -(lance) comment: %s\n", qPrintable(m_currentCommand));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_import(QRegExp re)
+{
+ QString importFile(re.cap(1));
+ QFileInfo fi(m_filepath);
+ QDir dir = fi.absoluteDir();
+ QFile *file = new QFile(dir.absolutePath() + QDir::separator() + importFile);
+
+ if (importFile.isEmpty() || !file->exists()) {
+ dir.cdUp();
+ dir.cd("data");
+ dir.cd("qps");
+ delete file;
+ file = new QFile(dir.absolutePath() + QDir::separator() + importFile);
+ }
+
+ if (importFile.isEmpty() || !file->exists()) {
+ dir.cdUp();
+ dir.cd("images");
+ delete file;
+ file = new QFile(dir.absolutePath() + QDir::separator() + importFile);
+ }
+
+ if (importFile.isEmpty() || !file->exists()) {
+ printf(" - importing non-existing file at line %d (%s)\n", m_currentCommandIndex,
+ qPrintable(file->fileName()));
+ delete file;
+ return;
+ }
+
+ if (!file->open(QIODevice::ReadOnly)) {
+ printf(" - failed to read file: '%s'\n", qPrintable(file->fileName()));
+ delete file;
+ return;
+ }
+ if (m_verboseMode)
+ printf(" -(lance) importing file at line %d (%s)\n", m_currentCommandIndex,
+ qPrintable(fi.fileName()));
+
+ QFileInfo fileinfo(*file);
+ m_commands[m_currentCommandIndex] = QString("# import file (%1) start").arg(fileinfo.fileName());
+ QTextStream textFile(file);
+ QString rawContent = textFile.readAll();
+ QStringList importedData = rawContent.split('\n', QString::SkipEmptyParts);
+ importedData.append(QString("# import file (%1) end ---").arg(fileinfo.fileName()));
+ insertAt(m_currentCommandIndex, importedData);
+
+ if (m_verboseMode) {
+ printf(" -(lance) Command buffer now looks like:\n");
+ for (int i = 0; i < m_commands.count(); ++i)
+ printf(" ---> {%s}\n", qPrintable(m_commands.at(i)));
+ }
+ delete file;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_begin_block(QRegExp re)
+{
+ const QString &blockName = re.cap(1);
+ if (m_verboseMode)
+ printf(" -(lance) begin_block (%s)\n", qPrintable(blockName));
+
+ m_commands[m_currentCommandIndex] = QString("# begin block (%1)").arg(blockName);
+ QStringList newBlock;
+ int i = m_currentCommandIndex + 1;
+ for (; i < m_commands.count(); ++i) {
+ const QString &nextCmd = m_commands.at(i);
+ if (nextCmd.startsWith("end_block")) {
+ m_commands[i] = QString("# end block (%1)").arg(blockName);
+ break;
+ }
+ newBlock += nextCmd;
+ }
+
+ if (m_verboseMode)
+ for (int j = 0; j < newBlock.count(); ++j)
+ printf(" %d: %s\n", j, qPrintable(newBlock.at(j)));
+
+ if (i >= m_commands.count())
+ printf(" - Warning! Block doesn't have an 'end_block' marker!\n");
+
+ m_blockMap.insert(blockName, newBlock);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_end_block(QRegExp)
+{
+ printf(" - end_block should be consumed by begin_block command.\n");
+ printf(" You will never see this if your block markers are in sync\n");
+ printf(" (noop)\n");
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_repeat_block(QRegExp re)
+{
+ QString blockName = re.cap(1);
+ if (m_verboseMode)
+ printf(" -(lance) repeating block (%s)\n", qPrintable(blockName));
+
+ QStringList block = m_blockMap.value(blockName);
+ if (block.isEmpty()) {
+ printf(" - repeated block (%s) is empty!\n", qPrintable(blockName));
+ return;
+ }
+
+ m_commands[m_currentCommandIndex] = QString("# repeated block (%1)").arg(blockName);
+ insertAt(m_currentCommandIndex, block);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawLine(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double x1 = convertToDouble(caps.at(1));
+ double y1 = convertToDouble(caps.at(2));
+ double x2 = convertToDouble(caps.at(3));
+ double y2 = convertToDouble(caps.at(4));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawLine((%.2f, %.2f), (%.2f, %.2f))\n", x1, y1, x2, y2);
+
+ m_painter->drawLine(QLineF(x1, y1, x2, y2));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawPath(QRegExp re)
+{
+ if (m_verboseMode)
+ printf(" -(lance) drawPath(name=%s)\n", qPrintable(re.cap(1)));
+
+ QPainterPath &path = m_pathMap[re.cap(1)];
+ m_painter->drawPath(path);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawPixmap(QRegExp re)
+{
+ QPixmap pm;
+ pm = m_pixmapMap[re.cap(1)]; // try cache first
+ if (pm.isNull())
+ pm = image_load<QPixmap>(re.cap(1));
+ if (pm.isNull()) {
+ QFileInfo fi(m_filepath);
+ QDir dir = fi.absoluteDir();
+ dir.cdUp();
+ dir.cd("images");
+ QString fileName = QString("%1/%2").arg(dir.absolutePath()).arg(re.cap(1));
+ pm = QPixmap(fileName);
+ if (pm.isNull() && !fileName.endsWith(".png")) {
+ fileName.append(".png");
+ pm = QPixmap(fileName);
+ }
+ }
+ if (pm.isNull()) {
+ fprintf(stderr, "ERROR(drawPixmap): failed to load pixmap: '%s'\n",
+ qPrintable(re.cap(1)));
+ return;
+ }
+
+ qreal tx = convertToFloat(re.cap(2));
+ qreal ty = convertToFloat(re.cap(3));
+ qreal tw = convertToFloat(re.cap(4));
+ qreal th = convertToFloat(re.cap(5));
+
+ qreal sx = convertToFloat(re.cap(6));
+ qreal sy = convertToFloat(re.cap(7));
+ qreal sw = convertToFloat(re.cap(8));
+ qreal sh = convertToFloat(re.cap(9));
+
+ if (tw == 0) tw = -1;
+ if (th == 0) th = -1;
+ if (sw == 0) sw = -1;
+ if (sh == 0) sh = -1;
+
+ if (m_verboseMode)
+ printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
+ qPrintable(re.cap(1)), pm.width(), pm.height(), pm.depth(),
+ tx, ty, tw, th, sx, sy, sw, sh);
+
+ m_painter->drawPixmap(QRectF(tx, ty, tw, th), pm, QRectF(sx, sy, sw, sh));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawImage(QRegExp re)
+{
+ QImage im;
+ im = m_imageMap[re.cap(1)]; // try cache first
+ if (im.isNull())
+ im = image_load<QImage>(re.cap(1));
+
+ if (im.isNull()) {
+ QFileInfo fi(m_filepath);
+ QDir dir = fi.absoluteDir();
+ dir.cdUp();
+ dir.cd("images");
+ QString fileName = QString("%1/%2").arg(dir.absolutePath()).arg(re.cap(1));
+ im = QImage(fileName);
+ if (im.isNull() && !fileName.endsWith(".png")) {
+ fileName.append(".png");
+ im = QImage(fileName);
+ }
+ }
+ if (im.isNull()) {
+ fprintf(stderr, "ERROR(drawImage): failed to load image: '%s'\n", qPrintable(re.cap(1)));
+ return;
+ }
+
+ qreal tx = convertToFloat(re.cap(2));
+ qreal ty = convertToFloat(re.cap(3));
+ qreal tw = convertToFloat(re.cap(4));
+ qreal th = convertToFloat(re.cap(5));
+
+ qreal sx = convertToFloat(re.cap(6));
+ qreal sy = convertToFloat(re.cap(7));
+ qreal sw = convertToFloat(re.cap(8));
+ qreal sh = convertToFloat(re.cap(9));
+
+ if (tw == 0) tw = -1;
+ if (th == 0) th = -1;
+ if (sw == 0) sw = -1;
+ if (sh == 0) sh = -1;
+
+ if (m_verboseMode)
+ printf(" -(lance) drawImage('%s' dim=(%d, %d), (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
+ qPrintable(re.cap(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh);
+
+ m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawTiledPixmap(QRegExp re)
+{
+ QPixmap pm;
+ pm = m_pixmapMap[re.cap(1)]; // try cache first
+ if (pm.isNull())
+ pm = image_load<QPixmap>(re.cap(1));
+ if (pm.isNull()) {
+ QFileInfo fi(m_filepath);
+ QDir dir = fi.absoluteDir();
+ dir.cdUp();
+ dir.cd("images");
+ QString fileName = QString("%1/%2").arg(dir.absolutePath()).arg(re.cap(1));
+ pm = QPixmap(fileName);
+ if (pm.isNull() && !fileName.endsWith(".png")) {
+ fileName.append(".png");
+ pm = QPixmap(fileName);
+ }
+ }
+ if (pm.isNull()) {
+ fprintf(stderr, "ERROR(drawTiledPixmap): failed to load pixmap: '%s'\n",
+ qPrintable(re.cap(1)));
+ return;
+ }
+
+ int tx = convertToInt(re.cap(2));
+ int ty = convertToInt(re.cap(3));
+ int tw = convertToInt(re.cap(4));
+ int th = convertToInt(re.cap(5));
+
+ int sx = convertToInt(re.cap(6));
+ int sy = convertToInt(re.cap(7));
+
+ if (tw == 0) tw = -1;
+ if (th == 0) th = -1;
+
+ if (m_verboseMode)
+ printf(" -(lance) drawTiledPixmap('%s' dim=(%d, %d), (%d, %d, %d, %d), (%d, %d)\n",
+ qPrintable(re.cap(1)), pm.width(), pm.height(), tx, ty, tw, th, sx, sy);
+
+ m_painter->drawTiledPixmap(tx, ty, tw, th, pm, sx, sy);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawPoint(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ float x = convertToFloat(caps.at(1));
+ float y = convertToFloat(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawPoint(%.2f, %.2f)\n", x, y);
+
+ m_painter->drawPoint(QPointF(x, y));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawPolygon(QRegExp re)
+{
+ static QRegExp separators("\\s");
+ QStringList caps = re.capturedTexts();
+ QString cap = caps.at(1);
+ QStringList numbers = cap.split(separators, QString::SkipEmptyParts);
+
+ QPolygonF array;
+ for (int i=0; i + 1<numbers.size(); i+=2)
+ array.append(QPointF(convertToDouble(numbers.at(i)), convertToDouble(numbers.at(i+1))));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawPolygon(size=%d)\n", array.size());
+
+ m_painter->drawPolygon(array, caps.at(2).toLower() == "winding" ? Qt::WindingFill : Qt::OddEvenFill);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawPolyline(QRegExp re)
+{
+ static QRegExp separators("\\s");
+ QStringList numbers = re.cap(1).split(separators, QString::SkipEmptyParts);
+
+ QPolygonF array;
+ for (int i=0; i + 1<numbers.size(); i+=2)
+ array.append(QPointF(numbers.at(i).toFloat(),numbers.at(i+1).toFloat()));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawPolyline(size=%d)\n", array.size());
+
+ m_painter->drawPolyline(array.toPolygon());
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawRect(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ float x = convertToFloat(caps.at(1));
+ float y = convertToFloat(caps.at(2));
+ float w = convertToFloat(caps.at(3));
+ float h = convertToFloat(caps.at(4));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawRect(%.2f, %.2f, %.2f, %.2f)\n", x, y, w, h);
+
+ m_painter->drawRect(QRectF(x, y, w, h));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawRoundedRect(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ float x = convertToFloat(caps.at(1));
+ float y = convertToFloat(caps.at(2));
+ float w = convertToFloat(caps.at(3));
+ float h = convertToFloat(caps.at(4));
+ float xr = convertToFloat(caps.at(5));
+ float yr = convertToFloat(caps.at(6));
+
+ int mode = translateEnum(sizeModeTable, caps.at(7), sizeof(sizeModeTable)/sizeof(char *));
+ if (mode < 0)
+ mode = Qt::AbsoluteSize;
+
+ if (m_verboseMode)
+ printf(" -(lance) drawRoundRect(%f, %f, %f, %f, %f, %f, %s)\n", x, y, w, h, xr, yr, mode ? "RelativeSize" : "AbsoluteSize");
+
+ m_painter->drawRoundedRect(QRectF(x, y, w, h), xr, yr, Qt::SizeMode(mode));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawRoundRect(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ int w = convertToInt(caps.at(3));
+ int h = convertToInt(caps.at(4));
+ int xs = caps.at(5).isEmpty() ? 50 : convertToInt(caps.at(5));
+ int ys = caps.at(6).isEmpty() ? 50 : convertToInt(caps.at(6));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawRoundRect(%d, %d, %d, %d, [%d, %d])\n", x, y, w, h, xs, ys);
+
+ m_painter->drawRoundRect(x, y, w, h, xs, ys);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawEllipse(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ float x = convertToFloat(caps.at(1));
+ float y = convertToFloat(caps.at(2));
+ float w = convertToFloat(caps.at(3));
+ float h = convertToFloat(caps.at(4));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawEllipse(%.2f, %.2f, %.2f, %.2f)\n", x, y, w, h);
+
+ m_painter->drawEllipse(QRectF(x, y, w, h));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawPie(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ int w = convertToInt(caps.at(3));
+ int h = convertToInt(caps.at(4));
+ int angle = convertToInt(caps.at(5));
+ int sweep = convertToInt(caps.at(6));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawPie(%d, %d, %d, %d, %d, %d)\n", x, y, w, h, angle, sweep);
+
+ m_painter->drawPie(x, y, w, h, angle, sweep);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawChord(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ int w = convertToInt(caps.at(3));
+ int h = convertToInt(caps.at(4));
+ int angle = convertToInt(caps.at(5));
+ int sweep = convertToInt(caps.at(6));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawChord(%d, %d, %d, %d, %d, %d)\n", x, y, w, h, angle, sweep);
+
+ m_painter->drawChord(x, y, w, h, angle, sweep);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawArc(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ int w = convertToInt(caps.at(3));
+ int h = convertToInt(caps.at(4));
+ int angle = convertToInt(caps.at(5));
+ int sweep = convertToInt(caps.at(6));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawArc(%d, %d, %d, %d, %d, %d)\n", x, y, w, h, angle, sweep);
+
+ m_painter->drawArc(x, y, w, h, angle, sweep);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawText(QRegExp re)
+{
+ if (!m_shouldDrawText)
+ return;
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ QString txt = caps.at(3);
+
+ if (m_verboseMode)
+ printf(" -(lance) drawText(%d, %d, %s)\n", x, y, qPrintable(txt));
+
+ m_painter->drawText(x, y, txt);
+}
+
+void PaintCommands::command_drawStaticText(QRegExp re)
+{
+ if (!m_shouldDrawText)
+ return;
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ QString txt = caps.at(3);
+
+ if (m_verboseMode)
+ printf(" -(lance) drawStaticText(%d, %d, %s)\n", x, y, qPrintable(txt));
+
+ m_painter->drawStaticText(x, y, QStaticText(txt));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_noop(QRegExp)
+{
+ if (m_verboseMode)
+ printf(" -(lance) noop: %s\n", qPrintable(m_currentCommand));
+
+ if (!m_currentCommand.trimmed().isEmpty()) {
+ fprintf(stderr, "unknown command: '%s'\n", qPrintable(m_currentCommand.trimmed()));
+ }
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_addText(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x = convertToDouble(caps.at(2));
+ double y = convertToDouble(caps.at(3));
+ QString text = caps.at(4);
+
+ if (m_verboseMode)
+ printf(" -(lance) path_addText(%s, %.2f, %.2f, text=%s\n", qPrintable(name), x, y, qPrintable(text));
+
+ m_pathMap[name].addText(x, y, m_painter->font(), text);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_addEllipse(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x = convertToDouble(caps.at(2));
+ double y = convertToDouble(caps.at(3));
+ double w = convertToDouble(caps.at(4));
+ double h = convertToDouble(caps.at(5));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_addEllipse(%s, %.2f, %.2f, %.2f, %.2f)\n", qPrintable(name), x, y, w, h);
+
+ m_pathMap[name].addEllipse(x, y, w, h);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_addRect(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x = convertToDouble(caps.at(2));
+ double y = convertToDouble(caps.at(3));
+ double w = convertToDouble(caps.at(4));
+ double h = convertToDouble(caps.at(5));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_addRect(%s, %.2f, %.2f, %.2f, %.2f)\n", qPrintable(name), x, y, w, h);
+
+ m_pathMap[name].addRect(x, y, w, h);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_addPolygon(QRegExp re)
+{
+ static QRegExp separators("\\s");
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ QString cap = caps.at(2);
+ QStringList numbers = cap.split(separators, QString::SkipEmptyParts);
+
+ QPolygonF array;
+ for (int i=0; i + 1<numbers.size(); i+=2)
+ array.append(QPointF(numbers.at(i).toFloat(),numbers.at(i+1).toFloat()));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_addPolygon(name=%s, size=%d)\n", qPrintable(name), array.size());
+
+ m_pathMap[name].addPolygon(array);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_arcTo(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x = convertToDouble(caps.at(2));
+ double y = convertToDouble(caps.at(3));
+ double w = convertToDouble(caps.at(4));
+ double h = convertToDouble(caps.at(5));
+ double angle = convertToDouble(caps.at(6));
+ double length = convertToDouble(caps.at(7));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_arcTo(%s, %.2f, %.2f, %.2f, %.2f, angle=%.2f, len=%.2f)\n", qPrintable(name), x, y, w, h, angle, length);
+
+ m_pathMap[name].arcTo(x, y, w, h, angle, length);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_createOutline(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ QString newName = caps.at(2);
+ QPen pen = m_painter->pen();
+
+ if (m_verboseMode)
+ printf(" -(lance) path_createOutline(%s, name=%s, width=%d)\n",
+ qPrintable(name), qPrintable(newName), pen.width());
+
+ if (!m_pathMap.contains(name)) {
+ fprintf(stderr, "createOutline(), unknown path: %s\n", qPrintable(name));
+ return;
+ }
+ QPainterPathStroker stroker;
+ stroker.setWidth(pen.widthF());
+ stroker.setDashPattern(pen.style());
+ stroker.setCapStyle(pen.capStyle());
+ stroker.setJoinStyle(pen.joinStyle());
+ m_pathMap[newName] = stroker.createStroke(m_pathMap[name]);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_cubicTo(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x1 = convertToDouble(caps.at(2));
+ double y1 = convertToDouble(caps.at(3));
+ double x2 = convertToDouble(caps.at(4));
+ double y2 = convertToDouble(caps.at(5));
+ double x3 = convertToDouble(caps.at(6));
+ double y3 = convertToDouble(caps.at(7));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_cubicTo(%s, (%.2f, %.2f), (%.2f, %.2f), (%.2f, %.2f))\n", qPrintable(name), x1, y1, x2, y2, x3, y3);
+
+ m_pathMap[name].cubicTo(x1, y1, x2, y2, x3, y3);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_moveTo(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x1 = convertToDouble(caps.at(2));
+ double y1 = convertToDouble(caps.at(3));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_moveTo(%s, (%.2f, %.2f))\n", qPrintable(name), x1, y1);
+
+ m_pathMap[name].moveTo(x1, y1);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_lineTo(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ double x1 = convertToDouble(caps.at(2));
+ double y1 = convertToDouble(caps.at(3));
+
+ if (m_verboseMode)
+ printf(" -(lance) path_lineTo(%s, (%.2f, %.2f))\n", qPrintable(name), x1, y1);
+
+ m_pathMap[name].lineTo(x1, y1);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_setFillRule(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ bool winding = caps.at(2).toLower() == "winding";
+
+ if (m_verboseMode)
+ printf(" -(lance) path_setFillRule(name=%s, winding=%d)\n", qPrintable(name), winding);
+
+ m_pathMap[name].setFillRule(winding ? Qt::WindingFill : Qt::OddEvenFill);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_closeSubpath(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+
+ if (m_verboseMode)
+ printf(" -(lance) path_closeSubpath(name=%s)\n", qPrintable(name));
+
+ m_pathMap[name].closeSubpath();
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_getClipPath(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+
+ if (m_verboseMode)
+ printf(" -(lance) path_closeSubpath(name=%s)\n", qPrintable(name));
+
+ m_pathMap[name] = m_painter->clipPath();
+}
+
+/***************************************************************************************************/
+static void qt_debug_path(const QPainterPath &path, const QString &name)
+{
+ const char *names[] = {
+ "MoveTo ",
+ "LineTo ",
+ "CurveTo ",
+ "CurveToData"
+ };
+
+ printf("\nQPainterPath (%s): elementCount=%d\n", qPrintable(name), path.elementCount());
+ for (int i=0; i<path.elementCount(); ++i) {
+ const QPainterPath::Element &e = path.elementAt(i);
+ Q_ASSERT(e.type >= 0 && e.type <= QPainterPath::CurveToDataElement);
+ printf(" - %3d:: %s, (%.2f, %.2f)\n", i, names[e.type], e.x, e.y);
+ }
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_path_debugPrint(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ qt_debug_path(m_pathMap[name], name);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_region_addRect(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ int x = convertToInt(caps.at(2));
+ int y = convertToInt(caps.at(3));
+ int w = convertToInt(caps.at(4));
+ int h = convertToInt(caps.at(5));
+
+ if (m_verboseMode)
+ printf(" -(lance) region_addRect(%s, %d, %d, %d, %d)\n", qPrintable(name), x, y, w, h);
+
+ m_regionMap[name] += QRect(x, y, w, h);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_region_addEllipse(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ int x = convertToInt(caps.at(2));
+ int y = convertToInt(caps.at(3));
+ int w = convertToInt(caps.at(4));
+ int h = convertToInt(caps.at(5));
+
+ if (m_verboseMode)
+ printf(" -(lance) region_addEllipse(%s, %d, %d, %d, %d)\n", qPrintable(name), x, y, w, h);
+
+ m_regionMap[name] += QRegion(x, y, w, h, QRegion::Ellipse);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_region_getClipRegion(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString name = caps.at(1);
+ QRegion region = m_painter->clipRegion();
+
+ if (m_verboseMode)
+ printf(" -(lance) region_getClipRegion(name=%s), bounds=[%d, %d, %d, %d]\n", qPrintable(name),
+ region.boundingRect().x(),
+ region.boundingRect().y(),
+ region.boundingRect().width(),
+ region.boundingRect().height());
+
+ m_regionMap[name] = region;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_resetMatrix(QRegExp)
+{
+ if (m_verboseMode)
+ printf(" -(lance) resetMatrix()\n");
+
+ m_painter->resetTransform();
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_restore(QRegExp)
+{
+ if (m_verboseMode)
+ printf(" -(lance) restore()\n");
+
+ m_painter->restore();
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_rotate(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double angle = convertToDouble(caps.at(1));
+
+ if (m_verboseMode)
+ printf(" -(lance) rotate(%.2f)\n", angle);
+
+ m_painter->rotate(angle);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_rotate_x(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double angle = convertToDouble(caps.at(1));
+
+ if (m_verboseMode)
+ printf(" -(lance) rotate_x(%.2f)\n", angle);
+
+ QTransform transform;
+ transform.rotate(angle, Qt::XAxis);
+ m_painter->setTransform(transform, true);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_rotate_y(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double angle = convertToDouble(caps.at(1));
+
+ if (m_verboseMode)
+ printf(" -(lance) rotate_y(%.2f)\n", angle);
+
+ QTransform transform;
+ transform.rotate(angle, Qt::YAxis);
+ m_painter->setTransform(transform, true);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_save(QRegExp)
+{
+ if (m_verboseMode)
+ printf(" -(lance) save()\n");
+
+ m_painter->save();
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_mapQuadToQuad(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double x1 = convertToDouble(caps.at(1));
+ double y1 = convertToDouble(caps.at(2));
+ double x2 = convertToDouble(caps.at(3));
+ double y2 = convertToDouble(caps.at(4));
+ double x3 = convertToDouble(caps.at(5));
+ double y3 = convertToDouble(caps.at(6));
+ double x4 = convertToDouble(caps.at(7));
+ double y4 = convertToDouble(caps.at(8));
+ QPolygonF poly1(4);
+ poly1[0] = QPointF(x1, y1);
+ poly1[1] = QPointF(x2, y2);
+ poly1[2] = QPointF(x3, y3);
+ poly1[3] = QPointF(x4, y4);
+
+ double x5 = convertToDouble(caps.at(9));
+ double y5 = convertToDouble(caps.at(10));
+ double x6 = convertToDouble(caps.at(11));
+ double y6 = convertToDouble(caps.at(12));
+ double x7 = convertToDouble(caps.at(13));
+ double y7 = convertToDouble(caps.at(14));
+ double x8 = convertToDouble(caps.at(15));
+ double y8 = convertToDouble(caps.at(16));
+ QPolygonF poly2(4);
+ poly2[0] = QPointF(x5, y5);
+ poly2[1] = QPointF(x6, y6);
+ poly2[2] = QPointF(x7, y7);
+ poly2[3] = QPointF(x8, y8);
+
+ if (m_verboseMode)
+ printf(" -(lance) mapQuadToQuad(%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f ->\n\t"
+ ",%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
+ x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8);
+
+ QTransform trans;
+
+ if (!QTransform::quadToQuad(poly1, poly2, trans)) {
+ qWarning("Couldn't perform quad to quad transformation!");
+ }
+
+ m_painter->setTransform(trans, true);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setMatrix(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double m11 = convertToDouble(caps.at(1));
+ double m12 = convertToDouble(caps.at(2));
+ double m13 = convertToDouble(caps.at(3));
+ double m21 = convertToDouble(caps.at(4));
+ double m22 = convertToDouble(caps.at(5));
+ double m23 = convertToDouble(caps.at(6));
+ double m31 = convertToDouble(caps.at(7));
+ double m32 = convertToDouble(caps.at(8));
+ double m33 = convertToDouble(caps.at(9));
+
+ if (m_verboseMode)
+ printf(" -(lance) setMatrix(%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
+ m11, m12, m13, m21, m22, m23, m31, m32, m33);
+
+ QTransform trans;
+ trans.setMatrix(m11, m12, m13,
+ m21, m22, m23,
+ m31, m32, m33);
+
+ m_painter->setTransform(trans, true);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_scale(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double sx = convertToDouble(caps.at(1));
+ double sy = convertToDouble(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) scale(%.2f, %.2f)\n", sx, sy);
+
+
+ m_painter->scale(sx, sy);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setBackground(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QColor color = convertToColor(caps.at(1));
+ QString pattern = caps.at(2);
+
+ int style = translateEnum(brushStyleTable, pattern, Qt::LinearGradientPattern);
+ if (style < 0)
+ style = Qt::SolidPattern;
+
+ if (m_verboseMode)
+ printf(" -(lance) setBackground(%s, %s)\n", qPrintable(color.name()), qPrintable(pattern));
+
+ m_painter->setBackground(QBrush(color, Qt::BrushStyle(style)));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setOpacity(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double opacity = convertToDouble(caps.at(1));
+
+ if (m_verboseMode)
+ printf(" -(lance) setOpacity(%lf)\n", opacity);
+
+ m_painter->setOpacity(opacity);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setBgMode(QRegExp re)
+{
+ QString cap = re.cap(2);
+ Qt::BGMode mode = Qt::TransparentMode;
+ if (cap.toLower() == QLatin1String("opaquemode") || cap.toLower() == QLatin1String("opaque"))
+ mode = Qt::OpaqueMode;
+
+ if (m_verboseMode)
+ printf(" -(lance) setBackgroundMode(%s)\n", mode == Qt::OpaqueMode ? "OpaqueMode" : "TransparentMode");
+
+ m_painter->setBackgroundMode(mode);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setBrush(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QPixmap pm = image_load<QPixmap>(caps.at(1));
+ if (!pm.isNull()) { // Assume pixmap
+ if (m_verboseMode)
+ printf(" -(lance) setBrush(pixmap=%s, width=%d, height=%d)\n",
+ qPrintable(caps.at(1)), pm.width(), pm.height());
+
+ m_painter->setBrush(QBrush(pm));
+ } else if (caps.at(1).toLower() == "nobrush") {
+ m_painter->setBrush(Qt::NoBrush);
+ if (m_verboseMode)
+ printf(" -(lance) setBrush(Qt::NoBrush)\n");
+ } else {
+ QColor color = convertToColor(caps.at(1));
+ QString pattern = caps.at(2);
+
+ int style = translateEnum(brushStyleTable, pattern, Qt::LinearGradientPattern);
+ if (style < 0)
+ style = Qt::SolidPattern;
+
+ if (m_verboseMode)
+ printf(" -(lance) setBrush(%s, %s (%d))\n", qPrintable(color.name()), qPrintable(pattern), style);
+
+ m_painter->setBrush(QBrush(color, Qt::BrushStyle(style)));
+ }
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setBrushOrigin(QRegExp re)
+{
+ int x = convertToInt(re.cap(1));
+ int y = convertToInt(re.cap(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) setBrushOrigin(%d, %d)\n", x, y);
+
+ m_painter->setBrushOrigin(x, y);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_brushTranslate(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double dx = convertToDouble(caps.at(1));
+ double dy = convertToDouble(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) brushTranslate(%f, %f)\n", dx, dy);
+
+ QBrush new_brush = m_painter->brush();
+ QTransform brush_matrix = new_brush.transform();
+ brush_matrix.translate(dx, dy);
+ new_brush.setTransform(brush_matrix);
+ m_painter->setBrush(new_brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_brushScale(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double sx = convertToDouble(caps.at(1));
+ double sy = convertToDouble(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) brushScale(%f, %f)\n", sx, sy);
+
+ QBrush new_brush = m_painter->brush();
+ QTransform brush_matrix = new_brush.transform();
+ brush_matrix.scale(sx, sy);
+ new_brush.setTransform(brush_matrix);
+ m_painter->setBrush(new_brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_brushRotate(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double rot = convertToDouble(caps.at(1));
+
+ if (m_verboseMode)
+ printf(" -(lance) brushScale(%f)\n", rot);
+
+ QBrush new_brush = m_painter->brush();
+ QTransform brush_matrix = new_brush.transform();
+ brush_matrix.rotate(rot);
+ new_brush.setTransform(brush_matrix);
+ m_painter->setBrush(new_brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_brushShear(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double sx = convertToDouble(caps.at(1));
+ double sy = convertToDouble(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) brushShear(%f, %f)\n", sx, sy);
+
+ QBrush new_brush = m_painter->brush();
+ QTransform brush_matrix = new_brush.transform();
+ brush_matrix.shear(sx, sy);
+ new_brush.setTransform(brush_matrix);
+ m_painter->setBrush(new_brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setClipping(QRegExp re)
+{
+ bool clipping = re.cap(1).toLower() == "true";
+
+ if (m_verboseMode)
+ printf(" -(lance) setClipping(%d)\n", clipping);
+
+ m_painter->setClipping(clipping);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setClipRect(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ int w = convertToInt(caps.at(3));
+ int h = convertToInt(caps.at(4));
+
+ int combine = translateEnum(clipOperationTable, caps.at(5), Qt::IntersectClip + 1);
+ if (combine == -1)
+ combine = Qt::ReplaceClip;
+
+ if (m_verboseMode)
+ printf(" -(lance) setClipRect(%d, %d, %d, %d), %s\n", x, y, w, h, clipOperationTable[combine]);
+
+ m_painter->setClipRect(x, y, w, h, Qt::ClipOperation(combine));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setClipPath(QRegExp re)
+{
+ int combine = translateEnum(clipOperationTable, re.cap(2), Qt::IntersectClip + 1);
+ if (combine == -1)
+ combine = Qt::ReplaceClip;
+
+ if (m_verboseMode)
+ printf(" -(lance) setClipPath(name=%s), %s\n", qPrintable(re.cap(1)), clipOperationTable[combine]);
+
+ if (!m_pathMap.contains(re.cap(1)))
+ fprintf(stderr, " - setClipPath, no such path");
+ m_painter->setClipPath(m_pathMap[re.cap(1)], Qt::ClipOperation(combine));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setClipRegion(QRegExp re)
+{
+ int combine = translateEnum(clipOperationTable, re.cap(2), Qt::IntersectClip + 1);
+ if (combine == -1)
+ combine = Qt::ReplaceClip;
+ QRegion r = m_regionMap[re.cap(1)];
+
+ if (m_verboseMode)
+ printf(" -(lance) setClipRegion(name=%s), bounds=[%d, %d, %d, %d], %s\n",
+ qPrintable(re.cap(1)),
+ r.boundingRect().x(),
+ r.boundingRect().y(),
+ r.boundingRect().width(),
+ r.boundingRect().height(),
+ clipOperationTable[combine]);
+
+ m_painter->setClipRegion(m_regionMap[re.cap(1)], Qt::ClipOperation(combine));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setFont(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QString family = caps.at(1);
+ int size = convertToInt(caps.at(2));
+
+ int weight = translateEnum(fontWeightTable, re.cap(3).toLower(), 5);
+ if (weight != -1) {
+ switch (weight) {
+ case 0: weight = QFont::Light; break;
+ case 1: weight = QFont::Normal; break;
+ case 2: weight = QFont::DemiBold; break;
+ case 3: weight = QFont::Bold; break;
+ case 4: weight = QFont::Black; break;
+ }
+ } else {
+ weight = convertToInt(re.cap(3));
+ }
+
+ bool italic = caps.at(4).toLower() == "true" || caps.at(4).toLower() == "italic";
+
+ QFont font(family, size, weight, italic);
+
+#if QT_VERSION >= 0x040800
+ int hinting = translateEnum(fontHintingTable, caps.at(5), 4);
+ if (hinting == -1)
+ hinting = 0;
+ else
+ font.setHintingPreference(QFont::HintingPreference(hinting));
+#else
+ int hinting = 1;
+#endif
+ if (m_verboseMode)
+ printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d hinting=%s\n",
+ qPrintable(family), size, weight, italic, fontHintingTable[hinting]);
+
+ m_painter->setFont(font);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setPen(QRegExp re)
+{
+ QString cap = re.cap(1);
+ int style = translateEnum(penStyleTable, cap, Qt::DashDotDotLine + 1);
+ if (style >= 0) {
+ if (m_verboseMode)
+ printf(" -(lance) setPen(%s)\n", qPrintable(cap));
+
+ m_painter->setPen(Qt::PenStyle(style));
+ } else if (cap.toLower() == "brush") {
+ QPen pen(m_painter->brush(), 0);
+ if (m_verboseMode) {
+ printf(" -(lance) setPen(brush), style=%d, color=%08x\n",
+ pen.brush().style(), pen.color().rgba());
+ }
+ m_painter->setPen(pen);
+ } else {
+ QColor color = convertToColor(cap);
+ if (m_verboseMode)
+ printf(" -(lance) setPen(%s)\n", qPrintable(color.name()));
+
+ m_painter->setPen(color);
+ }
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setPen2(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QBrush brush;
+
+ if (caps.at(1).toLower() == "brush")
+ brush = m_painter->brush();
+ else
+ brush = convertToColor(caps.at(1));
+
+ double width = convertToDouble(caps.at(2));
+ int penStyle = translateEnum(penStyleTable, caps.at(3), Qt::DashDotDotLine + 1);
+ if (penStyle < 0)
+ penStyle = Qt::SolidLine;
+
+ Qt::PenCapStyle capStyle = Qt::SquareCap;
+ if (caps.at(4).toLower() == "flatcap") capStyle = Qt::FlatCap;
+ else if (caps.at(4).toLower() == "squarecap") capStyle = Qt::SquareCap;
+ else if (caps.at(4).toLower() == "roundcap") capStyle = Qt::RoundCap;
+ else if (!caps.at(4).isEmpty())
+ fprintf(stderr, "ERROR: setPen, unknown capStyle: %s\n", qPrintable(caps.at(4)));
+
+ Qt::PenJoinStyle joinStyle = Qt::BevelJoin;
+ if (caps.at(5).toLower() == "miterjoin") joinStyle = Qt::MiterJoin;
+ else if (caps.at(5).toLower() == "beveljoin") joinStyle = Qt::BevelJoin;
+ else if (caps.at(5).toLower() == "roundjoin") joinStyle = Qt::RoundJoin;
+ else if (!caps.at(5).isEmpty())
+ fprintf(stderr, "ERROR: setPen, unknown joinStyle: %s\n", qPrintable(caps.at(5)));
+
+ if (m_verboseMode)
+ printf(" -(lance) setPen(%s, width=%f, style=%d, cap=%d, join=%d)\n",
+ qPrintable(brush.color().name()), width, penStyle, capStyle, joinStyle);
+
+ m_painter->setPen(QPen(brush, width, Qt::PenStyle(penStyle), capStyle, joinStyle));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setRenderHint(QRegExp re)
+{
+ QString hintString = re.cap(1).toLower();
+ bool on = re.cap(2).isEmpty() || re.cap(2).toLower() == "true";
+ if (hintString.contains("antialiasing")) {
+ if (m_verboseMode)
+ printf(" -(lance) setRenderHint Antialiasing\n");
+
+ m_painter->setRenderHint(QPainter::Antialiasing, on);
+ } else if (hintString.contains("smoothpixmaptransform")) {
+ if (m_verboseMode)
+ printf(" -(lance) setRenderHint SmoothPixmapTransform\n");
+ m_painter->setRenderHint(QPainter::SmoothPixmapTransform, on);
+ } else {
+ fprintf(stderr, "ERROR(setRenderHint): unknown hint '%s'\n", qPrintable(hintString));
+ }
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_clearRenderHint(QRegExp /*re*/)
+{
+ m_painter->setRenderHint(QPainter::Antialiasing, false);
+ m_painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
+ if (m_verboseMode)
+ printf(" -(lance) clearRenderHint\n");
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_setCompositionMode(QRegExp re)
+{
+ QString modeString = re.cap(1).toLower();
+ int mode = translateEnum(compositionModeTable, modeString, 33);
+
+ if (mode < 0 || mode > QPainter::RasterOp_SourceAndNotDestination) {
+ fprintf(stderr, "ERROR: invalid mode: %s\n", qPrintable(modeString));
+ return;
+ }
+
+ if (m_verboseMode)
+ printf(" -(lance) setCompositionMode: %d: %s\n", mode, qPrintable(modeString));
+
+ m_painter->setCompositionMode(QPainter::CompositionMode(mode));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_translate(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double dx = convertToDouble(caps.at(1));
+ double dy = convertToDouble(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) translate(%f, %f)\n", dx, dy);
+
+ m_painter->translate(dx, dy);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_pixmap_load(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString fileName = caps.at(1);
+ QString name = caps.at(2);
+
+ if (name.isEmpty())
+ name = fileName;
+
+ QImage im = image_load<QImage>(fileName);
+ QPixmap px = QPixmap::fromImage(im, Qt::OrderedDither | Qt::OrderedAlphaDither);
+
+ if (m_verboseMode)
+ printf(" -(lance) pixmap_load(%s as %s), size=[%d, %d], depth=%d\n",
+ qPrintable(fileName), qPrintable(name),
+ px.width(), px.height(), px.depth());
+
+ m_pixmapMap[name] = px;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_bitmap_load(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString fileName = caps.at(1);
+ QString name = caps.at(2);
+
+ if (name.isEmpty())
+ name = fileName;
+
+ QBitmap bm = image_load<QBitmap>(fileName);
+
+ if (m_verboseMode)
+ printf(" -(lance) bitmap_load(%s as %s), size=[%d, %d], depth=%d\n",
+ qPrintable(fileName), qPrintable(name),
+ bm.width(), bm.height(), bm.depth());
+
+ m_pixmapMap[name] = bm;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_pixmap_setMask(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ QBitmap mask = image_load<QBitmap>(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) pixmap_setMask(%s, %s)\n", qPrintable(caps.at(1)), qPrintable(caps.at(2)));
+
+ if (!m_pixmapMap[caps.at(1)].isNull())
+ m_pixmapMap[caps.at(1)].setMask(mask);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_image_load(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString fileName = caps.at(1);
+ QString name = caps.at(2);
+
+ if (name.isEmpty())
+ name = fileName;
+
+ QImage image = image_load<QImage>(fileName);
+
+ if (m_verboseMode)
+ printf(" -(lance) image_load(%s as %s), size=[%d, %d], format=%d\n",
+ qPrintable(fileName), qPrintable(name),
+ image.width(), image.height(), image.format());
+
+ m_imageMap[name] = image;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_image_setColorCount(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString name = caps.at(1);
+ int count = convertToInt(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) image_setColorCount(%s), %d -> %d\n",
+ qPrintable(name), m_imageMap[name].colorCount(), count);
+
+ m_imageMap[name].setColorCount(count);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_image_setColor(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString name = caps.at(1);
+ int index = convertToInt(caps.at(2));
+ QColor color = convertToColor(caps.at(3));
+
+ if (m_verboseMode)
+ printf(" -(lance) image_setColor(%s), %d = %08x\n", qPrintable(name), index, color.rgba());
+
+ m_imageMap[name].setColor(index, color.rgba());
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_abort(QRegExp)
+{
+ m_abort = true;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_clearStops(QRegExp)
+{
+ if (m_verboseMode)
+ printf(" -(lance) gradient_clearStops\n");
+ m_gradientStops.clear();
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_appendStop(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double pos = convertToDouble(caps.at(1));
+ QColor color = convertToColor(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_appendStop(%.2f, %x)\n", pos, color.rgba());
+
+ m_gradientStops << QGradientStop(pos, color);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_setLinear(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double x1 = convertToDouble(caps.at(1));
+ double y1 = convertToDouble(caps.at(2));
+ double x2 = convertToDouble(caps.at(3));
+ double y2 = convertToDouble(caps.at(4));
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_setLinear (%.2f, %.2f), (%.2f, %.2f), spread=%d\n",
+ x1, y1, x2, y2, m_gradientSpread);
+
+ QLinearGradient lg(QPointF(x1, y1), QPointF(x2, y2));
+ lg.setStops(m_gradientStops);
+ lg.setSpread(m_gradientSpread);
+ lg.setCoordinateMode(m_gradientCoordinate);
+ QBrush brush(lg);
+ QTransform brush_matrix = m_painter->brush().transform();
+ brush.setTransform(brush_matrix);
+ m_painter->setBrush(brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_setLinearPen(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double x1 = convertToDouble(caps.at(1));
+ double y1 = convertToDouble(caps.at(2));
+ double x2 = convertToDouble(caps.at(3));
+ double y2 = convertToDouble(caps.at(4));
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_setLinear (%.2f, %.2f), (%.2f, %.2f), spread=%d\n",
+ x1, y1, x2, y2, m_gradientSpread);
+
+ QLinearGradient lg(QPointF(x1, y1), QPointF(x2, y2));
+ lg.setStops(m_gradientStops);
+ lg.setSpread(m_gradientSpread);
+ lg.setCoordinateMode(m_gradientCoordinate);
+ QPen pen = m_painter->pen();
+ pen.setBrush(lg);
+ m_painter->setPen(pen);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_setRadial(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double cx = convertToDouble(caps.at(1));
+ double cy = convertToDouble(caps.at(2));
+ double rad = convertToDouble(caps.at(3));
+ double fx = convertToDouble(caps.at(4));
+ double fy = convertToDouble(caps.at(5));
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_setRadial center=(%.2f, %.2f), radius=%.2f, focal=(%.2f, %.2f), "
+ "spread=%d\n",
+ cx, cy, rad, fx, fy, m_gradientSpread);
+
+ QRadialGradient rg(QPointF(cx, cy), rad, QPointF(fx, fy));
+ rg.setStops(m_gradientStops);
+ rg.setSpread(m_gradientSpread);
+ rg.setCoordinateMode(m_gradientCoordinate);
+ QBrush brush(rg);
+ QTransform brush_matrix = m_painter->brush().transform();
+ brush.setTransform(brush_matrix);
+ m_painter->setBrush(brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_setRadialExtended(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double cx = convertToDouble(caps.at(1));
+ double cy = convertToDouble(caps.at(2));
+ double rad = convertToDouble(caps.at(3));
+ double fx = convertToDouble(caps.at(4));
+ double fy = convertToDouble(caps.at(5));
+ double frad = convertToDouble(caps.at(6));
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_setRadialExtended center=(%.2f, %.2f), radius=%.2f, focal=(%.2f, %.2f), "
+ "focal radius=%.2f, spread=%d\n",
+ cx, cy, rad, fx, fy, frad, m_gradientSpread);
+
+ QRadialGradient rg(QPointF(cx, cy), rad, QPointF(fx, fy), frad);
+ rg.setStops(m_gradientStops);
+ rg.setSpread(m_gradientSpread);
+ rg.setCoordinateMode(m_gradientCoordinate);
+ QBrush brush(rg);
+ QTransform brush_matrix = m_painter->brush().transform();
+ brush.setTransform(brush_matrix);
+ m_painter->setBrush(brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_setConical(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double cx = convertToDouble(caps.at(1));
+ double cy = convertToDouble(caps.at(2));
+ double angle = convertToDouble(caps.at(3));
+
+ if (m_verboseMode) {
+ printf(" -(lance) gradient_setConical center=(%.2f, %.2f), angle=%.2f\n, spread=%d",
+ cx, cy, angle, m_gradientSpread);
+ }
+
+ QConicalGradient cg(QPointF(cx, cy), angle);
+ cg.setStops(m_gradientStops);
+ cg.setSpread(m_gradientSpread);
+ cg.setCoordinateMode(m_gradientCoordinate);
+ QBrush brush(cg);
+ QTransform brush_matrix = m_painter->brush().transform();
+ brush.setTransform(brush_matrix);
+ m_painter->setBrush(brush);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_gradient_setSpread(QRegExp re)
+{
+ int spreadMethod = translateEnum(spreadMethodTable, re.cap(1), 3);
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_setSpread %d=[%s]\n", spreadMethod, spreadMethodTable[spreadMethod]);
+
+ m_gradientSpread = QGradient::Spread(spreadMethod);
+}
+
+void PaintCommands::command_gradient_setCoordinateMode(QRegExp re)
+{
+ int coord = translateEnum(coordinateMethodTable, re.cap(1), 3);
+
+ if (m_verboseMode)
+ printf(" -(lance) gradient_setCoordinateMode %d=[%s]\n", coord,
+ coordinateMethodTable[coord]);
+
+ m_gradientCoordinate = QGradient::CoordinateMode(coord);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_surface_begin(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double x = convertToDouble(caps.at(1));
+ double y = convertToDouble(caps.at(2));
+ double w = convertToDouble(caps.at(3));
+ double h = convertToDouble(caps.at(4));
+
+ if (m_surface_painter) {
+ fprintf(stderr, "ERROR: surface already active");
+ return;
+ }
+
+ if (m_verboseMode)
+ printf(" -(lance) surface_begin, pos=[%.2f, %.2f], size=[%.2f, %.2f]\n", x, y, w, h);
+
+ m_surface_painter = m_painter;
+
+ if (m_type == OpenGLType || m_type == OpenGLPBufferType) {
+#ifndef QT_NO_OPENGL
+ m_surface_pbuffer = new QGLPixelBuffer(qRound(w), qRound(h));
+ m_painter = new QPainter(m_surface_pbuffer);
+ m_painter->fillRect(QRect(0, 0, qRound(w), qRound(h)), Qt::transparent);
+#endif
+#ifdef Q_WS_X11
+ } else if (m_type == WidgetType) {
+ m_surface_pixmap = QPixmap(qRound(w), qRound(h));
+ m_surface_pixmap.fill(Qt::transparent);
+ m_painter = new QPainter(&m_surface_pixmap);
+#endif
+ } else {
+ m_surface_image = QImage(qRound(w), qRound(h), QImage::Format_ARGB32_Premultiplied);
+ m_surface_image.fill(0);
+ m_painter = new QPainter(&m_surface_image);
+ }
+ m_surface_rect = QRectF(x, y, w, h);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_surface_end(QRegExp)
+{
+ if (!m_surface_painter) {
+ fprintf(stderr, "ERROR: surface not active");
+ return;
+ }
+
+ if (m_verboseMode)
+ printf(" -(lance) surface_end, pos=[%.2f, %.2f], size=[%.2f, %.2f]\n",
+ m_surface_rect.x(),
+ m_surface_rect.y(),
+ m_surface_rect.width(),
+ m_surface_rect.height());
+ m_painter->end();
+
+ delete m_painter;
+ m_painter = m_surface_painter;
+ m_surface_painter = 0;
+
+ if (m_type == OpenGLType || m_type == OpenGLPBufferType) {
+#ifndef QT_NO_OPENGL
+ QImage image = m_surface_pbuffer->toImage();
+ QImage new_image(image.bits(), image.width(),
+ image.height(), QImage::Format_ARGB32_Premultiplied);
+ QPaintDevice *pdev = m_painter->device();
+ if (pdev->devType() == QInternal::Widget) {
+ QWidget *w = static_cast<QWidget *>(pdev);
+ static_cast<QGLWidget *>(w)->makeCurrent();
+ } else if (pdev->devType() == QInternal::Pbuffer) {
+ static_cast<QGLPixelBuffer *>(pdev)->makeCurrent();
+ }
+
+ m_painter->drawImage(m_surface_rect, new_image);
+
+ delete m_surface_pbuffer;
+ m_surface_pbuffer = 0;
+#endif
+#ifdef Q_WS_X11
+ } else if (m_type == WidgetType) {
+ m_painter->drawPixmap(m_surface_rect.topLeft(), m_surface_pixmap);
+ m_surface_pixmap = QPixmap();
+#endif
+ } else {
+ m_painter->drawImage(m_surface_rect, m_surface_image);
+ m_surface_image = QImage();
+ }
+ m_surface_rect = QRectF();
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_image_convertToFormat(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString srcName = caps.at(1);
+ QString destName = caps.at(2);
+
+ if (!m_imageMap.contains(srcName)) {
+ fprintf(stderr, "ERROR(convertToFormat): no such image '%s'\n", qPrintable(srcName));
+ return;
+ }
+
+ int format = translateEnum(imageFormatTable, caps.at(3), QImage::NImageFormats);
+ if (format < 0 || format >= QImage::NImageFormats) {
+ fprintf(stderr, "ERROR(convertToFormat): invalid format %d = '%s'\n",
+ format, qPrintable(caps.at(3)));
+ return;
+ }
+
+ QImage src = m_imageMap[srcName];
+ QImage dest = src.convertToFormat(QImage::Format(format),
+ Qt::OrderedAlphaDither | Qt::OrderedDither);
+
+ if (m_verboseMode) {
+ printf(" -(lance) convertToFormat %s:%d -> %s:%d\n",
+ qPrintable(srcName), src.format(),
+ qPrintable(destName), dest.format());
+ }
+
+ m_imageMap[destName] = dest;
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_textlayout_draw(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+
+ QString text = caps.at(1);
+ double width = convertToDouble(caps.at(2));
+
+ if (m_verboseMode)
+ printf(" -(lance) textlayout_draw text='%s', width=%f\n",
+ qPrintable(text), width);
+
+ QFont copy = m_painter->font();
+ copy.setPointSize(10);
+
+ QTextLayout layout(text, copy, m_painter->device());
+ layout.beginLayout();
+
+ double y_offset = 0;
+
+ while (true) {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ line.setLineWidth(width);
+ line.setPosition(QPointF(0, y_offset));
+
+ y_offset += line.height();
+ }
+
+ layout.draw(m_painter, QPointF(0, 0));
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_pen_setDashOffset(QRegExp re)
+{
+ QStringList caps = re.capturedTexts();
+ double offset = convertToDouble(caps.at(1));
+
+ if (m_verboseMode)
+ printf(" -(lance) setDashOffset(%lf)\n", offset);
+
+ QPen p = m_painter->pen();
+ p.setDashOffset(offset);
+ m_painter->setPen(p);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_pen_setDashPattern(QRegExp re)
+{
+ static QRegExp separators("\\s");
+ QStringList caps = re.capturedTexts();
+ QString cap = caps.at(1);
+ QStringList numbers = cap.split(separators, QString::SkipEmptyParts);
+
+ QVector<qreal> pattern;
+ for (int i=0; i<numbers.size(); ++i)
+ pattern.append(convertToDouble(numbers.at(i)));
+
+ if (m_verboseMode)
+ printf(" -(lance) pen_setDashPattern(size=%d)\n", pattern.size());
+
+ QPen p = m_painter->pen();
+ p.setDashPattern(pattern);
+ m_painter->setPen(p);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_pen_setCosmetic(QRegExp re)
+{
+ QString hm = re.capturedTexts().at(1);
+ bool on = hm == "true" || hm == "yes" || hm == "on";
+
+ if (m_verboseMode) {
+ printf(" -(lance) pen_setCosmetic(%s)\n", on ? "true" : "false");
+ }
+
+ QPen p = m_painter->pen();
+ p.setCosmetic(on);
+
+ m_painter->setPen(p);
+}
+
+/***************************************************************************************************/
+void PaintCommands::command_drawConvexPolygon(QRegExp re)
+{
+ static QRegExp separators("\\s");
+ QStringList caps = re.capturedTexts();
+ QString cap = caps.at(1);
+ QStringList numbers = cap.split(separators, QString::SkipEmptyParts);
+
+ QPolygonF array;
+ for (int i=0; i + 1<numbers.size(); i+=2)
+ array.append(QPointF(convertToDouble(numbers.at(i)), convertToDouble(numbers.at(i+1))));
+
+ if (m_verboseMode)
+ printf(" -(lance) drawConvexPolygon(size=%d)\n", array.size());
+
+
+ m_painter->drawConvexPolygon(array);
+}
diff --git a/tests/auto/lancelot/paintcommands.h b/tests/auto/lancelot/paintcommands.h
new file mode 100644
index 0000000000..925a867f2f
--- /dev/null
+++ b/tests/auto/lancelot/paintcommands.h
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PAINTCOMMANDS_H
+#define PAINTCOMMANDS_H
+
+#include <qcolor.h>
+#include <qmap.h>
+#include <qpainterpath.h>
+#include <qregion.h>
+#include <qstringlist.h>
+#include <qpixmap.h>
+#include <qbrush.h>
+#include <qhash.h>
+
+QT_FORWARD_DECLARE_CLASS(QPainter)
+QT_FORWARD_DECLARE_CLASS(QRegExp)
+#ifndef QT_NO_OPENGL
+QT_FORWARD_DECLARE_CLASS(QGLPixelBuffer)
+#endif
+
+enum DeviceType {
+ WidgetType,
+ BitmapType,
+ PixmapType,
+ ImageType,
+ ImageMonoType,
+ OpenGLType,
+ OpenGLPBufferType,
+ PictureType,
+ PrinterType,
+ PdfType,
+ PsType,
+ GrabType,
+ CustomDeviceType,
+ CustomWidgetType,
+ ImageWidgetType
+};
+
+/************************************************************************/
+class PaintCommands
+{
+public:
+ // construction / initialization
+ PaintCommands(const QStringList &cmds, int w, int h)
+ : m_painter(0)
+ , m_surface_painter(0)
+ , m_commands(cmds)
+ , m_gradientSpread(QGradient::PadSpread)
+ , m_gradientCoordinate(QGradient::LogicalMode)
+ , m_width(w)
+ , m_height(h)
+ , m_verboseMode(false)
+ , m_type(WidgetType)
+ , m_checkers_background(true)
+ , m_shouldDrawText(true)
+ { staticInit(); }
+
+public:
+ void setCheckersBackground(bool b) { staticInit(); m_checkers_background = b; }
+ void setContents(const QStringList &cmds) {
+ staticInit();
+ m_blockMap.clear();
+ m_pathMap.clear();
+ m_pixmapMap.clear();
+ m_imageMap.clear();
+ m_regionMap.clear();
+ m_gradientStops.clear();
+ m_controlPoints.clear();
+ m_gradientSpread = QGradient::PadSpread;
+ m_gradientCoordinate = QGradient::LogicalMode;
+ m_commands = cmds;
+
+
+ }
+ void setPainter(QPainter *pt) { staticInit(); m_painter = pt; }
+ void setType(DeviceType t) { staticInit(); m_type = t; }
+ void setFilePath(const QString &path) { staticInit(); m_filepath = path; }
+ void setControlPoints(const QVector<QPointF> &points) { staticInit(); m_controlPoints = points; }
+ void setVerboseMode(bool v) { staticInit(); m_verboseMode = v; }
+ void insertAt(int commandIndex, const QStringList &newCommands);
+ void setShouldDrawText(bool drawText) { m_shouldDrawText = drawText; }
+
+ // run
+ void runCommands();
+
+private:
+ // run
+ void runCommand(const QString &scriptLine);
+
+ // conversion methods
+ int convertToInt(const QString &str);
+ double convertToDouble(const QString &str);
+ float convertToFloat(const QString &str);
+ QColor convertToColor(const QString &str);
+
+ // commands: comments
+ void command_comment(QRegExp re);
+
+ // commands: importer
+ void command_import(QRegExp re);
+
+ // commands: blocks
+ void command_begin_block(QRegExp re);
+ void command_end_block(QRegExp re);
+ void command_repeat_block(QRegExp re);
+
+ // commands: misc
+ void command_textlayout_draw(QRegExp re);
+ void command_abort(QRegExp re);
+
+ // commands: noops
+ void command_noop(QRegExp re);
+
+ // commands: setters
+ void command_setBgMode(QRegExp re);
+ void command_setBackground(QRegExp re);
+ void command_setOpacity(QRegExp re);
+ void command_path_setFillRule(QRegExp re);
+ void command_setBrush(QRegExp re);
+ void command_setBrushOrigin(QRegExp re);
+ void command_brushTranslate(QRegExp re);
+ void command_brushRotate(QRegExp re);
+ void command_brushScale(QRegExp re);
+ void command_brushShear(QRegExp re);
+ void command_setClipPath(QRegExp re);
+ void command_setClipRect(QRegExp re);
+ void command_setClipRectangle(QRegExp re);
+ void command_setClipRegion(QRegExp re);
+ void command_setClipping(QRegExp re);
+ void command_setCompositionMode(QRegExp re);
+ void command_setFont(QRegExp re);
+ void command_setPen(QRegExp re);
+ void command_setPen2(QRegExp re);
+ void command_pen_setDashOffset(QRegExp re);
+ void command_pen_setDashPattern(QRegExp re);
+ void command_pen_setCosmetic(QRegExp re);
+ void command_setRenderHint(QRegExp re);
+ void command_clearRenderHint(QRegExp re);
+ void command_gradient_appendStop(QRegExp re);
+ void command_gradient_clearStops(QRegExp re);
+ void command_gradient_setConical(QRegExp re);
+ void command_gradient_setLinear(QRegExp re);
+ void command_gradient_setRadial(QRegExp re);
+ void command_gradient_setRadialExtended(QRegExp re);
+ void command_gradient_setLinearPen(QRegExp re);
+ void command_gradient_setSpread(QRegExp re);
+ void command_gradient_setCoordinateMode(QRegExp re);
+
+ // commands: drawing ops
+ void command_drawArc(QRegExp re);
+ void command_drawChord(QRegExp re);
+ void command_drawConvexPolygon(QRegExp re);
+ void command_drawEllipse(QRegExp re);
+ void command_drawImage(QRegExp re);
+ void command_drawLine(QRegExp re);
+ void command_drawPath(QRegExp re);
+ void command_drawPie(QRegExp re);
+ void command_drawPixmap(QRegExp re);
+ void command_drawPoint(QRegExp re);
+ void command_drawPolygon(QRegExp re);
+ void command_drawPolyline(QRegExp re);
+ void command_drawRect(QRegExp re);
+ void command_drawRoundedRect(QRegExp re);
+ void command_drawRoundRect(QRegExp re);
+ void command_drawText(QRegExp re);
+ void command_drawStaticText(QRegExp re);
+ void command_drawTiledPixmap(QRegExp re);
+ void command_path_addEllipse(QRegExp re);
+ void command_path_addPolygon(QRegExp re);
+ void command_path_addRect(QRegExp re);
+ void command_path_addText(QRegExp re);
+ void command_path_arcTo(QRegExp re);
+ void command_path_closeSubpath(QRegExp re);
+ void command_path_createOutline(QRegExp re);
+ void command_path_cubicTo(QRegExp re);
+ void command_path_debugPrint(QRegExp re);
+ void command_path_lineTo(QRegExp re);
+ void command_path_moveTo(QRegExp re);
+ void command_region_addEllipse(QRegExp re);
+ void command_region_addRect(QRegExp re);
+
+ // getters
+ void command_region_getClipRegion(QRegExp re);
+ void command_path_getClipPath(QRegExp re);
+
+ // commands: surface begin/end
+ void command_surface_begin(QRegExp re);
+ void command_surface_end(QRegExp re);
+
+ // commands: save/restore painter state
+ void command_restore(QRegExp re);
+ void command_save(QRegExp re);
+
+ // commands: pixmap/image
+ void command_pixmap_load(QRegExp re);
+ void command_pixmap_setMask(QRegExp re);
+ void command_bitmap_load(QRegExp re);
+ void command_image_convertToFormat(QRegExp re);
+ void command_image_load(QRegExp re);
+ void command_image_setColor(QRegExp re);
+ void command_image_setColorCount(QRegExp re);
+
+ // commands: transformation
+ void command_resetMatrix(QRegExp re);
+ void command_translate(QRegExp re);
+ void command_rotate(QRegExp re);
+ void command_rotate_x(QRegExp re);
+ void command_rotate_y(QRegExp re);
+ void command_scale(QRegExp re);
+ void command_mapQuadToQuad(QRegExp re);
+ void command_setMatrix(QRegExp re);
+
+ // attributes
+ QPainter *m_painter;
+ QPainter *m_surface_painter;
+ QImage m_surface_image;
+ QPixmap m_surface_pixmap;
+#ifndef QT_NO_OPENGL
+ QGLPixelBuffer *m_surface_pbuffer;
+#endif
+ QRectF m_surface_rect;
+ QStringList m_commands;
+ QString m_currentCommand;
+ int m_currentCommandIndex;
+ QString m_filepath;
+ QMap<QString, QStringList> m_blockMap;
+ QMap<QString, QPainterPath> m_pathMap;
+ QMap<QString, QPixmap> m_pixmapMap;
+ QMap<QString, QImage> m_imageMap;
+ QMap<QString, QRegion> m_regionMap;
+ QGradientStops m_gradientStops;
+ QGradient::Spread m_gradientSpread;
+ QGradient::CoordinateMode m_gradientCoordinate;
+ bool m_abort;
+ int m_width;
+ int m_height;
+
+ bool m_verboseMode;
+ DeviceType m_type;
+ bool m_checkers_background;
+ bool m_shouldDrawText;
+
+ QVector<QPointF> m_controlPoints;
+
+ // painter functionalities string tables
+ static const char *brushStyleTable[];
+ static const char *penStyleTable[];
+ static const char *fontWeightTable[];
+ static const char *fontHintingTable[];
+ static const char *clipOperationTable[];
+ static const char *spreadMethodTable[];
+ static const char *coordinateMethodTable[];
+ static const char *compositionModeTable[];
+ static const char *imageFormatTable[];
+ static const char *sizeModeTable[];
+ static int translateEnum(const char *table[], const QString &pattern, int limit);
+
+ // utility
+ template <typename T> T image_load(const QString &filepath);
+
+ // commands dictionary management
+ static void staticInit();
+
+public:
+ struct PaintCommandInfos
+ {
+ PaintCommandInfos(QString id, void (PaintCommands::*p)(QRegExp), QRegExp r, QString sy, QString sa)
+ : identifier(id)
+ , regExp(r)
+ , syntax(sy)
+ , sample(sa)
+ , paintMethod(p)
+ {}
+ PaintCommandInfos(QString title)
+ : identifier(title), paintMethod(0) {}
+ bool isSectionHeader() const { return paintMethod == 0; }
+ QString identifier;
+ QRegExp regExp;
+ QString syntax;
+ QString sample;
+ void (PaintCommands::*paintMethod)(QRegExp);
+ };
+
+ static PaintCommandInfos *findCommandById(const QString &identifier) {
+ for (int i=0; i<s_commandInfoTable.size(); i++)
+ if (s_commandInfoTable[i].identifier == identifier)
+ return &s_commandInfoTable[i];
+ return 0;
+ }
+
+ static QList<PaintCommandInfos> s_commandInfoTable;
+ static QList<QPair<QString,QStringList> > s_enumsTable;
+ static QMultiHash<QString, int> s_commandHash;
+};
+
+#endif // PAINTCOMMANDS_H
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 79cb362d87..997f9a5b38 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -1515,7 +1515,7 @@ void tst_QApplication::testDeleteLaterProcessEvents()
}
/*
- Test for crash whith QApplication::setDesktopSettingsAware(false).
+ Test for crash with QApplication::setDesktopSettingsAware(false).
*/
void tst_QApplication::desktopSettingsAware()
{
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 9889aae09b..54885591a7 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -644,7 +644,7 @@ void tst_QByteArray::qstrncpy()
QCOMPARE(QByteArray(::qstrncpy(dst.data(), src.data(), src.size())),
QByteArray("Tumdelidu"));
- // normal copy with length is longer than neccessary
+ // normal copy with length is longer than necessary
src = QByteArray( "Tumdelidum\0foo" );
dst.resize(128*1024);
QCOMPARE(QByteArray(::qstrncpy(dst.data(), src.data(), dst.size())),
diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp
index 4c68cefc4c..4d3bb29e13 100644
--- a/tests/auto/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/qclipboard/tst_qclipboard.cpp
@@ -140,8 +140,8 @@ void tst_QClipboard::modes()
}
/*
- Test that the apropriate signals are emitted when the cliboard
- contents is changed by calling the qt funcitons.
+ Test that the appropriate signals are emitted when the cliboard
+ contents is changed by calling the qt functions.
*/
void tst_QClipboard::testSignals()
{
@@ -170,7 +170,7 @@ void tst_QClipboard::testSignals()
changedSpy.clear();
- // Test the selction mode signal.
+ // Test the selection mode signal.
if (clipboard->supportsSelection()) {
clipboard->setText(text, QClipboard::Selection);
QCOMPARE(selectionChangedSpy.count(), 1);
diff --git a/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
index 86d5f240fb..6a51bf4bba 100644
--- a/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+++ b/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -360,7 +360,7 @@ void tst_QCommandLinkButton::toggled()
testWidget->toggle();
QVERIFY( toggle_count == 0 );
- // do it again, just to be shure
+ // do it again, just to be sure
resetCounters();
testWidget->toggle();
QVERIFY( toggle_count == 0 );
diff --git a/tests/auto/qeventloop/tst_qeventloop.cpp b/tests/auto/qeventloop/tst_qeventloop.cpp
index b31f8cd76c..828366ba49 100644
--- a/tests/auto/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/qeventloop/tst_qeventloop.cpp
@@ -59,6 +59,8 @@
#include <unistd.h>
#endif
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -208,6 +210,7 @@ private slots:
void quit();
void processEventsExcludeSocket();
void processEventsExcludeTimers();
+ void deliverInDefinedOrder_QTBUG19637();
// keep this test last:
void nestedLoops();
@@ -284,7 +287,7 @@ void tst_QEventLoop::onlySymbianActiveScheduler() {
// In here we try to use timers and sockets exclusively using the Symbian
// active scheduler and no processEvents().
// This test should therefore be run first, so that we can verify that
- // the first occurrence of processEvents does not do any initalization that
+ // the first occurrence of processEvents does not do any initialization that
// we depend on.
// Open up a pipe so we can test socket notifiers.
@@ -837,5 +840,77 @@ void tst_QEventLoop::symbianNestedActiveSchedulerLoop()
#endif
}
+Q_DECLARE_METATYPE(QThread*)
+
+namespace DeliverInDefinedOrder_QTBUG19637 {
+ enum { NbThread = 3, NbObject = 500, NbEventQueue = 5, NbEvent = 50 };
+
+ struct CustomEvent : public QEvent {
+ CustomEvent(int q, int v) : QEvent(Type(User + q)), value(v) {}
+ int value;
+ };
+
+ struct Object : public QObject {
+ Q_OBJECT
+ public:
+ Object() : count(0) {
+ for (int i = 0; i < NbEventQueue; i++)
+ lastReceived[i] = -1;
+ }
+ int lastReceived[NbEventQueue];
+ int count;
+ virtual void customEvent(QEvent* e) {
+ QVERIFY(e->type() >= QEvent::User);
+ QVERIFY(e->type() < QEvent::User + 5);
+ uint idx = e->type() - QEvent::User;
+ int value = static_cast<CustomEvent *>(e)->value;
+ QVERIFY(lastReceived[idx] < value);
+ lastReceived[idx] = value;
+ count++;
+ }
+
+ public slots:
+ void moveToThread(QThread *t) {
+ QObject::moveToThread(t);
+ }
+ };
+
+}
+
+void tst_QEventLoop::deliverInDefinedOrder_QTBUG19637()
+{
+ using namespace DeliverInDefinedOrder_QTBUG19637;
+ qMetaTypeId<QThread*>();
+ QThread threads[NbThread];
+ Object objects[NbObject];
+ for (int t = 0; t < NbThread; t++) {
+ threads[t].start();
+ }
+
+ int event = 0;
+
+ for (int o = 0; o < NbObject; o++) {
+ objects[o].moveToThread(&threads[o % NbThread]);
+ for (int e = 0; e < NbEvent; e++) {
+ int q = e % NbEventQueue;
+ QCoreApplication::postEvent(&objects[o], new CustomEvent(q, ++event) , q);
+ if (e % 7)
+ QMetaObject::invokeMethod(&objects[o], "moveToThread", Qt::QueuedConnection, Q_ARG(QThread*, &threads[(e+o)%NbThread]));
+ }
+ }
+
+ QTest::qWait(30);
+ for (int o = 0; o < NbObject; o++) {
+ QTRY_COMPARE(objects[o].count, int(NbEvent));
+ }
+
+ for (int t = 0; t < NbThread; t++) {
+ threads[t].quit();
+ threads[t].wait();
+ }
+
+}
+
+
QTEST_MAIN(tst_QEventLoop)
#include "tst_qeventloop.moc"
diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 1fa0787b61..62b454099b 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -1416,7 +1416,7 @@ void tst_QFtp::abort()
QVERIFY( bytesDone != bytesTotal );
}
} else {
- // this could be tested by verifying that no more progress signals are emited
+ // this could be tested by verifying that no more progress signals are emitted
QVERIFY(bytesDone <= bytesTotal);
}
} else {
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 9c51e026d2..7d46ada820 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -1742,12 +1742,6 @@ public:
painter->fillRect(rect(), Qt::green);
painter->restore();
- painter->save();
- painter->setClipRect(0, 60, 60, 25, Qt::IntersectClip);
- painter->setClipRect(60, 60, 50, 25, Qt::UniteClip);
- painter->fillRect(rect(), Qt::yellow);
- painter->restore();
-
painter->restore();
painter->translate(100, 100);
@@ -1793,17 +1787,6 @@ public:
}
painter->fillRect(rect(), Qt::green);
painter->restore();
-
- painter->save();
- {
- QPainterPath path;
- path.addRect(0, 60, 60, 25);
- path.addRect(10, 10, 10, 10);
- painter->setClipPath(path, Qt::IntersectClip);
- }
- painter->setClipRect(60, 60, 50, 25, Qt::UniteClip);
- painter->fillRect(rect(), Qt::yellow);
- painter->restore();
}
protected:
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 4fd23bfa70..9e90a9f03c 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -6413,6 +6413,7 @@ void tst_QGraphicsItem::boundingRegion_data()
QTest::newRow("(0, 0, 10, 10) | 0.0 | identity | {(0, 0, 10, 10)}") << QLineF(0, 0, 10, 10) << qreal(0.0) << QTransform()
<< QRegion(QRect(0, 0, 10, 10));
+#if 0
{
QRegion r;
r += QRect(0, 0, 6, 2);
@@ -6430,6 +6431,7 @@ void tst_QGraphicsItem::boundingRegion_data()
r += QRect(6, 9, 4, 1);
QTest::newRow("(0, 0, 10, 10) | 1.0 | identity | {(0, 0, 10, 10)}") << QLineF(0, 0, 10, 10) << qreal(1.0) << QTransform() << r;
}
+#endif
QTest::newRow("(0, 0, 10, 0) | 0.0 | identity | {(0, 0, 10, 10)}") << QLineF(0, 0, 10, 0) << qreal(0.0) << QTransform()
<< QRegion(QRect(0, 0, 10, 1));
QTest::newRow("(0, 0, 10, 0) | 0.5 | identity | {(0, 0, 10, 1)}") << QLineF(0, 0, 10, 0) << qreal(0.5) << QTransform()
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 399dddeb4e..196519096c 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -3054,7 +3054,7 @@ void tst_QGraphicsView::task210599_unsetDragWhileDragging()
QApplication::sendEvent(view.viewport(), &move);
}
- // Check that no draggin has occured...
+ // Check that no draggin has occurred...
QCOMPARE(basePos, view.mapFromScene(0, 0));
}
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 5260a1a349..1df9d38bb8 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -2456,7 +2456,7 @@ void tst_QGraphicsWidget::popupMouseGrabber()
QCOMPARE(widgetUngrabEventSpy.count(), 1);
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
- // Showing it grabs the mosue again
+ // Showing it grabs the mouse again
widget->show();
QCOMPARE(widgetGrabEventSpy.count(), 2);
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)widget);
@@ -3175,7 +3175,7 @@ void tst_QGraphicsWidget::initialShow2()
// Don't let paint events triggered by the windowing system
// influence our test case. We're only interested in knowing
// whether a QGraphicsWidget generates an additional repaint
- // on the inital show. Hence create a dummy scenario to find out
+ // on the initial show. Hence create a dummy scenario to find out
// how many repaints we should expect.
QGraphicsScene dummyScene(0, 0, 200, 200);
dummyScene.addItem(new QGraphicsRectItem(0, 0, 100, 100));
diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp
index 93c08cdc6b..35c8d8d95c 100644
--- a/tests/auto/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp
@@ -250,7 +250,7 @@ void tst_QHostInfo::initTestCase()
void tst_QHostInfo::init()
{
- // delete the cache so inidividual testcase results are independant from each other
+ // delete the cache so inidividual testcase results are independent from each other
qt_qhostinfo_clear_cache();
QFETCH_GLOBAL(bool, cache);
diff --git a/tests/auto/qitemmodel/tst_qitemmodel.cpp b/tests/auto/qitemmodel/tst_qitemmodel.cpp
index 4bdfadd9e6..191e9e88a9 100644
--- a/tests/auto/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/qitemmodel/tst_qitemmodel.cpp
@@ -67,7 +67,7 @@ Q_DECLARE_METATYPE(QModelIndex)
See modelstotest.cpp for instructions on how to have your model tested with these tests.
Each test such as rowCount have a _data() function which populate the QTest data with
- the tests specified by modelstotest.cpp and any extra data needed for that perticular test.
+ the tests specified by modelstotest.cpp and any extra data needed for that particular test.
setupWithNoTestData() fills the QTest data with just the tests and is used by most tests.
@@ -192,7 +192,7 @@ void tst_QItemModel::nonDestructiveBasicTest_data()
}
/*!
- nonDestructiveBasicTest trys to call a number of the basic functions (not all)
+ nonDestructiveBasicTest tries to call a number of the basic functions (not all)
to make sure the model doesn't segfault, testing the functions that makes sense.
*/
void tst_QItemModel::nonDestructiveBasicTest()
@@ -516,7 +516,7 @@ void tst_QItemModel::parent()
QCOMPARE(currentModel->parent(childIndex), topIndex);
}
- // Common error test #3, the second colum has the same children
+ // Common error test #3, the second column has the same children
// as the first column in a row.
QModelIndex topIndex1 = currentModel->index(0, 1, QModelIndex());
if (currentModel->rowCount(topIndex1) > 0) {
@@ -817,7 +817,7 @@ void tst_QItemModel::remove_data()
makeTestRow(":valid start, invalid count", MIDDLE, 9999, NOSIGNALS, NOSIGNALS, NOSIGNALS, NOSIGNALS, !RECURSIVE, 0, 0, FAIL);
makeTestRow(":valid start, invalid count", END, 9999, NOSIGNALS, NOSIGNALS, NOSIGNALS, NOSIGNALS, !RECURSIVE, 0, 0, FAIL);
- // Recursive remove's might assert, havn't decided yet...
+ // Recursive remove's might assert, haven't decided yet...
//makeTestRow(":one at the start recursivly", START, DEFAULTCOUNT, 2, DNS, 2, DNS, RECURSIVE, START, DEFAULTCOUNT, FAIL);
//makeTestRow(":one at the middle recursivly", MIDDLE, DEFAULTCOUNT, 2, DNS, 2, DNS, RECURSIVE, START, DEFAULTCOUNT, SUCCESS);
//makeTestRow(":one at the end recursivly", END, DEFAULTCOUNT, 2, DNS, 2, DNS, RECURSIVE, START, DEFAULTCOUNT, SUCCESS);
@@ -849,7 +849,7 @@ void tst_QItemModel::remove()
QFETCH(bool, shouldSucceed);
// Populate the test area so we can remove something. See: cleanup()
- // parentOfRemoved is stored so that the slots can make sure parentOfRemoved is the index that is emited.
+ // parentOfRemoved is stored so that the slots can make sure parentOfRemoved is the index that is emitted.
parentOfRemoved = testModels->populateTestArea(currentModel);
if (count == -1)
@@ -866,7 +866,7 @@ void tst_QItemModel::remove()
//qDebug() << "remove start:" << start << "count:" << count << "rowCount:" << currentModel->rowCount(parentOfRemoved);
// When a row or column is removed there should be two signals.
- // Watch to make sure they are emited and get the row/column count when they do get emited by connecting them to a slot
+ // Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot
qRegisterMetaType<QModelIndex>("QModelIndex");
QSignalSpy columnsAboutToBeRemovedSpy(currentModel, SIGNAL(columnsAboutToBeRemoved( const QModelIndex &, int , int )));
QSignalSpy rowsAboutToBeRemovedSpy(currentModel, SIGNAL(rowsAboutToBeRemoved( const QModelIndex &, int , int )));
@@ -914,7 +914,7 @@ void tst_QItemModel::remove()
QVERIFY(parentOfRemoved == parent);
}
- // Only the row signals should have been emited
+ // Only the row signals should have been emitted
if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >=1 ){
QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
@@ -928,7 +928,7 @@ void tst_QItemModel::remove()
QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals);
}
- // The row count should only change *after* rowsAboutToBeRemoved has been emited
+ // The row count should only change *after* rowsAboutToBeRemoved has been emitted
//qDebug() << beforeRemoveRowCount << afterAboutToRemoveRowCount << afterRemoveRowCount << currentModel->rowCount(parentOfRemoved);
if (shouldSucceed) {
if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0){
@@ -978,7 +978,7 @@ void tst_QItemModel::remove()
QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals);
}
- // The column count should only change *after* rowsAboutToBeRemoved has been emited
+ // The column count should only change *after* rowsAboutToBeRemoved has been emitted
if (shouldSucceed) {
if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0){
QCOMPARE(afterAboutToRemoveColumnCount, beforeRemoveColumnCount);
@@ -1160,7 +1160,7 @@ void tst_QItemModel::insert_data()
makeTestRow(":valid start, invalid count", MIDDLE, -2, NOSIGNALS, NOSIGNALS, NOSIGNALS, NOSIGNALS, !RECURSIVE, 0, 0, FAIL);
makeTestRow(":valid start, invalid count", END, -2, NOSIGNALS, NOSIGNALS, NOSIGNALS, NOSIGNALS, !RECURSIVE, 0, 0, FAIL);
- // Recursive insert's might assert, havn't decided yet...
+ // Recursive insert's might assert, haven't decided yet...
//makeTestRow(":one at the start recursivly", START, DEFAULTCOUNT, 2, DNS, 2, DNS, RECURSIVE, START, DEFAULTCOUNT, FAIL);
//makeTestRow(":one at the middle recursivly", MIDDLE, DEFAULTCOUNT, 2, DNS, 2, DNS, RECURSIVE, START, DEFAULTCOUNT, SUCCESS);
//makeTestRow(":one at the end recursivly", END, DEFAULTCOUNT, 2, DNS, 2, DNS, RECURSIVE, START, DEFAULTCOUNT, SUCCESS);
@@ -1191,7 +1191,7 @@ void tst_QItemModel::insert()
QFETCH(bool, shouldSucceed);
// Populate the test area so we can insert something. See: cleanup()
- // parentOfInserted is stored so that the slots can make sure parentOfInserted is the index that is emited.
+ // parentOfInserted is stored so that the slots can make sure parentOfInserted is the index that is emitted.
parentOfInserted = testModels->populateTestArea(currentModel);
if (count == -1)
@@ -1208,7 +1208,7 @@ void tst_QItemModel::insert()
//qDebug() << "insert start:" << start << "count:" << count << "rowCount:" << currentModel->rowCount(parentOfInserted);
// When a row or column is inserted there should be two signals.
- // Watch to make sure they are emited and get the row/column count when they do get emited by connecting them to a slot
+ // Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot
qRegisterMetaType<QModelIndex>("QModelIndex");
QSignalSpy columnsAboutToBeInsertedSpy(currentModel, SIGNAL(columnsAboutToBeInserted( const QModelIndex &, int , int )));
QSignalSpy rowsAboutToBeInsertedSpy(currentModel, SIGNAL(rowsAboutToBeInserted( const QModelIndex &, int , int )));
@@ -1253,7 +1253,7 @@ void tst_QItemModel::insert()
QVERIFY(parentOfInserted == parent);
}
- // Only the row signals should have been emited
+ // Only the row signals should have been emitted
if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1) {
QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0);
QCOMPARE(rowsAboutToBeInsertedSpy.count(), 0);
@@ -1266,7 +1266,7 @@ void tst_QItemModel::insert()
QCOMPARE(columnsInsertedSpy.count(), 0);
QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals);
}
- // The row count should only change *after* rowsAboutToBeInserted has been emited
+ // The row count should only change *after* rowsAboutToBeInserted has been emitted
//qDebug() << beforeInsertRowCount << afterAboutToInsertRowCount << afterInsertRowCount << currentModel->rowCount(parentOfInserted);
if (shouldSucceed) {
if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0) {
@@ -1315,7 +1315,7 @@ void tst_QItemModel::insert()
QCOMPARE(columnsInsertedSpy.count(), numberOfColumnsInsertedSignals);
QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals);
}
- // The column count should only change *after* rowsAboutToBeInserted has been emited
+ // The column count should only change *after* rowsAboutToBeInserted has been emitted
if (shouldSucceed) {
if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0) {
QCOMPARE(afterAboutToInsertColumnCount, beforeInsertColumnCount);
diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp
index 1f43568240..b957f73eec 100644
--- a/tests/auto/qitemview/tst_qitemview.cpp
+++ b/tests/auto/qitemview/tst_qitemview.cpp
@@ -86,7 +86,7 @@ bool qt_wince_is_mobile() {
See viewstotest.cpp for instructions on how to have your view tested with these tests.
Each test such as visualRect have a _data() function which populate the QTest data with
- tests specified by viewstotest.cpp and any extra data needed for that perticular test.
+ tests specified by viewstotest.cpp and any extra data needed for that particular test.
setupWithNoTestData() fills QTest data with only the tests it is used by most tests.
@@ -324,7 +324,7 @@ void tst_QItemView::nonDestructiveBasicTest_data()
}
/*!
- nonDestructiveBasicTest trys to call a number of the basic functions (not all)
+ nonDestructiveBasicTest tries to call a number of the basic functions (not all)
to make sure the view doesn't segfault, testing the functions that makes sense.
*/
void tst_QItemView::nonDestructiveBasicTest()
diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp
index 517e44f743..5753fb8df4 100644
--- a/tests/auto/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp
@@ -291,7 +291,7 @@ void tst_QKeySequence::checkMultipleCodes()
}
/*
-* We must ensure that the keyBindings data is allways sorted
+* We must ensure that the keyBindings data is always sorted
* so that we can safely perform binary searches.
*/
void tst_QKeySequence::ensureSorted()
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index ce3d88f9d7..1c35098152 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -979,7 +979,7 @@ void tst_QListView::selection_data()
<< IntList(); // expected items
#if defined(Q_OS_WINCE)
- // depending on wether the display is double-pixeld, we need
+ // depending on whether the display is double-pixeld, we need
// to click at a different position
bool doubledSize = false;
int dpi = GetDeviceCaps(GetDC(0), LOGPIXELSX);
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index dfa7bf5aec..b3c41e1c2b 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -302,7 +302,7 @@ void tst_QMenu::mouseActivation()
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
- //context menus can allways be accessed with right click except on windows
+ //context menus can always be accessed with right click except on windows
menu.show();
QTest::mouseClick(&menu, Qt::RightButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 3b31e84556..782d533bbf 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -348,6 +348,7 @@ private Q_SLOTS:
void getFromHttpIntoBuffer();
void getFromHttpIntoBuffer2_data();
void getFromHttpIntoBuffer2();
+ void getFromHttpIntoBufferCanReadLine();
void ioGetFromHttpWithoutContentLength();
@@ -5824,6 +5825,33 @@ void tst_QNetworkReply::getFromHttpIntoBuffer2()
}
+void tst_QNetworkReply::getFromHttpIntoBufferCanReadLine()
+{
+ QString header("HTTP/1.0 200 OK\r\nContent-Length: 7\r\n\r\nxxx\nxxx");
+
+ MiniHttpServer server(header.toAscii());
+ server.doClose = true;
+
+ QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
+ request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 1024*1024*128); // 128 MB is max allowed
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(reply->canReadLine());
+ QCOMPARE(reply->read(1), QByteArray("x"));
+ QVERIFY(reply->canReadLine());
+ QCOMPARE(reply->read(3), QByteArray("xx\n"));
+ QVERIFY(!reply->canReadLine());
+ QCOMPARE(reply->readAll(), QByteArray("xxx"));
+ QVERIFY(!reply->canReadLine());
+}
+
+
+
// Is handled somewhere else too, introduced this special test to have it more accessible
void tst_QNetworkReply::ioGetFromHttpWithoutContentLength()
{
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index a149e087cd..8898a4874d 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -1294,7 +1294,7 @@ void tst_QPainter::drawRect2()
p.end();
QRect stroke = getPaintedSize(image, Qt::white);
- QCOMPARE(stroke, fill.adjusted(0, 0, 1, 1));
+ QCOMPARE(stroke.adjusted(1, 1, 0, 0), fill.adjusted(0, 0, 1, 1));
}
}
@@ -1391,13 +1391,13 @@ void tst_QPainter::drawPath_data()
{
QPainterPath p;
p.addRect(2.25, 2.25, 10, 10);
- QTest::newRow("non-aligned rect") << p << QRect(2, 2, 10, 10) << 10 * 10;
+ QTest::newRow("non-aligned rect") << p << QRect(3, 3, 10, 10) << 10 * 10;
}
{
QPainterPath p;
p.addRect(2.25, 2.25, 10.5, 10.5);
- QTest::newRow("non-aligned rect 2") << p << QRect(2, 2, 11, 11) << 11 * 11;
+ QTest::newRow("non-aligned rect 2") << p << QRect(3, 3, 10, 10) << 10 * 10;
}
{
@@ -1820,26 +1820,10 @@ int countPixels(const QImage &img, const QRgb &color)
template <typename T>
void testClipping(QImage &img)
{
- img.fill(0x0);
QPainterPath a, b;
a.addRect(QRect(2, 2, 4, 4));
b.addRect(QRect(4, 4, 4, 4));
-
QPainter p(&img);
- p.setClipPath(a);
- p.setClipPath(b, Qt::UniteClip);
-
- p.setClipping(false);
- p.setPen(Qt::NoPen);
- p.setBrush(QColor(0xff0000));
- p.drawRect(T(0, 0, 10, 10));
-
- p.setClipping(true);
- p.setBrush(QColor(0x00ff00));
- p.drawRect(T(0, 0, 10, 10));
-
- QCOMPARE(countPixels(img, 0xff0000), 72);
- QCOMPARE(countPixels(img, 0x00ff00), 28);
p.end();
img.fill(0x0);
@@ -2002,43 +1986,8 @@ void tst_QPainter::setEqualClipRegionAndPath()
QCOMPARE(img1, img2);
#endif
- // simple uniteclip
img1.fill(0x12345678);
img2.fill(0x12345678);
- {
- QPainter p(&img1);
- p.setClipRegion(region);
- p.setClipRegion(region, Qt::UniteClip);
- p.fillRect(0, 0, img1.width(), img1.height(), QColor(Qt::red));
- }
- {
- QPainter p(&img2);
- p.setClipPath(path);
- p.setClipPath(path, Qt::UniteClip);
- p.fillRect(0, 0, img2.width(), img2.height(), QColor(Qt::red));
- }
- QCOMPARE(img1, img2);
- img1.fill(0x12345678);
- img2.fill(0x12345678);
- {
- QPainter p(&img1);
- p.setClipPath(path);
- p.setClipRegion(region, Qt::UniteClip);
- p.fillRect(0, 0, img1.width(), img1.height(), QColor(Qt::red));
- }
- {
- QPainter p(&img2);
- p.setClipRegion(region);
- p.setClipPath(path, Qt::UniteClip);
- p.fillRect(0, 0, img2.width(), img2.height(), QColor(Qt::red));
- }
-#if 0
- if (img1 != img2) {
- img1.save("setEqualClipRegionAndPath_1.xpm", "XPM");
- img2.save("setEqualClipRegionAndPath_2.xpm", "XPM");
- }
-#endif
- QCOMPARE(img1, img2);
// simple intersectclip
img1.fill(0x12345678);
diff --git a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp
index 582fd4694e..7e5da4a6f8 100644
--- a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp
@@ -292,7 +292,7 @@ void tst_QPrinterInfo::testForPrinters()
for (int i = 0; i < sysPrinters.size(); ++i) {
if (!qtPrinters.value(sysPrinters.at(i))) {
- qDebug() << "Avaliable printers: " << qtPrinters;
+ qDebug() << "Available printers: " << qtPrinters;
QFAIL(qPrintable(QString("Printer '%1' reported by system, but not reported by Qt").arg(sysPrinters.at(i))));
}
}
diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp
index 8fcd1bf80b..7742f6b567 100644
--- a/tests/auto/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp
@@ -382,7 +382,7 @@ void tst_QPushButton::toggled()
testWidget->toggle();
QVERIFY( toggle_count == 0 );
- // do it again, just to be shure
+ // do it again, just to be sure
resetCounters();
testWidget->toggle();
QVERIFY( toggle_count == 0 );
diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
index 1a6f944965..06c0ecbafd 100644
--- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
+++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
@@ -72,6 +72,7 @@ private Q_SLOTS:
void isNullSignature();
void objectSize();
void comparison();
+ void array();
// TODO instanciate on const object
};
@@ -437,5 +438,26 @@ void tst_QScopedPointer::comparison()
QCOMPARE( int(RefCounted::instanceCount), 0 );
}
+void tst_QScopedPointer::array()
+{
+ int instCount = RefCounted::instanceCount;
+ {
+ QScopedArrayPointer<RefCounted> array;
+ array.reset(new RefCounted[42]);
+ QCOMPARE(instCount + 42, int(RefCounted::instanceCount));
+ }
+ QCOMPARE(instCount, int(RefCounted::instanceCount));
+ {
+ QScopedArrayPointer<RefCounted> array(new RefCounted[42]);
+ QCOMPARE(instCount + 42, int(RefCounted::instanceCount));
+ array.reset(new RefCounted[28]);
+ QCOMPARE(instCount + 28, int(RefCounted::instanceCount));
+ array.reset(0);
+ QCOMPARE(instCount, int(RefCounted::instanceCount));
+ }
+ QCOMPARE(instCount, int(RefCounted::instanceCount));
+}
+
+
QTEST_MAIN(tst_QScopedPointer)
#include "tst_qscopedpointer.moc"
diff --git a/tests/auto/qshortcut/tst_qshortcut.cpp b/tests/auto/qshortcut/tst_qshortcut.cpp
index 01b6b876d1..a78e8cfd27 100644
--- a/tests/auto/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/qshortcut/tst_qshortcut.cpp
@@ -1030,7 +1030,7 @@ void tst_QShortcut::context()
other1->clear();
other2->clear();
- // edit doens't have focus, so ActiveWindow context should work
+ // edit doesn't have focus, so ActiveWindow context should work
// ..but Focus context shouldn't..
// Changing focus to edit should make focus context work
// Application context should always work
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 45c6269148..edc81bc3ec 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -218,7 +218,7 @@ void tst_QSqlRelationalTableModel::data()
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
- //try a non-existant index
+ //try a non-existent index
QVERIFY2(model.data(model.index(0,4)).isValid() == false,"Invalid index returned valid QVariant");
//check data retrieval when relational key is a non-integer type
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index 0700e9d978..96a1f1caa5 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -1293,7 +1293,7 @@ void tst_QSqlTableModel::tableModifyWithBlank()
QCOMPARE(model.rowCount(), 1); //verify only one entry
QCOMPARE(model.record(0).value(0).toString(), timeString); //verify correct record
- //At this point we know that the intial value (timestamp) was succsefully stored in the database
+ //At this point we know that the initial value (timestamp) was succsefully stored in the database
//Attempt to modify the data in the new record
//equivalent to query.exec("update test set column3="... command in direct test
//set the data in the first column to "col1ModelData"
diff --git a/tests/auto/qsslcertificate/more-certificates/test-cn-two-cns-cert.pem b/tests/auto/qsslcertificate/more-certificates/test-cn-two-cns-cert.pem
new file mode 100644
index 0000000000..bc43c63f21
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/test-cn-two-cns-cert.pem
@@ -0,0 +1,67 @@
+Certificate:
+ Data:
+ Version: 3 (0x2)
+ Serial Number: 10 (0xa)
+ Signature Algorithm: sha1WithRSAEncryption
+ Issuer: CN=Westpoint Certificate Test CA, ST=Lancashire, C=UK/emailAddress=ca@example.com, O=Westpoint Certificate Test Root Certification Authority
+ Validity
+ Not Before: Jun 21 21:32:19 2011 GMT
+ Not After : Jun 18 21:32:19 2021 GMT
+ Subject: CN=www.example.com, CN=www2.example.com, ST=Lancashire, C=UK, O=Some organisation
+ Subject Public Key Info:
+ Public Key Algorithm: rsaEncryption
+ Public-Key: (1024 bit)
+ Modulus:
+ 00:b8:b3:72:13:cd:17:2c:01:78:16:62:5d:72:71:
+ 33:14:41:be:0c:17:ac:85:db:f8:1e:e8:55:98:3e:
+ 7b:46:a5:08:a7:db:0e:dc:78:d8:b7:1e:e0:78:30:
+ 6e:b9:e2:43:2e:f2:7d:98:fb:b4:a8:5e:63:42:e8:
+ 5c:26:79:20:5e:f6:0e:1d:12:ac:c5:0e:a4:b6:68:
+ 79:5f:3d:52:ce:44:f9:20:c9:8e:b3:fb:20:42:d5:
+ 97:9f:a4:41:8f:b8:b1:8d:c3:14:61:70:b8:d1:f7:
+ ff:48:99:c1:a0:dd:71:cb:8b:91:e6:60:29:1e:af:
+ a9:00:91:d2:c3:af:7f:cd:f9
+ Exponent: 65537 (0x10001)
+ X509v3 extensions:
+ X509v3 Basic Constraints:
+ CA:FALSE
+ Authority Information Access:
+ OCSP - URI:http://ocsp.example.com:8888/
+
+ Signature Algorithm: sha1WithRSAEncryption
+ 4c:c8:bc:0e:84:4b:bb:9e:c1:7b:81:4d:65:60:e5:d1:86:6a:
+ 00:f2:fb:ff:6d:a1:23:a1:88:c7:85:4a:b2:3d:24:cf:92:c8:
+ ab:60:10:b8:17:fa:d2:4f:60:cd:94:40:2a:b7:6e:4a:e9:f9:
+ 2b:e6:54:70:7f:f3:71:f8:fc:45:df:cf:43:f4:26:d6:73:69:
+ b3:ff:d9:da:dc:12:05:e2:52:62:2f:d4:b0:0a:e3:a1:e8:f2:
+ c1:80:b7:44:8e:3a:46:ca:1b:6d:82:c0:16:c2:f6:4f:56:89:
+ 24:86:42:8e:f9:5e:63:91:7d:88:ff:c4:bd:0d:f5:00:ad:ba:
+ 6c:fd:5d:02:32:4f:94:3f:4e:10:4a:a6:15:c2:77:e6:be:a0:
+ ea:15:e3:49:40:e8:f0:7d:e0:fe:33:f2:6b:36:a6:a6:70:52:
+ 21:d2:ff:ee:ce:2d:46:50:dd:c2:19:4d:9a:1a:f1:a8:e8:45:
+ 41:2d:6e:29:d3:c8:59:69:dd:1b:5c:21:21:31:b6:be:98:64:
+ 31:a2:3e:a6:36:9c:27:8f:86:bb:0e:aa:67:f1:0b:e1:ea:d6:
+ d6:50:72:6c:24:cd:85:8e:32:26:45:44:2e:7c:83:69:54:9b:
+ 8b:1b:94:71:ba:8e:49:77:dd:d1:d4:30:a6:56:80:95:5e:6b:
+ b8:11:bf:b0
+-----BEGIN CERTIFICATE-----
+MIIDXjCCAkagAwIBAgIBCjANBgkqhkiG9w0BAQUFADCBqzEmMCQGA1UEAxMdV2Vz
+dHBvaW50IENlcnRpZmljYXRlIFRlc3QgQ0ExEzARBgNVBAgTCkxhbmNhc2hpcmUx
+CzAJBgNVBAYTAlVLMR0wGwYJKoZIhvcNAQkBFg5jYUBleGFtcGxlLmNvbTFAMD4G
+A1UEChM3V2VzdHBvaW50IENlcnRpZmljYXRlIFRlc3QgUm9vdCBDZXJ0aWZpY2F0
+aW9uIEF1dGhvcml0eTAeFw0xMTA2MjEyMTMyMTlaFw0yMTA2MTgyMTMyMTlaMHMx
+GDAWBgNVBAMTD3d3dy5leGFtcGxlLmNvbTEZMBcGA1UEAxMQd3d3Mi5leGFtcGxl
+LmNvbTETMBEGA1UECBMKTGFuY2FzaGlyZTELMAkGA1UEBhMCVUsxGjAYBgNVBAoT
+EVNvbWUgb3JnYW5pc2F0aW9uMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4
+s3ITzRcsAXgWYl1ycTMUQb4MF6yF2/ge6FWYPntGpQin2w7ceNi3HuB4MG654kMu
+8n2Y+7SoXmNC6FwmeSBe9g4dEqzFDqS2aHlfPVLORPkgyY6z+yBC1ZefpEGPuLGN
+wxRhcLjR9/9ImcGg3XHLi5HmYCker6kAkdLDr3/N+QIDAQABo0gwRjAJBgNVHRME
+AjAAMDkGCCsGAQUFBwEBBC0wKzApBggrBgEFBQcwAYYdaHR0cDovL29jc3AuZXhh
+bXBsZS5jb206ODg4OC8wDQYJKoZIhvcNAQEFBQADggEBAEzIvA6ES7uewXuBTWVg
+5dGGagDy+/9toSOhiMeFSrI9JM+SyKtgELgX+tJPYM2UQCq3bkrp+SvmVHB/83H4
+/EXfz0P0JtZzabP/2drcEgXiUmIv1LAK46Ho8sGAt0SOOkbKG22CwBbC9k9WiSSG
+Qo75XmORfYj/xL0N9QCtumz9XQIyT5Q/ThBKphXCd+a+oOoV40lA6PB94P4z8ms2
+pqZwUiHS/+7OLUZQ3cIZTZoa8ajoRUEtbinTyFlp3RtcISExtr6YZDGiPqY2nCeP
+hrsOqmfxC+Hq1tZQcmwkzYWOMiZFRC58g2lUm4sblHG6jkl33dHUMKZWgJVea7gR
+v7A=
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
index 6e29072d8f..e95af1e97c 100644
--- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
@@ -114,6 +114,7 @@ private slots:
void largeExpirationDate();
void blacklistedCertificates();
void toText();
+ void multipleCommonNames();
// ### add tests for certificate bundles (multiple certificates concatenated into a single
// structure); both PEM and DER formatted
@@ -195,8 +196,8 @@ void tst_QSslCertificate::emptyConstructor()
QCOMPARE(certificate.version() , QByteArray());
QCOMPARE(certificate.serialNumber(), QByteArray());
QCOMPARE(certificate.digest(), QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5));
- QCOMPARE(certificate.issuerInfo(QSslCertificate::Organization), QString());
- QCOMPARE(certificate.subjectInfo(QSslCertificate::Organization), QString());
+ QCOMPARE(certificate.issuerInfo(QSslCertificate::Organization), QStringList());
+ QCOMPARE(certificate.subjectInfo(QSslCertificate::Organization), QStringList());
QCOMPARE(certificate.alternateSubjectNames(),(QMultiMap<QSsl::AlternateNameEntryType, QString>()));
#ifndef QT_NO_TEXTSTREAM
QCOMPARE(certificate.effectiveDate(), QDateTime());
@@ -423,11 +424,11 @@ void tst_QSslCertificate::utf8SubjectNames()
static const char *ou = "\xe3\x88\xa7" "A" "\xe3\x89\x81\xef\xbd\xab" "BC";
// the following two tests should help find "\x"-literal encoding bugs in the test itself
- QCOMPARE(cert.subjectInfo("O").length(), QString::fromUtf8(o).length());
- QCOMPARE (cert.subjectInfo("O").toUtf8().toHex(), QByteArray(o).toHex());
+ QCOMPARE(cert.subjectInfo("O")[0].length(), QString::fromUtf8(o).length());
+ QCOMPARE (cert.subjectInfo("O")[0].toUtf8().toHex(), QByteArray(o).toHex());
- QCOMPARE(cert.subjectInfo("O"), QString::fromUtf8(o));
- QCOMPARE(cert.subjectInfo("OU"), QString::fromUtf8(ou));
+ QCOMPARE(cert.subjectInfo("O")[0], QString::fromUtf8(o));
+ QCOMPARE(cert.subjectInfo("OU")[0], QString::fromUtf8(ou));
}
void tst_QSslCertificate::publicKey_data()
@@ -680,33 +681,33 @@ void tst_QSslCertificate::certInfo()
QRegExp::FixedString).first();
QVERIFY(!cert.isNull());
- QCOMPARE(cert.issuerInfo(QSslCertificate::Organization), QString("CryptSoft Pty Ltd"));
- QCOMPARE(cert.issuerInfo(QSslCertificate::CommonName), QString("Test CA (1024 bit)"));
- QCOMPARE(cert.issuerInfo(QSslCertificate::LocalityName), QString());
- QCOMPARE(cert.issuerInfo(QSslCertificate::OrganizationalUnitName), QString());
- QCOMPARE(cert.issuerInfo(QSslCertificate::CountryName), QString("AU"));
- QCOMPARE(cert.issuerInfo(QSslCertificate::StateOrProvinceName), QString("Queensland"));
-
- QCOMPARE(cert.issuerInfo("O"), QString("CryptSoft Pty Ltd"));
- QCOMPARE(cert.issuerInfo("CN"), QString("Test CA (1024 bit)"));
- QCOMPARE(cert.issuerInfo("L"), QString());
- QCOMPARE(cert.issuerInfo("OU"), QString());
- QCOMPARE(cert.issuerInfo("C"), QString("AU"));
- QCOMPARE(cert.issuerInfo("ST"), QString("Queensland"));
-
- QCOMPARE(cert.subjectInfo(QSslCertificate::Organization), QString());
- QCOMPARE(cert.subjectInfo(QSslCertificate::CommonName), QString("name/with/slashes"));
- QCOMPARE(cert.subjectInfo(QSslCertificate::LocalityName), QString());
- QCOMPARE(cert.subjectInfo(QSslCertificate::OrganizationalUnitName), QString());
- QCOMPARE(cert.subjectInfo(QSslCertificate::CountryName), QString("NO"));
- QCOMPARE(cert.subjectInfo(QSslCertificate::StateOrProvinceName), QString());
-
- QCOMPARE(cert.subjectInfo("O"), QString());
- QCOMPARE(cert.subjectInfo("CN"), QString("name/with/slashes"));
- QCOMPARE(cert.subjectInfo("L"), QString());
- QCOMPARE(cert.subjectInfo("OU"), QString());
- QCOMPARE(cert.subjectInfo("C"), QString("NO"));
- QCOMPARE(cert.subjectInfo("ST"), QString());
+ QCOMPARE(cert.issuerInfo(QSslCertificate::Organization)[0], QString("CryptSoft Pty Ltd"));
+ QCOMPARE(cert.issuerInfo(QSslCertificate::CommonName)[0], QString("Test CA (1024 bit)"));
+ QCOMPARE(cert.issuerInfo(QSslCertificate::LocalityName), QStringList());
+ QCOMPARE(cert.issuerInfo(QSslCertificate::OrganizationalUnitName), QStringList());
+ QCOMPARE(cert.issuerInfo(QSslCertificate::CountryName)[0], QString("AU"));
+ QCOMPARE(cert.issuerInfo(QSslCertificate::StateOrProvinceName)[0], QString("Queensland"));
+
+ QCOMPARE(cert.issuerInfo("O")[0], QString("CryptSoft Pty Ltd"));
+ QCOMPARE(cert.issuerInfo("CN")[0], QString("Test CA (1024 bit)"));
+ QCOMPARE(cert.issuerInfo("L"), QStringList());
+ QCOMPARE(cert.issuerInfo("OU"), QStringList());
+ QCOMPARE(cert.issuerInfo("C")[0], QString("AU"));
+ QCOMPARE(cert.issuerInfo("ST")[0], QString("Queensland"));
+
+ QCOMPARE(cert.subjectInfo(QSslCertificate::Organization), QStringList());
+ QCOMPARE(cert.subjectInfo(QSslCertificate::CommonName)[0], QString("name/with/slashes"));
+ QCOMPARE(cert.subjectInfo(QSslCertificate::LocalityName), QStringList());
+ QCOMPARE(cert.subjectInfo(QSslCertificate::OrganizationalUnitName), QStringList());
+ QCOMPARE(cert.subjectInfo(QSslCertificate::CountryName)[0], QString("NO"));
+ QCOMPARE(cert.subjectInfo(QSslCertificate::StateOrProvinceName), QStringList());
+
+ QCOMPARE(cert.subjectInfo("O"), QStringList());
+ QCOMPARE(cert.subjectInfo("CN")[0], QString("name/with/slashes"));
+ QCOMPARE(cert.subjectInfo("L"), QStringList());
+ QCOMPARE(cert.subjectInfo("OU"), QStringList());
+ QCOMPARE(cert.subjectInfo("C")[0], QString("NO"));
+ QCOMPARE(cert.subjectInfo("ST"), QStringList());
QCOMPARE(cert.version(), QByteArray::number(1));
QCOMPARE(cert.serialNumber(), QByteArray::number(17));
@@ -739,8 +740,8 @@ void tst_QSslCertificate::certInfoQByteArray()
// in this test, check the bytearray variants before the enum variants to see if
// we fixed a bug we had with lazy initialization of the values.
- QCOMPARE(cert.issuerInfo("CN"), QString("Test CA (1024 bit)"));
- QCOMPARE(cert.subjectInfo("CN"), QString("name/with/slashes"));
+ QCOMPARE(cert.issuerInfo("CN")[0], QString("Test CA (1024 bit)"));
+ QCOMPARE(cert.subjectInfo("CN")[0], QString("name/with/slashes"));
}
void tst_QSslCertificate::task256066toPem()
@@ -789,7 +790,7 @@ void tst_QSslCertificate::nulInCN()
const QSslCertificate &cert = certList.at(0);
QVERIFY(!cert.isNull());
- QString cn = cert.subjectInfo(QSslCertificate::CommonName);
+ QString cn = cert.subjectInfo(QSslCertificate::CommonName)[0];
QVERIFY(cn != "www.bank.com");
static const char realCN[] = "www.bank.com\0.badguy.com";
@@ -871,6 +872,17 @@ void tst_QSslCertificate::toText()
QVERIFY(txtOld == cert.toText() || txtNew == cert.toText());
}
+void tst_QSslCertificate::multipleCommonNames()
+{
+ QList<QSslCertificate> certList =
+ QSslCertificate::fromPath(SRCDIR "more-certificates/test-cn-two-cns-cert.pem");
+ QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
+
+ QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName);
+ QVERIFY(commonNames.contains(QString("www.example.com")));
+ QVERIFY(commonNames.contains(QString("www2.example.com")));
+}
+
#endif // QT_NO_OPENSSL
QTEST_MAIN(tst_QSslCertificate)
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 999cad55ba..5070d4b043 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -1992,9 +1992,9 @@ void tst_QSslSocket::writeBigChunk()
qWarning() << socket->error() << socket->errorString();
QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
}
- // also check the error string. If another error (than UnknownError) occured, it should be different than before
+ // also check the error string. If another error (than UnknownError) occurred, it should be different than before
QVERIFY(errorBefore == errorAfter);
-
+
// check that everything has been written to OpenSSL
QVERIFY(socket->bytesToWrite() == 0);
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 547fdaf04b..4608019218 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -96,6 +96,9 @@ private slots:
void drawUnderlinedText();
void unprintableCharacter_qtbug12614();
+
+ void underlinedColor_qtbug20159();
+ void textDocumentColor();
};
void tst_QStaticText::init()
@@ -783,5 +786,42 @@ void tst_QStaticText::unprintableCharacter_qtbug12614()
QVERIFY(staticText.size().isValid()); // Force layout. Should not crash.
}
+void tst_QStaticText::underlinedColor_qtbug20159()
+{
+ QString multiScriptText;
+ multiScriptText += QChar(0x0410); // Cyrillic 'A'
+ multiScriptText += QLatin1Char('A');
+
+ QStaticText staticText(multiScriptText);
+
+ QFont font;
+ font.setUnderline(true);
+
+ staticText.prepare(QTransform(), font);
+
+ QStaticTextPrivate *d = QStaticTextPrivate::get(&staticText);
+ QCOMPARE(d->itemCount, 2);
+
+ // The pen should not be marked as dirty when drawing the underline
+ QVERIFY(!d->items[0].color.isValid());
+ QVERIFY(!d->items[1].color.isValid());
+}
+
+void tst_QStaticText::textDocumentColor()
+{
+ QStaticText staticText("A<font color=\"red\">B</font>");
+ staticText.setTextFormat(Qt::RichText);
+ staticText.prepare();
+
+ QStaticTextPrivate *d = QStaticTextPrivate::get(&staticText);
+ QCOMPARE(d->itemCount, 2);
+
+ // The pen should not be marked as dirty when drawing the underline
+ QVERIFY(!d->items[0].color.isValid());
+ QVERIFY(d->items[1].color.isValid());
+
+ QCOMPARE(d->items[1].color, QColor(Qt::red));
+}
+
QTEST_MAIN(tst_QStaticText)
#include "tst_qstatictext.moc"
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index 2327ef55f9..de7ad656e4 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -133,6 +133,12 @@ void runScenario()
QCOMPARE(r, string);
r = string P ba;
QCOMPARE(r, string);
+
+ const char *zero = 0;
+ r = string P zero;
+ QCOMPARE(r, string);
+ r = zero P string;
+ QCOMPARE(r, string);
#endif
string = QString::fromLatin1(LITERAL);
@@ -161,6 +167,12 @@ void runScenario()
QCOMPARE(r, r2);
r2 = QByteArray("hello\0") P UTF8_LITERAL;
QCOMPARE(r, r2);
+
+ const char *zero = 0;
+ r = ba P zero;
+ QCOMPARE(r, ba);
+ r = zero P ba;
+ QCOMPARE(r, ba);
}
//operator QString +=
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp
index beeb6c7655..b566e5cebd 100644
--- a/tests/auto/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp
@@ -281,9 +281,6 @@ void tst_QTcpServer::dualStack_data()
void tst_QTcpServer::dualStack()
{
-#ifdef QT_NO_IPV6
- QSKIP("test requires IPv6 support", SkipAll);
-#else
QFETCH_GLOBAL(bool, setProxy);
if (setProxy)
QSKIP("test server proxy doesn't support ipv6", SkipSingle);
@@ -302,7 +299,6 @@ void tst_QTcpServer::dualStack()
QCOMPARE(v4client.waitForConnected(5000), v4ok);
QCOMPARE(v6client.waitForConnected(5000), v6ok);
-#endif
}
//----------------------------------------------------------------------------------
diff --git a/tests/auto/qtextformat/tst_qtextformat.cpp b/tests/auto/qtextformat/tst_qtextformat.cpp
index d70df6bf56..b235b112b6 100644
--- a/tests/auto/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/qtextformat/tst_qtextformat.cpp
@@ -226,7 +226,7 @@ void tst_QTextFormat::resolveFont()
QVERIFY(fmt.font().underline());
QVERIFY(!fmt.hasProperty(QTextFormat::FontUnderline));
- // verify that deleting a non-existant property does not affect the font resolving
+ // verify that deleting a non-existent property does not affect the font resolving
QVERIFY(!fmt.hasProperty(QTextFormat::BackgroundBrush));
fmt.clearProperty(QTextFormat::BackgroundBrush);
@@ -235,7 +235,7 @@ void tst_QTextFormat::resolveFont()
QVERIFY(!fmt.hasProperty(QTextFormat::FontUnderline));
QVERIFY(fmt.font().underline());
- // verify that deleting an existant but font _unrelated_ property does not affect the font resolving
+ // verify that deleting an existent but font _unrelated_ property does not affect the font resolving
QVERIFY(fmt.hasProperty(QTextFormat::ForegroundBrush));
fmt.clearProperty(QTextFormat::ForegroundBrush);
diff --git a/tests/auto/qtipc/qsharedmemory/src/qsystemlock.cpp b/tests/auto/qtipc/qsharedmemory/src/qsystemlock.cpp
index f50bcd2e13..b48bd7bebe 100644
--- a/tests/auto/qtipc/qsharedmemory/src/qsystemlock.cpp
+++ b/tests/auto/qtipc/qsharedmemory/src/qsystemlock.cpp
@@ -124,7 +124,7 @@
systemLock.unlock();
}
- If this is called from two seperate processes the resulting log file is
+ If this is called from two separate processes the resulting log file is
guaranteed to contain both lines.
When you call lock(), other threads or processes that try to call lock()
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index 03e224682f..ad7bfbb116 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -380,9 +380,6 @@ void tst_QUdpSocket::ipv6Loop_data()
void tst_QUdpSocket::ipv6Loop()
{
-#if defined(QT_NO_IPV6)
- QSKIP("IPv6 is not yet supported", SkipAll);
-#endif
QFETCH(QByteArray, peterMessage);
QFETCH(QByteArray, paulMessage);
QFETCH(bool, success);
@@ -760,7 +757,7 @@ void tst_QUdpSocket::bindMode()
// Depending on the user's privileges, this or will succeed or
// fail. Admins are allowed to reuse the address, but nobody else.
if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData())
- qWarning("Failed to bind with QUdpSocket::ReuseAddressHint, user isn't an adminstrator?");
+ qWarning("Failed to bind with QUdpSocket::ReuseAddressHint, user isn't an administrator?");
socket.close();
QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());
QVERIFY(!socket2.bind(socket.localPort()));
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 4aa7185c17..d7f7742d46 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -201,6 +201,8 @@ private slots:
void task_240612();
void taskQTBUG_6962();
void taskQTBUG_8701();
+ void removeAllEncodedQueryItems_data();
+ void removeAllEncodedQueryItems();
};
// Testing get/set functions
@@ -4020,5 +4022,28 @@ void tst_QUrl::effectiveTLDs()
QCOMPARE(domain.topLevelDomain(), TLD);
}
+void tst_QUrl::removeAllEncodedQueryItems_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QByteArray>("key");
+ QTest::addColumn<QUrl>("result");
+
+ QTest::newRow("test1") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("bbb") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&ccc=c");
+ QTest::newRow("test2") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("aaa") << QUrl::fromEncoded("http://qt.nokia.com/foo?bbb=b&ccc=c");
+// QTest::newRow("test3") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("ccc") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b");
+ QTest::newRow("test4") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("b%62b") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c");
+ QTest::newRow("test5") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&b%62b=b&ccc=c") << QByteArray("b%62b") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&ccc=c");
+ QTest::newRow("test6") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&b%62b=b&ccc=c") << QByteArray("bbb") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&b%62b=b&ccc=c");
+}
+
+void tst_QUrl::removeAllEncodedQueryItems()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QByteArray, key);
+ QFETCH(QUrl, result);
+ url.removeAllEncodedQueryItems(key);
+ QCOMPARE(url, result);
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"