summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit983a4b61f1da719dac647a7190533d1edf2b2159 (patch)
tree3b52101d36c2b432540c20e0e188f62197c42c59 /examples
downloadqtsvg-983a4b61f1da719dac647a7190533d1edf2b2159.tar.gz
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'examples')
-rw-r--r--examples/desktop/desktop.pro2
-rw-r--r--examples/desktop/systray/images/bad.svg64
-rw-r--r--examples/desktop/systray/images/heart.svg55
-rw-r--r--examples/desktop/systray/images/trash.svg58
-rw-r--r--examples/desktop/systray/main.cpp62
-rw-r--r--examples/desktop/systray/systray.pro24
-rw-r--r--examples/desktop/systray/systray.qrc7
-rw-r--r--examples/desktop/systray/window.cpp258
-rw-r--r--examples/desktop/systray/window.h112
-rw-r--r--examples/draganddrop/delayedencoding/delayedencoding.pro16
-rw-r--r--examples/draganddrop/delayedencoding/delayedencoding.qrc6
-rw-r--r--examples/draganddrop/delayedencoding/images/drag.pngbin0 -> 977 bytes
-rw-r--r--examples/draganddrop/delayedencoding/images/example.svg58
-rw-r--r--examples/draganddrop/delayedencoding/main.cpp51
-rw-r--r--examples/draganddrop/delayedencoding/mimedata.cpp65
-rw-r--r--examples/draganddrop/delayedencoding/mimedata.h63
-rw-r--r--examples/draganddrop/delayedencoding/sourcewidget.cpp114
-rw-r--r--examples/draganddrop/delayedencoding/sourcewidget.h70
-rw-r--r--examples/draganddrop/draganddrop.pro2
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/network/bearercloud/bearercloud.cpp196
-rw-r--r--examples/network/bearercloud/bearercloud.h80
-rw-r--r--examples/network/bearercloud/bearercloud.pro16
-rw-r--r--examples/network/bearercloud/bluetooth.svg24
-rw-r--r--examples/network/bearercloud/cell.svg25
-rw-r--r--examples/network/bearercloud/cloud.cpp386
-rw-r--r--examples/network/bearercloud/cloud.h98
-rw-r--r--examples/network/bearercloud/gprs.svg199
-rw-r--r--examples/network/bearercloud/icons.qrc11
-rwxr-xr-xexamples/network/bearercloud/lan.svg33
-rw-r--r--examples/network/bearercloud/main.cpp88
-rw-r--r--examples/network/bearercloud/umts.svg200
-rw-r--r--examples/network/bearercloud/unknown.svg76
-rw-r--r--examples/network/bearercloud/wlan.svg151
-rw-r--r--examples/network/network.pro2
-rw-r--r--examples/opengl/framebufferobject/bubbles.svg215
-rw-r--r--examples/opengl/framebufferobject/designer.pngbin0 -> 2810 bytes
-rw-r--r--examples/opengl/framebufferobject/framebufferobject.pro24
-rw-r--r--examples/opengl/framebufferobject/framebufferobject.qrc6
-rw-r--r--examples/opengl/framebufferobject/glwidget.cpp329
-rw-r--r--examples/opengl/framebufferobject/glwidget.h82
-rw-r--r--examples/opengl/framebufferobject/main.cpp61
-rw-r--r--examples/opengl/opengl.pro2
-rw-r--r--examples/painting/painting.pro2
-rw-r--r--examples/painting/svggenerator/displaywidget.cpp148
-rw-r--r--examples/painting/svggenerator/displaywidget.h79
-rw-r--r--examples/painting/svggenerator/forms/window.ui249
-rw-r--r--examples/painting/svggenerator/main.cpp51
-rw-r--r--examples/painting/svggenerator/resources/shapes.datbin0 -> 2088 bytes
-rw-r--r--examples/painting/svggenerator/svggenerator.pro22
-rw-r--r--examples/painting/svggenerator/svggenerator.qrc5
-rw-r--r--examples/painting/svggenerator/window.cpp100
-rw-r--r--examples/painting/svggenerator/window.h65
-rw-r--r--examples/painting/svgviewer/files/bubbles.svg215
-rw-r--r--examples/painting/svgviewer/files/cubic.svg77
-rw-r--r--examples/painting/svgviewer/files/spheres.svg72
-rw-r--r--examples/painting/svgviewer/main.cpp62
-rw-r--r--examples/painting/svgviewer/mainwindow.cpp163
-rw-r--r--examples/painting/svgviewer/mainwindow.h80
-rw-r--r--examples/painting/svgviewer/svgview.cpp188
-rw-r--r--examples/painting/svgviewer/svgview.h83
-rw-r--r--examples/painting/svgviewer/svgviewer.pro31
-rw-r--r--examples/painting/svgviewer/svgviewer.qrc6
-rw-r--r--examples/richtext/richtext.pro2
-rw-r--r--examples/richtext/textobject/files/heart.svg55
-rw-r--r--examples/richtext/textobject/main.cpp54
-rw-r--r--examples/richtext/textobject/svgtextobject.cpp71
-rw-r--r--examples/richtext/textobject/svgtextobject.h69
-rw-r--r--examples/richtext/textobject/textobject.pro18
-rw-r--r--examples/richtext/textobject/window.cpp116
-rw-r--r--examples/richtext/textobject/window.h80
71 files changed, 5556 insertions, 0 deletions
diff --git a/examples/desktop/desktop.pro b/examples/desktop/desktop.pro
new file mode 100644
index 0000000..6eab5e7
--- /dev/null
+++ b/examples/desktop/desktop.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += systray
diff --git a/examples/desktop/systray/images/bad.svg b/examples/desktop/systray/images/bad.svg
new file mode 100644
index 0000000..186dba9
--- /dev/null
+++ b/examples/desktop/systray/images/bad.svg
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg viewBox="-10 -10 178 178" height="177.523" id="svg1" inkscape:version="0.40" sodipodi:docbase="/mnt/donnees/09-Mes_images/Travaux/Travaux vectoriel/pictogrammes/sécu SVG/produits chimiques" sodipodi:docname="XiIrritant.svg" sodipodi:version="0.32" width="155.932" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
+<metadata>
+<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<cc:Work rdf:about="">
+<dc:title>Irritant</dc:title>
+<dc:description>produit chimique</dc:description>
+<dc:subject>
+<rdf:Bag>
+<rdf:li></rdf:li>
+<rdf:li>symbol</rdf:li>
+<rdf:li>signs_and_symbols</rdf:li>
+</rdf:Bag>
+</dc:subject>
+<dc:publisher>
+<cc:Agent rdf:about="http://www.openclipart.org">
+<dc:title>yves GUILLOU</dc:title>
+</cc:Agent>
+</dc:publisher>
+<dc:creator>
+<cc:Agent>
+<dc:title>yves GUILLOU</dc:title>
+</cc:Agent>
+</dc:creator>
+<dc:rights>
+<cc:Agent>
+<dc:title>yves GUILLOU</dc:title>
+</cc:Agent>
+</dc:rights>
+<dc:date></dc:date>
+<dc:format>image/svg+xml</dc:format>
+<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
+<dc:language>en</dc:language>
+</cc:Work>
+<cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+</cc:License>
+</rdf:RDF>
+</metadata>
+<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="svg1" inkscape:cx="62.372805" inkscape:cy="34.864537" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="1121" inkscape:window-width="1590" inkscape:window-x="200" inkscape:window-y="0" inkscape:zoom="6.6399849" pagecolor="#ffffff"/>
+<defs id="defs2">
+<marker id="ArrowEnd" markerHeight="3" markerUnits="strokeWidth" markerWidth="4" orient="auto" refX="0" refY="5" viewBox="0 0 10 10">
+<path d="M 0 0 L 10 5 L 0 10 z" id="path4"/>
+</marker>
+<marker id="ArrowStart" markerHeight="3" markerUnits="strokeWidth" markerWidth="4" orient="auto" refX="10" refY="5" viewBox="0 0 10 10">
+<path d="M 10 0 L 0 5 L 10 10 z" id="path6"/>
+</marker>
+</defs>
+<g id="g7">
+<g id="g8">
+<path d="M 155.932 155.932L 155.932 0L 0 0L 0 155.932L 155.932 155.932z" id="path9" style="stroke:none; fill:#000000"/>
+<path d="M 150.83 150.83L 150.83 5.1011L 5.1011 5.1011L 5.1011 150.83L 150.83 150.83z" id="path10" style="stroke:none; fill:#ff9900"/>
+</g>
+<g id="g11">
+<path d="M 140.823 111.783L 44.3677 14.0771L 15.1084 44.1489L 111.564 141.854L 140.823 111.783z" id="path12" style="stroke:none; fill:#000000"/>
+<path d="M 111.783 15.1084L 14.0771 111.564L 44.1489 140.823L 141.855 44.3677L 111.783 15.1084z" id="path13" style="stroke:none; fill:#000000"/>
+</g>
+</g>
+</svg>
diff --git a/examples/desktop/systray/images/heart.svg b/examples/desktop/systray/images/heart.svg
new file mode 100644
index 0000000..ba5f050
--- /dev/null
+++ b/examples/desktop/systray/images/heart.svg
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) --><svg viewBox="100 200 550 500" height="595.27559pt" id="svg1" inkscape:version="0.40+cvs" sodipodi:docbase="C:\Documents and Settings\Jon Phillips\My Documents\projects\clipart-project\submissions" sodipodi:docname="heart-left-highlight.svg" sodipodi:version="0.32" width="595.27559pt" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
+<metadata>
+<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<cc:Work rdf:about="">
+<dc:title>Heart Left-Highlight</dc:title>
+<dc:description>This is a normal valentines day heart.</dc:description>
+<dc:subject>
+<rdf:Bag>
+<rdf:li>holiday</rdf:li>
+<rdf:li>valentines</rdf:li>
+<rdf:li></rdf:li>
+<rdf:li>valentine</rdf:li>
+<rdf:li>hash(0x8a091c0)</rdf:li>
+<rdf:li>hash(0x8a0916c)</rdf:li>
+<rdf:li>signs_and_symbols</rdf:li>
+<rdf:li>hash(0x8a091f0)</rdf:li>
+<rdf:li>day</rdf:li>
+</rdf:Bag>
+</dc:subject>
+<dc:publisher>
+<cc:Agent rdf:about="http://www.openclipart.org">
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:publisher>
+<dc:creator>
+<cc:Agent>
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:creator>
+<dc:rights>
+<cc:Agent>
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:rights>
+<dc:date></dc:date>
+<dc:format>image/svg+xml</dc:format>
+<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
+<dc:language>en</dc:language>
+</cc:Work>
+<cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+</cc:License>
+</rdf:RDF>
+</metadata>
+<defs id="defs3"/>
+<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="layer1" inkscape:cx="549.40674" inkscape:cy="596.00159" inkscape:document-units="px" inkscape:guide-bbox="true" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="615" inkscape:window-width="866" inkscape:window-x="88" inkscape:window-y="116" inkscape:zoom="0.35000000" pagecolor="#ffffff" showguides="true"/>
+<g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1">
+<path d="M 263.41570,235.14588 C 197.17570,235.14588 143.41575,288.90587 143.41575,355.14588 C 143.41575,489.90139 279.34890,525.23318 371.97820,658.45392 C 459.55244,526.05056 600.54070,485.59932 600.54070,355.14588 C 600.54070,288.90588 546.78080,235.14587 480.54070,235.14588 C 432.49280,235.14588 391.13910,263.51631 371.97820,304.33338 C 352.81740,263.51630 311.46370,235.14587 263.41570,235.14588 z " id="path7" sodipodi:nodetypes="ccccccc" style="fill:#e60000;fill-opacity:1.0000000;stroke:#000000;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
+<path d="M 265.00000,253.59375 C 207.04033,253.59375 160.00000,300.63407 160.00000,358.59375 C 160.00000,476.50415 278.91857,507.43251 359.96875,624.00000 C 366.52868,614.08205 220.00000,478.47309 220.00000,378.59375 C 220.00000,320.63407 267.04033,273.59375 325.00000,273.59375 C 325.50453,273.59375 325.99718,273.64912 326.50000,273.65625 C 309.22436,261.07286 288.00557,253.59374 265.00000,253.59375 z " id="path220" sodipodi:nodetypes="ccccccc" style="fill:#e6e6e6;fill-opacity:0.64556962;stroke:none;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
+</g>
+</svg>
diff --git a/examples/desktop/systray/images/trash.svg b/examples/desktop/systray/images/trash.svg
new file mode 100644
index 0000000..c44e4c7
--- /dev/null
+++ b/examples/desktop/systray/images/trash.svg
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 10, SVG Export Plug-In . SVG Version: 3.0.0 Build 76) --><svg enable-background="new 0 0 347 348" height="348" i:pageBounds="0 792 612 0" i:rulerOrigin="0 0" i:viewOrigin="131 567" overflow="visible" space="preserve" viewBox="-20 -20 387 388" width="347" xmlns="http://www.w3.org/2000/svg" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" xmlns:graph="http://ns.adobe.com/Graphs/1.0/" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:x="http://ns.adobe.com/Extensibility/1.0/" xmlns:xlink="http://www.w3.org/1999/xlink">
+<metadata>
+<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<cc:Work rdf:about="">
+<dc:title>Keep Tidy Inside</dc:title>
+<dc:description></dc:description>
+<dc:subject>
+<rdf:Bag>
+<rdf:li></rdf:li>
+<rdf:li>symbol</rdf:li>
+<rdf:li>bin</rdf:li>
+<rdf:li>signs_and_symbols</rdf:li>
+<rdf:li>clean</rdf:li>
+<rdf:li>rubish</rdf:li>
+<rdf:li>trash</rdf:li>
+<rdf:li>inside</rdf:li>
+<rdf:li>garbage</rdf:li>
+<rdf:li>sign</rdf:li>
+</rdf:Bag>
+</dc:subject>
+<dc:publisher>
+<cc:Agent rdf:about="http://www.openclipart.org">
+<dc:title>Martin Owens</dc:title>
+</cc:Agent>
+</dc:publisher>
+<dc:creator>
+<cc:Agent>
+<dc:title>Martin Owens</dc:title>
+</cc:Agent>
+</dc:creator>
+<dc:rights>
+<cc:Agent>
+<dc:title>Martin Owens</dc:title>
+</cc:Agent>
+</dc:rights>
+<dc:date></dc:date>
+<dc:format>image/svg+xml</dc:format>
+<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
+<dc:language>en</dc:language>
+</cc:Work>
+<cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+</cc:License>
+</rdf:RDF>
+</metadata>
+<g i:dimmedPercent="50" i:knockout="Off" i:layer="yes" i:rgbTrio="#4F008000FFFF" id="Layer_1">
+<path d="M347,174c0,96.098-77.679,174-173.5,174C77.679,348,0,270.098,0,174 C0,77.902,77.679,0,173.5,0C269.321,0,347,77.902,347,174z" fill="#10A040" i:knockout="Off"/>
+<path d="M238,53c0,13.807-11.864,25-26.5,25S185,66.807,185,53s11.864-25,26.5-25 S238,39.193,238,53z" fill="#FFFFFF" i:knockout="Off"/>
+<path d="M66,175c1.055,6.355,19.333,126.417,19.333,126.417h68.333 c0,0,14.105-122.524,14.333-126.417c6.224-0.622,6.667-13-2-13c-12.164,0-89.205-0.059-98,0S61.167,174.487,66,175z" fill="#FFFFFF" i:knockout="Off"/>
+<path d="M78,141c17.292-5.325,24.179-23.532,27-31c14.513,6.596,40.333,12.265,59,8 c3.683,19.419-28.043,19.31-23,37C132.577,145.705,89.404,167.292,78,141z" fill="#FFFFFF" i:knockout="Off"/>
+<path d="M103,82l139-1c-0.6,3.421,33.633,57.497,29,67c-4.089,0.418-67,5-67,5 c6.109-9.379-13-43-13-43L103,82z" fill="#FFFFFF" i:knockout="Off"/>
+<path d="M270,156l-66-3c0,0-23.565,143.355-24,145s1.855,2.536,3,1s51-82,51-82 s19.754,80.701,20,82s3.721,1.209,4,0S270,156,270,156z" fill="#FFFFFF" i:knockout="Off"/>
+</g>
+</svg>
diff --git a/examples/desktop/systray/main.cpp b/examples/desktop/systray/main.cpp
new file mode 100644
index 0000000..6c84e58
--- /dev/null
+++ b/examples/desktop/systray/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(systray);
+
+ QApplication app(argc, argv);
+
+ if (!QSystemTrayIcon::isSystemTrayAvailable()) {
+ QMessageBox::critical(0, QObject::tr("Systray"),
+ QObject::tr("I couldn't detect any system tray "
+ "on this system."));
+ return 1;
+ }
+ QApplication::setQuitOnLastWindowClosed(false);
+
+ Window window;
+ window.show();
+ return app.exec();
+}
diff --git a/examples/desktop/systray/systray.pro b/examples/desktop/systray/systray.pro
new file mode 100644
index 0000000..3be05da
--- /dev/null
+++ b/examples/desktop/systray/systray.pro
@@ -0,0 +1,24 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
+RESOURCES = systray.qrc
+QT += xml svg
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/desktop/systray
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS systray.pro resources images
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/desktop/systray
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+
+wince* {
+ CONFIG(debug, release|debug) {
+ addPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/qsvgd4.dll
+ }
+ CONFIG(release, release|debug) {
+ addPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/qsvg4.dll
+ }
+ addPlugins.path = imageformats
+ DEPLOYMENT += addPlugins
+}
diff --git a/examples/desktop/systray/systray.qrc b/examples/desktop/systray/systray.qrc
new file mode 100644
index 0000000..b0d5e0c
--- /dev/null
+++ b/examples/desktop/systray/systray.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>images/bad.svg</file>
+ <file>images/heart.svg</file>
+ <file>images/trash.svg</file>
+</qresource>
+</RCC>
diff --git a/examples/desktop/systray/window.cpp b/examples/desktop/systray/window.cpp
new file mode 100644
index 0000000..4091358
--- /dev/null
+++ b/examples/desktop/systray/window.cpp
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+//! [0]
+Window::Window()
+{
+ createIconGroupBox();
+ createMessageGroupBox();
+
+ iconLabel->setMinimumWidth(durationLabel->sizeHint().width());
+
+ createActions();
+ createTrayIcon();
+
+ connect(showMessageButton, SIGNAL(clicked()), this, SLOT(showMessage()));
+ connect(showIconCheckBox, SIGNAL(toggled(bool)),
+ trayIcon, SLOT(setVisible(bool)));
+ connect(iconComboBox, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(setIcon(int)));
+ connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
+ connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+ this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(iconGroupBox);
+ mainLayout->addWidget(messageGroupBox);
+ setLayout(mainLayout);
+
+ iconComboBox->setCurrentIndex(1);
+ trayIcon->show();
+
+ setWindowTitle(tr("Systray"));
+ resize(400, 300);
+}
+//! [0]
+
+//! [1]
+void Window::setVisible(bool visible)
+{
+ minimizeAction->setEnabled(visible);
+ maximizeAction->setEnabled(!isMaximized());
+ restoreAction->setEnabled(isMaximized() || !visible);
+ QDialog::setVisible(visible);
+}
+//! [1]
+
+//! [2]
+void Window::closeEvent(QCloseEvent *event)
+{
+ if (trayIcon->isVisible()) {
+ QMessageBox::information(this, tr("Systray"),
+ tr("The program will keep running in the "
+ "system tray. To terminate the program, "
+ "choose <b>Quit</b> in the context menu "
+ "of the system tray entry."));
+ hide();
+ event->ignore();
+ }
+}
+//! [2]
+
+//! [3]
+void Window::setIcon(int index)
+{
+ QIcon icon = iconComboBox->itemIcon(index);
+ trayIcon->setIcon(icon);
+ setWindowIcon(icon);
+
+ trayIcon->setToolTip(iconComboBox->itemText(index));
+}
+//! [3]
+
+//! [4]
+void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
+{
+ switch (reason) {
+ case QSystemTrayIcon::Trigger:
+ case QSystemTrayIcon::DoubleClick:
+ iconComboBox->setCurrentIndex((iconComboBox->currentIndex() + 1)
+ % iconComboBox->count());
+ break;
+ case QSystemTrayIcon::MiddleClick:
+ showMessage();
+ break;
+ default:
+ ;
+ }
+}
+//! [4]
+
+//! [5]
+void Window::showMessage()
+{
+ QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(
+ typeComboBox->itemData(typeComboBox->currentIndex()).toInt());
+ trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon,
+ durationSpinBox->value() * 1000);
+}
+//! [5]
+
+//! [6]
+void Window::messageClicked()
+{
+ QMessageBox::information(0, tr("Systray"),
+ tr("Sorry, I already gave what help I could.\n"
+ "Maybe you should try asking a human?"));
+}
+//! [6]
+
+void Window::createIconGroupBox()
+{
+ iconGroupBox = new QGroupBox(tr("Tray Icon"));
+
+ iconLabel = new QLabel("Icon:");
+
+ iconComboBox = new QComboBox;
+ iconComboBox->addItem(QIcon(":/images/bad.svg"), tr("Bad"));
+ iconComboBox->addItem(QIcon(":/images/heart.svg"), tr("Heart"));
+ iconComboBox->addItem(QIcon(":/images/trash.svg"), tr("Trash"));
+
+ showIconCheckBox = new QCheckBox(tr("Show icon"));
+ showIconCheckBox->setChecked(true);
+
+ QHBoxLayout *iconLayout = new QHBoxLayout;
+ iconLayout->addWidget(iconLabel);
+ iconLayout->addWidget(iconComboBox);
+ iconLayout->addStretch();
+ iconLayout->addWidget(showIconCheckBox);
+ iconGroupBox->setLayout(iconLayout);
+}
+
+void Window::createMessageGroupBox()
+{
+ messageGroupBox = new QGroupBox(tr("Balloon Message"));
+
+ typeLabel = new QLabel(tr("Type:"));
+
+ typeComboBox = new QComboBox;
+ typeComboBox->addItem(tr("None"), QSystemTrayIcon::NoIcon);
+ typeComboBox->addItem(style()->standardIcon(
+ QStyle::SP_MessageBoxInformation), tr("Information"),
+ QSystemTrayIcon::Information);
+ typeComboBox->addItem(style()->standardIcon(
+ QStyle::SP_MessageBoxWarning), tr("Warning"),
+ QSystemTrayIcon::Warning);
+ typeComboBox->addItem(style()->standardIcon(
+ QStyle::SP_MessageBoxCritical), tr("Critical"),
+ QSystemTrayIcon::Critical);
+ typeComboBox->setCurrentIndex(1);
+
+ durationLabel = new QLabel(tr("Duration:"));
+
+ durationSpinBox = new QSpinBox;
+ durationSpinBox->setRange(5, 60);
+ durationSpinBox->setSuffix(" s");
+ durationSpinBox->setValue(15);
+
+ durationWarningLabel = new QLabel(tr("(some systems might ignore this "
+ "hint)"));
+ durationWarningLabel->setIndent(10);
+
+ titleLabel = new QLabel(tr("Title:"));
+
+ titleEdit = new QLineEdit(tr("Cannot connect to network"));
+
+ bodyLabel = new QLabel(tr("Body:"));
+
+ bodyEdit = new QTextEdit;
+ bodyEdit->setPlainText(tr("Don't believe me. Honestly, I don't have a "
+ "clue.\nClick this balloon for details."));
+
+ showMessageButton = new QPushButton(tr("Show Message"));
+ showMessageButton->setDefault(true);
+
+ QGridLayout *messageLayout = new QGridLayout;
+ messageLayout->addWidget(typeLabel, 0, 0);
+ messageLayout->addWidget(typeComboBox, 0, 1, 1, 2);
+ messageLayout->addWidget(durationLabel, 1, 0);
+ messageLayout->addWidget(durationSpinBox, 1, 1);
+ messageLayout->addWidget(durationWarningLabel, 1, 2, 1, 3);
+ messageLayout->addWidget(titleLabel, 2, 0);
+ messageLayout->addWidget(titleEdit, 2, 1, 1, 4);
+ messageLayout->addWidget(bodyLabel, 3, 0);
+ messageLayout->addWidget(bodyEdit, 3, 1, 2, 4);
+ messageLayout->addWidget(showMessageButton, 5, 4);
+ messageLayout->setColumnStretch(3, 1);
+ messageLayout->setRowStretch(4, 1);
+ messageGroupBox->setLayout(messageLayout);
+}
+
+void Window::createActions()
+{
+ minimizeAction = new QAction(tr("Mi&nimize"), this);
+ connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide()));
+
+ maximizeAction = new QAction(tr("Ma&ximize"), this);
+ connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
+
+ restoreAction = new QAction(tr("&Restore"), this);
+ connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
+
+ quitAction = new QAction(tr("&Quit"), this);
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+}
+
+void Window::createTrayIcon()
+{
+ trayIconMenu = new QMenu(this);
+ trayIconMenu->addAction(minimizeAction);
+ trayIconMenu->addAction(maximizeAction);
+ trayIconMenu->addAction(restoreAction);
+ trayIconMenu->addSeparator();
+ trayIconMenu->addAction(quitAction);
+
+ trayIcon = new QSystemTrayIcon(this);
+ trayIcon->setContextMenu(trayIconMenu);
+}
diff --git a/examples/desktop/systray/window.h b/examples/desktop/systray/window.h
new file mode 100644
index 0000000..537a8a2
--- /dev/null
+++ b/examples/desktop/systray/window.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QSystemTrayIcon>
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QCheckBox;
+class QComboBox;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QMenu;
+class QPushButton;
+class QSpinBox;
+class QTextEdit;
+QT_END_NAMESPACE
+
+//! [0]
+class Window : public QDialog
+{
+ Q_OBJECT
+
+public:
+ Window();
+
+ void setVisible(bool visible);
+
+protected:
+ void closeEvent(QCloseEvent *event);
+
+private slots:
+ void setIcon(int index);
+ void iconActivated(QSystemTrayIcon::ActivationReason reason);
+ void showMessage();
+ void messageClicked();
+
+private:
+ void createIconGroupBox();
+ void createMessageGroupBox();
+ void createActions();
+ void createTrayIcon();
+
+ QGroupBox *iconGroupBox;
+ QLabel *iconLabel;
+ QComboBox *iconComboBox;
+ QCheckBox *showIconCheckBox;
+
+ QGroupBox *messageGroupBox;
+ QLabel *typeLabel;
+ QLabel *durationLabel;
+ QLabel *durationWarningLabel;
+ QLabel *titleLabel;
+ QLabel *bodyLabel;
+ QComboBox *typeComboBox;
+ QSpinBox *durationSpinBox;
+ QLineEdit *titleEdit;
+ QTextEdit *bodyEdit;
+ QPushButton *showMessageButton;
+
+ QAction *minimizeAction;
+ QAction *maximizeAction;
+ QAction *restoreAction;
+ QAction *quitAction;
+
+ QSystemTrayIcon *trayIcon;
+ QMenu *trayIconMenu;
+};
+//! [0]
+
+#endif
diff --git a/examples/draganddrop/delayedencoding/delayedencoding.pro b/examples/draganddrop/delayedencoding/delayedencoding.pro
new file mode 100644
index 0000000..e3805a8
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/delayedencoding.pro
@@ -0,0 +1,16 @@
+QT += svg
+
+HEADERS = mimedata.h \
+ sourcewidget.h
+RESOURCES = delayedencoding.qrc
+SOURCES = main.cpp \
+ mimedata.cpp \
+ sourcewidget.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop/delayedencoding
+sources.files = $$SOURCES $$HEADERS *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/itemviews/delayedencoding
+INSTALLS += target sources
+
+symbian:TARGET.UID3 = 0xA000C614 \ No newline at end of file
diff --git a/examples/draganddrop/delayedencoding/delayedencoding.qrc b/examples/draganddrop/delayedencoding/delayedencoding.qrc
new file mode 100644
index 0000000..374f211
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/delayedencoding.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="">
+ <file>images/drag.png</file>
+ <file>images/example.svg</file>
+</qresource>
+</RCC>
diff --git a/examples/draganddrop/delayedencoding/images/drag.png b/examples/draganddrop/delayedencoding/images/drag.png
new file mode 100644
index 0000000..dd795cf
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/images/drag.png
Binary files differ
diff --git a/examples/draganddrop/delayedencoding/images/example.svg b/examples/draganddrop/delayedencoding/images/example.svg
new file mode 100644
index 0000000..e3505d7
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/images/example.svg
@@ -0,0 +1,58 @@
+<?xml version="1.0" standalone="no"?>
+<!-- ***********************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+************************************************************************ -->
+<svg width="8cm" height="8cm" viewBox="0 0 400 400"
+ xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" version="1.1">
+ <title>Sphere</title>
+ <desc>A gradient filled sphere.</desc>
+ <g>
+ <defs>
+ <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+ cx="200" cy="200" r="100" fx="150" fy="150">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="blue" />
+ <stop offset="100%" stop-color="black" />
+ </radialGradient>
+ </defs>
+ <rect fill="lightblue" x="0" y="0" width="400" height="400" />
+ <circle fill="url(#blueSphere)" stroke="black" stroke-width="2"
+ cx="200" cy="200" r="100"/>
+ </g>
+</svg>
diff --git a/examples/draganddrop/delayedencoding/main.cpp b/examples/draganddrop/delayedencoding/main.cpp
new file mode 100644
index 0000000..a8d8e53
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "sourcewidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ SourceWidget window;
+ window.show();
+ return app.exec();
+}
+
diff --git a/examples/draganddrop/delayedencoding/mimedata.cpp b/examples/draganddrop/delayedencoding/mimedata.cpp
new file mode 100644
index 0000000..34d08a3
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/mimedata.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "mimedata.h"
+
+MimeData::MimeData()
+ : QMimeData()
+{
+}
+
+//![0]
+QStringList MimeData::formats() const
+{
+ return QMimeData::formats() << "image/png";
+}
+//![0]
+
+//![1]
+QVariant MimeData::retrieveData(const QString &mimeType, QVariant::Type type)
+ const
+{
+ emit dataRequested(mimeType);
+
+ return QMimeData::retrieveData(mimeType, type);
+}
+//![1]
+
diff --git a/examples/draganddrop/delayedencoding/mimedata.h b/examples/draganddrop/delayedencoding/mimedata.h
new file mode 100644
index 0000000..0558f29
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/mimedata.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MIMEDATA_H
+#define MIMEDATA_H
+
+#include <QMimeData>
+
+//![0]
+class MimeData : public QMimeData
+{
+ Q_OBJECT
+
+public:
+ MimeData();
+ QStringList formats() const;
+
+signals:
+ void dataRequested(const QString &mimeType) const;
+
+protected:
+ QVariant retrieveData(const QString &mimetype, QVariant::Type type) const;
+};
+//![0]
+
+#endif
diff --git a/examples/draganddrop/delayedencoding/sourcewidget.cpp b/examples/draganddrop/delayedencoding/sourcewidget.cpp
new file mode 100644
index 0000000..9620502
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/sourcewidget.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtSvg>
+#include "mimedata.h"
+#include "sourcewidget.h"
+
+SourceWidget::SourceWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QFile imageFile(":/images/example.svg");
+ imageFile.open(QIODevice::ReadOnly);
+ imageData = imageFile.readAll();
+ imageFile.close();
+
+ QScrollArea *imageArea = new QScrollArea;
+ imageLabel = new QSvgWidget;
+ imageLabel->renderer()->load(imageData);
+ imageArea->setWidget(imageLabel);
+ //imageLabel->setMinimumSize(imageLabel->renderer()->viewBox().size());
+
+ QLabel *instructTopLabel = new QLabel(tr("This is an SVG drawing:"));
+ QLabel *instructBottomLabel = new QLabel(
+ tr("Drag the icon to copy the drawing as a PNG file:"));
+ QPushButton *dragIcon = new QPushButton(tr("Export"));
+ dragIcon->setIcon(QIcon(":/images/drag.png"));
+
+ connect(dragIcon, SIGNAL(pressed()), this, SLOT(startDrag()));
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(instructTopLabel, 0, 0, 1, 2);
+ layout->addWidget(imageArea, 1, 0, 2, 2);
+ layout->addWidget(instructBottomLabel, 3, 0);
+ layout->addWidget(dragIcon, 3, 1);
+ setLayout(layout);
+ setWindowTitle(tr("Delayed Encoding"));
+}
+
+//![1]
+void SourceWidget::createData(const QString &mimeType)
+{
+ if (mimeType != "image/png")
+ return;
+
+ QImage image(imageLabel->size(), QImage::Format_RGB32);
+ QPainter painter;
+ painter.begin(&image);
+ imageLabel->renderer()->render(&painter);
+ painter.end();
+
+ QByteArray data;
+ QBuffer buffer(&data);
+ buffer.open(QIODevice::WriteOnly);
+ image.save(&buffer, "PNG");
+ buffer.close();
+
+ mimeData->setData("image/png", data);
+}
+//![1]
+
+//![0]
+void SourceWidget::startDrag()
+{
+ mimeData = new MimeData;
+
+ connect(mimeData, SIGNAL(dataRequested(QString)),
+ this, SLOT(createData(QString)), Qt::DirectConnection);
+
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(QPixmap(":/images/drag.png"));
+
+ drag->exec(Qt::CopyAction);
+}
+//![0]
+
diff --git a/examples/draganddrop/delayedencoding/sourcewidget.h b/examples/draganddrop/delayedencoding/sourcewidget.h
new file mode 100644
index 0000000..eb97f56
--- /dev/null
+++ b/examples/draganddrop/delayedencoding/sourcewidget.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SOURCEWIDGET_H
+#define SOURCEWIDGET_H
+
+#include <QByteArray>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QSvgWidget;
+QT_END_NAMESPACE
+class MimeData;
+
+class SourceWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ SourceWidget(QWidget *parent = 0);
+//![0]
+public slots:
+ void createData(const QString &mimetype);
+ void startDrag();
+
+private:
+ QByteArray imageData;
+ QSvgWidget *imageLabel;
+ MimeData *mimeData;
+//![0]
+};
+
+#endif
diff --git a/examples/draganddrop/draganddrop.pro b/examples/draganddrop/draganddrop.pro
new file mode 100644
index 0000000..c643b11
--- /dev/null
+++ b/examples/draganddrop/draganddrop.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += delayedencoding
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 0000000..7595abd
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += opengl richtext draganddrop painting network desktop
diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp
new file mode 100644
index 0000000..a89c5df
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.cpp
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearercloud.h"
+#include "cloud.h"
+
+#include <QGraphicsTextItem>
+#include <QTimer>
+#include <QDateTime>
+#include <QHostInfo>
+
+#include <QDebug>
+
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+//! [0]
+BearerCloud::BearerCloud(QObject *parent)
+: QGraphicsScene(parent), timerId(0)
+{
+ setSceneRect(-300, -300, 600, 600);
+
+ qsrand(QDateTime::currentDateTime().toTime_t());
+
+ offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX;
+ offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6;
+ offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6;
+ offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6;
+
+ thisDevice = new QGraphicsTextItem(QHostInfo::localHostName());
+ thisDevice->setData(0, QLatin1String("This Device"));
+ thisDevice->setPos(thisDevice->boundingRect().width() / -2,
+ thisDevice->boundingRect().height() / -2);
+ addItem(thisDevice);
+
+ qreal radius = Cloud::getRadiusForState(QNetworkConfiguration::Active);
+ QGraphicsEllipseItem *orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::green));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Discovered);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::blue));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Defined);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::darkGray));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Undefined);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::lightGray));
+ addItem(orbit);
+
+ connect(&manager, SIGNAL(configurationAdded(QNetworkConfiguration)),
+ this, SLOT(configurationAdded(QNetworkConfiguration)));
+ connect(&manager, SIGNAL(configurationRemoved(QNetworkConfiguration)),
+ this, SLOT(configurationRemoved(QNetworkConfiguration)));
+ connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)),
+ this, SLOT(configurationChanged(QNetworkConfiguration)));
+
+ QTimer::singleShot(0, this, SLOT(updateConfigurations()));
+}
+//! [0]
+
+BearerCloud::~BearerCloud()
+{
+}
+
+void BearerCloud::cloudMoved()
+{
+ if (!timerId)
+ timerId = startTimer(1000 / 25);
+}
+
+void BearerCloud::timerEvent(QTimerEvent *)
+{
+ QList<Cloud *> clouds;
+ foreach (QGraphicsItem *item, items()) {
+ if (Cloud *cloud = qgraphicsitem_cast<Cloud *>(item))
+ clouds << cloud;
+ }
+
+ foreach (Cloud *cloud, clouds)
+ cloud->calculateForces();
+
+ bool cloudsMoved = false;
+ foreach (Cloud *cloud, clouds)
+ cloudsMoved |= cloud->advance();
+
+ if (!cloudsMoved) {
+ killTimer(timerId);
+ timerId = 0;
+ }
+}
+
+//! [2]
+void BearerCloud::configurationAdded(const QNetworkConfiguration &config)
+{
+ const QNetworkConfiguration::StateFlags state = config.state();
+
+ configStates.insert(state, config.identifier());
+
+ const qreal radius = Cloud::getRadiusForState(state);
+ const int count = configStates.count(state);
+ const qreal angle = 2 * M_PI / count;
+
+ Cloud *item = new Cloud(config);
+ configurations.insert(config.identifier(), item);
+
+ item->setPos(radius * cos((count-1) * angle + offset[state]),
+ radius * sin((count-1) * angle + offset[state]));
+
+ addItem(item);
+
+ cloudMoved();
+}
+//! [2]
+
+//! [3]
+void BearerCloud::configurationRemoved(const QNetworkConfiguration &config)
+{
+ foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys())
+ configStates.remove(state, config.identifier());
+
+ Cloud *item = configurations.take(config.identifier());
+
+ item->setFinalScale(0.0);
+ item->setDeleteAfterAnimation(true);
+
+ cloudMoved();
+}
+//! [3]
+
+//! [4]
+void BearerCloud::configurationChanged(const QNetworkConfiguration &config)
+{
+ foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys())
+ configStates.remove(state, config.identifier());
+
+ configStates.insert(config.state(), config.identifier());
+
+ cloudMoved();
+}
+//! [4]
+
+//! [1]
+void BearerCloud::updateConfigurations()
+{
+ QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
+
+ while (!allConfigurations.isEmpty())
+ configurationAdded(allConfigurations.takeFirst());
+
+ cloudMoved();
+}
+//! [1]
+
diff --git a/examples/network/bearercloud/bearercloud.h b/examples/network/bearercloud/bearercloud.h
new file mode 100644
index 0000000..54fa83d
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QNetworkConfigurationManager>
+
+#include <QGraphicsScene>
+#include <QMap>
+#include <QHash>
+
+QT_USE_NAMESPACE
+
+class Cloud;
+
+class BearerCloud : public QGraphicsScene
+{
+ Q_OBJECT
+
+public:
+ BearerCloud(QObject *parent = 0);
+ ~BearerCloud();
+
+ void cloudMoved();
+
+ void timerEvent(QTimerEvent *event);
+
+private Q_SLOTS:
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
+ void updateConfigurations();
+
+private:
+ QNetworkConfigurationManager manager;
+
+ QGraphicsTextItem *thisDevice;
+ QHash<QString, Cloud *> configurations;
+
+ QMap<QNetworkConfiguration::StateFlags, qreal> offset;
+ QMultiMap<QNetworkConfiguration::StateFlags, QString> configStates;
+
+ int timerId;
+};
+
diff --git a/examples/network/bearercloud/bearercloud.pro b/examples/network/bearercloud/bearercloud.pro
new file mode 100644
index 0000000..c07626a
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.pro
@@ -0,0 +1,16 @@
+HEADERS = bearercloud.h \
+ cloud.h
+
+SOURCES = main.cpp \
+ bearercloud.cpp \
+ cloud.cpp
+
+RESOURCES = icons.qrc
+
+TARGET = bearercloud
+
+QT = core gui network svg
+
+CONFIG += console
+
+symbian:TARGET.CAPABILITY = NetworkServices ReadUserData
diff --git a/examples/network/bearercloud/bluetooth.svg b/examples/network/bearercloud/bluetooth.svg
new file mode 100644
index 0000000..32e2fa3
--- /dev/null
+++ b/examples/network/bearercloud/bluetooth.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_svg "http://www.w3.org/2000/svg">
+ <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+]>
+<svg version="1.1" id="&#x56FE;&#x5C42;_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="21.792" height="21.819"
+ viewBox="0 0 21.792 21.819" overflow="visible" enable-background="new 0 0 21.792 21.819" xml:space="preserve">
+<linearGradient id="XMLID_2_" gradientUnits="userSpaceOnUse" x1="11.0322" y1="2.8701" x2="11.0322" y2="21.2133">
+ <stop offset="0" style="stop-color:#95D1DB"/>
+ <stop offset="0.0684" style="stop-color:#7FBAE0"/>
+ <stop offset="0.2073" style="stop-color:#5892EA"/>
+ <stop offset="0.3506" style="stop-color:#3871F1"/>
+ <stop offset="0.4971" style="stop-color:#2058F7"/>
+ <stop offset="0.648" style="stop-color:#0E45FC"/>
+ <stop offset="0.8061" style="stop-color:#033BFE"/>
+ <stop offset="0.9831" style="stop-color:#0037FF"/>
+</linearGradient>
+<path fill="url(#XMLID_2_)" stroke="#4D4D4D" stroke-width="0.5" stroke-linejoin="round" d="M10.496,10.931l5.303-4.672
+ L9.172,0.292l-0.05,9.427L9.109,9.708v0.029L7.304,8.168L6.266,9.364l1.802,1.567l-1.802,1.567l1.038,1.195l1.806-1.569v0.029
+ l0.013-0.012l0.05,9.428l6.627-5.966L10.496,10.931z M10.672,3.993l2.502,2.252l-2.525,2.225L10.672,3.993z M13.174,15.617
+ l-2.502,2.252l-0.023-4.477L13.174,15.617z"/>
+<rect opacity="0" fill="#FFFFFF" width="21.792" height="21.792"/>
+</svg>
diff --git a/examples/network/bearercloud/cell.svg b/examples/network/bearercloud/cell.svg
new file mode 100644
index 0000000..7519868
--- /dev/null
+++ b/examples/network/bearercloud/cell.svg
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_svg "http://www.w3.org/2000/svg">
+ <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+]>
+<svg version="1.1" id="&#x56FE;&#x5C42;_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="15.667" height="15.794"
+ viewBox="0 0 15.667 15.794" style="overflow:visible;enable-background:new 0 0 15.667 15.794;" xml:space="preserve">
+<rect style="fill:none;" width="15.667" height="15.666"/>
+<g>
+ <rect x="3.791" y="0.583" style="fill:#996633;" width="1" height="7.963"/>
+ <rect x="10.917" y="0.583" style="fill:#996633;" width="1" height="7.963"/>
+ <linearGradient id="XMLID_2_" gradientUnits="userSpaceOnUse" x1="7.8936" y1="1.6753" x2="7.8936" y2="15.1908">
+ <stop offset="0" style="stop-color:#D9C7A8"/>
+ <stop offset="0.1575" style="stop-color:#CEB28C"/>
+ <stop offset="0.395" style="stop-color:#C09869"/>
+ <stop offset="0.6188" style="stop-color:#B58550"/>
+ <stop offset="0.8212" style="stop-color:#AF7940"/>
+ <stop offset="0.9831" style="stop-color:#AD753B"/>
+ </linearGradient>
+ <rect x="6.728" y="0.583" style="fill:url(#XMLID_2_);stroke:#000000;stroke-width:0.75;" width="2.333" height="14.836"/>
+ <rect x="3.433" y="2.541" style="fill:#C4AB96;stroke:#000000;stroke-width:0.75;" width="8.92" height="2.413"/>
+ <rect x="3.433" y="6.635" style="fill:#C4AB96;stroke:#000000;stroke-width:0.75;" width="8.92" height="2.412"/>
+</g>
+</svg>
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
new file mode 100644
index 0000000..d182164
--- /dev/null
+++ b/examples/network/bearercloud/cloud.cpp
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cloud.h"
+#include "bearercloud.h"
+
+#include <qnetworksession.h>
+
+#include <QGraphicsTextItem>
+#include <QGraphicsSvgItem>
+#include <QGraphicsSceneMouseEvent>
+#include <QSvgRenderer>
+#include <QPainter>
+
+#include <QDebug>
+
+#include <math.h>
+
+static QMap<QNetworkConfiguration::BearerType, QSvgRenderer *> svgCache;
+
+//! [0]
+Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent)
+: QGraphicsItem(parent), configuration(config), deleteAfterAnimation(false)
+{
+ session = new QNetworkSession(configuration, this);
+ connect(session, SIGNAL(newConfigurationActivated()),
+ this, SLOT(newConfigurationActivated()));
+ connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
+ this, SLOT(stateChanged(QNetworkSession::State)));
+
+ setFlag(ItemIsMovable);
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
+ setFlag(ItemSendsGeometryChanges);
+#endif
+ setZValue(1);
+
+ icon = new QGraphicsSvgItem(this);
+ text = new QGraphicsTextItem(this);
+
+ currentScale = 0;
+ finalScale = 1;
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ setOpacity(0);
+
+ newConfigurationActivated();
+}
+//! [0]
+
+Cloud::~Cloud()
+{
+}
+
+void Cloud::setFinalScale(qreal factor)
+{
+ finalScale = factor;
+}
+
+void Cloud::setDeleteAfterAnimation(bool deleteAfter)
+{
+ deleteAfterAnimation = deleteAfter;
+}
+
+void Cloud::calculateForces()
+{
+ if (!scene() || scene()->mouseGrabberItem() == this) {
+ newPos = pos();
+ return;
+ }
+
+ // sum up all the forces push this item away
+ qreal xvel = 0;
+ qreal yvel = 0;
+ QLineF orbitForce;
+ foreach (QGraphicsItem *item, scene()->items()) {
+ // other clouds
+ Cloud *cloud = qgraphicsitem_cast<Cloud *>(item);
+ if (!cloud && item->data(0) != QLatin1String("This Device"))
+ continue;
+
+ qreal factor = 1.0;
+
+ QLineF line(cloud ? item->mapToScene(0, 0) : QPointF(0, 0), mapToScene(0, 0));
+ if (item->data(0) == QLatin1String("This Device"))
+ orbitForce = line;
+
+ if (cloud)
+ factor = cloud->currentScale;
+
+ qreal dx = line.dx();
+ qreal dy = line.dy();
+ double l = 2.0 * (dx * dx + dy * dy);
+ if (l > 0) {
+ xvel += factor * dx * 200.0 / l;
+ yvel += factor * dy * 200.0 / l;
+ }
+ }
+
+ // tendency to stay at a fixed orbit
+ qreal orbit = getRadiusForState(configuration.state());
+ qreal distance = orbitForce.length();
+
+ QLineF unit = orbitForce.unitVector();
+
+ orbitForce.setLength(xvel * unit.dx() + yvel * unit.dy());
+
+ qreal w = 2 - exp(-pow(distance-orbit, 2)/(2 * 50));
+
+ if (distance < orbit) {
+ xvel += orbitForce.dx() * w;
+ yvel += orbitForce.dy() * w;
+ } else {
+ xvel -= orbitForce.dx() * w;
+ yvel -= orbitForce.dy() * w;
+ }
+
+ if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
+ xvel = yvel = 0;
+
+ QRectF sceneRect = scene()->sceneRect();
+ newPos = pos() + QPointF(xvel, yvel);
+ newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
+ newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
+}
+
+bool Cloud::advance()
+{
+ static const qreal scaleDelta = 0.01;
+
+ bool animated = false;
+
+ if (currentScale < finalScale) {
+ animated = true;
+ currentScale = qMin<qreal>(currentScale + scaleDelta, finalScale);
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ } else if (currentScale > finalScale) {
+ animated = true;
+ currentScale = qMax<qreal>(currentScale - scaleDelta, finalScale);
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ }
+
+ if (newPos != pos()) {
+ setPos(newPos);
+ animated = true;
+ }
+
+ if (opacity() != finalOpacity) {
+ animated = true;
+ if (qAbs(finalScale - currentScale) > 0.0) {
+ // use scale as reference
+ setOpacity(opacity() + scaleDelta * (finalOpacity - opacity()) /
+ qAbs(finalScale - currentScale));
+ } else {
+ setOpacity(finalOpacity);
+ }
+ }
+
+ if (!animated && deleteAfterAnimation)
+ deleteLater();
+
+ return animated;
+}
+
+QRectF Cloud::boundingRect() const
+{
+ return childrenBoundingRect();
+}
+
+void Cloud::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+//! [4]
+QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ switch (change) {
+ case ItemPositionHasChanged:
+ if (BearerCloud *bearercloud = qobject_cast<BearerCloud *>(scene()))
+ bearercloud->cloudMoved();
+ default:
+ ;
+ };
+
+ return QGraphicsItem::itemChange(change, value);
+}
+//! [4]
+
+//! [3]
+void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ if (session->isOpen())
+ session->close();
+ else
+ session->open();
+
+ event->accept();
+ }
+}
+//! [3]
+
+//! [2]
+void Cloud::stateChanged(QNetworkSession::State state)
+{
+ if (configuration.name().isEmpty())
+ finalOpacity = qreal(0.1);
+ else if (session->state() == QNetworkSession::NotAvailable)
+ finalOpacity = 0.5;
+ else
+ finalOpacity = 1.0;
+
+#if !defined(Q_WS_MAEMO_5) && !defined(Q_WS_MAEMO_6) && \
+ !defined(Q_OS_SYMBIAN) && !defined(Q_OS_WINCE)
+ QString tooltip;
+
+ if (configuration.name().isEmpty())
+ tooltip += tr("<b>HIDDEN NETWORK</b><br>");
+ else
+ tooltip += tr("<b>%1</b><br>").arg(configuration.name());
+
+#ifndef QT_NO_NETWORKINTERFACE
+ const QNetworkInterface interface = session->interface();
+ if (interface.isValid())
+ tooltip += tr("<br>Interface: %1").arg(interface.humanReadableName());
+ tooltip += tr("<br>Id: %1").arg(configuration.identifier());
+#endif
+
+ const QString bearerTypeName = configuration.bearerTypeName();
+ if (!bearerTypeName.isEmpty())
+ tooltip += tr("<br>Bearer: %1").arg(bearerTypeName);
+
+ QString s = tr("<br>State: %1 (%2)");
+ switch (state) {
+ case QNetworkSession::Invalid:
+ s = s.arg(tr("Invalid"));
+ break;
+ case QNetworkSession::NotAvailable:
+ s = s.arg(tr("Not Available"));
+ break;
+ case QNetworkSession::Connecting:
+ s = s.arg(tr("Connecting"));
+ break;
+ case QNetworkSession::Connected:
+ s = s.arg(tr("Connected"));
+ break;
+ case QNetworkSession::Closing:
+ s = s.arg(tr("Closing"));
+ break;
+ case QNetworkSession::Disconnected:
+ s = s.arg(tr("Disconnected"));
+ break;
+ case QNetworkSession::Roaming:
+ s = s.arg(tr("Roaming"));
+ break;
+ default:
+ s = s.arg(tr("Unknown"));
+ }
+
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
+ else
+ s = s.arg(tr("Closed"));
+
+ tooltip += s;
+
+ tooltip += tr("<br><br>Active time: %1 seconds").arg(session->activeTime());
+ tooltip += tr("<br>Received data: %1 bytes").arg(session->bytesReceived());
+ tooltip += tr("<br>Sent data: %1 bytes").arg(session->bytesWritten());
+
+ setToolTip(tooltip);
+#else
+ Q_UNUSED(state);
+#endif
+}
+//! [2]
+
+//! [1]
+void Cloud::newConfigurationActivated()
+{
+ QNetworkConfiguration::BearerType bearerType = configuration.bearerType();
+ if (!svgCache.contains(bearerType)) {
+ QSvgRenderer *renderer = 0;
+ switch (bearerType) {
+ case QNetworkConfiguration::BearerWLAN:
+ renderer = new QSvgRenderer(QLatin1String(":wlan.svg"));
+ break;
+ case QNetworkConfiguration::BearerEthernet:
+ renderer = new QSvgRenderer(QLatin1String(":lan.svg"));
+ break;
+ case QNetworkConfiguration::Bearer2G:
+ renderer = new QSvgRenderer(QLatin1String(":cell.svg"));
+ break;
+ case QNetworkConfiguration::BearerBluetooth:
+ renderer = new QSvgRenderer(QLatin1String(":bluetooth.svg"));
+ break;
+ case QNetworkConfiguration::BearerCDMA2000:
+ case QNetworkConfiguration::BearerWCDMA:
+ case QNetworkConfiguration::BearerHSPA:
+ renderer = new QSvgRenderer(QLatin1String(":umts.svg"));
+ break;
+ default:
+ renderer = new QSvgRenderer(QLatin1String(":unknown.svg"));
+ }
+
+ if (renderer)
+ svgCache.insert(bearerType, renderer);
+ }
+
+ icon->setSharedRenderer(svgCache[bearerType]);
+
+ if (configuration.name().isEmpty()) {
+ text->setPlainText(tr("HIDDEN NETWORK"));
+ } else {
+ if (configuration.type() == QNetworkConfiguration::ServiceNetwork)
+ text->setHtml("<b>" + configuration.name() + "</b>");
+ else
+ text->setPlainText(configuration.name());
+ }
+
+ const qreal height = icon->boundingRect().height() + text->boundingRect().height();
+
+ icon->setPos(icon->boundingRect().width() / -2, height / -2);
+
+ text->setPos(text->boundingRect().width() / -2,
+ height / 2 - text->boundingRect().height());
+
+ stateChanged(session->state());
+}
+//! [1]
+
+qreal Cloud::getRadiusForState(QNetworkConfiguration::StateFlags state)
+{
+ switch (state) {
+ case QNetworkConfiguration::Active:
+ return 100;
+ break;
+ case QNetworkConfiguration::Discovered:
+ return 150;
+ break;
+ case QNetworkConfiguration::Defined:
+ return 200;
+ break;
+ case QNetworkConfiguration::Undefined:
+ return 250;
+ break;
+ default:
+ return 300;
+ }
+}
+
diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h
new file mode 100644
index 0000000..3efbb81
--- /dev/null
+++ b/examples/network/bearercloud/cloud.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+
+#include <QGraphicsItem>
+QT_USE_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+class QGraphicsTextItem;
+class QGraphicsSvgItem;
+QT_END_NAMESPACE
+
+class Cloud : public QObject, public QGraphicsItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem)
+
+public:
+ explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
+ ~Cloud();
+
+ enum { Type = UserType + 1 };
+ int type() const { return Type; }
+
+ void setFinalScale(qreal factor);
+ void setDeleteAfterAnimation(bool deleteAfter);
+
+ void calculateForces();
+
+ bool advance();
+ QRectF boundingRect() const;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ static qreal getRadiusForState(QNetworkConfiguration::StateFlags state);
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+
+private Q_SLOTS:
+ void stateChanged(QNetworkSession::State state);
+ void newConfigurationActivated();
+
+private:
+ QNetworkConfiguration configuration;
+ QNetworkSession *session;
+
+ QGraphicsTextItem *text;
+ QGraphicsSvgItem *icon;
+
+ qreal finalOpacity;
+ qreal finalScale;
+ qreal currentScale;
+
+ QPointF newPos;
+
+ bool deleteAfterAnimation;
+};
+
diff --git a/examples/network/bearercloud/gprs.svg b/examples/network/bearercloud/gprs.svg
new file mode 100644
index 0000000..4a992c1
--- /dev/null
+++ b/examples/network/bearercloud/gprs.svg
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.0"
+ id="图层_1"
+ width="13"
+ height="14"
+ viewBox="0 0 21.228 20.825"
+ style="overflow:visible;enable-background:new 0 0 21.228 20.825;"
+ xml:space="preserve"
+ sodipodi:version="0.32"
+ inkscape:version="0.44.1"
+ sodipodi:docname="GPRS-online.svg"
+ sodipodi:docbase="/home/user"><metadata
+ id="metadata76"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs74">
+ <linearGradient
+ y2="18.770201"
+ x2="19.1735"
+ y1="2.1933999"
+ x1="2.5967"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_5_"
+ gradientTransform="matrix(1.749056,0,0,1.749987,1.149567,1.483541)">
+ <stop
+ id="stop6"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop8"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop10"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop12"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop14"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop16"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop18"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+ <linearGradient
+ y2="13.7331"
+ x2="24.2068"
+ y1="-2.8408"
+ x1="7.6328001"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_6_">
+ <stop
+ id="stop23"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop25"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop27"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop29"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop31"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop33"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop35"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+ <linearGradient
+ y2="23.8965"
+ x2="14.043"
+ y1="7.3242002"
+ x1="-2.5293"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_7_">
+ <stop
+ id="stop40"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop42"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop44"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop46"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop48"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop50"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop52"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+ <linearGradient
+ y2="18.5788"
+ x2="19.364"
+ y1="2.0039001"
+ x1="2.7890999"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_8_">
+ <stop
+ id="stop57"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop59"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop61"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop63"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop65"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop67"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop69"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+</defs><sodipodi:namedview
+ inkscape:window-height="960"
+ inkscape:window-width="1183"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ width="13px"
+ height="14px"
+ inkscape:zoom="19.543817"
+ inkscape:cx="10.614"
+ inkscape:cy="10.386917"
+ inkscape:window-x="186"
+ inkscape:window-y="93"
+ inkscape:current-layer="图层_1" />
+<path
+ id="path20"
+ d="M 11.043976,12.916206 L 11.043976,9.4232323 L 19.388723,9.4232323 L 19.388723,16.573679 C 17.790085,17.616671 16.380346,18.330666 15.15076,18.708663 C 13.922922,19.084911 12.465959,19.272159 10.779869,19.272159 C 8.7054879,19.272159 7.0141507,18.934412 5.7076059,18.253667 C 4.399312,17.574672 3.3866086,16.564929 2.6677466,15.222689 C 1.9488846,13.880449 1.58683,12.336961 1.58683,10.599223 C 1.58683,8.7652372 1.9803676,7.172749 2.7674428,5.820009 C 3.5527689,4.4655191 4.7053968,3.4365268 6.2288246,2.7312819 C 7.4111865,2.190536 9.0045765,1.921038 11.008995,1.921038 C 12.939953,1.921038 14.386422,2.0890367 15.343156,2.4232842 C 16.301639,2.7610318 17.093961,3.2825279 17.728868,3.9860227 C 18.360278,4.6930174 18.834272,5.5890108 19.150851,6.6722527 L 13.938664,7.5629961 C 13.72353,6.9330008 13.361475,6.4465044 12.849002,6.1157569 C 12.33478,5.7815093 11.68588,5.6117606 10.890059,5.6117606 C 9.7111951,5.6117606 8.7632067,6.0072577 8.0653334,6.7965018 C 7.3622129,7.5839959 7.0071545,8.8352366 7.0071545,10.541474 C 7.0071545,12.35621 7.365711,13.654701 8.0740787,14.433445 C 8.7824464,15.212189 9.7776592,15.600686 11.043976,15.600686 C 11.647401,15.600686 12.224589,15.514937 12.770295,15.346938 C 13.321247,15.18069 13.943911,14.897192 14.652279,14.492945 L 14.652279,12.917956 L 11.043976,12.917956 L 11.043976,12.916206 z "
+ style="fill:black;stroke:white;stroke-width:1.30633846;stroke-miterlimit:4;stroke-dasharray:none;stroke-linejoin:round;stroke-linecap:butt;stroke-opacity:1;fill-opacity:1" />
+</svg>
diff --git a/examples/network/bearercloud/icons.qrc b/examples/network/bearercloud/icons.qrc
new file mode 100644
index 0000000..7dea1f2
--- /dev/null
+++ b/examples/network/bearercloud/icons.qrc
@@ -0,0 +1,11 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>wlan.svg</file>
+ <file>lan.svg</file>
+ <file>unknown.svg</file>
+ <file>bluetooth.svg</file>
+ <file>cell.svg</file>
+ <file>gprs.svg</file>
+ <file>umts.svg</file>
+</qresource>
+</RCC>
diff --git a/examples/network/bearercloud/lan.svg b/examples/network/bearercloud/lan.svg
new file mode 100755
index 0000000..4f7f63d
--- /dev/null
+++ b/examples/network/bearercloud/lan.svg
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_svg "http://www.w3.org/2000/svg">
+ <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+]>
+<svg version="1.1" id="&#x56FE;&#x5C42;_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="21.929" height="20.665"
+ viewBox="0 0 21.929 20.665" style="overflow:visible;enable-background:new 0 0 21.929 20.665;" xml:space="preserve">
+<g>
+ <linearGradient id="XMLID_3_" gradientUnits="userSpaceOnUse" x1="1.7178" y1="5.3706" x2="20.9333" y2="5.3706">
+ <stop offset="0.0393" style="stop-color:#C2DC1A"/>
+ <stop offset="0.2192" style="stop-color:#BEDA1A"/>
+ <stop offset="0.3978" style="stop-color:#B2D61B"/>
+ <stop offset="0.5758" style="stop-color:#9ECE1D"/>
+ <stop offset="0.7536" style="stop-color:#82C320"/>
+ <stop offset="0.9298" style="stop-color:#5FB423"/>
+ <stop offset="0.9326" style="stop-color:#5EB423"/>
+ </linearGradient>
+ <polygon style="fill:url(#XMLID_3_);stroke:#000000;stroke-linejoin:round;" points="21.429,7.716 10.965,7.716 10.965,0.5
+ 0.5,10.241 21.429,10.241 "/>
+ <linearGradient id="XMLID_4_" gradientUnits="userSpaceOnUse" x1="1.7178" y1="15.2944" x2="20.9333" y2="15.2944">
+ <stop offset="0.0393" style="stop-color:#C2DC1A"/>
+ <stop offset="0.2192" style="stop-color:#BEDA1A"/>
+ <stop offset="0.3978" style="stop-color:#B2D61B"/>
+ <stop offset="0.5758" style="stop-color:#9ECE1D"/>
+ <stop offset="0.7536" style="stop-color:#82C320"/>
+ <stop offset="0.9298" style="stop-color:#5FB423"/>
+ <stop offset="0.9326" style="stop-color:#5EB423"/>
+ </linearGradient>
+ <polygon style="fill:url(#XMLID_4_);stroke:#000000;stroke-linejoin:round;" points="0.5,12.949 10.965,12.949 10.965,20.165
+ 21.429,10.424 0.5,10.424 "/>
+</g>
+</svg>
diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp
new file mode 100644
index 0000000..e4fab27
--- /dev/null
+++ b/examples/network/bearercloud/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearercloud.h"
+
+#include <QApplication>
+#include <QGraphicsView>
+
+class CloudView : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ CloudView(QGraphicsScene *scene);
+ ~CloudView() { }
+
+protected:
+ void resizeEvent(QResizeEvent *) {
+ fitInView(sceneRect(), Qt::KeepAspectRatio);
+ }
+#ifdef Q_OS_WINCE
+ void hideEvent(QHideEvent *) {
+ qApp->quit();
+ }
+#endif
+};
+
+CloudView::CloudView(QGraphicsScene *scene)
+: QGraphicsView(scene)
+{
+ setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing |
+ QPainter::SmoothPixmapTransform);
+#if defined (Q_OS_SYMBIAN) || defined (Q_OS_WINCE)
+ setWindowState(Qt::WindowMaximized);
+#endif
+}
+
+#include "main.moc"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ BearerCloud bearerCloud;
+
+ CloudView view(&bearerCloud);
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/network/bearercloud/umts.svg b/examples/network/bearercloud/umts.svg
new file mode 100644
index 0000000..c1b372e
--- /dev/null
+++ b/examples/network/bearercloud/umts.svg
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.0"
+ id="图层_1"
+ width="13"
+ height="14"
+ viewBox="0 0 21.228 20.825"
+ style="overflow:visible;enable-background:new 0 0 21.228 20.825;"
+ xml:space="preserve"
+ sodipodi:version="0.32"
+ inkscape:version="0.44.1"
+ sodipodi:docname="umts-enabled.svg"
+ sodipodi:docbase="/home/user"><metadata
+ id="metadata76"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs74">
+ <linearGradient
+ y2="18.770201"
+ x2="19.1735"
+ y1="2.1933999"
+ x1="2.5967"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_5_"
+ gradientTransform="matrix(1.749056,0,0,1.749987,1.149567,1.483541)">
+ <stop
+ id="stop6"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop8"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop10"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop12"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop14"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop16"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop18"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+ <linearGradient
+ y2="13.7331"
+ x2="24.2068"
+ y1="-2.8408"
+ x1="7.6328001"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_6_">
+ <stop
+ id="stop23"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop25"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop27"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop29"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop31"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop33"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop35"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+ <linearGradient
+ y2="23.8965"
+ x2="14.043"
+ y1="7.3242002"
+ x1="-2.5293"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_7_">
+ <stop
+ id="stop40"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop42"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop44"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop46"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop48"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop50"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop52"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+ <linearGradient
+ y2="18.5788"
+ x2="19.364"
+ y1="2.0039001"
+ x1="2.7890999"
+ gradientUnits="userSpaceOnUse"
+ id="XMLID_8_">
+ <stop
+ id="stop57"
+ style="stop-color:#F8DB41"
+ offset="0" />
+ <stop
+ id="stop59"
+ style="stop-color:#F8D73F"
+ offset="0.1193" />
+ <stop
+ id="stop61"
+ style="stop-color:#F9CB3A"
+ offset="0.2384" />
+ <stop
+ id="stop63"
+ style="stop-color:#FAB731"
+ offset="0.3576" />
+ <stop
+ id="stop65"
+ style="stop-color:#FC9B24"
+ offset="0.4768" />
+ <stop
+ id="stop67"
+ style="stop-color:#FE7714"
+ offset="0.595" />
+ <stop
+ id="stop69"
+ style="stop-color:#FE7513"
+ offset="0.6011" />
+ </linearGradient>
+
+</defs><sodipodi:namedview
+ inkscape:window-height="960"
+ inkscape:window-width="1183"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ width="13px"
+ height="14px"
+ inkscape:zoom="53.714286"
+ inkscape:cx="6.5"
+ inkscape:cy="7"
+ inkscape:window-x="252"
+ inkscape:window-y="164"
+ inkscape:current-layer="图层_1" />
+
+<path
+ style="font-size:26.12677002px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:black;fill-opacity:1;stroke:white;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ d="M 10.438113,0.60410378 C 9.5195858,0.60412318 8.5840584,0.67216158 7.6315264,0.80821918 C 6.6789835,0.94431518 5.6924268,1.1484304 4.7228823,1.4205653 L 4.7228823,5.0436132 C 5.5223309,4.6949314 6.3643059,4.4057684 7.1722669,4.2271517 C 7.9802179,4.0485668 8.7796689,3.9720237 9.5706225,3.9720075 C 10.64222,3.9720235 11.433166,4.1846436 12.020007,4.5843536 C 12.606829,4.9840947 12.938516,5.5369062 12.938526,6.2683055 C 12.938515,7.0592656 12.623838,7.663106 12.020007,8.054315 C 11.416156,8.4370429 10.497638,8.615644 9.2644494,8.615632 L 7.1722669,8.615632 L 7.1722669,11.779421 L 9.1623917,11.779421 C 10.548667,11.779429 11.569243,11.992048 12.275151,12.442796 C 12.989544,12.885053 13.346746,13.565437 13.346757,14.43292 C 13.346746,15.2749 13.023563,15.921266 12.32618,16.372017 C 11.637281,16.822775 10.616705,17.035395 9.3154783,17.035392 C 8.4394768,17.035395 7.5719873,16.907823 6.6619784,16.67819 C 5.7604653,16.440059 4.8249372,16.116877 3.9064208,15.657613 L 3.9064208,19.433747 C 4.8674613,19.748424 5.8370084,19.995064 6.815065,20.148151 C 7.8016169,20.309742 8.7966784,20.403295 9.7747379,20.403295 C 12.547295,20.403294 14.656485,19.901511 16.102315,18.923459 C 17.548116,17.936904 18.296539,16.474077 18.296555,14.586007 C 18.296539,13.318797 17.947843,12.289717 17.275978,11.473248 C 16.612589,10.648291 15.286744,9.8267627 14.975337,9.738267 C 15.211467,9.5707147 16.382959,8.96434 16.969805,8.2584304 C 17.556621,7.544039 17.837281,6.617016 17.837296,5.5028728 C 17.837281,3.8699658 17.233439,2.6367701 16.000257,1.8287961 C 14.775552,1.0123535 12.913001,0.60412318 10.438113,0.60410378 z M 10.570571,1.2772502 C 13.045459,1.2772695 14.306521,1.5736708 15.531226,2.3901134 C 16.764408,3.1980876 17.174992,3.8601944 17.175007,5.4931014 C 17.174992,6.6072444 16.924732,7.1976942 16.337916,7.9120856 C 15.75107,8.617996 15.186496,9.1223119 15.071966,9.2290638 L 14.321733,9.8826672 C 15.605945,10.214364 16.173958,10.84372 16.837348,11.668677 C 17.509211,12.485146 17.613621,13.298168 17.613637,14.565378 C 17.613621,16.453449 16.977028,17.365815 15.531226,18.35237 C 14.085396,19.330422 12.587467,19.720376 9.8149096,19.720377 C 8.8368504,19.720377 7.7809882,19.596424 6.7944362,19.434833 C 5.8163797,19.281747 5.4689503,19.167564 4.5079098,18.852887 L 4.4775095,16.626075 C 5.3960259,17.085338 5.6790363,17.174005 6.5805495,17.412136 C 7.4905585,17.641769 8.5827919,17.809513 9.4587934,17.80951 C 10.76002,17.809513 12.167112,17.341749 12.856012,16.89099 C 13.553395,16.440238 14.111093,15.203243 14.111104,14.361263 C 14.111093,13.493779 13.591033,12.385621 12.87664,11.943364 C 12.170732,11.492617 10.853754,11.107368 9.4674791,11.10736 L 7.8041559,11.117131 L 7.8041559,9.277922 L 9.3871358,9.257293 C 10.620324,9.257304 12.006788,8.936474 12.610639,8.553746 C 13.21447,8.1625376 13.682233,7.0288655 13.682244,6.2379054 C 13.682234,5.5065062 13.268032,4.4542632 12.681211,4.0545222 C 12.09437,3.6548121 10.824621,3.2391624 9.7530236,3.2391464 C 8.9620698,3.2391624 7.9791321,3.3048486 7.1711811,3.4834335 C 6.3632201,3.66205 6.1954773,3.6645831 5.3960287,4.0132649 L 5.3862573,1.9308538 C 6.3558019,1.6587188 6.8320701,1.5566613 7.784613,1.4205653 C 8.7371446,1.2845077 9.6520438,1.2772696 10.570571,1.2772502 z "
+ id="text1901"
+ sodipodi:nodetypes="csccsssssccccsssssccssssscsssccsssccsssssccsssssccccsssssccsc" /></svg> \ No newline at end of file
diff --git a/examples/network/bearercloud/unknown.svg b/examples/network/bearercloud/unknown.svg
new file mode 100644
index 0000000..fd10298
--- /dev/null
+++ b/examples/network/bearercloud/unknown.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="9.0681238"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="unknown.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="15.244635"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1459"
+ inkscape:window-height="964"
+ inkscape:window-x="453"
+ inkscape:window-y="166" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-6.891787e-8,-19.931876)">
+ <text
+ xml:space="preserve"
+ style="font-size:13.16195393px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="-1.0539845"
+ y="29"
+ id="text3239"><tspan
+ sodipodi:role="line"
+ id="tspan3241"
+ x="-1.0539845"
+ y="29">NET</tspan></text>
+ </g>
+</svg>
diff --git a/examples/network/bearercloud/wlan.svg b/examples/network/bearercloud/wlan.svg
new file mode 100644
index 0000000..8b86089
--- /dev/null
+++ b/examples/network/bearercloud/wlan.svg
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="27"
+ height="29"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="wlan.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="23.665236"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1912"
+ inkscape:window-height="1130"
+ inkscape:window-x="0"
+ inkscape:window-y="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g6334"
+ transform="translate(1.0000001,0)">
+ <path
+ id="path2393"
+ d="M 12.500248,9.499893 L 12.500248,28.500095"
+ style="fill:none;fill-rule:evenodd;stroke:#3bb3ff;stroke-width:0.99981093;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(1.0216765,0,0,1.0324764,0.4493163,-22.692096)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3171"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(1.6055152,0,0,1.6224868,-7.5798083,-40.80263)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3175"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(2.4812855,0,0,2.5075146,-17.62358,-67.968804)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3177"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-1.0216765,0,0,1.0324764,24.550388,-22.692096)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3179"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-1.6055152,0,0,1.6224868,32.580246,-40.80263)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3181"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-2.4812855,0,0,2.5075146,42.623143,-67.968804)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3183"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ </g>
+ </g>
+</svg>
diff --git a/examples/network/network.pro b/examples/network/network.pro
new file mode 100644
index 0000000..a6c4b01
--- /dev/null
+++ b/examples/network/network.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += bearercloud
diff --git a/examples/opengl/framebufferobject/bubbles.svg b/examples/opengl/framebufferobject/bubbles.svg
new file mode 100644
index 0000000..5173012
--- /dev/null
+++ b/examples/opengl/framebufferobject/bubbles.svg
@@ -0,0 +1,215 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg width="20cm" height="15cm" viewBox="0 0 800 600"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink/"
+ baseProfile="tiny" version="1.2">
+ <title>Spheres</title>
+ <desc>Semi-transparent bubbles on a colored background.</desc>
+ <defs>
+ <!-- Create radial gradients for each bubble. -->
+ <radialGradient id="blueBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#cdcdff" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#cdaacd" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="redBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#ffcdcd" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#bbbb99" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="greenBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#cdffcd" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#99aaaa" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="yellowBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#ffffcd" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#bbbbaa" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="background" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="400" fx="250" fy="250">
+ <stop offset="0%" stop-color="#ffffee" />
+ <stop offset="100%" stop-color="#ccccaa" />
+ </radialGradient>
+ <linearGradient id="surface" gradientUnits="userSpaceOnUse"
+ x1="-100" y1="200" x2="400" y2="200">
+ <stop offset="0%" stop-color="#ffffcc" />
+ <stop offset="100%" stop-color="#bbbb88" />
+ </linearGradient>
+
+ <!-- Create radial gradients for each circle to make them look like
+ spheres. -->
+ <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="blue" />
+ <stop offset="100%" stop-color="#222244" />
+ </radialGradient>
+ <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="red" />
+ <stop offset="100%" stop-color="#442222" />
+ </radialGradient>
+ <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="green" />
+ <stop offset="100%" stop-color="#113311" />
+ </radialGradient>
+ <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="yellow" />
+ <stop offset="100%" stop-color="#444422" />
+ </radialGradient>
+ <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="50">
+ <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+ <stop offset="100%" stop-color="black" stop-opacity="0.0" />
+ </radialGradient>
+
+ <!-- Define a shadow for each sphere. -->
+ <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" />
+ <g id="bubble">
+ <circle fill="black" cx="0" cy="0" r="50" />
+ <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+ <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+ L -11,22 L -1,12 Z" />
+ <circle cx="0" cy="0" r="100" />
+ </g>
+ </defs>
+ <g>
+ <rect fill="url(#background)" x="0" y="0" width="800" height="600" />
+ </g>
+
+ <g transform="translate(200,700)">
+ <use xlink:href="#bubble" fill="url(#blueBubble)" />
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(315,700)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#bubble" fill="url(#redBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(80,700)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#bubble" fill="url(#greenBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(255,700)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(565,700)">
+ <g transform="scale(0.4,0.4)">
+ <use xlink:href="#bubble" fill="url(#blueBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(715,700)">
+ <g transform="scale(0.6,0.6)">
+ <use xlink:href="#bubble" fill="url(#redBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(645,700)">
+ <g transform="scale(0.375,0.375)">
+ <use xlink:href="#bubble" fill="url(#greenBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(555,700)">
+ <g transform="scale(0.9,0.9)">
+ <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" />
+ </g>
+
+ <g transform="translate(360,700)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#bubble" fill="url(#blueBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(215,700)">
+ <g transform="scale(0.45,0.45)">
+ <use xlink:href="#bubble" fill="url(#redBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(420,700)">
+ <g transform="scale(0.75,0.75)">
+ <use xlink:href="#bubble" fill="url(#greenBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(815,700)">
+ <g transform="scale(0.6,0.6)">
+ <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" />
+ </g>
+
+ <g transform="translate(225,375)" >
+ <g transform="scale(1.0,0.5)" >
+ <path d="M 0 0 L 350 0 L 450 450 L -100 450 z"
+ fill="url(#surface)" stroke="none" />
+ </g>
+ </g>
+ <g transform="translate(200,0)" >
+ <g transform="translate(200,490) scale(2.0,1.0) rotate(45)" >
+ <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" />
+ <circle fill="black" cx="0" cy="0" r="50" />
+ <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+ <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+ L -11,22 L -1,12 Z" />
+ <animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360"
+ begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(200,375)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+ </g>
+ <g transform="translate(315,440)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(80,475)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(255,525)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/examples/opengl/framebufferobject/designer.png b/examples/opengl/framebufferobject/designer.png
new file mode 100644
index 0000000..4f32d57
--- /dev/null
+++ b/examples/opengl/framebufferobject/designer.png
Binary files differ
diff --git a/examples/opengl/framebufferobject/framebufferobject.pro b/examples/opengl/framebufferobject/framebufferobject.pro
new file mode 100644
index 0000000..36efe73
--- /dev/null
+++ b/examples/opengl/framebufferobject/framebufferobject.pro
@@ -0,0 +1,24 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Fri May 12 17:15:46 2006
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT += opengl svg
+
+# Input
+HEADERS += glwidget.h
+SOURCES += glwidget.cpp main.cpp
+RESOURCES += framebufferobject.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/opengl/framebufferobject
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.png *.svg
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/opengl/framebufferobject
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+
diff --git a/examples/opengl/framebufferobject/framebufferobject.qrc b/examples/opengl/framebufferobject/framebufferobject.qrc
new file mode 100644
index 0000000..986f1ca
--- /dev/null
+++ b/examples/opengl/framebufferobject/framebufferobject.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/res">
+ <file>bubbles.svg</file>
+ <file>designer.png</file>
+</qresource>
+</RCC>
diff --git a/examples/opengl/framebufferobject/glwidget.cpp b/examples/opengl/framebufferobject/glwidget.cpp
new file mode 100644
index 0000000..3dfc10a
--- /dev/null
+++ b/examples/opengl/framebufferobject/glwidget.cpp
@@ -0,0 +1,329 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QImage>
+#include "glwidget.h"
+
+#include <math.h>
+
+#ifndef GL_MULTISAMPLE
+#define GL_MULTISAMPLE 0x809D
+#endif
+
+GLWidget::GLWidget(QWidget *parent)
+ : QGLWidget(QGLFormat(QGL::SampleBuffers|QGL::AlphaChannel), parent)
+{
+ setWindowTitle(tr("OpenGL framebuffer objects"));
+ makeCurrent();
+
+ if (QGLFramebufferObject::hasOpenGLFramebufferBlit()) {
+ QGLFramebufferObjectFormat format;
+ format.setSamples(4);
+ format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+
+ render_fbo = new QGLFramebufferObject(512, 512, format);
+ texture_fbo = new QGLFramebufferObject(512, 512);
+ } else {
+ render_fbo = new QGLFramebufferObject(1024, 1024);
+ texture_fbo = render_fbo;
+ }
+
+ rot_x = rot_y = rot_z = 0.0f;
+ scale = 0.1f;
+ anim = new QTimeLine(750, this);
+ anim->setUpdateInterval(20);
+ connect(anim, SIGNAL(valueChanged(qreal)), SLOT(animate(qreal)));
+ connect(anim, SIGNAL(finished()), SLOT(animFinished()));
+
+ svg_renderer = new QSvgRenderer(QLatin1String(":/res/bubbles.svg"), this);
+ connect(svg_renderer, SIGNAL(repaintNeeded()), this, SLOT(draw()));
+
+ logo = QImage(":/res/designer.png");
+ logo = logo.convertToFormat(QImage::Format_ARGB32);
+
+ tile_list = glGenLists(1);
+ glNewList(tile_list, GL_COMPILE);
+ glBegin(GL_QUADS);
+ {
+ glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
+
+ glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
+ glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
+
+ glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
+ glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
+
+ glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
+ glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
+
+ glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
+ glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
+
+ glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
+ }
+ glEnd();
+ glEndList();
+
+ wave = new GLfloat[logo.width()*logo.height()];
+ memset(wave, 0, logo.width()*logo.height());
+ startTimer(30); // wave timer
+}
+
+GLWidget::~GLWidget()
+{
+ delete[] wave;
+ glDeleteLists(tile_list, 1);
+ delete texture_fbo;
+ if (render_fbo != texture_fbo)
+ delete render_fbo;
+}
+
+void GLWidget::paintEvent(QPaintEvent *)
+{
+ draw();
+}
+
+void GLWidget::draw()
+{
+ QPainter p(this); // used for text overlay
+
+ // save the GL state set for QPainter
+ saveGLState();
+
+ // render the 'bubbles.svg' file into our framebuffer object
+ QPainter fbo_painter(render_fbo);
+ svg_renderer->render(&fbo_painter);
+ fbo_painter.end();
+
+ if (render_fbo != texture_fbo) {
+ QRect rect(0, 0, render_fbo->width(), render_fbo->height());
+ QGLFramebufferObject::blitFramebuffer(texture_fbo, rect,
+ render_fbo, rect);
+ }
+
+ // draw into the GL widget
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1, 1, -1, 1, 10, 100);
+ glTranslatef(0.0f, 0.0f, -15.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glViewport(0, 0, width(), height());
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glBindTexture(GL_TEXTURE_2D, texture_fbo->texture());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_MULTISAMPLE);
+ glEnable(GL_CULL_FACE);
+
+ // draw background
+ glPushMatrix();
+ glScalef(1.7f, 1.7f, 1.7f);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glCallList(tile_list);
+ glPopMatrix();
+
+ const int w = logo.width();
+ const int h = logo.height();
+
+ glRotatef(rot_x, 1.0f, 0.0f, 0.0f);
+ glRotatef(rot_y, 0.0f, 1.0f, 0.0f);
+ glRotatef(rot_z, 0.0f, 0.0f, 1.0f);
+ glScalef(scale/w, scale/w, scale/w);
+
+ glDepthFunc(GL_LESS);
+ glEnable(GL_DEPTH_TEST);
+ // draw the Qt icon
+ glTranslatef(-w+1, -h+1, 0.0f);
+ for (int y=h-1; y>=0; --y) {
+ uint *p = (uint*) logo.scanLine(y);
+ uint *end = p + w;
+ int x = 0;
+ while (p < end) {
+ glColor4ub(qRed(*p), qGreen(*p), qBlue(*p), uchar(qAlpha(*p)*.9));
+ glTranslatef(0.0f, 0.0f, wave[y*w+x]);
+ if (qAlpha(*p) > 128)
+ glCallList(tile_list);
+ glTranslatef(0.0f, 0.0f, -wave[y*w+x]);
+ glTranslatef(2.0f, 0.0f, 0.0f);
+ ++x;
+ ++p;
+ }
+ glTranslatef(-w*2.0f, 2.0f, 0.0f);
+ }
+
+ // restore the GL state that QPainter expects
+ restoreGLState();
+
+ // draw the overlayed text using QPainter
+ p.setPen(QColor(197, 197, 197, 157));
+ p.setBrush(QColor(197, 197, 197, 127));
+ p.drawRect(QRect(0, 0, width(), 50));
+ p.setPen(Qt::black);
+ p.setBrush(Qt::NoBrush);
+ const QString str1(tr("A simple OpenGL framebuffer object example."));
+ const QString str2(tr("Use the mouse wheel to zoom, press buttons and move mouse to rotate, double-click to flip."));
+ QFontMetrics fm(p.font());
+ p.drawText(width()/2 - fm.width(str1)/2, 20, str1);
+ p.drawText(width()/2 - fm.width(str2)/2, 20 + fm.lineSpacing(), str2);
+}
+
+void GLWidget::mousePressEvent(QMouseEvent *e)
+{
+ anchor = e->pos();
+}
+
+void GLWidget::mouseMoveEvent(QMouseEvent *e)
+{
+ QPoint diff = e->pos() - anchor;
+ if (e->buttons() & Qt::LeftButton) {
+ rot_x += diff.y()/5.0f;
+ rot_y += diff.x()/5.0f;
+ } else if (e->buttons() & Qt::RightButton) {
+ rot_z += diff.x()/5.0f;
+ }
+
+ anchor = e->pos();
+ draw();
+}
+
+void GLWidget::wheelEvent(QWheelEvent *e)
+{
+ e->delta() > 0 ? scale += scale*0.1f : scale -= scale*0.1f;
+ draw();
+}
+
+void GLWidget::mouseDoubleClickEvent(QMouseEvent *)
+{
+ anim->start();
+}
+
+void GLWidget::animate(qreal val)
+{
+ rot_y = val * 180;
+ draw();
+}
+
+void GLWidget::animFinished()
+{
+ if (anim->direction() == QTimeLine::Forward)
+ anim->setDirection(QTimeLine::Backward);
+ else
+ anim->setDirection(QTimeLine::Forward);
+}
+
+void GLWidget::saveGLState()
+{
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+}
+
+void GLWidget::restoreGLState()
+{
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glPopAttrib();
+}
+
+#define PI 3.14159
+
+void GLWidget::timerEvent(QTimerEvent *)
+{
+ if (QApplication::mouseButtons() != 0)
+ return;
+
+ static bool scale_in = true;
+
+ if (scale_in && scale > 35.0f)
+ scale_in = false;
+ else if (!scale_in && scale < .5f)
+ scale_in = true;
+
+ scale = scale_in ? scale + scale*0.01f : scale-scale*0.01f;
+ rot_z += 0.3f;
+ rot_x += 0.1f;
+
+ int dx, dy; // disturbance point
+ float s, v, W, t;
+ int i, j;
+ static float wt[128][128];
+ const int width = logo.width();
+ const int AMP = 5;
+
+ dx = dy = width >> 1;
+
+ W = .3f;
+ v = -4; // wave speed
+
+ for (i = 0; i < width; ++i) {
+ for ( j = 0; j < width; ++j) {
+ s = sqrt((double) ((j - dx) * (j - dx) + (i - dy) * (i - dy)));
+ wt[i][j] += 0.1f;
+ t = s / v;
+ if (s != 0)
+ wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)) / (0.2*(s + 2));
+ else
+ wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t));
+ }
+ }
+}
diff --git a/examples/opengl/framebufferobject/glwidget.h b/examples/opengl/framebufferobject/glwidget.h
new file mode 100644
index 0000000..109b680
--- /dev/null
+++ b/examples/opengl/framebufferobject/glwidget.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtOpenGL>
+#include <QImage>
+#include <QTimeLine>
+#include <QSvgRenderer>
+
+class GLWidget : public QGLWidget
+{
+ Q_OBJECT
+
+public:
+ GLWidget(QWidget *parent);
+ ~GLWidget();
+
+ void saveGLState();
+ void restoreGLState();
+
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseDoubleClickEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void timerEvent(QTimerEvent *);
+ void wheelEvent(QWheelEvent *);
+
+public slots:
+ void animate(qreal);
+ void animFinished();
+ void draw();
+
+private:
+ QPoint anchor;
+ float scale;
+ float rot_x, rot_y, rot_z;
+ GLuint tile_list;
+ GLfloat *wave;
+
+ QImage logo;
+ QTimeLine *anim;
+ QSvgRenderer *svg_renderer;
+ QGLFramebufferObject *render_fbo;
+ QGLFramebufferObject *texture_fbo;
+};
+
diff --git a/examples/opengl/framebufferobject/main.cpp b/examples/opengl/framebufferobject/main.cpp
new file mode 100644
index 0000000..c96392f
--- /dev/null
+++ b/examples/opengl/framebufferobject/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include <QtGui/QMessageBox>
+#include "glwidget.h"
+
+int main(int argc, char **argv)
+{
+ Q_INIT_RESOURCE(framebufferobject);
+
+ QApplication a(argc, argv);
+ if (!QGLFormat::hasOpenGL() || !QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
+ QMessageBox::information(0, "OpenGL framebuffer objects",
+ "This system does not support OpenGL/framebuffer objects.");
+ return -1;
+ }
+
+ GLWidget widget(0);
+ widget.resize(640, 480);
+ widget.show();
+ return a.exec();
+}
+
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
new file mode 100644
index 0000000..a2d85f5
--- /dev/null
+++ b/examples/opengl/opengl.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += framebufferobject
diff --git a/examples/painting/painting.pro b/examples/painting/painting.pro
new file mode 100644
index 0000000..1f1e54b
--- /dev/null
+++ b/examples/painting/painting.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += svgviewer svggenerator
diff --git a/examples/painting/svggenerator/displaywidget.cpp b/examples/painting/svggenerator/displaywidget.cpp
new file mode 100644
index 0000000..b99aa1f
--- /dev/null
+++ b/examples/painting/svggenerator/displaywidget.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "displaywidget.h"
+
+DisplayWidget::DisplayWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QPainterPath car;
+ QPainterPath house;
+
+ QFile file(":resources/shapes.dat");
+ file.open(QFile::ReadOnly);
+ QDataStream stream(&file);
+ stream >> car >> house >> tree >> moon;
+ file.close();
+
+ shapeMap[Car] = car;
+ shapeMap[House] = house;
+
+ background = Sky;
+ shapeColor = Qt::darkYellow;
+ shape = House;
+}
+
+//! [paint event]
+void DisplayWidget::paintEvent(QPaintEvent * /* event */)
+{
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ paint(painter);
+ painter.end();
+}
+//! [paint event]
+
+//! [paint function]
+void DisplayWidget::paint(QPainter &painter)
+{
+//![paint picture]
+ painter.setClipRect(QRect(0, 0, 200, 200));
+ painter.setPen(Qt::NoPen);
+
+ switch (background) {
+ case Sky:
+ default:
+ painter.fillRect(QRect(0, 0, 200, 200), Qt::darkBlue);
+ painter.translate(145, 10);
+ painter.setBrush(Qt::white);
+ painter.drawPath(moon);
+ painter.translate(-145, -10);
+ break;
+ case Trees:
+ {
+ painter.fillRect(QRect(0, 0, 200, 200), Qt::darkGreen);
+ painter.setBrush(Qt::green);
+ painter.setPen(Qt::black);
+ for (int y = -55, row = 0; y < 200; y += 50, ++row) {
+ int xs;
+ if (row == 2 || row == 3)
+ xs = 150;
+ else
+ xs = 50;
+ for (int x = 0; x < 200; x += xs) {
+ painter.save();
+ painter.translate(x, y);
+ painter.drawPath(tree);
+ painter.restore();
+ }
+ }
+ break;
+ }
+ case Road:
+ painter.fillRect(QRect(0, 0, 200, 200), Qt::gray);
+ painter.setPen(QPen(Qt::white, 4, Qt::DashLine));
+ painter.drawLine(QLine(0, 35, 200, 35));
+ painter.drawLine(QLine(0, 165, 200, 165));
+ break;
+ }
+
+ painter.setBrush(shapeColor);
+ painter.setPen(Qt::black);
+ painter.translate(100, 100);
+ painter.drawPath(shapeMap[shape]);
+//![paint picture]
+}
+//! [paint function]
+
+QColor DisplayWidget::color() const
+{
+ return shapeColor;
+}
+
+void DisplayWidget::setBackground(Background background)
+{
+ this->background = background;
+ update();
+}
+
+void DisplayWidget::setColor(const QColor &color)
+{
+ this->shapeColor = color;
+ update();
+}
+
+void DisplayWidget::setShape(Shape shape)
+{
+ this->shape = shape;
+ update();
+}
diff --git a/examples/painting/svggenerator/displaywidget.h b/examples/painting/svggenerator/displaywidget.h
new file mode 100644
index 0000000..9252f48
--- /dev/null
+++ b/examples/painting/svggenerator/displaywidget.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DISPLAYWIDGET_H
+#define DISPLAYWIDGET_H
+
+#include <QColor>
+#include <QHash>
+#include <QWidget>
+
+//! [DisplayWidget class definition]
+class DisplayWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ enum Shape { House = 0, Car = 1 };
+ enum Background { Sky = 0, Trees = 1, Road = 2 };
+
+ DisplayWidget(QWidget *parent = 0);
+ QColor color() const;
+ void paint(QPainter &painter);
+
+public slots:
+ void setBackground(Background background);
+ void setColor(const QColor &color);
+ void setShape(Shape shape);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ Background background;
+ QColor shapeColor;
+ Shape shape;
+ QHash<Shape,QPainterPath> shapeMap;
+ QPainterPath moon;
+ QPainterPath tree;
+};
+//! [DisplayWidget class definition]
+
+#endif
diff --git a/examples/painting/svggenerator/forms/window.ui b/examples/painting/svggenerator/forms/window.ui
new file mode 100644
index 0000000..bf11908
--- /dev/null
+++ b/examples/painting/svggenerator/forms/window.ui
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Window</class>
+ <widget class="QWidget" name="Window">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>339</width>
+ <height>353</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>SVG Generator</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item row="0" column="0">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1">
+ <widget class="DisplayWidget" name="displayWidget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>200</horstretch>
+ <verstretch>200</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" colspan="3">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>&amp;Shape:</string>
+ </property>
+ <property name="buddy">
+ <cstring>shapeComboBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="shapeComboBox">
+ <item>
+ <property name="text">
+ <string>House</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Car</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>&amp;Color:</string>
+ </property>
+ <property name="buddy">
+ <cstring>colorButton</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QToolButton" name="colorButton">
+ <property name="text">
+ <string>Choose Color...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>&amp;Background:</string>
+ </property>
+ <property name="buddy">
+ <cstring>shapeComboBox_2</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="shapeComboBox_2">
+ <item>
+ <property name="text">
+ <string>Sky</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Trees</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Road</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="toolButton_2">
+ <property name="text">
+ <string>Save &amp;As...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>DisplayWidget</class>
+ <extends>QWidget</extends>
+ <header>displaywidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>shapeComboBox</sender>
+ <signal>currentIndexChanged(int)</signal>
+ <receiver>Window</receiver>
+ <slot>updateShape(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>288</x>
+ <y>232</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>336</x>
+ <y>234</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>colorButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Window</receiver>
+ <slot>updateColor()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>301</x>
+ <y>262</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>337</x>
+ <y>267</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>shapeComboBox_2</sender>
+ <signal>currentIndexChanged(int)</signal>
+ <receiver>Window</receiver>
+ <slot>updateBackground(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>306</x>
+ <y>299</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>337</x>
+ <y>311</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>toolButton_2</sender>
+ <signal>clicked()</signal>
+ <receiver>Window</receiver>
+ <slot>saveSvg()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>298</x>
+ <y>336</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>307</x>
+ <y>348</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>updateBackground(int)</slot>
+ <slot>updateColor()</slot>
+ <slot>updateShape(int)</slot>
+ <slot>saveSvg()</slot>
+ </slots>
+</ui>
diff --git a/examples/painting/svggenerator/main.cpp b/examples/painting/svggenerator/main.cpp
new file mode 100644
index 0000000..f2079f5
--- /dev/null
+++ b/examples/painting/svggenerator/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window window;
+ window.show();
+ return app.exec();
+}
diff --git a/examples/painting/svggenerator/resources/shapes.dat b/examples/painting/svggenerator/resources/shapes.dat
new file mode 100644
index 0000000..d9b981e
--- /dev/null
+++ b/examples/painting/svggenerator/resources/shapes.dat
Binary files differ
diff --git a/examples/painting/svggenerator/svggenerator.pro b/examples/painting/svggenerator/svggenerator.pro
new file mode 100644
index 0000000..074780a
--- /dev/null
+++ b/examples/painting/svggenerator/svggenerator.pro
@@ -0,0 +1,22 @@
+FORMS = forms/window.ui
+HEADERS = displaywidget.h \
+ window.h
+RESOURCES = svggenerator.qrc
+SOURCES = displaywidget.cpp \
+ main.cpp \
+ window.cpp
+
+QT += svg
+
+INCLUDEPATH += $$PWD
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/painting/svggenerator
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS svggenerator.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/painting/svggenerator
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000CF68
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}
diff --git a/examples/painting/svggenerator/svggenerator.qrc b/examples/painting/svggenerator/svggenerator.qrc
new file mode 100644
index 0000000..061d1f6
--- /dev/null
+++ b/examples/painting/svggenerator/svggenerator.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>resources/shapes.dat</file>
+</qresource>
+</RCC>
diff --git a/examples/painting/svggenerator/window.cpp b/examples/painting/svggenerator/window.cpp
new file mode 100644
index 0000000..f3e950e
--- /dev/null
+++ b/examples/painting/svggenerator/window.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QColorDialog>
+#include <QFileDialog>
+#include <QPainter>
+#include <QSvgGenerator>
+#include "window.h"
+#include "displaywidget.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+}
+
+void Window::updateBackground(int background)
+{
+ displayWidget->setBackground(DisplayWidget::Background(background));
+}
+
+void Window::updateColor()
+{
+ QColor color = QColorDialog::getColor(displayWidget->color());
+ if (color.isValid())
+ displayWidget->setColor(color);
+}
+
+void Window::updateShape(int shape)
+{
+ displayWidget->setShape(DisplayWidget::Shape(shape));
+}
+
+//! [save SVG]
+void Window::saveSvg()
+{
+ QString newPath = QFileDialog::getSaveFileName(this, tr("Save SVG"),
+ path, tr("SVG files (*.svg)"));
+
+ if (newPath.isEmpty())
+ return;
+
+ path = newPath;
+
+//![configure SVG generator]
+ QSvgGenerator generator;
+ generator.setFileName(path);
+ generator.setSize(QSize(200, 200));
+ generator.setViewBox(QRect(0, 0, 200, 200));
+ generator.setTitle(tr("SVG Generator Example Drawing"));
+ generator.setDescription(tr("An SVG drawing created by the SVG Generator "
+ "Example provided with Qt."));
+//![configure SVG generator]
+//![begin painting]
+ QPainter painter;
+ painter.begin(&generator);
+//![begin painting]
+ displayWidget->paint(painter);
+//![end painting]
+ painter.end();
+//![end painting]
+}
+//! [save SVG]
diff --git a/examples/painting/svggenerator/window.h b/examples/painting/svggenerator/window.h
new file mode 100644
index 0000000..6637ec6
--- /dev/null
+++ b/examples/painting/svggenerator/window.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include "ui_window.h"
+
+//! [Window class definition]
+class Window : public QWidget, private Ui::Window
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+public slots:
+ void saveSvg();
+ void updateBackground(int background);
+ void updateColor();
+ void updateShape(int shape);
+
+private:
+ QString path;
+};
+//! [Window class definition]
+
+#endif
diff --git a/examples/painting/svgviewer/files/bubbles.svg b/examples/painting/svgviewer/files/bubbles.svg
new file mode 100644
index 0000000..5173012
--- /dev/null
+++ b/examples/painting/svgviewer/files/bubbles.svg
@@ -0,0 +1,215 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg width="20cm" height="15cm" viewBox="0 0 800 600"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink/"
+ baseProfile="tiny" version="1.2">
+ <title>Spheres</title>
+ <desc>Semi-transparent bubbles on a colored background.</desc>
+ <defs>
+ <!-- Create radial gradients for each bubble. -->
+ <radialGradient id="blueBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#cdcdff" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#cdaacd" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="redBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#ffcdcd" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#bbbb99" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="greenBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#cdffcd" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#99aaaa" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="yellowBubble" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" stop-opacity="1" />
+ <stop offset="25%" stop-color="#ffffcd" stop-opacity=".65" />
+ <stop offset="100%" stop-color="#bbbbaa" stop-opacity=".75" />
+ </radialGradient>
+ <radialGradient id="background" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="400" fx="250" fy="250">
+ <stop offset="0%" stop-color="#ffffee" />
+ <stop offset="100%" stop-color="#ccccaa" />
+ </radialGradient>
+ <linearGradient id="surface" gradientUnits="userSpaceOnUse"
+ x1="-100" y1="200" x2="400" y2="200">
+ <stop offset="0%" stop-color="#ffffcc" />
+ <stop offset="100%" stop-color="#bbbb88" />
+ </linearGradient>
+
+ <!-- Create radial gradients for each circle to make them look like
+ spheres. -->
+ <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="blue" />
+ <stop offset="100%" stop-color="#222244" />
+ </radialGradient>
+ <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="red" />
+ <stop offset="100%" stop-color="#442222" />
+ </radialGradient>
+ <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="green" />
+ <stop offset="100%" stop-color="#113311" />
+ </radialGradient>
+ <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="yellow" />
+ <stop offset="100%" stop-color="#444422" />
+ </radialGradient>
+ <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="50">
+ <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+ <stop offset="100%" stop-color="black" stop-opacity="0.0" />
+ </radialGradient>
+
+ <!-- Define a shadow for each sphere. -->
+ <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" />
+ <g id="bubble">
+ <circle fill="black" cx="0" cy="0" r="50" />
+ <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+ <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+ L -11,22 L -1,12 Z" />
+ <circle cx="0" cy="0" r="100" />
+ </g>
+ </defs>
+ <g>
+ <rect fill="url(#background)" x="0" y="0" width="800" height="600" />
+ </g>
+
+ <g transform="translate(200,700)">
+ <use xlink:href="#bubble" fill="url(#blueBubble)" />
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(315,700)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#bubble" fill="url(#redBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(80,700)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#bubble" fill="url(#greenBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(255,700)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(565,700)">
+ <g transform="scale(0.4,0.4)">
+ <use xlink:href="#bubble" fill="url(#blueBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(715,700)">
+ <g transform="scale(0.6,0.6)">
+ <use xlink:href="#bubble" fill="url(#redBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(645,700)">
+ <g transform="scale(0.375,0.375)">
+ <use xlink:href="#bubble" fill="url(#greenBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(555,700)">
+ <g transform="scale(0.9,0.9)">
+ <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" />
+ </g>
+
+ <g transform="translate(360,700)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#bubble" fill="url(#blueBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(215,700)">
+ <g transform="scale(0.45,0.45)">
+ <use xlink:href="#bubble" fill="url(#redBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(420,700)">
+ <g transform="scale(0.75,0.75)">
+ <use xlink:href="#bubble" fill="url(#greenBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(815,700)">
+ <g transform="scale(0.6,0.6)">
+ <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+ </g>
+ <animateTransform attributeName="transform" type="translate" additive="sum"
+ values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" />
+ </g>
+
+ <g transform="translate(225,375)" >
+ <g transform="scale(1.0,0.5)" >
+ <path d="M 0 0 L 350 0 L 450 450 L -100 450 z"
+ fill="url(#surface)" stroke="none" />
+ </g>
+ </g>
+ <g transform="translate(200,0)" >
+ <g transform="translate(200,490) scale(2.0,1.0) rotate(45)" >
+ <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" />
+ <circle fill="black" cx="0" cy="0" r="50" />
+ <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+ <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+ L -11,22 L -1,12 Z" />
+ <animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360"
+ begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" />
+ </g>
+ <g transform="translate(200,375)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+ </g>
+ <g transform="translate(315,440)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(80,475)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(255,525)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/examples/painting/svgviewer/files/cubic.svg b/examples/painting/svgviewer/files/cubic.svg
new file mode 100644
index 0000000..492bb72
--- /dev/null
+++ b/examples/painting/svgviewer/files/cubic.svg
@@ -0,0 +1,77 @@
+<?xml version="1.0" standalone="no"?>
+<svg width="10cm" height="10cm" viewBox="0 0 1000 1000"
+ xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny">
+ <title>Example cubic02 - cubic Bezier commands in path data</title>
+ <desc>Picture showing examples of "C" and "S" commands,
+ along with annotations showing the control points
+ and end points</desc>
+
+ <rect fill="none" stroke="blue" stroke-width="1" x="1" y="1" width="998" height="998" />
+
+ <!-- Path 1 -->
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="100,200 100,100" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="400,100 400,200" />
+ <path fill="none" stroke="red" stroke-width="5" d="M100,200 C100,100 400,100 400,200" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="100" cy="200" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="400" cy="200" r="10" />
+ <circle class="CtlPoint" cx="100" cy="100" r="10" />
+ <circle class="CtlPoint" cx="400" cy="100" r="10" />
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="250" y="275">M100,200 C100,100 400,100 400,200</text>
+
+ <!-- Path 2 -->
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="100,500 25,400" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="475,400 400,500" />
+ <path fill="none" stroke="red" stroke-width="5" d="M100,500 C25,400 475,400 400,500" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="100" cy="500" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="400" cy="500" r="10" />
+ <circle fill="#888888" stroke="none" cx="25" cy="400" r="10" />
+ <circle fill="#888888" stroke="none" cx="475" cy="400" r="10" />
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="250" y="575">M100,500 C25,400 475,400 400,500</text>
+
+ <!-- Path 3 -->
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="100,800 175,700" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="325,700 400,800" />
+ <path fill="none" stroke="red" stroke-width="5" d="M100,800 C175,700 325,700 400,800" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="100" cy="800" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="400" cy="800" r="10" />
+ <circle fill="#888888" stroke="none" cx="175" cy="700" r="10" />
+ <circle fill="#888888" stroke="none" cx="325" cy="700" r="10" />
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="250" y="875">M100,800 C175,700 325,700 400,800</text>
+
+ <!-- Path 4 -->
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="600,200 675,100" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="975,100 900,200" />
+ <path fill="none" stroke="red" stroke-width="5" d="M600,200 C675,100 975,100 900,200" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="600" cy="200" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="900" cy="200" r="10" />
+ <circle fill="#888888" stroke="none" cx="675" cy="100" r="10" />
+ <circle fill="#888888" stroke="none" cx="975" cy="100" r="10" />
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="275">M600,200 C675,100 975,100 900,200</text>
+
+ <!-- Path 5 -->
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="600,500 600,350" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="900,650 900,500" />
+ <path fill="none" stroke="red" stroke-width="5" d="M600,500 C600,350 900,650 900,500" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="600" cy="500" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="900" cy="500" r="10" />
+ <circle fill="#888888" stroke="none" cx="600" cy="350" r="10" />
+ <circle fill="#888888" stroke="none" cx="900" cy="650" r="10" />
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="575">M600,500 C600,350 900,650 900,500</text>
+
+ <!-- Path 6 (C and S command) -->
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="600,800 625,700" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="725,700 750,800" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="750,800 775,900" />
+ <polyline fill="none" stroke="#888888" stroke-width="2" points="875,900 900,800" />
+ <path fill="none" stroke="red" stroke-width="5" d="M600,800 C625,700 725,700 750,800
+ S875,900 900,800" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="600" cy="800" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="750" cy="800" r="10" />
+ <circle fill="none" stroke="#888888" stroke-width="2" cx="900" cy="800" r="10" />
+ <circle fill="#888888" stroke="none" cx="625" cy="700" r="10" />
+ <circle fill="#888888" stroke="none" cx="725" cy="700" r="10" />
+ <circle fill="#888888" stroke="none" cx="875" cy="900" r="10" />
+ <circle fill="none" stroke="blue" stroke-width="4" cx="775" cy="900" r="9" />
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="945">M600,800 C625,700 725,700 750,800</text>
+ <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="975">S875,900 900,800</text>
+</svg>
diff --git a/examples/painting/svgviewer/files/spheres.svg b/examples/painting/svgviewer/files/spheres.svg
new file mode 100644
index 0000000..b23164b
--- /dev/null
+++ b/examples/painting/svgviewer/files/spheres.svg
@@ -0,0 +1,72 @@
+<?xml version="1.0" standalone="no"?>
+<svg width="8cm" height="8cm" viewBox="0 0 400 400"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink/"
+ baseProfile="tiny" version="1.2">
+ <title>Spheres</title>
+ <desc>Gradient filled spheres with different colors.</desc>
+ <defs>
+ <!-- Create radial gradients for each circle to make them look like
+ spheres. -->
+ <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="blue" />
+ <stop offset="100%" stop-color="#222244" />
+ </radialGradient>
+ <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="red" />
+ <stop offset="100%" stop-color="#442222" />
+ </radialGradient>
+ <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="green" />
+ <stop offset="100%" stop-color="#113311" />
+ </radialGradient>
+ <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="yellow" />
+ <stop offset="100%" stop-color="#444422" />
+ </radialGradient>
+ <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="50">
+ <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+ <stop offset="100%" stop-color="white" stop-opacity="0.0" />
+ </radialGradient>
+
+ <!-- Define a shadow for each sphere. -->
+ <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" />
+ </defs>
+ <g fill="#ffee99" stroke="none" >
+ <rect x="0" y="0" width="400" height="400" />
+ </g>
+ <g fill="white" stroke="none" >
+ <rect x="0" y="175" width="400" height="225" />
+ </g>
+ <g transform="translate(200,175)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+ </g>
+ <g transform="translate(315,240)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(80,275)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(255,325)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+</svg>
diff --git a/examples/painting/svgviewer/main.cpp b/examples/painting/svgviewer/main.cpp
new file mode 100644
index 0000000..de5cc09
--- /dev/null
+++ b/examples/painting/svgviewer/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QString>
+#ifndef QT_NO_OPENGL
+#include <QGLFormat>
+#endif
+
+#include "mainwindow.h"
+
+int main(int argc, char **argv)
+{
+ Q_INIT_RESOURCE(svgviewer);
+
+ QApplication app(argc, argv);
+
+ MainWindow window;
+ if (argc == 2)
+ window.openFile(argv[1]);
+ else
+ window.openFile(":/files/bubbles.svg");
+ window.show();
+ return app.exec();
+}
diff --git a/examples/painting/svgviewer/mainwindow.cpp b/examples/painting/svgviewer/mainwindow.cpp
new file mode 100644
index 0000000..3821e51
--- /dev/null
+++ b/examples/painting/svgviewer/mainwindow.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+
+#include <QtGui>
+
+#include "svgview.h"
+
+MainWindow::MainWindow()
+ : QMainWindow()
+ , m_view(new SvgView)
+{
+ QMenu *fileMenu = new QMenu(tr("&File"), this);
+ QAction *openAction = fileMenu->addAction(tr("&Open..."));
+ openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcuts(QKeySequence::Quit);
+
+ menuBar()->addMenu(fileMenu);
+
+ QMenu *viewMenu = new QMenu(tr("&View"), this);
+ m_backgroundAction = viewMenu->addAction(tr("&Background"));
+ m_backgroundAction->setEnabled(false);
+ m_backgroundAction->setCheckable(true);
+ m_backgroundAction->setChecked(false);
+ connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool)));
+
+ m_outlineAction = viewMenu->addAction(tr("&Outline"));
+ m_outlineAction->setEnabled(false);
+ m_outlineAction->setCheckable(true);
+ m_outlineAction->setChecked(true);
+ connect(m_outlineAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewOutline(bool)));
+
+ menuBar()->addMenu(viewMenu);
+
+ QMenu *rendererMenu = new QMenu(tr("&Renderer"), this);
+ m_nativeAction = rendererMenu->addAction(tr("&Native"));
+ m_nativeAction->setCheckable(true);
+ m_nativeAction->setChecked(true);
+#ifndef QT_NO_OPENGL
+ m_glAction = rendererMenu->addAction(tr("&OpenGL"));
+ m_glAction->setCheckable(true);
+#endif
+ m_imageAction = rendererMenu->addAction(tr("&Image"));
+ m_imageAction->setCheckable(true);
+
+#ifndef QT_NO_OPENGL
+ rendererMenu->addSeparator();
+ m_highQualityAntialiasingAction = rendererMenu->addAction(tr("&High Quality Antialiasing"));
+ m_highQualityAntialiasingAction->setEnabled(false);
+ m_highQualityAntialiasingAction->setCheckable(true);
+ m_highQualityAntialiasingAction->setChecked(false);
+ connect(m_highQualityAntialiasingAction, SIGNAL(toggled(bool)), m_view, SLOT(setHighQualityAntialiasing(bool)));
+#endif
+
+ QActionGroup *rendererGroup = new QActionGroup(this);
+ rendererGroup->addAction(m_nativeAction);
+#ifndef QT_NO_OPENGL
+ rendererGroup->addAction(m_glAction);
+#endif
+ rendererGroup->addAction(m_imageAction);
+
+ menuBar()->addMenu(rendererMenu);
+
+ connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(rendererGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(setRenderer(QAction*)));
+
+ setCentralWidget(m_view);
+ setWindowTitle(tr("SVG Viewer"));
+}
+
+void MainWindow::openFile(const QString &path)
+{
+ QString fileName;
+ if (path.isNull())
+ fileName = QFileDialog::getOpenFileName(this, tr("Open SVG File"),
+ m_currentPath, "SVG files (*.svg *.svgz *.svg.gz)");
+ else
+ fileName = path;
+
+ if (!fileName.isEmpty()) {
+ QFile file(fileName);
+ if (!file.exists()) {
+ QMessageBox::critical(this, tr("Open SVG File"),
+ QString("Could not open file '%1'.").arg(fileName));
+
+ m_outlineAction->setEnabled(false);
+ m_backgroundAction->setEnabled(false);
+ return;
+ }
+
+ m_view->openFile(file);
+
+ if (!fileName.startsWith(":/")) {
+ m_currentPath = fileName;
+ setWindowTitle(tr("%1 - SVGViewer").arg(m_currentPath));
+ }
+
+ m_outlineAction->setEnabled(true);
+ m_backgroundAction->setEnabled(true);
+
+ resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
+ }
+}
+
+void MainWindow::setRenderer(QAction *action)
+{
+#ifndef QT_NO_OPENGL
+ m_highQualityAntialiasingAction->setEnabled(false);
+#endif
+
+ if (action == m_nativeAction)
+ m_view->setRenderer(SvgView::Native);
+#ifndef QT_NO_OPENGL
+ else if (action == m_glAction) {
+ m_highQualityAntialiasingAction->setEnabled(true);
+ m_view->setRenderer(SvgView::OpenGL);
+ }
+#endif
+ else if (action == m_imageAction) {
+ m_view->setRenderer(SvgView::Image);
+ }
+}
diff --git a/examples/painting/svgviewer/mainwindow.h b/examples/painting/svgviewer/mainwindow.h
new file mode 100644
index 0000000..eaf72e0
--- /dev/null
+++ b/examples/painting/svgviewer/mainwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QString>
+
+class SvgView;
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QGraphicsView;
+class QGraphicsScene;
+class QGraphicsRectItem;
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void openFile(const QString &path = QString());
+ void setRenderer(QAction *action);
+
+private:
+ QAction *m_nativeAction;
+ QAction *m_glAction;
+ QAction *m_imageAction;
+ QAction *m_highQualityAntialiasingAction;
+ QAction *m_backgroundAction;
+ QAction *m_outlineAction;
+
+ SvgView *m_view;
+
+ QString m_currentPath;
+};
+
+#endif
diff --git a/examples/painting/svgviewer/svgview.cpp b/examples/painting/svgviewer/svgview.cpp
new file mode 100644
index 0000000..18f0821
--- /dev/null
+++ b/examples/painting/svgviewer/svgview.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "svgview.h"
+
+#include <QFile>
+#include <QWheelEvent>
+#include <QMouseEvent>
+#include <QGraphicsRectItem>
+#include <QGraphicsSvgItem>
+#include <QPaintEvent>
+#include <qmath.h>
+
+#ifndef QT_NO_OPENGL
+#include <QGLWidget>
+#endif
+
+SvgView::SvgView(QWidget *parent)
+ : QGraphicsView(parent)
+ , m_renderer(Native)
+ , m_svgItem(0)
+ , m_backgroundItem(0)
+ , m_outlineItem(0)
+{
+ setScene(new QGraphicsScene(this));
+ setTransformationAnchor(AnchorUnderMouse);
+ setDragMode(ScrollHandDrag);
+ setViewportUpdateMode(FullViewportUpdate);
+
+ // Prepare background check-board pattern
+ QPixmap tilePixmap(64, 64);
+ tilePixmap.fill(Qt::white);
+ QPainter tilePainter(&tilePixmap);
+ QColor color(220, 220, 220);
+ tilePainter.fillRect(0, 0, 32, 32, color);
+ tilePainter.fillRect(32, 32, 32, 32, color);
+ tilePainter.end();
+
+ setBackgroundBrush(tilePixmap);
+}
+
+void SvgView::drawBackground(QPainter *p, const QRectF &)
+{
+ p->save();
+ p->resetTransform();
+ p->drawTiledPixmap(viewport()->rect(), backgroundBrush().texture());
+ p->restore();
+}
+
+void SvgView::openFile(const QFile &file)
+{
+ if (!file.exists())
+ return;
+
+ QGraphicsScene *s = scene();
+
+ bool drawBackground = (m_backgroundItem ? m_backgroundItem->isVisible() : false);
+ bool drawOutline = (m_outlineItem ? m_outlineItem->isVisible() : true);
+
+ s->clear();
+ resetTransform();
+
+ m_svgItem = new QGraphicsSvgItem(file.fileName());
+ m_svgItem->setFlags(QGraphicsItem::ItemClipsToShape);
+ m_svgItem->setCacheMode(QGraphicsItem::NoCache);
+ m_svgItem->setZValue(0);
+
+ m_backgroundItem = new QGraphicsRectItem(m_svgItem->boundingRect());
+ m_backgroundItem->setBrush(Qt::white);
+ m_backgroundItem->setPen(Qt::NoPen);
+ m_backgroundItem->setVisible(drawBackground);
+ m_backgroundItem->setZValue(-1);
+
+ m_outlineItem = new QGraphicsRectItem(m_svgItem->boundingRect());
+ QPen outline(Qt::black, 2, Qt::DashLine);
+ outline.setCosmetic(true);
+ m_outlineItem->setPen(outline);
+ m_outlineItem->setBrush(Qt::NoBrush);
+ m_outlineItem->setVisible(drawOutline);
+ m_outlineItem->setZValue(1);
+
+ s->addItem(m_backgroundItem);
+ s->addItem(m_svgItem);
+ s->addItem(m_outlineItem);
+
+ s->setSceneRect(m_outlineItem->boundingRect().adjusted(-10, -10, 10, 10));
+}
+
+void SvgView::setRenderer(RendererType type)
+{
+ m_renderer = type;
+
+ if (m_renderer == OpenGL) {
+#ifndef QT_NO_OPENGL
+ setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
+#endif
+ } else {
+ setViewport(new QWidget);
+ }
+}
+
+void SvgView::setHighQualityAntialiasing(bool highQualityAntialiasing)
+{
+#ifndef QT_NO_OPENGL
+ setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing);
+#else
+ Q_UNUSED(highQualityAntialiasing);
+#endif
+}
+
+void SvgView::setViewBackground(bool enable)
+{
+ if (!m_backgroundItem)
+ return;
+
+ m_backgroundItem->setVisible(enable);
+}
+
+void SvgView::setViewOutline(bool enable)
+{
+ if (!m_outlineItem)
+ return;
+
+ m_outlineItem->setVisible(enable);
+}
+
+void SvgView::paintEvent(QPaintEvent *event)
+{
+ if (m_renderer == Image) {
+ if (m_image.size() != viewport()->size()) {
+ m_image = QImage(viewport()->size(), QImage::Format_ARGB32_Premultiplied);
+ }
+
+ QPainter imagePainter(&m_image);
+ QGraphicsView::render(&imagePainter);
+ imagePainter.end();
+
+ QPainter p(viewport());
+ p.drawImage(0, 0, m_image);
+
+ } else {
+ QGraphicsView::paintEvent(event);
+ }
+}
+
+void SvgView::wheelEvent(QWheelEvent *event)
+{
+ qreal factor = qPow(1.2, event->delta() / 240.0);
+ scale(factor, factor);
+ event->accept();
+}
+
diff --git a/examples/painting/svgviewer/svgview.h b/examples/painting/svgviewer/svgview.h
new file mode 100644
index 0000000..a9e24f0
--- /dev/null
+++ b/examples/painting/svgviewer/svgview.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SVGVIEW_H
+#define SVGVIEW_H
+
+#include <QGraphicsView>
+
+QT_BEGIN_NAMESPACE
+class QWheelEvent;
+class QPaintEvent;
+class QFile;
+QT_END_NAMESPACE
+
+class SvgView : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ enum RendererType { Native, OpenGL, Image };
+
+ SvgView(QWidget *parent = 0);
+
+ void openFile(const QFile &file);
+ void setRenderer(RendererType type = Native);
+ void drawBackground(QPainter *p, const QRectF &rect);
+
+public slots:
+ void setHighQualityAntialiasing(bool highQualityAntialiasing);
+ void setViewBackground(bool enable);
+ void setViewOutline(bool enable);
+
+protected:
+ void wheelEvent(QWheelEvent *event);
+ void paintEvent(QPaintEvent *event);
+
+private:
+ RendererType m_renderer;
+
+ QGraphicsItem *m_svgItem;
+ QGraphicsRectItem *m_backgroundItem;
+ QGraphicsRectItem *m_outlineItem;
+
+ QImage m_image;
+};
+#endif // SVGVIEW_H
diff --git a/examples/painting/svgviewer/svgviewer.pro b/examples/painting/svgviewer/svgviewer.pro
new file mode 100644
index 0000000..d82c58b
--- /dev/null
+++ b/examples/painting/svgviewer/svgviewer.pro
@@ -0,0 +1,31 @@
+HEADERS = mainwindow.h \
+ svgview.h
+RESOURCES = svgviewer.qrc
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ svgview.cpp
+QT += svg xml
+
+contains(QT_CONFIG, opengl): QT += opengl
+
+CONFIG += console
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/painting/svgviewer
+sources.files = $$SOURCES $$HEADERS $$RESOURCES svgviewer.pro files
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/painting/svgviewer
+INSTALLS += target sources
+
+wince*: {
+ addFiles.files = files\\*.svg
+ addFiles.path = "\\My Documents"
+ DEPLOYMENT += addFiles
+}
+
+symbian: {
+ TARGET.UID3 = 0xA000A64E
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+ addFiles.files = files\\*.svg
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+}
diff --git a/examples/painting/svgviewer/svgviewer.qrc b/examples/painting/svgviewer/svgviewer.qrc
new file mode 100644
index 0000000..db611f5
--- /dev/null
+++ b/examples/painting/svgviewer/svgviewer.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>files/bubbles.svg</file>
+</qresource>
+</RCC>
+
diff --git a/examples/richtext/richtext.pro b/examples/richtext/richtext.pro
new file mode 100644
index 0000000..5bc54f9
--- /dev/null
+++ b/examples/richtext/richtext.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += textobject
diff --git a/examples/richtext/textobject/files/heart.svg b/examples/richtext/textobject/files/heart.svg
new file mode 100644
index 0000000..ba5f050
--- /dev/null
+++ b/examples/richtext/textobject/files/heart.svg
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) --><svg viewBox="100 200 550 500" height="595.27559pt" id="svg1" inkscape:version="0.40+cvs" sodipodi:docbase="C:\Documents and Settings\Jon Phillips\My Documents\projects\clipart-project\submissions" sodipodi:docname="heart-left-highlight.svg" sodipodi:version="0.32" width="595.27559pt" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
+<metadata>
+<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<cc:Work rdf:about="">
+<dc:title>Heart Left-Highlight</dc:title>
+<dc:description>This is a normal valentines day heart.</dc:description>
+<dc:subject>
+<rdf:Bag>
+<rdf:li>holiday</rdf:li>
+<rdf:li>valentines</rdf:li>
+<rdf:li></rdf:li>
+<rdf:li>valentine</rdf:li>
+<rdf:li>hash(0x8a091c0)</rdf:li>
+<rdf:li>hash(0x8a0916c)</rdf:li>
+<rdf:li>signs_and_symbols</rdf:li>
+<rdf:li>hash(0x8a091f0)</rdf:li>
+<rdf:li>day</rdf:li>
+</rdf:Bag>
+</dc:subject>
+<dc:publisher>
+<cc:Agent rdf:about="http://www.openclipart.org">
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:publisher>
+<dc:creator>
+<cc:Agent>
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:creator>
+<dc:rights>
+<cc:Agent>
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:rights>
+<dc:date></dc:date>
+<dc:format>image/svg+xml</dc:format>
+<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
+<dc:language>en</dc:language>
+</cc:Work>
+<cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+</cc:License>
+</rdf:RDF>
+</metadata>
+<defs id="defs3"/>
+<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="layer1" inkscape:cx="549.40674" inkscape:cy="596.00159" inkscape:document-units="px" inkscape:guide-bbox="true" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="615" inkscape:window-width="866" inkscape:window-x="88" inkscape:window-y="116" inkscape:zoom="0.35000000" pagecolor="#ffffff" showguides="true"/>
+<g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1">
+<path d="M 263.41570,235.14588 C 197.17570,235.14588 143.41575,288.90587 143.41575,355.14588 C 143.41575,489.90139 279.34890,525.23318 371.97820,658.45392 C 459.55244,526.05056 600.54070,485.59932 600.54070,355.14588 C 600.54070,288.90588 546.78080,235.14587 480.54070,235.14588 C 432.49280,235.14588 391.13910,263.51631 371.97820,304.33338 C 352.81740,263.51630 311.46370,235.14587 263.41570,235.14588 z " id="path7" sodipodi:nodetypes="ccccccc" style="fill:#e60000;fill-opacity:1.0000000;stroke:#000000;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
+<path d="M 265.00000,253.59375 C 207.04033,253.59375 160.00000,300.63407 160.00000,358.59375 C 160.00000,476.50415 278.91857,507.43251 359.96875,624.00000 C 366.52868,614.08205 220.00000,478.47309 220.00000,378.59375 C 220.00000,320.63407 267.04033,273.59375 325.00000,273.59375 C 325.50453,273.59375 325.99718,273.64912 326.50000,273.65625 C 309.22436,261.07286 288.00557,253.59374 265.00000,253.59375 z " id="path220" sodipodi:nodetypes="ccccccc" style="fill:#e6e6e6;fill-opacity:0.64556962;stroke:none;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
+</g>
+</svg>
diff --git a/examples/richtext/textobject/main.cpp b/examples/richtext/textobject/main.cpp
new file mode 100644
index 0000000..2b95252
--- /dev/null
+++ b/examples/richtext/textobject/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ Window window;
+ window.show();
+
+ return app.exec();
+}
+
diff --git a/examples/richtext/textobject/svgtextobject.cpp b/examples/richtext/textobject/svgtextobject.cpp
new file mode 100644
index 0000000..57d7fcc
--- /dev/null
+++ b/examples/richtext/textobject/svgtextobject.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtSvg>
+
+#include "svgtextobject.h"
+#include "window.h"
+
+//![0]
+QSizeF SvgTextObject::intrinsicSize(QTextDocument * /*doc*/, int /*posInDocument*/,
+ const QTextFormat &format)
+{
+ QImage bufferedImage = qvariant_cast<QImage>(format.property(Window::SvgData));
+ QSize size = bufferedImage.size();
+
+ if (size.height() > 25)
+ size *= 25.0 / (double) size.height();
+
+ return QSizeF(size);
+}
+//![0]
+
+//![1]
+void SvgTextObject::drawObject(QPainter *painter, const QRectF &rect,
+ QTextDocument * /*doc*/, int /*posInDocument*/,
+ const QTextFormat &format)
+{
+ QImage bufferedImage = qvariant_cast<QImage>(format.property(Window::SvgData));
+
+ painter->drawImage(rect, bufferedImage);
+}
+//![1]
+
diff --git a/examples/richtext/textobject/svgtextobject.h b/examples/richtext/textobject/svgtextobject.h
new file mode 100644
index 0000000..06865b1
--- /dev/null
+++ b/examples/richtext/textobject/svgtextobject.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SVGTEXTOBJECT_H
+#define SVGTEXTOBJECT_H
+
+#include <QTextObjectInterface>
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+class QTextFormat;
+class QPainter;
+class QRectF;
+class QSizeF;
+QT_END_NAMESPACE
+
+//![0] //![1]
+class SvgTextObject : public QObject, public QTextObjectInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QTextObjectInterface)
+//![1]
+
+public:
+ QSizeF intrinsicSize(QTextDocument *doc, int posInDocument,
+ const QTextFormat &format);
+ void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc,
+ int posInDocument, const QTextFormat &format);
+};
+//![0]
+
+#endif
diff --git a/examples/richtext/textobject/textobject.pro b/examples/richtext/textobject/textobject.pro
new file mode 100644
index 0000000..70ed427
--- /dev/null
+++ b/examples/richtext/textobject/textobject.pro
@@ -0,0 +1,18 @@
+HEADERS = svgtextobject.h \
+ window.h
+SOURCES = main.cpp \
+ svgtextobject.cpp \
+ window.cpp
+
+QT += svg
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/richtext/textobject
+sources.files = $$SOURCES $$HEADERS *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/richtext/textobject
+INSTALLS += target sources
+
+filesToDeploy.files = files/*.svg
+filesToDeploy.path = files
+DEPLOYMENT += filesToDeploy
+
diff --git a/examples/richtext/textobject/window.cpp b/examples/richtext/textobject/window.cpp
new file mode 100644
index 0000000..7feb918
--- /dev/null
+++ b/examples/richtext/textobject/window.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtSvg>
+
+#include "window.h"
+#include "svgtextobject.h"
+
+Window::Window()
+{
+ setupGui();
+ setupTextObject();
+
+ setWindowTitle("Text Object Example");
+}
+
+//![1]
+void Window::insertTextObject()
+{
+ QString fileName = fileNameLineEdit->text();
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::warning(this, tr("Error Opening File"),
+ tr("Could not open '%1'").arg(fileName));
+ }
+
+ QByteArray svgData = file.readAll();
+//![1]
+
+//![2]
+ QTextCharFormat svgCharFormat;
+ svgCharFormat.setObjectType(SvgTextFormat);
+ QSvgRenderer renderer(svgData);
+
+ QImage svgBufferImage(renderer.defaultSize(), QImage::Format_ARGB32);
+ QPainter painter(&svgBufferImage);
+ renderer.render(&painter, svgBufferImage.rect());
+
+ svgCharFormat.setProperty(SvgData, svgBufferImage);
+
+ QTextCursor cursor = textEdit->textCursor();
+ cursor.insertText(QString(QChar::ObjectReplacementCharacter), svgCharFormat);
+ textEdit->setTextCursor(cursor);
+}
+//![2]
+
+//![3]
+void Window::setupTextObject()
+{
+ QObject *svgInterface = new SvgTextObject;
+ textEdit->document()->documentLayout()->registerHandler(SvgTextFormat, svgInterface);
+}
+//![3]
+
+void Window::setupGui()
+{
+ fileNameLabel = new QLabel(tr("Svg File Name:"));
+ fileNameLineEdit = new QLineEdit;
+ insertTextObjectButton = new QPushButton(tr("Insert Image"));
+
+ fileNameLineEdit->setText("./files/heart.svg");
+ connect(insertTextObjectButton, SIGNAL(clicked()),
+ this, SLOT(insertTextObject()));
+
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ bottomLayout->addWidget(fileNameLabel);
+ bottomLayout->addWidget(fileNameLineEdit);
+ bottomLayout->addWidget(insertTextObjectButton);
+
+ textEdit = new QTextEdit;
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(textEdit);
+ mainLayout->addLayout(bottomLayout);
+
+ setLayout(mainLayout);
+}
+
diff --git a/examples/richtext/textobject/window.h b/examples/richtext/textobject/window.h
new file mode 100644
index 0000000..f6a0793
--- /dev/null
+++ b/examples/richtext/textobject/window.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+#include <QTextFormat>
+
+QT_BEGIN_NAMESPACE
+class QTextEdit;
+class QLineEdit;
+class QPushButton;
+class QLabel;
+QT_END_NAMESPACE
+
+//![0]
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ enum { SvgTextFormat = QTextFormat::UserObject + 1 };
+ enum SvgProperties { SvgData = 1 };
+
+ Window();
+
+private slots:
+ void insertTextObject();
+
+private:
+ void setupTextObject();
+ void setupGui();
+
+private:
+ QTextEdit *textEdit;
+ QLabel *fileNameLabel;
+ QLineEdit *fileNameLineEdit;
+ QPushButton *insertTextObjectButton;
+};
+//![0]
+
+#endif