From 806dda08d685bc5f9ed71dfe8b61f21848d48066 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 17 Aug 2012 13:23:19 +0200 Subject: Moving .qdoc files under examples/widgets/doc Updated those .qdoc files to refer to the new relative examples emplacement. Images and snippets to be moved later. Also grouped all widgets related examples under widgets. Change-Id: Ib29696e2d8948524537f53e8dda88f9ee26a597f Reviewed-by: J-P Nurmi --- examples/animation/README | 8 - .../animation/animatedtiles/animatedtiles.desktop | 11 - examples/animation/animatedtiles/animatedtiles.pro | 10 - examples/animation/animatedtiles/animatedtiles.qrc | 11 - .../animatedtiles/images/Time-For-Lunch-2.jpg | Bin 32471 -> 0 bytes .../animation/animatedtiles/images/centered.png | Bin 892 -> 0 bytes .../animation/animatedtiles/images/ellipse.png | Bin 10767 -> 0 bytes .../animation/animatedtiles/images/figure8.png | Bin 14050 -> 0 bytes .../animation/animatedtiles/images/kinetic.png | Bin 6776 -> 0 bytes examples/animation/animatedtiles/images/random.png | Bin 14969 -> 0 bytes examples/animation/animatedtiles/images/tile.png | Bin 16337 -> 0 bytes examples/animation/animatedtiles/main.cpp | 256 ---- examples/animation/animation.pro | 17 - .../appchooser/accessories-dictionary.png | Bin 5396 -> 0 bytes examples/animation/appchooser/akregator.png | Bin 4873 -> 0 bytes examples/animation/appchooser/appchooser.desktop | 11 - examples/animation/appchooser/appchooser.pro | 10 - examples/animation/appchooser/appchooser.qrc | 8 - examples/animation/appchooser/digikam.png | Bin 3334 -> 0 bytes examples/animation/appchooser/k3b.png | Bin 8220 -> 0 bytes examples/animation/appchooser/main.cpp | 173 --- examples/animation/easing/animation.h | 100 -- examples/animation/easing/easing.desktop | 11 - examples/animation/easing/easing.pro | 17 - examples/animation/easing/easing.qrc | 5 - examples/animation/easing/form.ui | 270 ---- examples/animation/easing/images/qt-logo.png | Bin 5149 -> 0 bytes examples/animation/easing/main.cpp | 54 - examples/animation/easing/window.cpp | 177 --- examples/animation/easing/window.h | 76 - examples/animation/moveblocks/main.cpp | 321 ----- examples/animation/moveblocks/moveblocks.desktop | 11 - examples/animation/moveblocks/moveblocks.pro | 9 - .../animation/states/accessories-dictionary.png | Bin 5396 -> 0 bytes examples/animation/states/akregator.png | Bin 4873 -> 0 bytes examples/animation/states/digikam.png | Bin 3334 -> 0 bytes examples/animation/states/help-browser.png | Bin 6984 -> 0 bytes examples/animation/states/k3b.png | Bin 8220 -> 0 bytes examples/animation/states/kchart.png | Bin 4887 -> 0 bytes examples/animation/states/main.cpp | 285 ---- examples/animation/states/states.desktop | 11 - examples/animation/states/states.pro | 10 - examples/animation/states/states.qrc | 10 - examples/animation/stickman/animation.cpp | 189 --- examples/animation/stickman/animation.h | 82 -- .../animation/stickman/animations/chilling.bin | Bin 6508 -> 0 bytes examples/animation/stickman/animations/dancing.bin | Bin 2348 -> 0 bytes examples/animation/stickman/animations/dead.bin | Bin 268 -> 0 bytes examples/animation/stickman/animations/jumping.bin | Bin 1308 -> 0 bytes examples/animation/stickman/graphicsview.cpp | 60 - examples/animation/stickman/graphicsview.h | 64 - examples/animation/stickman/lifecycle.cpp | 217 --- examples/animation/stickman/lifecycle.h | 80 -- examples/animation/stickman/main.cpp | 106 -- examples/animation/stickman/node.cpp | 92 -- examples/animation/stickman/node.h | 70 - examples/animation/stickman/rectbutton.cpp | 73 - examples/animation/stickman/rectbutton.h | 65 - examples/animation/stickman/stickman.cpp | 337 ----- examples/animation/stickman/stickman.desktop | 11 - examples/animation/stickman/stickman.h | 103 -- examples/animation/stickman/stickman.pro | 23 - examples/animation/stickman/stickman.qrc | 8 - examples/animation/sub-attaq/animationmanager.cpp | 98 -- examples/animation/sub-attaq/animationmanager.h | 73 - examples/animation/sub-attaq/boat.cpp | 272 ---- examples/animation/sub-attaq/boat.h | 95 -- examples/animation/sub-attaq/boat_p.h | 232 --- examples/animation/sub-attaq/bomb.cpp | 118 -- examples/animation/sub-attaq/bomb.h | 67 - examples/animation/sub-attaq/data.xml | 39 - examples/animation/sub-attaq/graphicsscene.cpp | 282 ---- examples/animation/sub-attaq/graphicsscene.h | 122 -- examples/animation/sub-attaq/main.cpp | 57 - examples/animation/sub-attaq/mainwindow.cpp | 82 -- examples/animation/sub-attaq/mainwindow.h | 63 - .../animation/sub-attaq/pics/big/background.png | Bin 48858 -> 0 bytes examples/animation/sub-attaq/pics/big/boat.png | Bin 5198 -> 0 bytes examples/animation/sub-attaq/pics/big/bomb.png | Bin 760 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step1.png | Bin 5760 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step2.png | Bin 9976 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step3.png | Bin 12411 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step4.png | Bin 15438 -> 0 bytes .../pics/big/explosion/submarine/step1.png | Bin 3354 -> 0 bytes .../pics/big/explosion/submarine/step2.png | Bin 6205 -> 0 bytes .../pics/big/explosion/submarine/step3.png | Bin 6678 -> 0 bytes .../pics/big/explosion/submarine/step4.png | Bin 6666 -> 0 bytes .../animation/sub-attaq/pics/big/submarine.png | Bin 3202 -> 0 bytes examples/animation/sub-attaq/pics/big/surface.png | Bin 575 -> 0 bytes examples/animation/sub-attaq/pics/big/torpedo.png | Bin 951 -> 0 bytes .../sub-attaq/pics/scalable/background-n810.svg | 171 --- .../sub-attaq/pics/scalable/background.svg | 171 --- .../animation/sub-attaq/pics/scalable/boat.svg | 279 ---- .../animation/sub-attaq/pics/scalable/bomb.svg | 138 -- .../animation/sub-attaq/pics/scalable/sand.svg | 103 -- examples/animation/sub-attaq/pics/scalable/see.svg | 44 - examples/animation/sub-attaq/pics/scalable/sky.svg | 45 - .../sub-attaq/pics/scalable/sub-attaq.svg | 1473 -------------------- .../sub-attaq/pics/scalable/submarine.svg | 214 --- .../animation/sub-attaq/pics/scalable/surface.svg | 49 - .../animation/sub-attaq/pics/scalable/torpedo.svg | 127 -- .../animation/sub-attaq/pics/small/background.png | Bin 34634 -> 0 bytes examples/animation/sub-attaq/pics/small/boat.png | Bin 2394 -> 0 bytes examples/animation/sub-attaq/pics/small/bomb.png | Bin 760 -> 0 bytes .../animation/sub-attaq/pics/small/submarine.png | Bin 1338 -> 0 bytes .../animation/sub-attaq/pics/small/surface.png | Bin 502 -> 0 bytes .../animation/sub-attaq/pics/small/torpedo.png | Bin 951 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-a.png | Bin 5972 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-a2.png | Bin 5969 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-b.png | Bin 6869 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-dash.png | Bin 2255 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-excl.png | Bin 2740 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-q.png | Bin 7016 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-s.png | Bin 5817 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-t.png | Bin 3717 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-t2.png | Bin 3688 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-u.png | Bin 5374 -> 0 bytes examples/animation/sub-attaq/pixmapitem.cpp | 76 - examples/animation/sub-attaq/pixmapitem.h | 63 - examples/animation/sub-attaq/progressitem.cpp | 67 - examples/animation/sub-attaq/progressitem.h | 61 - examples/animation/sub-attaq/qanimationstate.cpp | 150 -- examples/animation/sub-attaq/qanimationstate.h | 91 -- examples/animation/sub-attaq/states.cpp | 330 ----- examples/animation/sub-attaq/states.h | 180 --- examples/animation/sub-attaq/sub-attaq.pro | 42 - examples/animation/sub-attaq/subattaq.qrc | 39 - examples/animation/sub-attaq/submarine.cpp | 182 --- examples/animation/sub-attaq/submarine.h | 93 -- examples/animation/sub-attaq/submarine_p.h | 137 -- .../animation/sub-attaq/textinformationitem.cpp | 54 - examples/animation/sub-attaq/textinformationitem.h | 55 - examples/animation/sub-attaq/torpedo.cpp | 114 -- examples/animation/sub-attaq/torpedo.h | 67 - examples/desktop/README | 10 - examples/desktop/desktop.pro | 11 - examples/desktop/screenshot/main.cpp | 51 - examples/desktop/screenshot/screenshot.cpp | 199 --- examples/desktop/screenshot/screenshot.desktop | 11 - examples/desktop/screenshot/screenshot.h | 99 -- examples/desktop/screenshot/screenshot.pro | 12 - examples/desktop/systray/images/bad.png | Bin 2496 -> 0 bytes examples/desktop/systray/images/heart.png | Bin 25780 -> 0 bytes examples/desktop/systray/images/trash.png | Bin 12128 -> 0 bytes examples/desktop/systray/main.cpp | 63 - examples/desktop/systray/systray.desktop | 11 - examples/desktop/systray/systray.pro | 14 - examples/desktop/systray/systray.qrc | 7 - examples/desktop/systray/window.cpp | 270 ---- examples/desktop/systray/window.h | 112 -- examples/dialogs/README | 9 - examples/dialogs/classwizard/classwizard.cpp | 430 ------ examples/dialogs/classwizard/classwizard.desktop | 11 - examples/dialogs/classwizard/classwizard.h | 156 --- examples/dialogs/classwizard/classwizard.pro | 13 - examples/dialogs/classwizard/classwizard.qrc | 11 - examples/dialogs/classwizard/images/background.png | Bin 22578 -> 0 bytes examples/dialogs/classwizard/images/banner.png | Bin 3947 -> 0 bytes examples/dialogs/classwizard/images/logo1.png | Bin 1619 -> 0 bytes examples/dialogs/classwizard/images/logo2.png | Bin 1619 -> 0 bytes examples/dialogs/classwizard/images/logo3.png | Bin 1619 -> 0 bytes examples/dialogs/classwizard/images/watermark1.png | Bin 14516 -> 0 bytes examples/dialogs/classwizard/images/watermark2.png | Bin 14912 -> 0 bytes examples/dialogs/classwizard/main.cpp | 63 - examples/dialogs/configdialog/configdialog.cpp | 116 -- examples/dialogs/configdialog/configdialog.desktop | 11 - examples/dialogs/configdialog/configdialog.h | 69 - examples/dialogs/configdialog/configdialog.pro | 17 - examples/dialogs/configdialog/configdialog.qrc | 7 - examples/dialogs/configdialog/images/config.png | Bin 6758 -> 0 bytes examples/dialogs/configdialog/images/query.png | Bin 2116 -> 0 bytes examples/dialogs/configdialog/images/update.png | Bin 7890 -> 0 bytes examples/dialogs/configdialog/main.cpp | 52 - examples/dialogs/configdialog/pages.cpp | 151 -- examples/dialogs/configdialog/pages.h | 64 - examples/dialogs/dialogs.pro | 19 - examples/dialogs/extension/extension.desktop | 11 - examples/dialogs/extension/extension.pro | 12 - examples/dialogs/extension/finddialog.cpp | 114 -- examples/dialogs/extension/finddialog.h | 78 -- examples/dialogs/extension/main.cpp | 53 - examples/dialogs/findfiles/findfiles.desktop | 11 - examples/dialogs/findfiles/findfiles.pro | 11 - examples/dialogs/findfiles/main.cpp | 51 - examples/dialogs/findfiles/window.cpp | 247 ---- examples/dialogs/findfiles/window.h | 90 -- examples/dialogs/licensewizard/images/logo.png | Bin 1810 -> 0 bytes .../dialogs/licensewizard/images/watermark.png | Bin 34998 -> 0 bytes examples/dialogs/licensewizard/licensewizard.cpp | 363 ----- .../dialogs/licensewizard/licensewizard.desktop | 11 - examples/dialogs/licensewizard/licensewizard.h | 163 --- examples/dialogs/licensewizard/licensewizard.pro | 13 - examples/dialogs/licensewizard/licensewizard.qrc | 6 - examples/dialogs/licensewizard/main.cpp | 63 - examples/dialogs/sipdialog/dialog.cpp | 122 -- examples/dialogs/sipdialog/dialog.h | 63 - examples/dialogs/sipdialog/main.cpp | 52 - examples/dialogs/sipdialog/sipdialog.desktop | 11 - examples/dialogs/sipdialog/sipdialog.pro | 15 - examples/dialogs/standarddialogs/dialog.cpp | 471 ------- examples/dialogs/standarddialogs/dialog.h | 101 -- examples/dialogs/standarddialogs/main.cpp | 62 - .../standarddialogs/standarddialogs.desktop | 11 - .../dialogs/standarddialogs/standarddialogs.pro | 13 - examples/dialogs/tabdialog/main.cpp | 59 - examples/dialogs/tabdialog/tabdialog.cpp | 196 --- examples/dialogs/tabdialog/tabdialog.desktop | 11 - examples/dialogs/tabdialog/tabdialog.h | 99 -- examples/dialogs/tabdialog/tabdialog.pro | 12 - examples/dialogs/trivialwizard/trivialwizard.cpp | 135 -- .../dialogs/trivialwizard/trivialwizard.desktop | 11 - examples/dialogs/trivialwizard/trivialwizard.pro | 10 - examples/draganddrop/README | 9 - .../delayedencoding/delayedencoding.desktop | 11 - examples/draganddrop/draganddrop.pro | 13 - .../draggableicons/draggableicons.desktop | 11 - .../draganddrop/draggableicons/draggableicons.pro | 12 - .../draganddrop/draggableicons/draggableicons.qrc | 7 - examples/draganddrop/draggableicons/dragwidget.cpp | 168 --- examples/draganddrop/draggableicons/dragwidget.h | 65 - .../draganddrop/draggableicons/images/boat.png | Bin 2772 -> 0 bytes examples/draganddrop/draggableicons/images/car.png | Bin 2963 -> 0 bytes .../draganddrop/draggableicons/images/house.png | Bin 3292 -> 0 bytes examples/draganddrop/draggableicons/main.cpp | 61 - .../draggabletext/draggabletext.desktop | 11 - .../draganddrop/draggabletext/draggabletext.pro | 15 - .../draganddrop/draggabletext/draggabletext.qrc | 5 - examples/draganddrop/draggabletext/draglabel.cpp | 51 - examples/draganddrop/draggabletext/draglabel.h | 58 - examples/draganddrop/draggabletext/dragwidget.cpp | 165 --- examples/draganddrop/draggabletext/dragwidget.h | 62 - examples/draganddrop/draggabletext/main.cpp | 52 - examples/draganddrop/draggabletext/words.txt | 41 - examples/draganddrop/dropsite/droparea.cpp | 126 -- examples/draganddrop/dropsite/droparea.h | 77 - examples/draganddrop/dropsite/dropsite.desktop | 11 - examples/draganddrop/dropsite/dropsite.pro | 14 - examples/draganddrop/dropsite/dropsitewindow.cpp | 143 -- examples/draganddrop/dropsite/dropsitewindow.h | 77 - examples/draganddrop/dropsite/main.cpp | 53 - examples/draganddrop/fridgemagnets/draglabel.cpp | 89 -- examples/draganddrop/fridgemagnets/draglabel.h | 64 - examples/draganddrop/fridgemagnets/dragwidget.cpp | 212 --- examples/draganddrop/fridgemagnets/dragwidget.h | 65 - .../fridgemagnets/fridgemagnets.desktop | 11 - .../draganddrop/fridgemagnets/fridgemagnets.pro | 15 - .../draganddrop/fridgemagnets/fridgemagnets.qrc | 5 - examples/draganddrop/fridgemagnets/main.cpp | 61 - examples/draganddrop/fridgemagnets/words.txt | 48 - examples/draganddrop/puzzle/example.jpg | Bin 42654 -> 0 bytes examples/draganddrop/puzzle/main.cpp | 54 - examples/draganddrop/puzzle/mainwindow.cpp | 152 -- examples/draganddrop/puzzle/mainwindow.h | 76 - examples/draganddrop/puzzle/pieceslist.cpp | 121 -- examples/draganddrop/puzzle/pieceslist.h | 63 - examples/draganddrop/puzzle/puzzle.desktop | 11 - examples/draganddrop/puzzle/puzzle.pro | 23 - examples/draganddrop/puzzle/puzzle.qrc | 5 - examples/draganddrop/puzzle/puzzlewidget.cpp | 214 --- examples/draganddrop/puzzle/puzzlewidget.h | 89 -- examples/effects/blurpicker/blureffect.cpp | 68 - examples/effects/blurpicker/blureffect.h | 66 - examples/effects/blurpicker/blurpicker.cpp | 161 --- examples/effects/blurpicker/blurpicker.desktop | 11 - examples/effects/blurpicker/blurpicker.h | 75 - examples/effects/blurpicker/blurpicker.pro | 11 - examples/effects/blurpicker/blurpicker.qrc | 14 - examples/effects/blurpicker/images/README.txt | 5 - .../blurpicker/images/accessories-calculator.png | Bin 3760 -> 0 bytes .../blurpicker/images/accessories-text-editor.png | Bin 4746 -> 0 bytes examples/effects/blurpicker/images/background.jpg | Bin 16259 -> 0 bytes .../effects/blurpicker/images/help-browser.png | Bin 5392 -> 0 bytes .../blurpicker/images/internet-group-chat.png | Bin 2809 -> 0 bytes .../effects/blurpicker/images/internet-mail.png | Bin 3899 -> 0 bytes .../blurpicker/images/internet-web-browser.png | Bin 6376 -> 0 bytes .../effects/blurpicker/images/office-calendar.png | Bin 4010 -> 0 bytes .../effects/blurpicker/images/system-users.png | Bin 5353 -> 0 bytes examples/effects/blurpicker/main.cpp | 55 - examples/effects/effects.pro | 14 - examples/effects/fademessage/README.txt | 2 - examples/effects/fademessage/background.jpg | Bin 159108 -> 0 bytes examples/effects/fademessage/fademessage.cpp | 128 -- examples/effects/fademessage/fademessage.desktop | 11 - examples/effects/fademessage/fademessage.h | 70 - examples/effects/fademessage/fademessage.pro | 18 - examples/effects/fademessage/fademessage.qrc | 5 - examples/effects/fademessage/main.cpp | 55 - examples/effects/lighting/lighting.cpp | 139 -- examples/effects/lighting/lighting.desktop | 11 - examples/effects/lighting/lighting.h | 70 - examples/effects/lighting/lighting.pro | 11 - examples/effects/lighting/main.cpp | 55 - examples/examples.pro | 35 +- examples/graphicsview/README | 9 - .../graphicsview/anchorlayout/anchorlayout.desktop | 11 - .../graphicsview/anchorlayout/anchorlayout.pro | 13 - examples/graphicsview/anchorlayout/main.cpp | 129 -- .../basicgraphicslayouts.desktop | 11 - .../basicgraphicslayouts/basicgraphicslayouts.pro | 14 - .../basicgraphicslayouts/basicgraphicslayouts.qrc | 5 - .../basicgraphicslayouts/images/block.png | Bin 2146 -> 0 bytes .../basicgraphicslayouts/layoutitem.cpp | 130 -- .../graphicsview/basicgraphicslayouts/layoutitem.h | 65 - .../graphicsview/basicgraphicslayouts/main.cpp | 58 - .../graphicsview/basicgraphicslayouts/window.cpp | 90 -- .../graphicsview/basicgraphicslayouts/window.h | 57 - examples/graphicsview/boxes/3rdparty/fbm.c | 207 --- examples/graphicsview/boxes/3rdparty/fbm.h | 40 - examples/graphicsview/boxes/basic.fsh | 73 - examples/graphicsview/boxes/basic.vsh | 61 - examples/graphicsview/boxes/boxes.pro | 39 - examples/graphicsview/boxes/boxes.qrc | 25 - examples/graphicsview/boxes/cubemap_negx.jpg | Bin 41060 -> 0 bytes examples/graphicsview/boxes/cubemap_negy.jpg | Bin 15520 -> 0 bytes examples/graphicsview/boxes/cubemap_negz.jpg | Bin 68911 -> 0 bytes examples/graphicsview/boxes/cubemap_posx.jpg | Bin 74915 -> 0 bytes examples/graphicsview/boxes/cubemap_posy.jpg | Bin 24193 -> 0 bytes examples/graphicsview/boxes/cubemap_posz.jpg | Bin 57881 -> 0 bytes examples/graphicsview/boxes/dotted.fsh | 66 - examples/graphicsview/boxes/fresnel.fsh | 79 -- examples/graphicsview/boxes/glass.fsh | 76 - examples/graphicsview/boxes/glbuffers.cpp | 402 ------ examples/graphicsview/boxes/glbuffers.h | 366 ----- examples/graphicsview/boxes/glextensions.cpp | 98 -- examples/graphicsview/boxes/glextensions.h | 202 --- examples/graphicsview/boxes/gltrianglemesh.h | 91 -- examples/graphicsview/boxes/granite.fsh | 76 - examples/graphicsview/boxes/main.cpp | 150 -- examples/graphicsview/boxes/marble.fsh | 71 - examples/graphicsview/boxes/parameters.par | 5 - examples/graphicsview/boxes/qt-logo.jpg | Bin 40886 -> 0 bytes examples/graphicsview/boxes/qt-logo.png | Bin 13923 -> 0 bytes examples/graphicsview/boxes/qtbox.cpp | 480 ------- examples/graphicsview/boxes/qtbox.h | 118 -- examples/graphicsview/boxes/reflection.fsh | 54 - examples/graphicsview/boxes/refraction.fsh | 70 - examples/graphicsview/boxes/roundedbox.cpp | 161 --- examples/graphicsview/boxes/roundedbox.h | 72 - examples/graphicsview/boxes/scene.cpp | 1085 -------------- examples/graphicsview/boxes/scene.h | 245 ---- examples/graphicsview/boxes/smiley.png | Bin 14508 -> 0 bytes examples/graphicsview/boxes/square.jpg | Bin 14542 -> 0 bytes examples/graphicsview/boxes/trackball.cpp | 160 --- examples/graphicsview/boxes/trackball.h | 79 -- examples/graphicsview/boxes/wood.fsh | 70 - examples/graphicsview/chip/chip.cpp | 183 --- examples/graphicsview/chip/chip.h | 68 - examples/graphicsview/chip/chip.pro | 21 - examples/graphicsview/chip/fileprint.png | Bin 1456 -> 0 bytes examples/graphicsview/chip/images.qrc | 10 - examples/graphicsview/chip/main.cpp | 57 - examples/graphicsview/chip/mainwindow.cpp | 109 -- examples/graphicsview/chip/mainwindow.h | 68 - examples/graphicsview/chip/qt4logo.png | Bin 48333 -> 0 bytes examples/graphicsview/chip/rotateleft.png | Bin 1754 -> 0 bytes examples/graphicsview/chip/rotateright.png | Bin 1732 -> 0 bytes examples/graphicsview/chip/view.cpp | 279 ---- examples/graphicsview/chip/view.h | 104 -- examples/graphicsview/chip/zoomin.png | Bin 1622 -> 0 bytes examples/graphicsview/chip/zoomout.png | Bin 1601 -> 0 bytes .../collidingmice/collidingmice.desktop | 11 - .../graphicsview/collidingmice/collidingmice.pro | 17 - .../graphicsview/collidingmice/images/cheese.jpg | Bin 3029 -> 0 bytes examples/graphicsview/collidingmice/main.cpp | 91 -- examples/graphicsview/collidingmice/mice.qrc | 5 - examples/graphicsview/collidingmice/mouse.cpp | 200 --- examples/graphicsview/collidingmice/mouse.h | 68 - examples/graphicsview/diagramscene/arrow.cpp | 145 -- examples/graphicsview/diagramscene/arrow.h | 91 -- examples/graphicsview/diagramscene/diagramitem.cpp | 152 -- examples/graphicsview/diagramscene/diagramitem.h | 96 -- .../graphicsview/diagramscene/diagramscene.cpp | 240 ---- .../graphicsview/diagramscene/diagramscene.desktop | 11 - examples/graphicsview/diagramscene/diagramscene.h | 112 -- .../graphicsview/diagramscene/diagramscene.pro | 23 - .../graphicsview/diagramscene/diagramscene.qrc | 20 - .../graphicsview/diagramscene/diagramtextitem.cpp | 81 -- .../graphicsview/diagramscene/diagramtextitem.h | 78 -- .../diagramscene/images/background1.png | Bin 112 -> 0 bytes .../diagramscene/images/background2.png | Bin 114 -> 0 bytes .../diagramscene/images/background3.png | Bin 116 -> 0 bytes .../diagramscene/images/background4.png | Bin 96 -> 0 bytes examples/graphicsview/diagramscene/images/bold.png | Bin 274 -> 0 bytes .../diagramscene/images/bringtofront.png | Bin 293 -> 0 bytes .../graphicsview/diagramscene/images/delete.png | Bin 831 -> 0 bytes .../graphicsview/diagramscene/images/floodfill.png | Bin 282 -> 0 bytes .../graphicsview/diagramscene/images/italic.png | Bin 247 -> 0 bytes .../graphicsview/diagramscene/images/linecolor.png | Bin 145 -> 0 bytes .../diagramscene/images/linepointer.png | Bin 141 -> 0 bytes .../graphicsview/diagramscene/images/pointer.png | Bin 173 -> 0 bytes .../diagramscene/images/sendtoback.png | Bin 318 -> 0 bytes .../diagramscene/images/textpointer.png | Bin 753 -> 0 bytes .../graphicsview/diagramscene/images/underline.png | Bin 250 -> 0 bytes examples/graphicsview/diagramscene/main.cpp | 55 - examples/graphicsview/diagramscene/mainwindow.cpp | 661 --------- examples/graphicsview/diagramscene/mainwindow.h | 150 -- examples/graphicsview/dragdroprobot/coloritem.cpp | 142 -- examples/graphicsview/dragdroprobot/coloritem.h | 65 - .../dragdroprobot/dragdroprobot.desktop | 11 - .../graphicsview/dragdroprobot/dragdroprobot.pro | 22 - .../graphicsview/dragdroprobot/images/head.png | Bin 14972 -> 0 bytes examples/graphicsview/dragdroprobot/main.cpp | 94 -- examples/graphicsview/dragdroprobot/robot.cpp | 307 ---- examples/graphicsview/dragdroprobot/robot.h | 118 -- examples/graphicsview/dragdroprobot/robot.qrc | 5 - examples/graphicsview/elasticnodes/edge.cpp | 149 -- examples/graphicsview/elasticnodes/edge.h | 75 - .../graphicsview/elasticnodes/elasticnodes.desktop | 11 - .../graphicsview/elasticnodes/elasticnodes.pro | 20 - examples/graphicsview/elasticnodes/graphwidget.cpp | 250 ---- examples/graphicsview/elasticnodes/graphwidget.h | 77 - examples/graphicsview/elasticnodes/main.cpp | 57 - examples/graphicsview/elasticnodes/node.cpp | 212 --- examples/graphicsview/elasticnodes/node.h | 85 -- .../embeddeddialogs/No-Ones-Laughing-3.jpg | Bin 30730 -> 0 bytes .../graphicsview/embeddeddialogs/customproxy.cpp | 167 --- .../graphicsview/embeddeddialogs/customproxy.h | 76 - .../embeddeddialogs/embeddeddialog.cpp | 106 -- .../graphicsview/embeddeddialogs/embeddeddialog.h | 66 - .../graphicsview/embeddeddialogs/embeddeddialog.ui | 87 -- .../embeddeddialogs/embeddeddialogs.pro | 19 - .../embeddeddialogs/embeddeddialogs.qrc | 5 - examples/graphicsview/embeddeddialogs/main.cpp | 83 -- examples/graphicsview/flowlayout/flowlayout.cpp | 213 --- .../graphicsview/flowlayout/flowlayout.desktop | 11 - examples/graphicsview/flowlayout/flowlayout.h | 76 - examples/graphicsview/flowlayout/flowlayout.pro | 14 - examples/graphicsview/flowlayout/main.cpp | 57 - examples/graphicsview/flowlayout/window.cpp | 62 - examples/graphicsview/flowlayout/window.h | 47 - examples/graphicsview/graphicsview.pro | 28 - .../graphicsview/padnavigator/flippablepad.cpp | 98 -- examples/graphicsview/padnavigator/flippablepad.h | 63 - examples/graphicsview/padnavigator/form.ui | 208 --- .../padnavigator/images/artsfftscope.png | Bin 1291 -> 0 bytes .../padnavigator/images/blue_angle_swirl.jpg | Bin 11826 -> 0 bytes .../padnavigator/images/kontact_contacts.png | Bin 4382 -> 0 bytes .../padnavigator/images/kontact_journal.png | Bin 3261 -> 0 bytes .../padnavigator/images/kontact_mail.png | Bin 3202 -> 0 bytes .../padnavigator/images/kontact_notes.png | Bin 3893 -> 0 bytes .../padnavigator/images/kopeteavailable.png | Bin 2380 -> 0 bytes .../padnavigator/images/metacontact_online.png | Bin 2545 -> 0 bytes .../graphicsview/padnavigator/images/minitools.png | Bin 2087 -> 0 bytes examples/graphicsview/padnavigator/main.cpp | 55 - .../graphicsview/padnavigator/padnavigator.cpp | 306 ---- .../graphicsview/padnavigator/padnavigator.desktop | 11 - examples/graphicsview/padnavigator/padnavigator.h | 70 - .../graphicsview/padnavigator/padnavigator.pro | 28 - .../graphicsview/padnavigator/padnavigator.qrc | 13 - .../graphicsview/padnavigator/roundrectitem.cpp | 113 -- examples/graphicsview/padnavigator/roundrectitem.h | 75 - examples/graphicsview/padnavigator/splashitem.cpp | 83 -- examples/graphicsview/padnavigator/splashitem.h | 61 - .../portedasteroids/portedasteroids.desktop | 11 - .../graphicsview/portedcanvas/portedcanvas.desktop | 11 - examples/graphicsview/simpleanchorlayout/main.cpp | 134 -- .../simpleanchorlayout/simpleanchorlayout.desktop | 11 - .../simpleanchorlayout/simpleanchorlayout.pro | 12 - .../weatheranchorlayout/images/5days.jpg | Bin 5748 -> 0 bytes .../weatheranchorlayout/images/details.jpg | Bin 5323 -> 0 bytes .../weatheranchorlayout/images/place.jpg | Bin 62438 -> 0 bytes .../weatheranchorlayout/images/tabbar.jpg | Bin 849 -> 0 bytes .../weatheranchorlayout/images/title.jpg | Bin 3472 -> 0 bytes .../images/weather-few-clouds.png | Bin 18976 -> 0 bytes examples/graphicsview/weatheranchorlayout/main.cpp | 274 ---- .../weatheranchorlayout.desktop | 11 - .../weatheranchorlayout/weatheranchorlayout.pro | 12 - .../weatheranchorlayout/weatheranchorlayout.qrc | 10 - examples/itemviews/README | 8 - examples/itemviews/addressbook/adddialog.cpp | 82 -- examples/itemviews/addressbook/adddialog.h | 71 - examples/itemviews/addressbook/addressbook.desktop | 11 - examples/itemviews/addressbook/addressbook.pro | 19 - examples/itemviews/addressbook/addresswidget.cpp | 236 ---- examples/itemviews/addressbook/addresswidget.h | 82 -- examples/itemviews/addressbook/main.cpp | 52 - examples/itemviews/addressbook/mainwindow.cpp | 137 -- examples/itemviews/addressbook/mainwindow.h | 75 - examples/itemviews/addressbook/newaddresstab.cpp | 77 - examples/itemviews/addressbook/newaddresstab.h | 74 - examples/itemviews/addressbook/tablemodel.cpp | 184 --- examples/itemviews/addressbook/tablemodel.h | 72 - .../basicsortfiltermodel.desktop | 11 - .../basicsortfiltermodel/basicsortfiltermodel.pro | 12 - examples/itemviews/basicsortfiltermodel/main.cpp | 93 -- examples/itemviews/basicsortfiltermodel/window.cpp | 157 --- examples/itemviews/basicsortfiltermodel/window.h | 88 -- examples/itemviews/chart/chart.desktop | 11 - examples/itemviews/chart/chart.pro | 18 - examples/itemviews/chart/chart.qrc | 5 - examples/itemviews/chart/main.cpp | 53 - examples/itemviews/chart/mainwindow.cpp | 172 --- examples/itemviews/chart/mainwindow.h | 72 - examples/itemviews/chart/mydata.cht | 8 - examples/itemviews/chart/pieview.cpp | 557 -------- examples/itemviews/chart/pieview.h | 114 -- examples/itemviews/chart/qtdata.cht | 14 - .../coloreditorfactory/coloreditorfactory.desktop | 11 - .../coloreditorfactory/coloreditorfactory.pro | 14 - .../coloreditorfactory/colorlisteditor.cpp | 76 - .../itemviews/coloreditorfactory/colorlisteditor.h | 69 - examples/itemviews/coloreditorfactory/main.cpp | 53 - examples/itemviews/coloreditorfactory/window.cpp | 94 -- examples/itemviews/coloreditorfactory/window.h | 57 - .../combowidgetmapper/combowidgetmapper.desktop | 11 - .../combowidgetmapper/combowidgetmapper.pro | 11 - examples/itemviews/combowidgetmapper/main.cpp | 51 - examples/itemviews/combowidgetmapper/window.cpp | 136 -- examples/itemviews/combowidgetmapper/window.h | 86 -- .../customsortfiltermodel.desktop | 11 - .../customsortfiltermodel.pro | 14 - examples/itemviews/customsortfiltermodel/main.cpp | 95 -- .../mysortfilterproxymodel.cpp | 115 -- .../customsortfiltermodel/mysortfilterproxymodel.h | 73 - .../itemviews/customsortfiltermodel/window.cpp | 166 --- examples/itemviews/customsortfiltermodel/window.h | 90 -- examples/itemviews/dirview/dirview.desktop | 11 - examples/itemviews/dirview/dirview.pro | 9 - examples/itemviews/dirview/main.cpp | 62 - examples/itemviews/editabletreemodel/default.txt | 40 - .../editabletreemodel/editabletreemodel.desktop | 11 - .../editabletreemodel/editabletreemodel.pro | 18 - .../editabletreemodel/editabletreemodel.qrc | 5 - examples/itemviews/editabletreemodel/main.cpp | 53 - .../itemviews/editabletreemodel/mainwindow.cpp | 181 --- examples/itemviews/editabletreemodel/mainwindow.h | 71 - examples/itemviews/editabletreemodel/mainwindow.ui | 128 -- examples/itemviews/editabletreemodel/treeitem.cpp | 179 --- examples/itemviews/editabletreemodel/treeitem.h | 74 - examples/itemviews/editabletreemodel/treemodel.cpp | 288 ---- examples/itemviews/editabletreemodel/treemodel.h | 97 -- examples/itemviews/fetchmore/fetchmore.desktop | 11 - examples/itemviews/fetchmore/fetchmore.pro | 13 - examples/itemviews/fetchmore/filelistmodel.cpp | 116 -- examples/itemviews/fetchmore/filelistmodel.h | 75 - examples/itemviews/fetchmore/main.cpp | 50 - examples/itemviews/fetchmore/window.cpp | 81 -- examples/itemviews/fetchmore/window.h | 64 - .../itemviews/frozencolumn/freezetablewidget.cpp | 165 --- .../itemviews/frozencolumn/freezetablewidget.h | 72 - .../itemviews/frozencolumn/frozencolumn.desktop | 11 - examples/itemviews/frozencolumn/frozencolumn.pro | 11 - examples/itemviews/frozencolumn/grades.qrc | 5 - examples/itemviews/frozencolumn/grades.txt | 36 - examples/itemviews/frozencolumn/main.cpp | 88 -- examples/itemviews/interview/README | 2 - examples/itemviews/interview/images/folder.png | Bin 3910 -> 0 bytes examples/itemviews/interview/images/interview.png | Bin 174 -> 0 bytes examples/itemviews/interview/images/services.png | Bin 3749 -> 0 bytes examples/itemviews/interview/interview.pro | 19 - examples/itemviews/interview/interview.qrc | 7 - examples/itemviews/interview/main.cpp | 95 -- examples/itemviews/interview/model.cpp | 147 -- examples/itemviews/interview/model.h | 90 -- examples/itemviews/itemviews.pro | 25 - examples/itemviews/pixelator/imagemodel.cpp | 92 -- examples/itemviews/pixelator/imagemodel.h | 68 - examples/itemviews/pixelator/images.qrc | 5 - examples/itemviews/pixelator/images/qt.png | Bin 656 -> 0 bytes examples/itemviews/pixelator/main.cpp | 54 - examples/itemviews/pixelator/mainwindow.cpp | 248 ---- examples/itemviews/pixelator/mainwindow.h | 74 - examples/itemviews/pixelator/pixelator.desktop | 11 - examples/itemviews/pixelator/pixelator.pro | 17 - examples/itemviews/pixelator/pixeldelegate.cpp | 107 -- examples/itemviews/pixelator/pixeldelegate.h | 79 -- examples/itemviews/puzzle/example.jpg | Bin 42654 -> 0 bytes examples/itemviews/puzzle/main.cpp | 54 - examples/itemviews/puzzle/mainwindow.cpp | 149 -- examples/itemviews/puzzle/mainwindow.h | 77 - examples/itemviews/puzzle/piecesmodel.cpp | 203 --- examples/itemviews/puzzle/piecesmodel.h | 82 -- examples/itemviews/puzzle/puzzle.desktop | 11 - examples/itemviews/puzzle/puzzle.pro | 22 - examples/itemviews/puzzle/puzzle.qrc | 5 - examples/itemviews/puzzle/puzzlewidget.cpp | 214 --- examples/itemviews/puzzle/puzzlewidget.h | 89 -- examples/itemviews/simpledommodel/domitem.cpp | 101 -- examples/itemviews/simpledommodel/domitem.h | 66 - examples/itemviews/simpledommodel/dommodel.cpp | 189 --- examples/itemviews/simpledommodel/dommodel.h | 76 - examples/itemviews/simpledommodel/main.cpp | 52 - examples/itemviews/simpledommodel/mainwindow.cpp | 84 -- examples/itemviews/simpledommodel/mainwindow.h | 70 - .../simpledommodel/simpledommodel.desktop | 11 - .../itemviews/simpledommodel/simpledommodel.pro | 16 - examples/itemviews/simpletreemodel/default.txt | 40 - examples/itemviews/simpletreemodel/main.cpp | 61 - .../simpletreemodel/simpletreemodel.desktop | 11 - .../itemviews/simpletreemodel/simpletreemodel.pro | 15 - .../itemviews/simpletreemodel/simpletreemodel.qrc | 5 - examples/itemviews/simpletreemodel/treeitem.cpp | 116 -- examples/itemviews/simpletreemodel/treeitem.h | 70 - examples/itemviews/simpletreemodel/treemodel.cpp | 218 --- examples/itemviews/simpletreemodel/treemodel.h | 76 - examples/itemviews/simplewidgetmapper/main.cpp | 51 - .../simplewidgetmapper/simplewidgetmapper.desktop | 11 - .../simplewidgetmapper/simplewidgetmapper.pro | 11 - examples/itemviews/simplewidgetmapper/window.cpp | 133 -- examples/itemviews/simplewidgetmapper/window.h | 84 -- examples/itemviews/spinboxdelegate/delegate.cpp | 102 -- examples/itemviews/spinboxdelegate/delegate.h | 70 - examples/itemviews/spinboxdelegate/main.cpp | 86 -- .../spinboxdelegate/spinboxdelegate.desktop | 11 - .../itemviews/spinboxdelegate/spinboxdelegate.pro | 13 - .../itemviews/spreadsheet/images/interview.png | Bin 174 -> 0 bytes examples/itemviews/spreadsheet/main.cpp | 55 - examples/itemviews/spreadsheet/printview.cpp | 62 - examples/itemviews/spreadsheet/printview.h | 63 - examples/itemviews/spreadsheet/spreadsheet.cpp | 639 --------- examples/itemviews/spreadsheet/spreadsheet.h | 124 -- examples/itemviews/spreadsheet/spreadsheet.pro | 23 - examples/itemviews/spreadsheet/spreadsheet.qrc | 5 - .../itemviews/spreadsheet/spreadsheetdelegate.cpp | 114 -- .../itemviews/spreadsheet/spreadsheetdelegate.h | 65 - examples/itemviews/spreadsheet/spreadsheetitem.cpp | 167 --- examples/itemviews/spreadsheet/spreadsheetitem.h | 73 - examples/itemviews/stardelegate/main.cpp | 107 -- examples/itemviews/stardelegate/stardelegate.cpp | 129 -- .../itemviews/stardelegate/stardelegate.desktop | 11 - examples/itemviews/stardelegate/stardelegate.h | 69 - examples/itemviews/stardelegate/stardelegate.pro | 17 - examples/itemviews/stardelegate/stareditor.cpp | 98 -- examples/itemviews/stardelegate/stareditor.h | 77 - examples/itemviews/stardelegate/starrating.cpp | 102 -- examples/itemviews/stardelegate/starrating.h | 76 - examples/layouts/README | 10 - examples/layouts/basiclayouts/basiclayouts.desktop | 11 - examples/layouts/basiclayouts/basiclayouts.pro | 13 - examples/layouts/basiclayouts/dialog.cpp | 149 -- examples/layouts/basiclayouts/dialog.h | 90 -- examples/layouts/basiclayouts/main.cpp | 52 - examples/layouts/borderlayout/borderlayout.cpp | 213 --- examples/layouts/borderlayout/borderlayout.desktop | 11 - examples/layouts/borderlayout/borderlayout.h | 88 -- examples/layouts/borderlayout/borderlayout.pro | 13 - examples/layouts/borderlayout/main.cpp | 51 - examples/layouts/borderlayout/window.cpp | 68 - examples/layouts/borderlayout/window.h | 61 - examples/layouts/dynamiclayouts/dialog.cpp | 169 --- examples/layouts/dynamiclayouts/dialog.h | 91 -- .../layouts/dynamiclayouts/dynamiclayouts.desktop | 11 - examples/layouts/dynamiclayouts/dynamiclayouts.pro | 13 - examples/layouts/dynamiclayouts/main.cpp | 51 - examples/layouts/flowlayout/flowlayout.cpp | 213 --- examples/layouts/flowlayout/flowlayout.desktop | 11 - examples/layouts/flowlayout/flowlayout.h | 78 -- examples/layouts/flowlayout/flowlayout.pro | 13 - examples/layouts/flowlayout/main.cpp | 51 - examples/layouts/flowlayout/window.cpp | 59 - examples/layouts/flowlayout/window.h | 59 - examples/layouts/layouts.pro | 12 - examples/mainwindows/README | 9 - .../mainwindows/application/application.desktop | 11 - examples/mainwindows/application/application.pro | 16 - examples/mainwindows/application/application.qrc | 10 - examples/mainwindows/application/images/copy.png | Bin 1338 -> 0 bytes examples/mainwindows/application/images/cut.png | Bin 1323 -> 0 bytes examples/mainwindows/application/images/new.png | Bin 852 -> 0 bytes examples/mainwindows/application/images/open.png | Bin 2073 -> 0 bytes examples/mainwindows/application/images/paste.png | Bin 1645 -> 0 bytes examples/mainwindows/application/images/save.png | Bin 1187 -> 0 bytes examples/mainwindows/application/main.cpp | 57 - examples/mainwindows/application/mainwindow.cpp | 392 ------ examples/mainwindows/application/mainwindow.h | 105 -- .../mainwindows/dockwidgets/dockwidgets.desktop | 11 - examples/mainwindows/dockwidgets/dockwidgets.pro | 15 - examples/mainwindows/dockwidgets/dockwidgets.qrc | 8 - examples/mainwindows/dockwidgets/images/new.png | Bin 977 -> 0 bytes examples/mainwindows/dockwidgets/images/print.png | Bin 1732 -> 0 bytes examples/mainwindows/dockwidgets/images/save.png | Bin 1894 -> 0 bytes examples/mainwindows/dockwidgets/images/undo.png | Bin 1768 -> 0 bytes examples/mainwindows/dockwidgets/main.cpp | 52 - examples/mainwindows/dockwidgets/mainwindow.cpp | 345 ----- examples/mainwindows/dockwidgets/mainwindow.h | 97 -- examples/mainwindows/mainwindow/colorswatch.cpp | 746 ---------- examples/mainwindows/mainwindow/colorswatch.h | 136 -- examples/mainwindows/mainwindow/main.cpp | 164 --- examples/mainwindows/mainwindow/mainwindow.cpp | 509 ------- examples/mainwindows/mainwindow/mainwindow.h | 90 -- examples/mainwindows/mainwindow/mainwindow.pro | 17 - examples/mainwindows/mainwindow/mainwindow.qrc | 8 - examples/mainwindows/mainwindow/qt.png | Bin 2037 -> 0 bytes examples/mainwindows/mainwindow/titlebarCenter.png | Bin 146 -> 0 bytes examples/mainwindows/mainwindow/titlebarLeft.png | Bin 5148 -> 0 bytes examples/mainwindows/mainwindow/titlebarRight.png | Bin 2704 -> 0 bytes examples/mainwindows/mainwindow/toolbar.cpp | 383 ----- examples/mainwindows/mainwindow/toolbar.h | 118 -- examples/mainwindows/mainwindows.pro | 16 - examples/mainwindows/mdi/images/copy.png | Bin 1338 -> 0 bytes examples/mainwindows/mdi/images/cut.png | Bin 1323 -> 0 bytes examples/mainwindows/mdi/images/new.png | Bin 852 -> 0 bytes examples/mainwindows/mdi/images/open.png | Bin 2073 -> 0 bytes examples/mainwindows/mdi/images/paste.png | Bin 1645 -> 0 bytes examples/mainwindows/mdi/images/save.png | Bin 1187 -> 0 bytes examples/mainwindows/mdi/main.cpp | 53 - examples/mainwindows/mdi/mainwindow.cpp | 411 ------ examples/mainwindows/mdi/mainwindow.h | 122 -- examples/mainwindows/mdi/mdi.desktop | 11 - examples/mainwindows/mdi/mdi.pro | 16 - examples/mainwindows/mdi/mdi.qrc | 10 - examples/mainwindows/mdi/mdichild.cpp | 175 --- examples/mainwindows/mdi/mdichild.h | 76 - examples/mainwindows/menus/main.cpp | 51 - examples/mainwindows/menus/mainwindow.cpp | 370 ----- examples/mainwindows/menus/mainwindow.h | 124 -- examples/mainwindows/menus/menus.desktop | 11 - examples/mainwindows/menus/menus.pro | 11 - examples/mainwindows/recentfiles/main.cpp | 53 - examples/mainwindows/recentfiles/mainwindow.cpp | 251 ---- examples/mainwindows/recentfiles/mainwindow.h | 96 -- .../mainwindows/recentfiles/recentfiles.desktop | 11 - examples/mainwindows/recentfiles/recentfiles.pro | 13 - examples/mainwindows/sdi/images/copy.png | Bin 1338 -> 0 bytes examples/mainwindows/sdi/images/cut.png | Bin 1323 -> 0 bytes examples/mainwindows/sdi/images/new.png | Bin 852 -> 0 bytes examples/mainwindows/sdi/images/open.png | Bin 2073 -> 0 bytes examples/mainwindows/sdi/images/paste.png | Bin 1645 -> 0 bytes examples/mainwindows/sdi/images/save.png | Bin 1187 -> 0 bytes examples/mainwindows/sdi/main.cpp | 54 - examples/mainwindows/sdi/mainwindow.cpp | 372 ----- examples/mainwindows/sdi/mainwindow.h | 110 -- examples/mainwindows/sdi/sdi.desktop | 11 - examples/mainwindows/sdi/sdi.pro | 14 - examples/mainwindows/sdi/sdi.qrc | 10 - examples/painting/README | 11 - examples/painting/affine/affine.pro | 24 - examples/painting/affine/affine.qrc | 7 - examples/painting/affine/bg1.jpg | Bin 23771 -> 0 bytes examples/painting/affine/main.cpp | 65 - examples/painting/affine/xform.cpp | 902 ------------ examples/painting/affine/xform.h | 141 -- examples/painting/affine/xform.html | 23 - .../painting/basicdrawing/basicdrawing.desktop | 11 - examples/painting/basicdrawing/basicdrawing.pro | 14 - examples/painting/basicdrawing/basicdrawing.qrc | 6 - examples/painting/basicdrawing/images/brick.png | Bin 767 -> 0 bytes examples/painting/basicdrawing/images/qt-logo.png | Bin 3696 -> 0 bytes examples/painting/basicdrawing/main.cpp | 53 - examples/painting/basicdrawing/renderarea.cpp | 207 --- examples/painting/basicdrawing/renderarea.h | 83 -- examples/painting/basicdrawing/window.cpp | 259 ---- examples/painting/basicdrawing/window.h | 87 -- examples/painting/composition/composition.cpp | 522 ------- examples/painting/composition/composition.h | 187 --- examples/painting/composition/composition.html | 23 - examples/painting/composition/composition.pro | 29 - examples/painting/composition/composition.qrc | 8 - examples/painting/composition/flower.jpg | Bin 49616 -> 0 bytes examples/painting/composition/flower_alpha.jpg | Bin 67326 -> 0 bytes examples/painting/composition/main.cpp | 65 - .../painting/concentriccircles/circlewidget.cpp | 124 -- examples/painting/concentriccircles/circlewidget.h | 73 - .../concentriccircles/concentriccircles.desktop | 11 - .../concentriccircles/concentriccircles.pro | 14 - examples/painting/concentriccircles/main.cpp | 51 - examples/painting/concentriccircles/window.cpp | 93 -- examples/painting/concentriccircles/window.h | 70 - examples/painting/deform/deform.pro | 20 - examples/painting/deform/deform.qrc | 6 - examples/painting/deform/main.cpp | 72 - examples/painting/deform/pathdeform.cpp | 646 --------- examples/painting/deform/pathdeform.h | 153 -- examples/painting/deform/pathdeform.html | 24 - examples/painting/fontsampler/fontsampler.desktop | 11 - examples/painting/fontsampler/fontsampler.pro | 13 - examples/painting/fontsampler/main.cpp | 51 - examples/painting/fontsampler/mainwindow.cpp | 380 ----- examples/painting/fontsampler/mainwindow.h | 87 -- examples/painting/fontsampler/mainwindowbase.ui | 142 -- examples/painting/gradients/gradients.cpp | 516 ------- examples/painting/gradients/gradients.h | 170 --- examples/painting/gradients/gradients.html | 31 - examples/painting/gradients/gradients.pro | 20 - examples/painting/gradients/gradients.qrc | 6 - examples/painting/gradients/main.cpp | 63 - .../painting/imagecomposition/imagecomposer.cpp | 211 --- examples/painting/imagecomposition/imagecomposer.h | 87 -- .../imagecomposition/imagecomposition.desktop | 11 - .../painting/imagecomposition/imagecomposition.pro | 13 - .../painting/imagecomposition/imagecomposition.qrc | 6 - .../imagecomposition/images/background.png | Bin 18579 -> 0 bytes .../imagecomposition/images/blackrectangle.png | Bin 90 -> 0 bytes .../painting/imagecomposition/images/butterfly.png | Bin 36868 -> 0 bytes .../painting/imagecomposition/images/checker.png | Bin 10384 -> 0 bytes examples/painting/imagecomposition/main.cpp | 55 - examples/painting/painterpaths/main.cpp | 51 - .../painting/painterpaths/painterpaths.desktop | 11 - examples/painting/painterpaths/painterpaths.pro | 15 - examples/painting/painterpaths/renderarea.cpp | 130 -- examples/painting/painterpaths/renderarea.h | 80 -- examples/painting/painterpaths/window.cpp | 289 ---- examples/painting/painterpaths/window.h | 90 -- examples/painting/painting.pro | 36 - examples/painting/pathstroke/main.cpp | 71 - examples/painting/pathstroke/pathstroke.cpp | 685 --------- examples/painting/pathstroke/pathstroke.h | 171 --- examples/painting/pathstroke/pathstroke.html | 20 - examples/painting/pathstroke/pathstroke.pro | 21 - examples/painting/pathstroke/pathstroke.qrc | 6 - examples/painting/shared/arthurstyle.cpp | 452 ------ examples/painting/shared/arthurstyle.h | 79 -- examples/painting/shared/arthurwidgets.cpp | 355 ----- examples/painting/shared/arthurwidgets.h | 137 -- examples/painting/shared/hoverpoints.cpp | 415 ------ examples/painting/shared/hoverpoints.h | 162 --- examples/painting/shared/images/bg_pattern.png | Bin 104 -> 0 bytes .../shared/images/button_normal_cap_left.png | Bin 654 -> 0 bytes .../shared/images/button_normal_cap_right.png | Bin 674 -> 0 bytes .../shared/images/button_normal_stretch.png | Bin 185 -> 0 bytes .../shared/images/button_pressed_cap_left.png | Bin 710 -> 0 bytes .../shared/images/button_pressed_cap_right.png | Bin 785 -> 0 bytes .../shared/images/button_pressed_stretch.png | Bin 217 -> 0 bytes .../painting/shared/images/curve_thing_edit-6.png | Bin 58097 -> 0 bytes examples/painting/shared/images/frame_bottom.png | Bin 166 -> 0 bytes .../painting/shared/images/frame_bottomleft.png | Bin 602 -> 0 bytes .../painting/shared/images/frame_bottomright.png | Bin 553 -> 0 bytes examples/painting/shared/images/frame_left.png | Bin 182 -> 0 bytes examples/painting/shared/images/frame_right.png | Bin 175 -> 0 bytes examples/painting/shared/images/frame_top.png | Bin 188 -> 0 bytes examples/painting/shared/images/frame_topleft.png | Bin 801 -> 0 bytes examples/painting/shared/images/frame_topright.png | Bin 851 -> 0 bytes .../shared/images/groupframe_bottom_left.png | Bin 397 -> 0 bytes .../shared/images/groupframe_bottom_right.png | Bin 383 -> 0 bytes .../shared/images/groupframe_bottom_stretch.png | Bin 141 -> 0 bytes .../shared/images/groupframe_left_stretch.png | Bin 132 -> 0 bytes .../shared/images/groupframe_right_stretch.png | Bin 113 -> 0 bytes .../shared/images/groupframe_top_stretch.png | Bin 115 -> 0 bytes .../painting/shared/images/groupframe_topleft.png | Bin 412 -> 0 bytes .../painting/shared/images/groupframe_topright.png | Bin 449 -> 0 bytes examples/painting/shared/images/line_dash_dot.png | Bin 151 -> 0 bytes .../painting/shared/images/line_dash_dot_dot.png | Bin 155 -> 0 bytes examples/painting/shared/images/line_dashed.png | Bin 121 -> 0 bytes examples/painting/shared/images/line_dotted.png | Bin 116 -> 0 bytes examples/painting/shared/images/line_solid.png | Bin 110 -> 0 bytes .../painting/shared/images/radiobutton-off.png | Bin 442 -> 0 bytes examples/painting/shared/images/radiobutton-on.png | Bin 474 -> 0 bytes .../painting/shared/images/radiobutton_off.png | Bin 442 -> 0 bytes examples/painting/shared/images/radiobutton_on.png | Bin 499 -> 0 bytes examples/painting/shared/images/slider_bar.png | Bin 748 -> 0 bytes .../painting/shared/images/slider_thumb_off.png | Bin 823 -> 0 bytes .../painting/shared/images/slider_thumb_on.png | Bin 798 -> 0 bytes examples/painting/shared/images/title_cap_left.png | Bin 179 -> 0 bytes .../painting/shared/images/title_cap_right.png | Bin 184 -> 0 bytes examples/painting/shared/images/title_stretch.png | Bin 106 -> 0 bytes examples/painting/shared/shared.pri | 20 - examples/painting/shared/shared.pro | 34 - examples/painting/shared/shared.qrc | 39 - .../painting/svggenerator/svggenerator.desktop | 11 - examples/painting/svgviewer/svgviewer.desktop | 11 - examples/painting/transformations/main.cpp | 51 - examples/painting/transformations/renderarea.cpp | 172 --- examples/painting/transformations/renderarea.h | 90 -- .../transformations/transformations.desktop | 11 - .../painting/transformations/transformations.pro | 13 - examples/painting/transformations/window.cpp | 180 --- examples/painting/transformations/window.h | 80 -- examples/richtext/README | 11 - examples/richtext/calendar/calendar.desktop | 11 - examples/richtext/calendar/calendar.pro | 11 - examples/richtext/calendar/main.cpp | 52 - examples/richtext/calendar/mainwindow.cpp | 215 --- examples/richtext/calendar/mainwindow.h | 73 - examples/richtext/orderform/detailsdialog.cpp | 156 --- examples/richtext/orderform/detailsdialog.h | 90 -- examples/richtext/orderform/main.cpp | 55 - examples/richtext/orderform/mainwindow.cpp | 253 ---- examples/richtext/orderform/mainwindow.h | 76 - examples/richtext/orderform/orderform.desktop | 11 - examples/richtext/orderform/orderform.pro | 14 - examples/richtext/richtext.pro | 11 - .../richtext/syntaxhighlighter/highlighter.cpp | 147 -- examples/richtext/syntaxhighlighter/highlighter.h | 84 -- examples/richtext/syntaxhighlighter/main.cpp | 52 - examples/richtext/syntaxhighlighter/mainwindow.cpp | 128 -- examples/richtext/syntaxhighlighter/mainwindow.h | 75 - .../syntaxhighlighter/syntaxhighlighter.desktop | 11 - .../syntaxhighlighter/syntaxhighlighter.pro | 20 - examples/richtext/textedit/example.html | 79 -- examples/richtext/textedit/images/logo32.png | Bin 1410 -> 0 bytes examples/richtext/textedit/images/mac/editcopy.png | Bin 1468 -> 0 bytes examples/richtext/textedit/images/mac/editcut.png | Bin 1512 -> 0 bytes .../richtext/textedit/images/mac/editpaste.png | Bin 1906 -> 0 bytes examples/richtext/textedit/images/mac/editredo.png | Bin 1752 -> 0 bytes examples/richtext/textedit/images/mac/editundo.png | Bin 1746 -> 0 bytes .../richtext/textedit/images/mac/exportpdf.png | Bin 1215 -> 0 bytes examples/richtext/textedit/images/mac/filenew.png | Bin 1172 -> 0 bytes examples/richtext/textedit/images/mac/fileopen.png | Bin 2168 -> 0 bytes .../richtext/textedit/images/mac/fileprint.png | Bin 2087 -> 0 bytes examples/richtext/textedit/images/mac/filesave.png | Bin 1206 -> 0 bytes examples/richtext/textedit/images/mac/textbold.png | Bin 1611 -> 0 bytes .../richtext/textedit/images/mac/textcenter.png | Bin 1404 -> 0 bytes .../richtext/textedit/images/mac/textitalic.png | Bin 1164 -> 0 bytes .../richtext/textedit/images/mac/textjustify.png | Bin 1257 -> 0 bytes examples/richtext/textedit/images/mac/textleft.png | Bin 1235 -> 0 bytes .../richtext/textedit/images/mac/textright.png | Bin 1406 -> 0 bytes .../richtext/textedit/images/mac/textunder.png | Bin 1183 -> 0 bytes examples/richtext/textedit/images/mac/zoomin.png | Bin 1696 -> 0 bytes examples/richtext/textedit/images/mac/zoomout.png | Bin 1662 -> 0 bytes examples/richtext/textedit/images/win/editcopy.png | Bin 1325 -> 0 bytes examples/richtext/textedit/images/win/editcut.png | Bin 1896 -> 0 bytes .../richtext/textedit/images/win/editpaste.png | Bin 1482 -> 0 bytes examples/richtext/textedit/images/win/editredo.png | Bin 1787 -> 0 bytes examples/richtext/textedit/images/win/editundo.png | Bin 1768 -> 0 bytes .../richtext/textedit/images/win/exportpdf.png | Bin 1059 -> 0 bytes examples/richtext/textedit/images/win/filenew.png | Bin 768 -> 0 bytes examples/richtext/textedit/images/win/fileopen.png | Bin 1662 -> 0 bytes .../richtext/textedit/images/win/fileprint.png | Bin 1456 -> 0 bytes examples/richtext/textedit/images/win/filesave.png | Bin 1205 -> 0 bytes examples/richtext/textedit/images/win/textbold.png | Bin 1134 -> 0 bytes .../richtext/textedit/images/win/textcenter.png | Bin 627 -> 0 bytes .../richtext/textedit/images/win/textitalic.png | Bin 829 -> 0 bytes .../richtext/textedit/images/win/textjustify.png | Bin 695 -> 0 bytes examples/richtext/textedit/images/win/textleft.png | Bin 673 -> 0 bytes .../richtext/textedit/images/win/textright.png | Bin 677 -> 0 bytes .../richtext/textedit/images/win/textunder.png | Bin 971 -> 0 bytes examples/richtext/textedit/images/win/zoomin.png | Bin 1208 -> 0 bytes examples/richtext/textedit/images/win/zoomout.png | Bin 1226 -> 0 bytes examples/richtext/textedit/main.cpp | 54 - examples/richtext/textedit/textedit.cpp | 737 ---------- examples/richtext/textedit/textedit.h | 130 -- examples/richtext/textedit/textedit.pro | 23 - examples/richtext/textedit/textedit.qdoc | 45 - examples/richtext/textedit/textedit.qrc | 44 - examples/scroller/graphicsview/graphicsview.pro | 9 - examples/scroller/graphicsview/main.cpp | 291 ---- examples/scroller/scroller.pro | 2 - examples/statemachine/README | 6 - .../eventtransitions/eventtransitions.desktop | 11 - .../eventtransitions/eventtransitions.pro | 11 - examples/statemachine/eventtransitions/main.cpp | 115 -- examples/statemachine/factorial/factorial.desktop | 11 - examples/statemachine/factorial/factorial.pro | 13 - examples/statemachine/factorial/main.cpp | 175 --- examples/statemachine/pingpong/main.cpp | 139 -- examples/statemachine/pingpong/pingpong.desktop | 11 - examples/statemachine/pingpong/pingpong.pro | 13 - examples/statemachine/rogue/main.cpp | 54 - examples/statemachine/rogue/movementtransition.h | 112 -- examples/statemachine/rogue/rogue.desktop | 11 - examples/statemachine/rogue/rogue.pro | 13 - examples/statemachine/rogue/window.cpp | 251 ---- examples/statemachine/rogue/window.h | 90 -- examples/statemachine/statemachine.pro | 18 - examples/statemachine/trafficlight/main.cpp | 184 --- .../statemachine/trafficlight/trafficlight.desktop | 11 - .../statemachine/trafficlight/trafficlight.pro | 10 - examples/statemachine/twowaybutton/main.cpp | 81 -- .../statemachine/twowaybutton/twowaybutton.desktop | 11 - .../statemachine/twowaybutton/twowaybutton.pro | 10 - examples/widgets/README | 13 - examples/widgets/analogclock/analogclock.cpp | 145 -- examples/widgets/analogclock/analogclock.desktop | 11 - examples/widgets/analogclock/analogclock.h | 59 - examples/widgets/analogclock/analogclock.pro | 12 - examples/widgets/analogclock/main.cpp | 51 - examples/widgets/animation/README | 8 + .../animation/animatedtiles/animatedtiles.desktop | 11 + .../animation/animatedtiles/animatedtiles.pro | 10 + .../animation/animatedtiles/animatedtiles.qrc | 11 + .../animatedtiles/images/Time-For-Lunch-2.jpg | Bin 0 -> 32471 bytes .../animation/animatedtiles/images/centered.png | Bin 0 -> 892 bytes .../animation/animatedtiles/images/ellipse.png | Bin 0 -> 10767 bytes .../animation/animatedtiles/images/figure8.png | Bin 0 -> 14050 bytes .../animation/animatedtiles/images/kinetic.png | Bin 0 -> 6776 bytes .../animation/animatedtiles/images/random.png | Bin 0 -> 14969 bytes .../animation/animatedtiles/images/tile.png | Bin 0 -> 16337 bytes examples/widgets/animation/animatedtiles/main.cpp | 256 ++++ examples/widgets/animation/animation.pro | 17 + .../appchooser/accessories-dictionary.png | Bin 0 -> 5396 bytes .../widgets/animation/appchooser/akregator.png | Bin 0 -> 4873 bytes .../animation/appchooser/appchooser.desktop | 11 + .../widgets/animation/appchooser/appchooser.pro | 10 + .../widgets/animation/appchooser/appchooser.qrc | 8 + examples/widgets/animation/appchooser/digikam.png | Bin 0 -> 3334 bytes examples/widgets/animation/appchooser/k3b.png | Bin 0 -> 8220 bytes examples/widgets/animation/appchooser/main.cpp | 173 +++ examples/widgets/animation/easing/animation.h | 100 ++ examples/widgets/animation/easing/easing.desktop | 11 + examples/widgets/animation/easing/easing.pro | 17 + examples/widgets/animation/easing/easing.qrc | 5 + examples/widgets/animation/easing/form.ui | 270 ++++ .../widgets/animation/easing/images/qt-logo.png | Bin 0 -> 5149 bytes examples/widgets/animation/easing/main.cpp | 54 + examples/widgets/animation/easing/window.cpp | 177 +++ examples/widgets/animation/easing/window.h | 76 + examples/widgets/animation/moveblocks/main.cpp | 321 +++++ .../animation/moveblocks/moveblocks.desktop | 11 + .../widgets/animation/moveblocks/moveblocks.pro | 9 + .../animation/states/accessories-dictionary.png | Bin 0 -> 5396 bytes examples/widgets/animation/states/akregator.png | Bin 0 -> 4873 bytes examples/widgets/animation/states/digikam.png | Bin 0 -> 3334 bytes examples/widgets/animation/states/help-browser.png | Bin 0 -> 6984 bytes examples/widgets/animation/states/k3b.png | Bin 0 -> 8220 bytes examples/widgets/animation/states/kchart.png | Bin 0 -> 4887 bytes examples/widgets/animation/states/main.cpp | 285 ++++ examples/widgets/animation/states/states.desktop | 11 + examples/widgets/animation/states/states.pro | 10 + examples/widgets/animation/states/states.qrc | 10 + examples/widgets/animation/stickman/animation.cpp | 189 +++ examples/widgets/animation/stickman/animation.h | 82 ++ .../animation/stickman/animations/chilling.bin | Bin 0 -> 6508 bytes .../animation/stickman/animations/dancing.bin | Bin 0 -> 2348 bytes .../widgets/animation/stickman/animations/dead.bin | Bin 0 -> 268 bytes .../animation/stickman/animations/jumping.bin | Bin 0 -> 1308 bytes .../widgets/animation/stickman/graphicsview.cpp | 60 + examples/widgets/animation/stickman/graphicsview.h | 64 + examples/widgets/animation/stickman/lifecycle.cpp | 217 +++ examples/widgets/animation/stickman/lifecycle.h | 80 ++ examples/widgets/animation/stickman/main.cpp | 106 ++ examples/widgets/animation/stickman/node.cpp | 92 ++ examples/widgets/animation/stickman/node.h | 70 + examples/widgets/animation/stickman/rectbutton.cpp | 73 + examples/widgets/animation/stickman/rectbutton.h | 65 + examples/widgets/animation/stickman/stickman.cpp | 337 +++++ .../widgets/animation/stickman/stickman.desktop | 11 + examples/widgets/animation/stickman/stickman.h | 103 ++ examples/widgets/animation/stickman/stickman.pro | 23 + examples/widgets/animation/stickman/stickman.qrc | 8 + .../animation/sub-attaq/animationmanager.cpp | 98 ++ .../widgets/animation/sub-attaq/animationmanager.h | 73 + examples/widgets/animation/sub-attaq/boat.cpp | 272 ++++ examples/widgets/animation/sub-attaq/boat.h | 95 ++ examples/widgets/animation/sub-attaq/boat_p.h | 232 +++ examples/widgets/animation/sub-attaq/bomb.cpp | 118 ++ examples/widgets/animation/sub-attaq/bomb.h | 67 + examples/widgets/animation/sub-attaq/data.xml | 39 + .../widgets/animation/sub-attaq/graphicsscene.cpp | 282 ++++ .../widgets/animation/sub-attaq/graphicsscene.h | 122 ++ examples/widgets/animation/sub-attaq/main.cpp | 57 + .../widgets/animation/sub-attaq/mainwindow.cpp | 82 ++ examples/widgets/animation/sub-attaq/mainwindow.h | 63 + .../animation/sub-attaq/pics/big/background.png | Bin 0 -> 48858 bytes .../widgets/animation/sub-attaq/pics/big/boat.png | Bin 0 -> 5198 bytes .../widgets/animation/sub-attaq/pics/big/bomb.png | Bin 0 -> 760 bytes .../sub-attaq/pics/big/explosion/boat/step1.png | Bin 0 -> 5760 bytes .../sub-attaq/pics/big/explosion/boat/step2.png | Bin 0 -> 9976 bytes .../sub-attaq/pics/big/explosion/boat/step3.png | Bin 0 -> 12411 bytes .../sub-attaq/pics/big/explosion/boat/step4.png | Bin 0 -> 15438 bytes .../pics/big/explosion/submarine/step1.png | Bin 0 -> 3354 bytes .../pics/big/explosion/submarine/step2.png | Bin 0 -> 6205 bytes .../pics/big/explosion/submarine/step3.png | Bin 0 -> 6678 bytes .../pics/big/explosion/submarine/step4.png | Bin 0 -> 6666 bytes .../animation/sub-attaq/pics/big/submarine.png | Bin 0 -> 3202 bytes .../animation/sub-attaq/pics/big/surface.png | Bin 0 -> 575 bytes .../animation/sub-attaq/pics/big/torpedo.png | Bin 0 -> 951 bytes .../sub-attaq/pics/scalable/background-n810.svg | 171 +++ .../sub-attaq/pics/scalable/background.svg | 171 +++ .../animation/sub-attaq/pics/scalable/boat.svg | 279 ++++ .../animation/sub-attaq/pics/scalable/bomb.svg | 138 ++ .../animation/sub-attaq/pics/scalable/sand.svg | 103 ++ .../animation/sub-attaq/pics/scalable/see.svg | 44 + .../animation/sub-attaq/pics/scalable/sky.svg | 45 + .../sub-attaq/pics/scalable/sub-attaq.svg | 1473 ++++++++++++++++++++ .../sub-attaq/pics/scalable/submarine.svg | 214 +++ .../animation/sub-attaq/pics/scalable/surface.svg | 49 + .../animation/sub-attaq/pics/scalable/torpedo.svg | 127 ++ .../animation/sub-attaq/pics/small/background.png | Bin 0 -> 34634 bytes .../animation/sub-attaq/pics/small/boat.png | Bin 0 -> 2394 bytes .../animation/sub-attaq/pics/small/bomb.png | Bin 0 -> 760 bytes .../animation/sub-attaq/pics/small/submarine.png | Bin 0 -> 1338 bytes .../animation/sub-attaq/pics/small/surface.png | Bin 0 -> 502 bytes .../animation/sub-attaq/pics/small/torpedo.png | Bin 0 -> 951 bytes .../animation/sub-attaq/pics/welcome/logo-a.png | Bin 0 -> 5972 bytes .../animation/sub-attaq/pics/welcome/logo-a2.png | Bin 0 -> 5969 bytes .../animation/sub-attaq/pics/welcome/logo-b.png | Bin 0 -> 6869 bytes .../animation/sub-attaq/pics/welcome/logo-dash.png | Bin 0 -> 2255 bytes .../animation/sub-attaq/pics/welcome/logo-excl.png | Bin 0 -> 2740 bytes .../animation/sub-attaq/pics/welcome/logo-q.png | Bin 0 -> 7016 bytes .../animation/sub-attaq/pics/welcome/logo-s.png | Bin 0 -> 5817 bytes .../animation/sub-attaq/pics/welcome/logo-t.png | Bin 0 -> 3717 bytes .../animation/sub-attaq/pics/welcome/logo-t2.png | Bin 0 -> 3688 bytes .../animation/sub-attaq/pics/welcome/logo-u.png | Bin 0 -> 5374 bytes .../widgets/animation/sub-attaq/pixmapitem.cpp | 76 + examples/widgets/animation/sub-attaq/pixmapitem.h | 63 + .../widgets/animation/sub-attaq/progressitem.cpp | 67 + .../widgets/animation/sub-attaq/progressitem.h | 61 + .../animation/sub-attaq/qanimationstate.cpp | 150 ++ .../widgets/animation/sub-attaq/qanimationstate.h | 91 ++ examples/widgets/animation/sub-attaq/states.cpp | 330 +++++ examples/widgets/animation/sub-attaq/states.h | 180 +++ examples/widgets/animation/sub-attaq/sub-attaq.pro | 42 + examples/widgets/animation/sub-attaq/subattaq.qrc | 39 + examples/widgets/animation/sub-attaq/submarine.cpp | 182 +++ examples/widgets/animation/sub-attaq/submarine.h | 93 ++ examples/widgets/animation/sub-attaq/submarine_p.h | 137 ++ .../animation/sub-attaq/textinformationitem.cpp | 54 + .../animation/sub-attaq/textinformationitem.h | 55 + examples/widgets/animation/sub-attaq/torpedo.cpp | 114 ++ examples/widgets/animation/sub-attaq/torpedo.h | 67 + .../applicationicon/applicationicon.desktop | 11 - .../widgets/applicationicon/applicationicon.png | Bin 4023 -> 0 bytes .../widgets/applicationicon/applicationicon.pro | 17 - .../widgets/applicationicon/applicationicon.svg | 22 - examples/widgets/applicationicon/main.cpp | 50 - examples/widgets/calculator/button.cpp | 63 - examples/widgets/calculator/button.h | 58 - examples/widgets/calculator/calculator.cpp | 396 ------ examples/widgets/calculator/calculator.desktop | 11 - examples/widgets/calculator/calculator.h | 107 -- examples/widgets/calculator/calculator.pro | 14 - examples/widgets/calculator/main.cpp | 51 - examples/widgets/calculator/releasenotes.txt | 4 - .../widgets/calendarwidget/calendarwidget.desktop | 11 - examples/widgets/calendarwidget/calendarwidget.pro | 11 - examples/widgets/calendarwidget/main.cpp | 51 - examples/widgets/calendarwidget/window.cpp | 464 ------ examples/widgets/calendarwidget/window.h | 127 -- examples/widgets/charactermap/charactermap.desktop | 11 - examples/widgets/charactermap/charactermap.pro | 15 - examples/widgets/charactermap/characterwidget.cpp | 177 --- examples/widgets/charactermap/characterwidget.h | 86 -- examples/widgets/charactermap/main.cpp | 51 - examples/widgets/charactermap/mainwindow.cpp | 204 --- examples/widgets/charactermap/mainwindow.h | 87 -- examples/widgets/codeeditor/codeeditor.cpp | 170 --- examples/widgets/codeeditor/codeeditor.desktop | 11 - examples/widgets/codeeditor/codeeditor.h | 105 -- examples/widgets/codeeditor/codeeditor.pro | 11 - examples/widgets/codeeditor/main.cpp | 55 - examples/widgets/desktop/README | 10 + examples/widgets/desktop/desktop.pro | 11 + examples/widgets/desktop/screenshot/main.cpp | 51 + examples/widgets/desktop/screenshot/screenshot.cpp | 199 +++ .../widgets/desktop/screenshot/screenshot.desktop | 11 + examples/widgets/desktop/screenshot/screenshot.h | 99 ++ examples/widgets/desktop/screenshot/screenshot.pro | 12 + examples/widgets/desktop/systray/images/bad.png | Bin 0 -> 2496 bytes examples/widgets/desktop/systray/images/heart.png | Bin 0 -> 25780 bytes examples/widgets/desktop/systray/images/trash.png | Bin 0 -> 12128 bytes examples/widgets/desktop/systray/main.cpp | 63 + examples/widgets/desktop/systray/systray.desktop | 11 + examples/widgets/desktop/systray/systray.pro | 14 + examples/widgets/desktop/systray/systray.qrc | 7 + examples/widgets/desktop/systray/window.cpp | 270 ++++ examples/widgets/desktop/systray/window.h | 112 ++ examples/widgets/dialogs/README | 9 + .../widgets/dialogs/classwizard/classwizard.cpp | 430 ++++++ .../dialogs/classwizard/classwizard.desktop | 11 + examples/widgets/dialogs/classwizard/classwizard.h | 156 +++ .../widgets/dialogs/classwizard/classwizard.pro | 13 + .../widgets/dialogs/classwizard/classwizard.qrc | 11 + .../dialogs/classwizard/images/background.png | Bin 0 -> 22578 bytes .../widgets/dialogs/classwizard/images/banner.png | Bin 0 -> 3947 bytes .../widgets/dialogs/classwizard/images/logo1.png | Bin 0 -> 1619 bytes .../widgets/dialogs/classwizard/images/logo2.png | Bin 0 -> 1619 bytes .../widgets/dialogs/classwizard/images/logo3.png | Bin 0 -> 1619 bytes .../dialogs/classwizard/images/watermark1.png | Bin 0 -> 14516 bytes .../dialogs/classwizard/images/watermark2.png | Bin 0 -> 14912 bytes examples/widgets/dialogs/classwizard/main.cpp | 63 + .../widgets/dialogs/configdialog/configdialog.cpp | 116 ++ .../dialogs/configdialog/configdialog.desktop | 11 + .../widgets/dialogs/configdialog/configdialog.h | 69 + .../widgets/dialogs/configdialog/configdialog.pro | 17 + .../widgets/dialogs/configdialog/configdialog.qrc | 7 + .../widgets/dialogs/configdialog/images/config.png | Bin 0 -> 6758 bytes .../widgets/dialogs/configdialog/images/query.png | Bin 0 -> 2116 bytes .../widgets/dialogs/configdialog/images/update.png | Bin 0 -> 7890 bytes examples/widgets/dialogs/configdialog/main.cpp | 52 + examples/widgets/dialogs/configdialog/pages.cpp | 151 ++ examples/widgets/dialogs/configdialog/pages.h | 64 + examples/widgets/dialogs/dialogs.pro | 19 + .../widgets/dialogs/extension/extension.desktop | 11 + examples/widgets/dialogs/extension/extension.pro | 12 + examples/widgets/dialogs/extension/finddialog.cpp | 114 ++ examples/widgets/dialogs/extension/finddialog.h | 78 ++ examples/widgets/dialogs/extension/main.cpp | 53 + .../widgets/dialogs/findfiles/findfiles.desktop | 11 + examples/widgets/dialogs/findfiles/findfiles.pro | 11 + examples/widgets/dialogs/findfiles/main.cpp | 51 + examples/widgets/dialogs/findfiles/window.cpp | 247 ++++ examples/widgets/dialogs/findfiles/window.h | 90 ++ .../widgets/dialogs/licensewizard/images/logo.png | Bin 0 -> 1810 bytes .../dialogs/licensewizard/images/watermark.png | Bin 0 -> 34998 bytes .../dialogs/licensewizard/licensewizard.cpp | 363 +++++ .../dialogs/licensewizard/licensewizard.desktop | 11 + .../widgets/dialogs/licensewizard/licensewizard.h | 163 +++ .../dialogs/licensewizard/licensewizard.pro | 13 + .../dialogs/licensewizard/licensewizard.qrc | 6 + examples/widgets/dialogs/licensewizard/main.cpp | 63 + examples/widgets/dialogs/sipdialog/dialog.cpp | 122 ++ examples/widgets/dialogs/sipdialog/dialog.h | 63 + examples/widgets/dialogs/sipdialog/main.cpp | 52 + .../widgets/dialogs/sipdialog/sipdialog.desktop | 11 + examples/widgets/dialogs/sipdialog/sipdialog.pro | 15 + .../widgets/dialogs/standarddialogs/dialog.cpp | 471 +++++++ examples/widgets/dialogs/standarddialogs/dialog.h | 101 ++ examples/widgets/dialogs/standarddialogs/main.cpp | 62 + .../standarddialogs/standarddialogs.desktop | 11 + .../dialogs/standarddialogs/standarddialogs.pro | 13 + examples/widgets/dialogs/tabdialog/main.cpp | 59 + examples/widgets/dialogs/tabdialog/tabdialog.cpp | 196 +++ .../widgets/dialogs/tabdialog/tabdialog.desktop | 11 + examples/widgets/dialogs/tabdialog/tabdialog.h | 99 ++ examples/widgets/dialogs/tabdialog/tabdialog.pro | 12 + .../dialogs/trivialwizard/trivialwizard.cpp | 135 ++ .../dialogs/trivialwizard/trivialwizard.desktop | 11 + .../dialogs/trivialwizard/trivialwizard.pro | 10 + examples/widgets/digitalclock/digitalclock.cpp | 72 - examples/widgets/digitalclock/digitalclock.desktop | 11 - examples/widgets/digitalclock/digitalclock.h | 59 - examples/widgets/digitalclock/digitalclock.pro | 11 - examples/widgets/digitalclock/main.cpp | 51 - examples/widgets/doc/addressbook.qdoc | 442 ++++++ examples/widgets/doc/affine.qdoc | 48 + examples/widgets/doc/analogclock.qdoc | 154 ++ examples/widgets/doc/animatedtiles.qdoc | 36 + examples/widgets/doc/appchooser.qdoc | 38 + examples/widgets/doc/application.qdoc | 396 ++++++ examples/widgets/doc/basicdrawing.qdoc | 454 ++++++ examples/widgets/doc/basicgraphicslayouts.qdoc | 164 +++ examples/widgets/doc/basiclayouts.qdoc | 190 +++ examples/widgets/doc/basicsortfiltermodel.qdoc | 37 + examples/widgets/doc/blurpicker.qdoc | 33 + examples/widgets/doc/borderlayout.qdoc | 36 + examples/widgets/doc/boxes.qdoc | 49 + examples/widgets/doc/calculator.qdoc | 375 +++++ examples/widgets/doc/calendar.qdoc | 223 +++ examples/widgets/doc/calendarwidget.qdoc | 291 ++++ examples/widgets/doc/charactermap.qdoc | 274 ++++ examples/widgets/doc/chart.qdoc | 82 ++ examples/widgets/doc/chip.qdoc | 38 + examples/widgets/doc/classwizard.qdoc | 190 +++ examples/widgets/doc/codeeditor.qdoc | 197 +++ examples/widgets/doc/coloreditorfactory.qdoc | 155 ++ examples/widgets/doc/combowidgetmapper.qdoc | 167 +++ examples/widgets/doc/composition.qdoc | 44 + examples/widgets/doc/concentriccircles.qdoc | 231 +++ examples/widgets/doc/configdialog.qdoc | 36 + examples/widgets/doc/customsortfiltermodel.qdoc | 289 ++++ examples/widgets/doc/deform.qdoc | 51 + examples/widgets/doc/diagramscene.qdoc | 834 +++++++++++ examples/widgets/doc/digitalclock.qdoc | 74 + examples/widgets/doc/dirview.qdoc | 36 + examples/widgets/doc/dockwidgets.qdoc | 163 +++ examples/widgets/doc/dragdroprobot.qdoc | 365 +++++ examples/widgets/doc/dynamiclayouts.qdoc | 34 + examples/widgets/doc/easing.qdoc | 37 + examples/widgets/doc/editabletreemodel.qdoc | 446 ++++++ examples/widgets/doc/elasticnodes.qdoc | 430 ++++++ examples/widgets/doc/elidedlabel.qdoc | 162 +++ examples/widgets/doc/embeddeddialogs.qdoc | 37 + examples/widgets/doc/eventtransitions.qdoc | 72 + examples/widgets/doc/extension.qdoc | 138 ++ examples/widgets/doc/factorial.qdoc | 88 ++ examples/widgets/doc/fademessage.qdoc | 37 + examples/widgets/doc/fetchmore.qdoc | 111 ++ examples/widgets/doc/findfiles.qdoc | 249 ++++ examples/widgets/doc/flowlayout.qdoc | 145 ++ examples/widgets/doc/fontsampler.qdoc | 35 + examples/widgets/doc/frozencolumn.qdoc | 133 ++ examples/widgets/doc/gradients.qdoc | 55 + examples/widgets/doc/groupbox.qdoc | 140 ++ examples/widgets/doc/icons.qdoc | 780 +++++++++++ examples/widgets/doc/imagecomposition.qdoc | 165 +++ examples/widgets/doc/imageviewer.qdoc | 326 +++++ examples/widgets/doc/interview.qdoc | 37 + examples/widgets/doc/licensewizard.qdoc | 218 +++ examples/widgets/doc/lighting.qdoc | 33 + examples/widgets/doc/lineedits.qdoc | 161 +++ examples/widgets/doc/mainwindow.qdoc | 36 + examples/widgets/doc/mdi.qdoc | 37 + examples/widgets/doc/menus.qdoc | 218 +++ examples/widgets/doc/moveblocks.qdoc | 214 +++ examples/widgets/doc/movie.qdoc | 39 + examples/widgets/doc/orderform.qdoc | 364 +++++ examples/widgets/doc/padnavigator.qdoc | 583 ++++++++ examples/widgets/doc/painterpaths.qdoc | 418 ++++++ examples/widgets/doc/pathstroke.qdoc | 47 + examples/widgets/doc/pingpong.qdoc | 93 ++ examples/widgets/doc/pixelator.qdoc | 255 ++++ examples/widgets/doc/recentfiles.qdoc | 36 + examples/widgets/doc/rogue.qdoc | 208 +++ examples/widgets/doc/screenshot.qdoc | 247 ++++ examples/widgets/doc/scribble.qdoc | 417 ++++++ examples/widgets/doc/sdi.qdoc | 36 + examples/widgets/doc/shapedclock.qdoc | 131 ++ examples/widgets/doc/simpledommodel.qdoc | 280 ++++ examples/widgets/doc/simpletreemodel.qdoc | 333 +++++ examples/widgets/doc/simplewidgetmapper.qdoc | 125 ++ examples/widgets/doc/sipdialog.qdoc | 127 ++ examples/widgets/doc/sliders.qdoc | 255 ++++ examples/widgets/doc/spinboxdelegate.qdoc | 141 ++ examples/widgets/doc/spinboxes.qdoc | 191 +++ examples/widgets/doc/spreadsheet.qdoc | 37 + examples/widgets/doc/standarddialogs.qdoc | 35 + examples/widgets/doc/stardelegate.qdoc | 296 ++++ examples/widgets/doc/states.qdoc | 36 + examples/widgets/doc/stickman.qdoc | 102 ++ examples/widgets/doc/styles.qdoc | 472 +++++++ examples/widgets/doc/stylesheet.qdoc | 36 + examples/widgets/doc/sub-attaq.qdoc | 40 + examples/widgets/doc/syntaxhighlighter.qdoc | 252 ++++ examples/widgets/doc/tabdialog.qdoc | 134 ++ examples/widgets/doc/tablet.qdoc | 369 +++++ examples/widgets/doc/tetrix.qdoc | 431 ++++++ examples/widgets/doc/textedit.qdoc | 36 + examples/widgets/doc/tooltips.qdoc | 394 ++++++ examples/widgets/doc/trafficlight.qdoc | 85 ++ examples/widgets/doc/transformations.qdoc | 371 +++++ examples/widgets/doc/trivialwizard.qdoc | 82 ++ examples/widgets/doc/twowaybutton.qdoc | 68 + examples/widgets/doc/wiggly.qdoc | 167 +++ examples/widgets/doc/windowflags.qdoc | 216 +++ examples/widgets/draganddrop/README | 9 + .../delayedencoding/delayedencoding.desktop | 11 + examples/widgets/draganddrop/draganddrop.pro | 13 + .../draggableicons/draggableicons.desktop | 11 + .../draganddrop/draggableicons/draggableicons.pro | 12 + .../draganddrop/draggableicons/draggableicons.qrc | 7 + .../draganddrop/draggableicons/dragwidget.cpp | 168 +++ .../draganddrop/draggableicons/dragwidget.h | 65 + .../draganddrop/draggableicons/images/boat.png | Bin 0 -> 2772 bytes .../draganddrop/draggableicons/images/car.png | Bin 0 -> 2963 bytes .../draganddrop/draggableicons/images/house.png | Bin 0 -> 3292 bytes .../widgets/draganddrop/draggableicons/main.cpp | 61 + .../draggabletext/draggabletext.desktop | 11 + .../draganddrop/draggabletext/draggabletext.pro | 15 + .../draganddrop/draggabletext/draggabletext.qrc | 5 + .../draganddrop/draggabletext/draglabel.cpp | 51 + .../widgets/draganddrop/draggabletext/draglabel.h | 58 + .../draganddrop/draggabletext/dragwidget.cpp | 165 +++ .../widgets/draganddrop/draggabletext/dragwidget.h | 62 + .../widgets/draganddrop/draggabletext/main.cpp | 52 + .../widgets/draganddrop/draggabletext/words.txt | 41 + examples/widgets/draganddrop/dropsite/droparea.cpp | 126 ++ examples/widgets/draganddrop/dropsite/droparea.h | 77 + .../widgets/draganddrop/dropsite/dropsite.desktop | 11 + examples/widgets/draganddrop/dropsite/dropsite.pro | 14 + .../draganddrop/dropsite/dropsitewindow.cpp | 143 ++ .../widgets/draganddrop/dropsite/dropsitewindow.h | 77 + examples/widgets/draganddrop/dropsite/main.cpp | 53 + .../draganddrop/fridgemagnets/draglabel.cpp | 89 ++ .../widgets/draganddrop/fridgemagnets/draglabel.h | 64 + .../draganddrop/fridgemagnets/dragwidget.cpp | 212 +++ .../widgets/draganddrop/fridgemagnets/dragwidget.h | 65 + .../fridgemagnets/fridgemagnets.desktop | 11 + .../draganddrop/fridgemagnets/fridgemagnets.pro | 15 + .../draganddrop/fridgemagnets/fridgemagnets.qrc | 5 + .../widgets/draganddrop/fridgemagnets/main.cpp | 61 + .../widgets/draganddrop/fridgemagnets/words.txt | 48 + examples/widgets/draganddrop/puzzle/example.jpg | Bin 0 -> 42654 bytes examples/widgets/draganddrop/puzzle/main.cpp | 54 + examples/widgets/draganddrop/puzzle/mainwindow.cpp | 152 ++ examples/widgets/draganddrop/puzzle/mainwindow.h | 76 + examples/widgets/draganddrop/puzzle/pieceslist.cpp | 121 ++ examples/widgets/draganddrop/puzzle/pieceslist.h | 63 + examples/widgets/draganddrop/puzzle/puzzle.desktop | 11 + examples/widgets/draganddrop/puzzle/puzzle.pro | 23 + examples/widgets/draganddrop/puzzle/puzzle.qrc | 5 + .../widgets/draganddrop/puzzle/puzzlewidget.cpp | 214 +++ examples/widgets/draganddrop/puzzle/puzzlewidget.h | 89 ++ examples/widgets/effects/blurpicker/blureffect.cpp | 68 + examples/widgets/effects/blurpicker/blureffect.h | 66 + examples/widgets/effects/blurpicker/blurpicker.cpp | 161 +++ .../widgets/effects/blurpicker/blurpicker.desktop | 11 + examples/widgets/effects/blurpicker/blurpicker.h | 75 + examples/widgets/effects/blurpicker/blurpicker.pro | 11 + examples/widgets/effects/blurpicker/blurpicker.qrc | 14 + .../widgets/effects/blurpicker/images/README.txt | 5 + .../blurpicker/images/accessories-calculator.png | Bin 0 -> 3760 bytes .../blurpicker/images/accessories-text-editor.png | Bin 0 -> 4746 bytes .../effects/blurpicker/images/background.jpg | Bin 0 -> 16259 bytes .../effects/blurpicker/images/help-browser.png | Bin 0 -> 5392 bytes .../blurpicker/images/internet-group-chat.png | Bin 0 -> 2809 bytes .../effects/blurpicker/images/internet-mail.png | Bin 0 -> 3899 bytes .../blurpicker/images/internet-web-browser.png | Bin 0 -> 6376 bytes .../effects/blurpicker/images/office-calendar.png | Bin 0 -> 4010 bytes .../effects/blurpicker/images/system-users.png | Bin 0 -> 5353 bytes examples/widgets/effects/blurpicker/main.cpp | 55 + examples/widgets/effects/effects.pro | 14 + examples/widgets/effects/fademessage/README.txt | 2 + .../widgets/effects/fademessage/background.jpg | Bin 0 -> 159108 bytes .../widgets/effects/fademessage/fademessage.cpp | 128 ++ .../effects/fademessage/fademessage.desktop | 11 + examples/widgets/effects/fademessage/fademessage.h | 70 + .../widgets/effects/fademessage/fademessage.pro | 18 + .../widgets/effects/fademessage/fademessage.qrc | 5 + examples/widgets/effects/fademessage/main.cpp | 55 + examples/widgets/effects/lighting/lighting.cpp | 139 ++ examples/widgets/effects/lighting/lighting.desktop | 11 + examples/widgets/effects/lighting/lighting.h | 70 + examples/widgets/effects/lighting/lighting.pro | 11 + examples/widgets/effects/lighting/main.cpp | 55 + examples/widgets/elidedlabel/elidedlabel.cpp | 111 -- examples/widgets/elidedlabel/elidedlabel.desktop | 11 - examples/widgets/elidedlabel/elidedlabel.h | 76 - examples/widgets/elidedlabel/elidedlabel.pro | 21 - examples/widgets/elidedlabel/main.cpp | 53 - examples/widgets/elidedlabel/testwidget.cpp | 161 --- examples/widgets/elidedlabel/testwidget.h | 76 - examples/widgets/graphicsview/README | 9 + .../graphicsview/anchorlayout/anchorlayout.desktop | 11 + .../graphicsview/anchorlayout/anchorlayout.pro | 13 + .../widgets/graphicsview/anchorlayout/main.cpp | 129 ++ .../basicgraphicslayouts.desktop | 11 + .../basicgraphicslayouts/basicgraphicslayouts.pro | 14 + .../basicgraphicslayouts/basicgraphicslayouts.qrc | 5 + .../basicgraphicslayouts/images/block.png | Bin 0 -> 2146 bytes .../basicgraphicslayouts/layoutitem.cpp | 130 ++ .../graphicsview/basicgraphicslayouts/layoutitem.h | 65 + .../graphicsview/basicgraphicslayouts/main.cpp | 58 + .../graphicsview/basicgraphicslayouts/window.cpp | 90 ++ .../graphicsview/basicgraphicslayouts/window.h | 57 + examples/widgets/graphicsview/boxes/3rdparty/fbm.c | 207 +++ examples/widgets/graphicsview/boxes/3rdparty/fbm.h | 40 + examples/widgets/graphicsview/boxes/basic.fsh | 73 + examples/widgets/graphicsview/boxes/basic.vsh | 61 + examples/widgets/graphicsview/boxes/boxes.pro | 39 + examples/widgets/graphicsview/boxes/boxes.qrc | 25 + .../widgets/graphicsview/boxes/cubemap_negx.jpg | Bin 0 -> 41060 bytes .../widgets/graphicsview/boxes/cubemap_negy.jpg | Bin 0 -> 15520 bytes .../widgets/graphicsview/boxes/cubemap_negz.jpg | Bin 0 -> 68911 bytes .../widgets/graphicsview/boxes/cubemap_posx.jpg | Bin 0 -> 74915 bytes .../widgets/graphicsview/boxes/cubemap_posy.jpg | Bin 0 -> 24193 bytes .../widgets/graphicsview/boxes/cubemap_posz.jpg | Bin 0 -> 57881 bytes examples/widgets/graphicsview/boxes/dotted.fsh | 66 + examples/widgets/graphicsview/boxes/fresnel.fsh | 79 ++ examples/widgets/graphicsview/boxes/glass.fsh | 76 + examples/widgets/graphicsview/boxes/glbuffers.cpp | 402 ++++++ examples/widgets/graphicsview/boxes/glbuffers.h | 366 +++++ .../widgets/graphicsview/boxes/glextensions.cpp | 98 ++ examples/widgets/graphicsview/boxes/glextensions.h | 202 +++ .../widgets/graphicsview/boxes/gltrianglemesh.h | 91 ++ examples/widgets/graphicsview/boxes/granite.fsh | 76 + examples/widgets/graphicsview/boxes/main.cpp | 150 ++ examples/widgets/graphicsview/boxes/marble.fsh | 71 + examples/widgets/graphicsview/boxes/parameters.par | 5 + examples/widgets/graphicsview/boxes/qt-logo.jpg | Bin 0 -> 40886 bytes examples/widgets/graphicsview/boxes/qt-logo.png | Bin 0 -> 13923 bytes examples/widgets/graphicsview/boxes/qtbox.cpp | 480 +++++++ examples/widgets/graphicsview/boxes/qtbox.h | 118 ++ examples/widgets/graphicsview/boxes/reflection.fsh | 54 + examples/widgets/graphicsview/boxes/refraction.fsh | 70 + examples/widgets/graphicsview/boxes/roundedbox.cpp | 161 +++ examples/widgets/graphicsview/boxes/roundedbox.h | 72 + examples/widgets/graphicsview/boxes/scene.cpp | 1085 ++++++++++++++ examples/widgets/graphicsview/boxes/scene.h | 245 ++++ examples/widgets/graphicsview/boxes/smiley.png | Bin 0 -> 14508 bytes examples/widgets/graphicsview/boxes/square.jpg | Bin 0 -> 14542 bytes examples/widgets/graphicsview/boxes/trackball.cpp | 160 +++ examples/widgets/graphicsview/boxes/trackball.h | 79 ++ examples/widgets/graphicsview/boxes/wood.fsh | 70 + examples/widgets/graphicsview/chip/chip.cpp | 183 +++ examples/widgets/graphicsview/chip/chip.h | 68 + examples/widgets/graphicsview/chip/chip.pro | 21 + examples/widgets/graphicsview/chip/fileprint.png | Bin 0 -> 1456 bytes examples/widgets/graphicsview/chip/images.qrc | 10 + examples/widgets/graphicsview/chip/main.cpp | 57 + examples/widgets/graphicsview/chip/mainwindow.cpp | 109 ++ examples/widgets/graphicsview/chip/mainwindow.h | 68 + examples/widgets/graphicsview/chip/qt4logo.png | Bin 0 -> 48333 bytes examples/widgets/graphicsview/chip/rotateleft.png | Bin 0 -> 1754 bytes examples/widgets/graphicsview/chip/rotateright.png | Bin 0 -> 1732 bytes examples/widgets/graphicsview/chip/view.cpp | 279 ++++ examples/widgets/graphicsview/chip/view.h | 104 ++ examples/widgets/graphicsview/chip/zoomin.png | Bin 0 -> 1622 bytes examples/widgets/graphicsview/chip/zoomout.png | Bin 0 -> 1601 bytes .../collidingmice/collidingmice.desktop | 11 + .../graphicsview/collidingmice/collidingmice.pro | 17 + .../graphicsview/collidingmice/images/cheese.jpg | Bin 0 -> 3029 bytes .../widgets/graphicsview/collidingmice/main.cpp | 91 ++ .../widgets/graphicsview/collidingmice/mice.qrc | 5 + .../widgets/graphicsview/collidingmice/mouse.cpp | 200 +++ .../widgets/graphicsview/collidingmice/mouse.h | 68 + .../widgets/graphicsview/diagramscene/arrow.cpp | 145 ++ examples/widgets/graphicsview/diagramscene/arrow.h | 91 ++ .../graphicsview/diagramscene/diagramitem.cpp | 152 ++ .../graphicsview/diagramscene/diagramitem.h | 96 ++ .../graphicsview/diagramscene/diagramscene.cpp | 240 ++++ .../graphicsview/diagramscene/diagramscene.desktop | 11 + .../graphicsview/diagramscene/diagramscene.h | 112 ++ .../graphicsview/diagramscene/diagramscene.pro | 23 + .../graphicsview/diagramscene/diagramscene.qrc | 20 + .../graphicsview/diagramscene/diagramtextitem.cpp | 81 ++ .../graphicsview/diagramscene/diagramtextitem.h | 78 ++ .../diagramscene/images/background1.png | Bin 0 -> 112 bytes .../diagramscene/images/background2.png | Bin 0 -> 114 bytes .../diagramscene/images/background3.png | Bin 0 -> 116 bytes .../diagramscene/images/background4.png | Bin 0 -> 96 bytes .../graphicsview/diagramscene/images/bold.png | Bin 0 -> 274 bytes .../diagramscene/images/bringtofront.png | Bin 0 -> 293 bytes .../graphicsview/diagramscene/images/delete.png | Bin 0 -> 831 bytes .../graphicsview/diagramscene/images/floodfill.png | Bin 0 -> 282 bytes .../graphicsview/diagramscene/images/italic.png | Bin 0 -> 247 bytes .../graphicsview/diagramscene/images/linecolor.png | Bin 0 -> 145 bytes .../diagramscene/images/linepointer.png | Bin 0 -> 141 bytes .../graphicsview/diagramscene/images/pointer.png | Bin 0 -> 173 bytes .../diagramscene/images/sendtoback.png | Bin 0 -> 318 bytes .../diagramscene/images/textpointer.png | Bin 0 -> 753 bytes .../graphicsview/diagramscene/images/underline.png | Bin 0 -> 250 bytes .../widgets/graphicsview/diagramscene/main.cpp | 55 + .../graphicsview/diagramscene/mainwindow.cpp | 661 +++++++++ .../widgets/graphicsview/diagramscene/mainwindow.h | 150 ++ .../graphicsview/dragdroprobot/coloritem.cpp | 142 ++ .../widgets/graphicsview/dragdroprobot/coloritem.h | 65 + .../dragdroprobot/dragdroprobot.desktop | 11 + .../graphicsview/dragdroprobot/dragdroprobot.pro | 22 + .../graphicsview/dragdroprobot/images/head.png | Bin 0 -> 14972 bytes .../widgets/graphicsview/dragdroprobot/main.cpp | 94 ++ .../widgets/graphicsview/dragdroprobot/robot.cpp | 307 ++++ .../widgets/graphicsview/dragdroprobot/robot.h | 118 ++ .../widgets/graphicsview/dragdroprobot/robot.qrc | 5 + .../widgets/graphicsview/elasticnodes/edge.cpp | 149 ++ examples/widgets/graphicsview/elasticnodes/edge.h | 75 + .../graphicsview/elasticnodes/elasticnodes.desktop | 11 + .../graphicsview/elasticnodes/elasticnodes.pro | 20 + .../graphicsview/elasticnodes/graphwidget.cpp | 250 ++++ .../graphicsview/elasticnodes/graphwidget.h | 77 + .../widgets/graphicsview/elasticnodes/main.cpp | 57 + .../widgets/graphicsview/elasticnodes/node.cpp | 212 +++ examples/widgets/graphicsview/elasticnodes/node.h | 85 ++ .../embeddeddialogs/No-Ones-Laughing-3.jpg | Bin 0 -> 30730 bytes .../graphicsview/embeddeddialogs/customproxy.cpp | 167 +++ .../graphicsview/embeddeddialogs/customproxy.h | 76 + .../embeddeddialogs/embeddeddialog.cpp | 106 ++ .../graphicsview/embeddeddialogs/embeddeddialog.h | 66 + .../graphicsview/embeddeddialogs/embeddeddialog.ui | 87 ++ .../embeddeddialogs/embeddeddialogs.pro | 19 + .../embeddeddialogs/embeddeddialogs.qrc | 5 + .../widgets/graphicsview/embeddeddialogs/main.cpp | 83 ++ .../widgets/graphicsview/flowlayout/flowlayout.cpp | 213 +++ .../graphicsview/flowlayout/flowlayout.desktop | 11 + .../widgets/graphicsview/flowlayout/flowlayout.h | 76 + .../widgets/graphicsview/flowlayout/flowlayout.pro | 14 + examples/widgets/graphicsview/flowlayout/main.cpp | 57 + .../widgets/graphicsview/flowlayout/window.cpp | 62 + examples/widgets/graphicsview/flowlayout/window.h | 47 + examples/widgets/graphicsview/graphicsview.pro | 28 + .../graphicsview/padnavigator/flippablepad.cpp | 98 ++ .../graphicsview/padnavigator/flippablepad.h | 63 + examples/widgets/graphicsview/padnavigator/form.ui | 208 +++ .../padnavigator/images/artsfftscope.png | Bin 0 -> 1291 bytes .../padnavigator/images/blue_angle_swirl.jpg | Bin 0 -> 11826 bytes .../padnavigator/images/kontact_contacts.png | Bin 0 -> 4382 bytes .../padnavigator/images/kontact_journal.png | Bin 0 -> 3261 bytes .../padnavigator/images/kontact_mail.png | Bin 0 -> 3202 bytes .../padnavigator/images/kontact_notes.png | Bin 0 -> 3893 bytes .../padnavigator/images/kopeteavailable.png | Bin 0 -> 2380 bytes .../padnavigator/images/metacontact_online.png | Bin 0 -> 2545 bytes .../graphicsview/padnavigator/images/minitools.png | Bin 0 -> 2087 bytes .../widgets/graphicsview/padnavigator/main.cpp | 55 + .../graphicsview/padnavigator/padnavigator.cpp | 306 ++++ .../graphicsview/padnavigator/padnavigator.desktop | 11 + .../graphicsview/padnavigator/padnavigator.h | 70 + .../graphicsview/padnavigator/padnavigator.pro | 28 + .../graphicsview/padnavigator/padnavigator.qrc | 13 + .../graphicsview/padnavigator/roundrectitem.cpp | 113 ++ .../graphicsview/padnavigator/roundrectitem.h | 75 + .../graphicsview/padnavigator/splashitem.cpp | 83 ++ .../widgets/graphicsview/padnavigator/splashitem.h | 61 + .../portedasteroids/portedasteroids.desktop | 11 + .../graphicsview/portedcanvas/portedcanvas.desktop | 11 + .../graphicsview/simpleanchorlayout/main.cpp | 134 ++ .../simpleanchorlayout/simpleanchorlayout.desktop | 11 + .../simpleanchorlayout/simpleanchorlayout.pro | 12 + .../weatheranchorlayout/images/5days.jpg | Bin 0 -> 5748 bytes .../weatheranchorlayout/images/details.jpg | Bin 0 -> 5323 bytes .../weatheranchorlayout/images/place.jpg | Bin 0 -> 62438 bytes .../weatheranchorlayout/images/tabbar.jpg | Bin 0 -> 849 bytes .../weatheranchorlayout/images/title.jpg | Bin 0 -> 3472 bytes .../images/weather-few-clouds.png | Bin 0 -> 18976 bytes .../graphicsview/weatheranchorlayout/main.cpp | 274 ++++ .../weatheranchorlayout.desktop | 11 + .../weatheranchorlayout/weatheranchorlayout.pro | 12 + .../weatheranchorlayout/weatheranchorlayout.qrc | 10 + examples/widgets/groupbox/groupbox.desktop | 11 - examples/widgets/groupbox/groupbox.pro | 13 - examples/widgets/groupbox/main.cpp | 51 - examples/widgets/groupbox/window.cpp | 189 --- examples/widgets/groupbox/window.h | 66 - examples/widgets/icons/iconpreviewarea.cpp | 141 -- examples/widgets/icons/iconpreviewarea.h | 77 - examples/widgets/icons/icons.desktop | 11 - examples/widgets/icons/icons.pro | 29 - examples/widgets/icons/iconsizespinbox.cpp | 70 - examples/widgets/icons/iconsizespinbox.h | 59 - examples/widgets/icons/imagedelegate.cpp | 105 -- examples/widgets/icons/imagedelegate.h | 68 - examples/widgets/icons/images/designer.png | Bin 4205 -> 0 bytes examples/widgets/icons/images/find_disabled.png | Bin 501 -> 0 bytes examples/widgets/icons/images/find_normal.png | Bin 838 -> 0 bytes .../widgets/icons/images/monkey_off_128x128.png | Bin 7045 -> 0 bytes examples/widgets/icons/images/monkey_off_16x16.png | Bin 683 -> 0 bytes examples/widgets/icons/images/monkey_off_32x32.png | Bin 1609 -> 0 bytes examples/widgets/icons/images/monkey_off_64x64.png | Bin 3533 -> 0 bytes .../widgets/icons/images/monkey_on_128x128.png | Bin 6909 -> 0 bytes examples/widgets/icons/images/monkey_on_16x16.png | Bin 681 -> 0 bytes examples/widgets/icons/images/monkey_on_32x32.png | Bin 1577 -> 0 bytes examples/widgets/icons/images/monkey_on_64x64.png | Bin 3479 -> 0 bytes .../widgets/icons/images/qt_extended_16x16.png | Bin 834 -> 0 bytes .../widgets/icons/images/qt_extended_32x32.png | Bin 1892 -> 0 bytes .../widgets/icons/images/qt_extended_48x48.png | Bin 3672 -> 0 bytes examples/widgets/icons/main.cpp | 51 - examples/widgets/icons/mainwindow.cpp | 442 ------ examples/widgets/icons/mainwindow.h | 116 -- examples/widgets/imageviewer/imageviewer.cpp | 280 ---- examples/widgets/imageviewer/imageviewer.desktop | 11 - examples/widgets/imageviewer/imageviewer.h | 105 -- examples/widgets/imageviewer/imageviewer.pro | 18 - examples/widgets/imageviewer/main.cpp | 51 - examples/widgets/itemviews/README | 8 + .../widgets/itemviews/addressbook/adddialog.cpp | 82 ++ examples/widgets/itemviews/addressbook/adddialog.h | 71 + .../itemviews/addressbook/addressbook.desktop | 11 + .../widgets/itemviews/addressbook/addressbook.pro | 19 + .../itemviews/addressbook/addresswidget.cpp | 236 ++++ .../widgets/itemviews/addressbook/addresswidget.h | 82 ++ examples/widgets/itemviews/addressbook/main.cpp | 52 + .../widgets/itemviews/addressbook/mainwindow.cpp | 137 ++ .../widgets/itemviews/addressbook/mainwindow.h | 75 + .../itemviews/addressbook/newaddresstab.cpp | 77 + .../widgets/itemviews/addressbook/newaddresstab.h | 74 + .../widgets/itemviews/addressbook/tablemodel.cpp | 184 +++ .../widgets/itemviews/addressbook/tablemodel.h | 72 + .../basicsortfiltermodel.desktop | 11 + .../basicsortfiltermodel/basicsortfiltermodel.pro | 12 + .../itemviews/basicsortfiltermodel/main.cpp | 93 ++ .../itemviews/basicsortfiltermodel/window.cpp | 157 +++ .../itemviews/basicsortfiltermodel/window.h | 88 ++ examples/widgets/itemviews/chart/chart.desktop | 11 + examples/widgets/itemviews/chart/chart.pro | 18 + examples/widgets/itemviews/chart/chart.qrc | 5 + examples/widgets/itemviews/chart/main.cpp | 53 + examples/widgets/itemviews/chart/mainwindow.cpp | 172 +++ examples/widgets/itemviews/chart/mainwindow.h | 72 + examples/widgets/itemviews/chart/mydata.cht | 8 + examples/widgets/itemviews/chart/pieview.cpp | 557 ++++++++ examples/widgets/itemviews/chart/pieview.h | 114 ++ examples/widgets/itemviews/chart/qtdata.cht | 14 + .../coloreditorfactory/coloreditorfactory.desktop | 11 + .../coloreditorfactory/coloreditorfactory.pro | 14 + .../coloreditorfactory/colorlisteditor.cpp | 76 + .../itemviews/coloreditorfactory/colorlisteditor.h | 69 + .../widgets/itemviews/coloreditorfactory/main.cpp | 53 + .../itemviews/coloreditorfactory/window.cpp | 94 ++ .../widgets/itemviews/coloreditorfactory/window.h | 57 + .../combowidgetmapper/combowidgetmapper.desktop | 11 + .../combowidgetmapper/combowidgetmapper.pro | 11 + .../widgets/itemviews/combowidgetmapper/main.cpp | 51 + .../widgets/itemviews/combowidgetmapper/window.cpp | 136 ++ .../widgets/itemviews/combowidgetmapper/window.h | 86 ++ .../customsortfiltermodel.desktop | 11 + .../customsortfiltermodel.pro | 14 + .../itemviews/customsortfiltermodel/main.cpp | 95 ++ .../mysortfilterproxymodel.cpp | 115 ++ .../customsortfiltermodel/mysortfilterproxymodel.h | 73 + .../itemviews/customsortfiltermodel/window.cpp | 166 +++ .../itemviews/customsortfiltermodel/window.h | 90 ++ examples/widgets/itemviews/dirview/dirview.desktop | 11 + examples/widgets/itemviews/dirview/dirview.pro | 9 + examples/widgets/itemviews/dirview/main.cpp | 62 + .../itemviews/editabletreemodel/default.txt | 40 + .../editabletreemodel/editabletreemodel.desktop | 11 + .../editabletreemodel/editabletreemodel.pro | 18 + .../editabletreemodel/editabletreemodel.qrc | 5 + .../widgets/itemviews/editabletreemodel/main.cpp | 53 + .../itemviews/editabletreemodel/mainwindow.cpp | 181 +++ .../itemviews/editabletreemodel/mainwindow.h | 71 + .../itemviews/editabletreemodel/mainwindow.ui | 128 ++ .../itemviews/editabletreemodel/treeitem.cpp | 179 +++ .../widgets/itemviews/editabletreemodel/treeitem.h | 74 + .../itemviews/editabletreemodel/treemodel.cpp | 288 ++++ .../itemviews/editabletreemodel/treemodel.h | 97 ++ .../widgets/itemviews/fetchmore/fetchmore.desktop | 11 + examples/widgets/itemviews/fetchmore/fetchmore.pro | 13 + .../widgets/itemviews/fetchmore/filelistmodel.cpp | 116 ++ .../widgets/itemviews/fetchmore/filelistmodel.h | 75 + examples/widgets/itemviews/fetchmore/main.cpp | 50 + examples/widgets/itemviews/fetchmore/window.cpp | 81 ++ examples/widgets/itemviews/fetchmore/window.h | 64 + .../itemviews/frozencolumn/freezetablewidget.cpp | 165 +++ .../itemviews/frozencolumn/freezetablewidget.h | 72 + .../itemviews/frozencolumn/frozencolumn.desktop | 11 + .../itemviews/frozencolumn/frozencolumn.pro | 11 + examples/widgets/itemviews/frozencolumn/grades.qrc | 5 + examples/widgets/itemviews/frozencolumn/grades.txt | 36 + examples/widgets/itemviews/frozencolumn/main.cpp | 88 ++ examples/widgets/itemviews/interview/README | 2 + .../widgets/itemviews/interview/images/folder.png | Bin 0 -> 3910 bytes .../itemviews/interview/images/interview.png | Bin 0 -> 174 bytes .../itemviews/interview/images/services.png | Bin 0 -> 3749 bytes examples/widgets/itemviews/interview/interview.pro | 19 + examples/widgets/itemviews/interview/interview.qrc | 7 + examples/widgets/itemviews/interview/main.cpp | 95 ++ examples/widgets/itemviews/interview/model.cpp | 147 ++ examples/widgets/itemviews/interview/model.h | 90 ++ examples/widgets/itemviews/itemviews.pro | 25 + .../widgets/itemviews/pixelator/imagemodel.cpp | 92 ++ examples/widgets/itemviews/pixelator/imagemodel.h | 68 + examples/widgets/itemviews/pixelator/images.qrc | 5 + examples/widgets/itemviews/pixelator/images/qt.png | Bin 0 -> 656 bytes examples/widgets/itemviews/pixelator/main.cpp | 54 + .../widgets/itemviews/pixelator/mainwindow.cpp | 248 ++++ examples/widgets/itemviews/pixelator/mainwindow.h | 74 + .../widgets/itemviews/pixelator/pixelator.desktop | 11 + examples/widgets/itemviews/pixelator/pixelator.pro | 17 + .../widgets/itemviews/pixelator/pixeldelegate.cpp | 107 ++ .../widgets/itemviews/pixelator/pixeldelegate.h | 79 ++ examples/widgets/itemviews/puzzle/example.jpg | Bin 0 -> 42654 bytes examples/widgets/itemviews/puzzle/main.cpp | 54 + examples/widgets/itemviews/puzzle/mainwindow.cpp | 149 ++ examples/widgets/itemviews/puzzle/mainwindow.h | 77 + examples/widgets/itemviews/puzzle/piecesmodel.cpp | 203 +++ examples/widgets/itemviews/puzzle/piecesmodel.h | 82 ++ examples/widgets/itemviews/puzzle/puzzle.desktop | 11 + examples/widgets/itemviews/puzzle/puzzle.pro | 22 + examples/widgets/itemviews/puzzle/puzzle.qrc | 5 + examples/widgets/itemviews/puzzle/puzzlewidget.cpp | 214 +++ examples/widgets/itemviews/puzzle/puzzlewidget.h | 89 ++ .../widgets/itemviews/simpledommodel/domitem.cpp | 101 ++ .../widgets/itemviews/simpledommodel/domitem.h | 66 + .../widgets/itemviews/simpledommodel/dommodel.cpp | 189 +++ .../widgets/itemviews/simpledommodel/dommodel.h | 76 + examples/widgets/itemviews/simpledommodel/main.cpp | 52 + .../itemviews/simpledommodel/mainwindow.cpp | 84 ++ .../widgets/itemviews/simpledommodel/mainwindow.h | 70 + .../simpledommodel/simpledommodel.desktop | 11 + .../itemviews/simpledommodel/simpledommodel.pro | 16 + .../widgets/itemviews/simpletreemodel/default.txt | 40 + .../widgets/itemviews/simpletreemodel/main.cpp | 61 + .../simpletreemodel/simpletreemodel.desktop | 11 + .../itemviews/simpletreemodel/simpletreemodel.pro | 15 + .../itemviews/simpletreemodel/simpletreemodel.qrc | 5 + .../widgets/itemviews/simpletreemodel/treeitem.cpp | 116 ++ .../widgets/itemviews/simpletreemodel/treeitem.h | 70 + .../itemviews/simpletreemodel/treemodel.cpp | 218 +++ .../widgets/itemviews/simpletreemodel/treemodel.h | 76 + .../widgets/itemviews/simplewidgetmapper/main.cpp | 51 + .../simplewidgetmapper/simplewidgetmapper.desktop | 11 + .../simplewidgetmapper/simplewidgetmapper.pro | 11 + .../itemviews/simplewidgetmapper/window.cpp | 133 ++ .../widgets/itemviews/simplewidgetmapper/window.h | 84 ++ .../widgets/itemviews/spinboxdelegate/delegate.cpp | 102 ++ .../widgets/itemviews/spinboxdelegate/delegate.h | 70 + .../widgets/itemviews/spinboxdelegate/main.cpp | 86 ++ .../spinboxdelegate/spinboxdelegate.desktop | 11 + .../itemviews/spinboxdelegate/spinboxdelegate.pro | 13 + .../itemviews/spreadsheet/images/interview.png | Bin 0 -> 174 bytes examples/widgets/itemviews/spreadsheet/main.cpp | 55 + .../widgets/itemviews/spreadsheet/printview.cpp | 62 + examples/widgets/itemviews/spreadsheet/printview.h | 63 + .../widgets/itemviews/spreadsheet/spreadsheet.cpp | 639 +++++++++ .../widgets/itemviews/spreadsheet/spreadsheet.h | 124 ++ .../widgets/itemviews/spreadsheet/spreadsheet.pro | 23 + .../widgets/itemviews/spreadsheet/spreadsheet.qrc | 5 + .../itemviews/spreadsheet/spreadsheetdelegate.cpp | 114 ++ .../itemviews/spreadsheet/spreadsheetdelegate.h | 65 + .../itemviews/spreadsheet/spreadsheetitem.cpp | 167 +++ .../itemviews/spreadsheet/spreadsheetitem.h | 73 + examples/widgets/itemviews/stardelegate/main.cpp | 107 ++ .../itemviews/stardelegate/stardelegate.cpp | 129 ++ .../itemviews/stardelegate/stardelegate.desktop | 11 + .../widgets/itemviews/stardelegate/stardelegate.h | 69 + .../itemviews/stardelegate/stardelegate.pro | 17 + .../widgets/itemviews/stardelegate/stareditor.cpp | 98 ++ .../widgets/itemviews/stardelegate/stareditor.h | 77 + .../widgets/itemviews/stardelegate/starrating.cpp | 102 ++ .../widgets/itemviews/stardelegate/starrating.h | 76 + examples/widgets/layouts/README | 10 + .../layouts/basiclayouts/basiclayouts.desktop | 11 + .../widgets/layouts/basiclayouts/basiclayouts.pro | 13 + examples/widgets/layouts/basiclayouts/dialog.cpp | 149 ++ examples/widgets/layouts/basiclayouts/dialog.h | 90 ++ examples/widgets/layouts/basiclayouts/main.cpp | 52 + .../widgets/layouts/borderlayout/borderlayout.cpp | 213 +++ .../layouts/borderlayout/borderlayout.desktop | 11 + .../widgets/layouts/borderlayout/borderlayout.h | 88 ++ .../widgets/layouts/borderlayout/borderlayout.pro | 13 + examples/widgets/layouts/borderlayout/main.cpp | 51 + examples/widgets/layouts/borderlayout/window.cpp | 68 + examples/widgets/layouts/borderlayout/window.h | 61 + examples/widgets/layouts/dynamiclayouts/dialog.cpp | 169 +++ examples/widgets/layouts/dynamiclayouts/dialog.h | 91 ++ .../layouts/dynamiclayouts/dynamiclayouts.desktop | 11 + .../layouts/dynamiclayouts/dynamiclayouts.pro | 13 + examples/widgets/layouts/dynamiclayouts/main.cpp | 51 + examples/widgets/layouts/flowlayout/flowlayout.cpp | 213 +++ .../widgets/layouts/flowlayout/flowlayout.desktop | 11 + examples/widgets/layouts/flowlayout/flowlayout.h | 78 ++ examples/widgets/layouts/flowlayout/flowlayout.pro | 13 + examples/widgets/layouts/flowlayout/main.cpp | 51 + examples/widgets/layouts/flowlayout/window.cpp | 59 + examples/widgets/layouts/flowlayout/window.h | 59 + examples/widgets/layouts/layouts.pro | 12 + examples/widgets/lineedits/lineedits.desktop | 11 - examples/widgets/lineedits/lineedits.pro | 11 - examples/widgets/lineedits/main.cpp | 51 - examples/widgets/lineedits/window.cpp | 256 ---- examples/widgets/lineedits/window.h | 75 - examples/widgets/mainwindows/README | 9 + .../mainwindows/application/application.desktop | 11 + .../mainwindows/application/application.pro | 16 + .../mainwindows/application/application.qrc | 10 + .../mainwindows/application/images/copy.png | Bin 0 -> 1338 bytes .../widgets/mainwindows/application/images/cut.png | Bin 0 -> 1323 bytes .../widgets/mainwindows/application/images/new.png | Bin 0 -> 852 bytes .../mainwindows/application/images/open.png | Bin 0 -> 2073 bytes .../mainwindows/application/images/paste.png | Bin 0 -> 1645 bytes .../mainwindows/application/images/save.png | Bin 0 -> 1187 bytes examples/widgets/mainwindows/application/main.cpp | 57 + .../widgets/mainwindows/application/mainwindow.cpp | 392 ++++++ .../widgets/mainwindows/application/mainwindow.h | 105 ++ .../mainwindows/dockwidgets/dockwidgets.desktop | 11 + .../mainwindows/dockwidgets/dockwidgets.pro | 15 + .../mainwindows/dockwidgets/dockwidgets.qrc | 8 + .../widgets/mainwindows/dockwidgets/images/new.png | Bin 0 -> 977 bytes .../mainwindows/dockwidgets/images/print.png | Bin 0 -> 1732 bytes .../mainwindows/dockwidgets/images/save.png | Bin 0 -> 1894 bytes .../mainwindows/dockwidgets/images/undo.png | Bin 0 -> 1768 bytes examples/widgets/mainwindows/dockwidgets/main.cpp | 52 + .../widgets/mainwindows/dockwidgets/mainwindow.cpp | 345 +++++ .../widgets/mainwindows/dockwidgets/mainwindow.h | 97 ++ .../widgets/mainwindows/mainwindow/colorswatch.cpp | 746 ++++++++++ .../widgets/mainwindows/mainwindow/colorswatch.h | 136 ++ examples/widgets/mainwindows/mainwindow/main.cpp | 164 +++ .../widgets/mainwindows/mainwindow/mainwindow.cpp | 509 +++++++ .../widgets/mainwindows/mainwindow/mainwindow.h | 90 ++ .../widgets/mainwindows/mainwindow/mainwindow.pro | 17 + .../widgets/mainwindows/mainwindow/mainwindow.qrc | 8 + examples/widgets/mainwindows/mainwindow/qt.png | Bin 0 -> 2037 bytes .../mainwindows/mainwindow/titlebarCenter.png | Bin 0 -> 146 bytes .../mainwindows/mainwindow/titlebarLeft.png | Bin 0 -> 5148 bytes .../mainwindows/mainwindow/titlebarRight.png | Bin 0 -> 2704 bytes .../widgets/mainwindows/mainwindow/toolbar.cpp | 383 +++++ examples/widgets/mainwindows/mainwindow/toolbar.h | 118 ++ examples/widgets/mainwindows/mainwindows.pro | 16 + examples/widgets/mainwindows/mdi/images/copy.png | Bin 0 -> 1338 bytes examples/widgets/mainwindows/mdi/images/cut.png | Bin 0 -> 1323 bytes examples/widgets/mainwindows/mdi/images/new.png | Bin 0 -> 852 bytes examples/widgets/mainwindows/mdi/images/open.png | Bin 0 -> 2073 bytes examples/widgets/mainwindows/mdi/images/paste.png | Bin 0 -> 1645 bytes examples/widgets/mainwindows/mdi/images/save.png | Bin 0 -> 1187 bytes examples/widgets/mainwindows/mdi/main.cpp | 53 + examples/widgets/mainwindows/mdi/mainwindow.cpp | 411 ++++++ examples/widgets/mainwindows/mdi/mainwindow.h | 122 ++ examples/widgets/mainwindows/mdi/mdi.desktop | 11 + examples/widgets/mainwindows/mdi/mdi.pro | 16 + examples/widgets/mainwindows/mdi/mdi.qrc | 10 + examples/widgets/mainwindows/mdi/mdichild.cpp | 175 +++ examples/widgets/mainwindows/mdi/mdichild.h | 76 + examples/widgets/mainwindows/menus/main.cpp | 51 + examples/widgets/mainwindows/menus/mainwindow.cpp | 370 +++++ examples/widgets/mainwindows/menus/mainwindow.h | 124 ++ examples/widgets/mainwindows/menus/menus.desktop | 11 + examples/widgets/mainwindows/menus/menus.pro | 11 + examples/widgets/mainwindows/recentfiles/main.cpp | 53 + .../widgets/mainwindows/recentfiles/mainwindow.cpp | 251 ++++ .../widgets/mainwindows/recentfiles/mainwindow.h | 96 ++ .../mainwindows/recentfiles/recentfiles.desktop | 11 + .../mainwindows/recentfiles/recentfiles.pro | 13 + examples/widgets/mainwindows/sdi/images/copy.png | Bin 0 -> 1338 bytes examples/widgets/mainwindows/sdi/images/cut.png | Bin 0 -> 1323 bytes examples/widgets/mainwindows/sdi/images/new.png | Bin 0 -> 852 bytes examples/widgets/mainwindows/sdi/images/open.png | Bin 0 -> 2073 bytes examples/widgets/mainwindows/sdi/images/paste.png | Bin 0 -> 1645 bytes examples/widgets/mainwindows/sdi/images/save.png | Bin 0 -> 1187 bytes examples/widgets/mainwindows/sdi/main.cpp | 54 + examples/widgets/mainwindows/sdi/mainwindow.cpp | 372 +++++ examples/widgets/mainwindows/sdi/mainwindow.h | 110 ++ examples/widgets/mainwindows/sdi/sdi.desktop | 11 + examples/widgets/mainwindows/sdi/sdi.pro | 14 + examples/widgets/mainwindows/sdi/sdi.qrc | 10 + examples/widgets/mousebuttons/buttontester.cpp | 172 --- examples/widgets/mousebuttons/buttontester.h | 64 - examples/widgets/mousebuttons/main.cpp | 66 - examples/widgets/mousebuttons/mousebuttons.pro | 18 - examples/widgets/movie/animation.gif | Bin 42629 -> 0 bytes examples/widgets/movie/main.cpp | 52 - examples/widgets/movie/movie.desktop | 11 - examples/widgets/movie/movie.pro | 20 - examples/widgets/movie/movieplayer.cpp | 210 --- examples/widgets/movie/movieplayer.h | 96 -- examples/widgets/orientation/image_a.png | Bin 1075 -> 0 bytes examples/widgets/orientation/image_b.png | Bin 1020 -> 0 bytes examples/widgets/orientation/image_c.png | Bin 1163 -> 0 bytes examples/widgets/orientation/images.qrc | 7 - examples/widgets/orientation/landscape.ui | 114 -- examples/widgets/orientation/main.cpp | 55 - examples/widgets/orientation/mainwindow.cpp | 112 -- examples/widgets/orientation/mainwindow.h | 75 - examples/widgets/orientation/orientation.desktop | 11 - examples/widgets/orientation/orientation.pro | 31 - examples/widgets/orientation/portrait.ui | 61 - examples/widgets/painting/README | 11 + examples/widgets/painting/affine/affine.pro | 24 + examples/widgets/painting/affine/affine.qrc | 7 + examples/widgets/painting/affine/bg1.jpg | Bin 0 -> 23771 bytes examples/widgets/painting/affine/main.cpp | 65 + examples/widgets/painting/affine/xform.cpp | 902 ++++++++++++ examples/widgets/painting/affine/xform.h | 141 ++ examples/widgets/painting/affine/xform.html | 23 + .../painting/basicdrawing/basicdrawing.desktop | 11 + .../widgets/painting/basicdrawing/basicdrawing.pro | 14 + .../widgets/painting/basicdrawing/basicdrawing.qrc | 6 + .../widgets/painting/basicdrawing/images/brick.png | Bin 0 -> 767 bytes .../painting/basicdrawing/images/qt-logo.png | Bin 0 -> 3696 bytes examples/widgets/painting/basicdrawing/main.cpp | 53 + .../widgets/painting/basicdrawing/renderarea.cpp | 207 +++ .../widgets/painting/basicdrawing/renderarea.h | 83 ++ examples/widgets/painting/basicdrawing/window.cpp | 259 ++++ examples/widgets/painting/basicdrawing/window.h | 87 ++ .../widgets/painting/composition/composition.cpp | 522 +++++++ .../widgets/painting/composition/composition.h | 187 +++ .../widgets/painting/composition/composition.html | 23 + .../widgets/painting/composition/composition.pro | 29 + .../widgets/painting/composition/composition.qrc | 8 + examples/widgets/painting/composition/flower.jpg | Bin 0 -> 49616 bytes .../widgets/painting/composition/flower_alpha.jpg | Bin 0 -> 67326 bytes examples/widgets/painting/composition/main.cpp | 65 + .../painting/concentriccircles/circlewidget.cpp | 124 ++ .../painting/concentriccircles/circlewidget.h | 73 + .../concentriccircles/concentriccircles.desktop | 11 + .../concentriccircles/concentriccircles.pro | 14 + .../widgets/painting/concentriccircles/main.cpp | 51 + .../widgets/painting/concentriccircles/window.cpp | 93 ++ .../widgets/painting/concentriccircles/window.h | 70 + examples/widgets/painting/deform/deform.pro | 20 + examples/widgets/painting/deform/deform.qrc | 6 + examples/widgets/painting/deform/main.cpp | 72 + examples/widgets/painting/deform/pathdeform.cpp | 646 +++++++++ examples/widgets/painting/deform/pathdeform.h | 153 ++ examples/widgets/painting/deform/pathdeform.html | 24 + .../painting/fontsampler/fontsampler.desktop | 11 + .../widgets/painting/fontsampler/fontsampler.pro | 13 + examples/widgets/painting/fontsampler/main.cpp | 51 + .../widgets/painting/fontsampler/mainwindow.cpp | 380 +++++ examples/widgets/painting/fontsampler/mainwindow.h | 87 ++ .../widgets/painting/fontsampler/mainwindowbase.ui | 142 ++ examples/widgets/painting/gradients/gradients.cpp | 516 +++++++ examples/widgets/painting/gradients/gradients.h | 170 +++ examples/widgets/painting/gradients/gradients.html | 31 + examples/widgets/painting/gradients/gradients.pro | 20 + examples/widgets/painting/gradients/gradients.qrc | 6 + examples/widgets/painting/gradients/main.cpp | 63 + .../painting/imagecomposition/imagecomposer.cpp | 211 +++ .../painting/imagecomposition/imagecomposer.h | 87 ++ .../imagecomposition/imagecomposition.desktop | 11 + .../painting/imagecomposition/imagecomposition.pro | 13 + .../painting/imagecomposition/imagecomposition.qrc | 6 + .../imagecomposition/images/background.png | Bin 0 -> 18579 bytes .../imagecomposition/images/blackrectangle.png | Bin 0 -> 90 bytes .../painting/imagecomposition/images/butterfly.png | Bin 0 -> 36868 bytes .../painting/imagecomposition/images/checker.png | Bin 0 -> 10384 bytes .../widgets/painting/imagecomposition/main.cpp | 55 + examples/widgets/painting/painterpaths/main.cpp | 51 + .../painting/painterpaths/painterpaths.desktop | 11 + .../widgets/painting/painterpaths/painterpaths.pro | 15 + .../widgets/painting/painterpaths/renderarea.cpp | 130 ++ .../widgets/painting/painterpaths/renderarea.h | 80 ++ examples/widgets/painting/painterpaths/window.cpp | 289 ++++ examples/widgets/painting/painterpaths/window.h | 90 ++ examples/widgets/painting/painting.pro | 36 + examples/widgets/painting/pathstroke/main.cpp | 71 + .../widgets/painting/pathstroke/pathstroke.cpp | 685 +++++++++ examples/widgets/painting/pathstroke/pathstroke.h | 171 +++ .../widgets/painting/pathstroke/pathstroke.html | 20 + .../widgets/painting/pathstroke/pathstroke.pro | 21 + .../widgets/painting/pathstroke/pathstroke.qrc | 6 + examples/widgets/painting/shared/arthurstyle.cpp | 452 ++++++ examples/widgets/painting/shared/arthurstyle.h | 79 ++ examples/widgets/painting/shared/arthurwidgets.cpp | 355 +++++ examples/widgets/painting/shared/arthurwidgets.h | 137 ++ examples/widgets/painting/shared/hoverpoints.cpp | 415 ++++++ examples/widgets/painting/shared/hoverpoints.h | 162 +++ .../widgets/painting/shared/images/bg_pattern.png | Bin 0 -> 104 bytes .../shared/images/button_normal_cap_left.png | Bin 0 -> 654 bytes .../shared/images/button_normal_cap_right.png | Bin 0 -> 674 bytes .../shared/images/button_normal_stretch.png | Bin 0 -> 185 bytes .../shared/images/button_pressed_cap_left.png | Bin 0 -> 710 bytes .../shared/images/button_pressed_cap_right.png | Bin 0 -> 785 bytes .../shared/images/button_pressed_stretch.png | Bin 0 -> 217 bytes .../painting/shared/images/curve_thing_edit-6.png | Bin 0 -> 58097 bytes .../painting/shared/images/frame_bottom.png | Bin 0 -> 166 bytes .../painting/shared/images/frame_bottomleft.png | Bin 0 -> 602 bytes .../painting/shared/images/frame_bottomright.png | Bin 0 -> 553 bytes .../widgets/painting/shared/images/frame_left.png | Bin 0 -> 182 bytes .../widgets/painting/shared/images/frame_right.png | Bin 0 -> 175 bytes .../widgets/painting/shared/images/frame_top.png | Bin 0 -> 188 bytes .../painting/shared/images/frame_topleft.png | Bin 0 -> 801 bytes .../painting/shared/images/frame_topright.png | Bin 0 -> 851 bytes .../shared/images/groupframe_bottom_left.png | Bin 0 -> 397 bytes .../shared/images/groupframe_bottom_right.png | Bin 0 -> 383 bytes .../shared/images/groupframe_bottom_stretch.png | Bin 0 -> 141 bytes .../shared/images/groupframe_left_stretch.png | Bin 0 -> 132 bytes .../shared/images/groupframe_right_stretch.png | Bin 0 -> 113 bytes .../shared/images/groupframe_top_stretch.png | Bin 0 -> 115 bytes .../painting/shared/images/groupframe_topleft.png | Bin 0 -> 412 bytes .../painting/shared/images/groupframe_topright.png | Bin 0 -> 449 bytes .../painting/shared/images/line_dash_dot.png | Bin 0 -> 151 bytes .../painting/shared/images/line_dash_dot_dot.png | Bin 0 -> 155 bytes .../widgets/painting/shared/images/line_dashed.png | Bin 0 -> 121 bytes .../widgets/painting/shared/images/line_dotted.png | Bin 0 -> 116 bytes .../widgets/painting/shared/images/line_solid.png | Bin 0 -> 110 bytes .../painting/shared/images/radiobutton-off.png | Bin 0 -> 442 bytes .../painting/shared/images/radiobutton-on.png | Bin 0 -> 474 bytes .../painting/shared/images/radiobutton_off.png | Bin 0 -> 442 bytes .../painting/shared/images/radiobutton_on.png | Bin 0 -> 499 bytes .../widgets/painting/shared/images/slider_bar.png | Bin 0 -> 748 bytes .../painting/shared/images/slider_thumb_off.png | Bin 0 -> 823 bytes .../painting/shared/images/slider_thumb_on.png | Bin 0 -> 798 bytes .../painting/shared/images/title_cap_left.png | Bin 0 -> 179 bytes .../painting/shared/images/title_cap_right.png | Bin 0 -> 184 bytes .../painting/shared/images/title_stretch.png | Bin 0 -> 106 bytes examples/widgets/painting/shared/shared.pri | 20 + examples/widgets/painting/shared/shared.pro | 34 + examples/widgets/painting/shared/shared.qrc | 39 + .../painting/svggenerator/svggenerator.desktop | 11 + .../widgets/painting/svgviewer/svgviewer.desktop | 11 + examples/widgets/painting/transformations/main.cpp | 51 + .../painting/transformations/renderarea.cpp | 172 +++ .../widgets/painting/transformations/renderarea.h | 90 ++ .../transformations/transformations.desktop | 11 + .../painting/transformations/transformations.pro | 13 + .../widgets/painting/transformations/window.cpp | 180 +++ examples/widgets/painting/transformations/window.h | 80 ++ examples/widgets/richtext/README | 11 + .../widgets/richtext/calendar/calendar.desktop | 11 + examples/widgets/richtext/calendar/calendar.pro | 11 + examples/widgets/richtext/calendar/main.cpp | 52 + examples/widgets/richtext/calendar/mainwindow.cpp | 215 +++ examples/widgets/richtext/calendar/mainwindow.h | 73 + .../widgets/richtext/orderform/detailsdialog.cpp | 156 +++ .../widgets/richtext/orderform/detailsdialog.h | 90 ++ examples/widgets/richtext/orderform/main.cpp | 55 + examples/widgets/richtext/orderform/mainwindow.cpp | 253 ++++ examples/widgets/richtext/orderform/mainwindow.h | 76 + .../widgets/richtext/orderform/orderform.desktop | 11 + examples/widgets/richtext/orderform/orderform.pro | 14 + examples/widgets/richtext/richtext.pro | 11 + .../richtext/syntaxhighlighter/highlighter.cpp | 147 ++ .../richtext/syntaxhighlighter/highlighter.h | 84 ++ .../widgets/richtext/syntaxhighlighter/main.cpp | 52 + .../richtext/syntaxhighlighter/mainwindow.cpp | 128 ++ .../richtext/syntaxhighlighter/mainwindow.h | 75 + .../syntaxhighlighter/syntaxhighlighter.desktop | 11 + .../syntaxhighlighter/syntaxhighlighter.pro | 20 + examples/widgets/richtext/textedit/example.html | 79 ++ .../widgets/richtext/textedit/images/logo32.png | Bin 0 -> 1410 bytes .../richtext/textedit/images/mac/editcopy.png | Bin 0 -> 1468 bytes .../richtext/textedit/images/mac/editcut.png | Bin 0 -> 1512 bytes .../richtext/textedit/images/mac/editpaste.png | Bin 0 -> 1906 bytes .../richtext/textedit/images/mac/editredo.png | Bin 0 -> 1752 bytes .../richtext/textedit/images/mac/editundo.png | Bin 0 -> 1746 bytes .../richtext/textedit/images/mac/exportpdf.png | Bin 0 -> 1215 bytes .../richtext/textedit/images/mac/filenew.png | Bin 0 -> 1172 bytes .../richtext/textedit/images/mac/fileopen.png | Bin 0 -> 2168 bytes .../richtext/textedit/images/mac/fileprint.png | Bin 0 -> 2087 bytes .../richtext/textedit/images/mac/filesave.png | Bin 0 -> 1206 bytes .../richtext/textedit/images/mac/textbold.png | Bin 0 -> 1611 bytes .../richtext/textedit/images/mac/textcenter.png | Bin 0 -> 1404 bytes .../richtext/textedit/images/mac/textitalic.png | Bin 0 -> 1164 bytes .../richtext/textedit/images/mac/textjustify.png | Bin 0 -> 1257 bytes .../richtext/textedit/images/mac/textleft.png | Bin 0 -> 1235 bytes .../richtext/textedit/images/mac/textright.png | Bin 0 -> 1406 bytes .../richtext/textedit/images/mac/textunder.png | Bin 0 -> 1183 bytes .../richtext/textedit/images/mac/zoomin.png | Bin 0 -> 1696 bytes .../richtext/textedit/images/mac/zoomout.png | Bin 0 -> 1662 bytes .../richtext/textedit/images/win/editcopy.png | Bin 0 -> 1325 bytes .../richtext/textedit/images/win/editcut.png | Bin 0 -> 1896 bytes .../richtext/textedit/images/win/editpaste.png | Bin 0 -> 1482 bytes .../richtext/textedit/images/win/editredo.png | Bin 0 -> 1787 bytes .../richtext/textedit/images/win/editundo.png | Bin 0 -> 1768 bytes .../richtext/textedit/images/win/exportpdf.png | Bin 0 -> 1059 bytes .../richtext/textedit/images/win/filenew.png | Bin 0 -> 768 bytes .../richtext/textedit/images/win/fileopen.png | Bin 0 -> 1662 bytes .../richtext/textedit/images/win/fileprint.png | Bin 0 -> 1456 bytes .../richtext/textedit/images/win/filesave.png | Bin 0 -> 1205 bytes .../richtext/textedit/images/win/textbold.png | Bin 0 -> 1134 bytes .../richtext/textedit/images/win/textcenter.png | Bin 0 -> 627 bytes .../richtext/textedit/images/win/textitalic.png | Bin 0 -> 829 bytes .../richtext/textedit/images/win/textjustify.png | Bin 0 -> 695 bytes .../richtext/textedit/images/win/textleft.png | Bin 0 -> 673 bytes .../richtext/textedit/images/win/textright.png | Bin 0 -> 677 bytes .../richtext/textedit/images/win/textunder.png | Bin 0 -> 971 bytes .../richtext/textedit/images/win/zoomin.png | Bin 0 -> 1208 bytes .../richtext/textedit/images/win/zoomout.png | Bin 0 -> 1226 bytes examples/widgets/richtext/textedit/main.cpp | 54 + examples/widgets/richtext/textedit/textedit.cpp | 737 ++++++++++ examples/widgets/richtext/textedit/textedit.h | 130 ++ examples/widgets/richtext/textedit/textedit.pro | 23 + examples/widgets/richtext/textedit/textedit.qdoc | 45 + examples/widgets/richtext/textedit/textedit.qrc | 44 + examples/widgets/scribble/main.cpp | 51 - examples/widgets/scribble/mainwindow.cpp | 250 ---- examples/widgets/scribble/mainwindow.h | 92 -- examples/widgets/scribble/scribble.desktop | 11 - examples/widgets/scribble/scribble.pro | 14 - examples/widgets/scribble/scribblearea.cpp | 219 --- examples/widgets/scribble/scribblearea.h | 90 -- .../widgets/scroller/graphicsview/graphicsview.pro | 9 + examples/widgets/scroller/graphicsview/main.cpp | 291 ++++ examples/widgets/scroller/scroller.pro | 2 + examples/widgets/shapedclock/main.cpp | 51 - examples/widgets/shapedclock/shapedclock.cpp | 158 --- examples/widgets/shapedclock/shapedclock.desktop | 11 - examples/widgets/shapedclock/shapedclock.h | 66 - examples/widgets/shapedclock/shapedclock.pro | 12 - examples/widgets/sliders/main.cpp | 51 - examples/widgets/sliders/sliders.desktop | 11 - examples/widgets/sliders/sliders.pro | 15 - examples/widgets/sliders/slidersgroup.cpp | 132 -- examples/widgets/sliders/slidersgroup.h | 78 -- examples/widgets/sliders/window.cpp | 145 -- examples/widgets/sliders/window.h | 84 -- examples/widgets/softkeys/main.cpp | 50 - examples/widgets/softkeys/softkeys.cpp | 188 --- examples/widgets/softkeys/softkeys.desktop | 11 - examples/widgets/softkeys/softkeys.h | 88 -- examples/widgets/softkeys/softkeys.pro | 13 - examples/widgets/spinboxes/main.cpp | 51 - examples/widgets/spinboxes/spinboxes.desktop | 11 - examples/widgets/spinboxes/spinboxes.pro | 13 - examples/widgets/spinboxes/window.cpp | 251 ---- examples/widgets/spinboxes/window.h | 81 -- examples/widgets/statemachine/README | 6 + .../eventtransitions/eventtransitions.desktop | 11 + .../eventtransitions/eventtransitions.pro | 11 + .../widgets/statemachine/eventtransitions/main.cpp | 115 ++ .../statemachine/factorial/factorial.desktop | 11 + .../widgets/statemachine/factorial/factorial.pro | 13 + examples/widgets/statemachine/factorial/main.cpp | 175 +++ examples/widgets/statemachine/pingpong/main.cpp | 139 ++ .../widgets/statemachine/pingpong/pingpong.desktop | 11 + .../widgets/statemachine/pingpong/pingpong.pro | 13 + examples/widgets/statemachine/rogue/main.cpp | 54 + .../statemachine/rogue/movementtransition.h | 112 ++ examples/widgets/statemachine/rogue/rogue.desktop | 11 + examples/widgets/statemachine/rogue/rogue.pro | 13 + examples/widgets/statemachine/rogue/window.cpp | 251 ++++ examples/widgets/statemachine/rogue/window.h | 90 ++ examples/widgets/statemachine/statemachine.pro | 18 + .../widgets/statemachine/trafficlight/main.cpp | 184 +++ .../statemachine/trafficlight/trafficlight.desktop | 11 + .../statemachine/trafficlight/trafficlight.pro | 10 + .../widgets/statemachine/twowaybutton/main.cpp | 81 ++ .../statemachine/twowaybutton/twowaybutton.desktop | 11 + .../statemachine/twowaybutton/twowaybutton.pro | 10 + examples/widgets/styles/images/woodbackground.png | Bin 7691 -> 0 bytes examples/widgets/styles/images/woodbutton.png | Bin 7689 -> 0 bytes examples/widgets/styles/main.cpp | 53 - examples/widgets/styles/norwegianwoodstyle.cpp | 330 ----- examples/widgets/styles/norwegianwoodstyle.h | 78 -- examples/widgets/styles/styles.desktop | 11 - examples/widgets/styles/styles.pro | 18 - examples/widgets/styles/styles.qrc | 6 - examples/widgets/styles/widgetgallery.cpp | 275 ---- examples/widgets/styles/widgetgallery.h | 121 -- .../widgets/stylesheet/images/checkbox_checked.png | Bin 263 -> 0 bytes .../stylesheet/images/checkbox_checked_hover.png | Bin 266 -> 0 bytes .../stylesheet/images/checkbox_checked_pressed.png | Bin 425 -> 0 bytes .../stylesheet/images/checkbox_unchecked.png | Bin 159 -> 0 bytes .../stylesheet/images/checkbox_unchecked_hover.png | Bin 159 -> 0 bytes .../images/checkbox_unchecked_pressed.png | Bin 320 -> 0 bytes examples/widgets/stylesheet/images/down_arrow.png | Bin 175 -> 0 bytes .../stylesheet/images/down_arrow_disabled.png | Bin 174 -> 0 bytes examples/widgets/stylesheet/images/frame.png | Bin 253 -> 0 bytes examples/widgets/stylesheet/images/pagefold.png | Bin 1545 -> 0 bytes examples/widgets/stylesheet/images/pushbutton.png | Bin 533 -> 0 bytes .../widgets/stylesheet/images/pushbutton_hover.png | Bin 525 -> 0 bytes .../stylesheet/images/pushbutton_pressed.png | Bin 513 -> 0 bytes .../stylesheet/images/radiobutton_checked.png | Bin 355 -> 0 bytes .../images/radiobutton_checked_hover.png | Bin 532 -> 0 bytes .../images/radiobutton_checked_pressed.png | Bin 599 -> 0 bytes .../stylesheet/images/radiobutton_unchecked.png | Bin 240 -> 0 bytes .../images/radiobutton_unchecked_hover.png | Bin 492 -> 0 bytes .../images/radiobutton_unchecked_pressed.png | Bin 556 -> 0 bytes examples/widgets/stylesheet/images/sizegrip.png | Bin 129 -> 0 bytes examples/widgets/stylesheet/images/spindown.png | Bin 276 -> 0 bytes .../widgets/stylesheet/images/spindown_hover.png | Bin 268 -> 0 bytes .../widgets/stylesheet/images/spindown_off.png | Bin 249 -> 0 bytes .../widgets/stylesheet/images/spindown_pressed.png | Bin 264 -> 0 bytes examples/widgets/stylesheet/images/spinup.png | Bin 283 -> 0 bytes .../widgets/stylesheet/images/spinup_hover.png | Bin 277 -> 0 bytes examples/widgets/stylesheet/images/spinup_off.png | Bin 274 -> 0 bytes .../widgets/stylesheet/images/spinup_pressed.png | Bin 277 -> 0 bytes examples/widgets/stylesheet/images/up_arrow.png | Bin 197 -> 0 bytes .../stylesheet/images/up_arrow_disabled.png | Bin 172 -> 0 bytes examples/widgets/stylesheet/layouts/default.ui | 329 ----- examples/widgets/stylesheet/layouts/pagefold.ui | 349 ----- examples/widgets/stylesheet/main.cpp | 53 - examples/widgets/stylesheet/mainwindow.cpp | 74 - examples/widgets/stylesheet/mainwindow.h | 66 - examples/widgets/stylesheet/mainwindow.ui | 356 ----- examples/widgets/stylesheet/qss/coffee.qss | 112 -- examples/widgets/stylesheet/qss/default.qss | 1 - examples/widgets/stylesheet/qss/pagefold.qss | 299 ---- examples/widgets/stylesheet/stylesheet.desktop | 11 - examples/widgets/stylesheet/stylesheet.pro | 18 - examples/widgets/stylesheet/stylesheet.qrc | 39 - examples/widgets/stylesheet/stylesheeteditor.cpp | 93 -- examples/widgets/stylesheet/stylesheeteditor.h | 67 - examples/widgets/stylesheet/stylesheeteditor.ui | 171 --- examples/widgets/tablet/main.cpp | 59 - examples/widgets/tablet/mainwindow.cpp | 274 ---- examples/widgets/tablet/mainwindow.h | 113 -- examples/widgets/tablet/tablet.desktop | 11 - examples/widgets/tablet/tablet.pro | 17 - examples/widgets/tablet/tabletapplication.cpp | 56 - examples/widgets/tablet/tabletapplication.h | 66 - examples/widgets/tablet/tabletcanvas.cpp | 275 ---- examples/widgets/tablet/tabletcanvas.h | 114 -- examples/widgets/tetrix/main.cpp | 54 - examples/widgets/tetrix/tetrix.desktop | 11 - examples/widgets/tetrix/tetrix.pro | 16 - examples/widgets/tetrix/tetrixboard.cpp | 408 ------ examples/widgets/tetrix/tetrixboard.h | 116 -- examples/widgets/tetrix/tetrixpiece.cpp | 145 -- examples/widgets/tetrix/tetrixpiece.h | 75 - examples/widgets/tetrix/tetrixwindow.cpp | 115 -- examples/widgets/tetrix/tetrixwindow.h | 76 - examples/widgets/tooltips/images/circle.png | Bin 165 -> 0 bytes examples/widgets/tooltips/images/square.png | Bin 94 -> 0 bytes examples/widgets/tooltips/images/triangle.png | Bin 170 -> 0 bytes examples/widgets/tooltips/main.cpp | 54 - examples/widgets/tooltips/shapeitem.cpp | 99 -- examples/widgets/tooltips/shapeitem.h | 70 - examples/widgets/tooltips/sortingbox.cpp | 301 ---- examples/widgets/tooltips/sortingbox.h | 106 -- examples/widgets/tooltips/tooltips.desktop | 11 - examples/widgets/tooltips/tooltips.pro | 14 - examples/widgets/tooltips/tooltips.qrc | 7 - examples/widgets/validators/ledoff.png | Bin 562 -> 0 bytes examples/widgets/validators/ledon.png | Bin 486 -> 0 bytes examples/widgets/validators/ledwidget.cpp | 62 - examples/widgets/validators/ledwidget.h | 64 - examples/widgets/validators/localeselector.cpp | 312 ----- examples/widgets/validators/localeselector.h | 60 - examples/widgets/validators/main.cpp | 136 -- examples/widgets/validators/validators.desktop | 11 - examples/widgets/validators/validators.pro | 15 - examples/widgets/validators/validators.qrc | 6 - examples/widgets/validators/validators.ui | 468 ------- examples/widgets/widgets.pro | 52 +- examples/widgets/widgets/README | 13 + .../widgets/widgets/analogclock/analogclock.cpp | 145 ++ .../widgets/analogclock/analogclock.desktop | 11 + examples/widgets/widgets/analogclock/analogclock.h | 59 + .../widgets/widgets/analogclock/analogclock.pro | 12 + examples/widgets/widgets/analogclock/main.cpp | 51 + .../applicationicon/applicationicon.desktop | 11 + .../widgets/applicationicon/applicationicon.png | Bin 0 -> 4023 bytes .../widgets/applicationicon/applicationicon.pro | 17 + .../widgets/applicationicon/applicationicon.svg | 22 + examples/widgets/widgets/applicationicon/main.cpp | 50 + examples/widgets/widgets/calculator/button.cpp | 63 + examples/widgets/widgets/calculator/button.h | 58 + examples/widgets/widgets/calculator/calculator.cpp | 396 ++++++ .../widgets/widgets/calculator/calculator.desktop | 11 + examples/widgets/widgets/calculator/calculator.h | 107 ++ examples/widgets/widgets/calculator/calculator.pro | 14 + examples/widgets/widgets/calculator/main.cpp | 51 + .../widgets/widgets/calculator/releasenotes.txt | 4 + .../widgets/calendarwidget/calendarwidget.desktop | 11 + .../widgets/calendarwidget/calendarwidget.pro | 11 + examples/widgets/widgets/calendarwidget/main.cpp | 51 + examples/widgets/widgets/calendarwidget/window.cpp | 464 ++++++ examples/widgets/widgets/calendarwidget/window.h | 127 ++ .../widgets/charactermap/charactermap.desktop | 11 + .../widgets/widgets/charactermap/charactermap.pro | 15 + .../widgets/charactermap/characterwidget.cpp | 177 +++ .../widgets/widgets/charactermap/characterwidget.h | 86 ++ examples/widgets/widgets/charactermap/main.cpp | 51 + .../widgets/widgets/charactermap/mainwindow.cpp | 204 +++ examples/widgets/widgets/charactermap/mainwindow.h | 87 ++ examples/widgets/widgets/codeeditor/codeeditor.cpp | 170 +++ .../widgets/widgets/codeeditor/codeeditor.desktop | 11 + examples/widgets/widgets/codeeditor/codeeditor.h | 105 ++ examples/widgets/widgets/codeeditor/codeeditor.pro | 11 + examples/widgets/widgets/codeeditor/main.cpp | 55 + .../widgets/widgets/digitalclock/digitalclock.cpp | 72 + .../widgets/digitalclock/digitalclock.desktop | 11 + .../widgets/widgets/digitalclock/digitalclock.h | 59 + .../widgets/widgets/digitalclock/digitalclock.pro | 11 + examples/widgets/widgets/digitalclock/main.cpp | 51 + .../widgets/widgets/elidedlabel/elidedlabel.cpp | 111 ++ .../widgets/elidedlabel/elidedlabel.desktop | 11 + examples/widgets/widgets/elidedlabel/elidedlabel.h | 76 + .../widgets/widgets/elidedlabel/elidedlabel.pro | 21 + examples/widgets/widgets/elidedlabel/main.cpp | 53 + .../widgets/widgets/elidedlabel/testwidget.cpp | 161 +++ examples/widgets/widgets/elidedlabel/testwidget.h | 76 + examples/widgets/widgets/groupbox/groupbox.desktop | 11 + examples/widgets/widgets/groupbox/groupbox.pro | 13 + examples/widgets/widgets/groupbox/main.cpp | 51 + examples/widgets/widgets/groupbox/window.cpp | 189 +++ examples/widgets/widgets/groupbox/window.h | 66 + examples/widgets/widgets/icons/iconpreviewarea.cpp | 141 ++ examples/widgets/widgets/icons/iconpreviewarea.h | 77 + examples/widgets/widgets/icons/icons.desktop | 11 + examples/widgets/widgets/icons/icons.pro | 29 + examples/widgets/widgets/icons/iconsizespinbox.cpp | 70 + examples/widgets/widgets/icons/iconsizespinbox.h | 59 + examples/widgets/widgets/icons/imagedelegate.cpp | 105 ++ examples/widgets/widgets/icons/imagedelegate.h | 68 + examples/widgets/widgets/icons/images/designer.png | Bin 0 -> 4205 bytes .../widgets/widgets/icons/images/find_disabled.png | Bin 0 -> 501 bytes .../widgets/widgets/icons/images/find_normal.png | Bin 0 -> 838 bytes .../widgets/icons/images/monkey_off_128x128.png | Bin 0 -> 7045 bytes .../widgets/icons/images/monkey_off_16x16.png | Bin 0 -> 683 bytes .../widgets/icons/images/monkey_off_32x32.png | Bin 0 -> 1609 bytes .../widgets/icons/images/monkey_off_64x64.png | Bin 0 -> 3533 bytes .../widgets/icons/images/monkey_on_128x128.png | Bin 0 -> 6909 bytes .../widgets/icons/images/monkey_on_16x16.png | Bin 0 -> 681 bytes .../widgets/icons/images/monkey_on_32x32.png | Bin 0 -> 1577 bytes .../widgets/icons/images/monkey_on_64x64.png | Bin 0 -> 3479 bytes .../widgets/icons/images/qt_extended_16x16.png | Bin 0 -> 834 bytes .../widgets/icons/images/qt_extended_32x32.png | Bin 0 -> 1892 bytes .../widgets/icons/images/qt_extended_48x48.png | Bin 0 -> 3672 bytes examples/widgets/widgets/icons/main.cpp | 51 + examples/widgets/widgets/icons/mainwindow.cpp | 442 ++++++ examples/widgets/widgets/icons/mainwindow.h | 116 ++ .../widgets/widgets/imageviewer/imageviewer.cpp | 280 ++++ .../widgets/imageviewer/imageviewer.desktop | 11 + examples/widgets/widgets/imageviewer/imageviewer.h | 105 ++ .../widgets/widgets/imageviewer/imageviewer.pro | 18 + examples/widgets/widgets/imageviewer/main.cpp | 51 + .../widgets/widgets/lineedits/lineedits.desktop | 11 + examples/widgets/widgets/lineedits/lineedits.pro | 11 + examples/widgets/widgets/lineedits/main.cpp | 51 + examples/widgets/widgets/lineedits/window.cpp | 256 ++++ examples/widgets/widgets/lineedits/window.h | 75 + .../widgets/widgets/mousebuttons/buttontester.cpp | 172 +++ .../widgets/widgets/mousebuttons/buttontester.h | 64 + examples/widgets/widgets/mousebuttons/main.cpp | 66 + .../widgets/widgets/mousebuttons/mousebuttons.pro | 18 + examples/widgets/widgets/movie/animation.gif | Bin 0 -> 42629 bytes examples/widgets/widgets/movie/main.cpp | 52 + examples/widgets/widgets/movie/movie.desktop | 11 + examples/widgets/widgets/movie/movie.pro | 20 + examples/widgets/widgets/movie/movieplayer.cpp | 210 +++ examples/widgets/widgets/movie/movieplayer.h | 96 ++ examples/widgets/widgets/orientation/image_a.png | Bin 0 -> 1075 bytes examples/widgets/widgets/orientation/image_b.png | Bin 0 -> 1020 bytes examples/widgets/widgets/orientation/image_c.png | Bin 0 -> 1163 bytes examples/widgets/widgets/orientation/images.qrc | 7 + examples/widgets/widgets/orientation/landscape.ui | 114 ++ examples/widgets/widgets/orientation/main.cpp | 55 + .../widgets/widgets/orientation/mainwindow.cpp | 112 ++ examples/widgets/widgets/orientation/mainwindow.h | 75 + .../widgets/orientation/orientation.desktop | 11 + .../widgets/widgets/orientation/orientation.pro | 31 + examples/widgets/widgets/orientation/portrait.ui | 61 + examples/widgets/widgets/scribble/main.cpp | 51 + examples/widgets/widgets/scribble/mainwindow.cpp | 250 ++++ examples/widgets/widgets/scribble/mainwindow.h | 92 ++ examples/widgets/widgets/scribble/scribble.desktop | 11 + examples/widgets/widgets/scribble/scribble.pro | 14 + examples/widgets/widgets/scribble/scribblearea.cpp | 219 +++ examples/widgets/widgets/scribble/scribblearea.h | 90 ++ examples/widgets/widgets/shapedclock/main.cpp | 51 + .../widgets/widgets/shapedclock/shapedclock.cpp | 158 +++ .../widgets/shapedclock/shapedclock.desktop | 11 + examples/widgets/widgets/shapedclock/shapedclock.h | 66 + .../widgets/widgets/shapedclock/shapedclock.pro | 12 + examples/widgets/widgets/sliders/main.cpp | 51 + examples/widgets/widgets/sliders/sliders.desktop | 11 + examples/widgets/widgets/sliders/sliders.pro | 15 + examples/widgets/widgets/sliders/slidersgroup.cpp | 132 ++ examples/widgets/widgets/sliders/slidersgroup.h | 78 ++ examples/widgets/widgets/sliders/window.cpp | 145 ++ examples/widgets/widgets/sliders/window.h | 84 ++ examples/widgets/widgets/softkeys/main.cpp | 50 + examples/widgets/widgets/softkeys/softkeys.cpp | 188 +++ examples/widgets/widgets/softkeys/softkeys.desktop | 11 + examples/widgets/widgets/softkeys/softkeys.h | 88 ++ examples/widgets/widgets/softkeys/softkeys.pro | 13 + examples/widgets/widgets/spinboxes/main.cpp | 51 + .../widgets/widgets/spinboxes/spinboxes.desktop | 11 + examples/widgets/widgets/spinboxes/spinboxes.pro | 13 + examples/widgets/widgets/spinboxes/window.cpp | 251 ++++ examples/widgets/widgets/spinboxes/window.h | 81 ++ .../widgets/styles/images/woodbackground.png | Bin 0 -> 7691 bytes .../widgets/widgets/styles/images/woodbutton.png | Bin 0 -> 7689 bytes examples/widgets/widgets/styles/main.cpp | 53 + .../widgets/widgets/styles/norwegianwoodstyle.cpp | 330 +++++ .../widgets/widgets/styles/norwegianwoodstyle.h | 78 ++ examples/widgets/widgets/styles/styles.desktop | 11 + examples/widgets/widgets/styles/styles.pro | 18 + examples/widgets/widgets/styles/styles.qrc | 6 + examples/widgets/widgets/styles/widgetgallery.cpp | 275 ++++ examples/widgets/widgets/styles/widgetgallery.h | 121 ++ .../widgets/stylesheet/images/checkbox_checked.png | Bin 0 -> 263 bytes .../stylesheet/images/checkbox_checked_hover.png | Bin 0 -> 266 bytes .../stylesheet/images/checkbox_checked_pressed.png | Bin 0 -> 425 bytes .../stylesheet/images/checkbox_unchecked.png | Bin 0 -> 159 bytes .../stylesheet/images/checkbox_unchecked_hover.png | Bin 0 -> 159 bytes .../images/checkbox_unchecked_pressed.png | Bin 0 -> 320 bytes .../widgets/stylesheet/images/down_arrow.png | Bin 0 -> 175 bytes .../stylesheet/images/down_arrow_disabled.png | Bin 0 -> 174 bytes .../widgets/widgets/stylesheet/images/frame.png | Bin 0 -> 253 bytes .../widgets/widgets/stylesheet/images/pagefold.png | Bin 0 -> 1545 bytes .../widgets/stylesheet/images/pushbutton.png | Bin 0 -> 533 bytes .../widgets/stylesheet/images/pushbutton_hover.png | Bin 0 -> 525 bytes .../stylesheet/images/pushbutton_pressed.png | Bin 0 -> 513 bytes .../stylesheet/images/radiobutton_checked.png | Bin 0 -> 355 bytes .../images/radiobutton_checked_hover.png | Bin 0 -> 532 bytes .../images/radiobutton_checked_pressed.png | Bin 0 -> 599 bytes .../stylesheet/images/radiobutton_unchecked.png | Bin 0 -> 240 bytes .../images/radiobutton_unchecked_hover.png | Bin 0 -> 492 bytes .../images/radiobutton_unchecked_pressed.png | Bin 0 -> 556 bytes .../widgets/widgets/stylesheet/images/sizegrip.png | Bin 0 -> 129 bytes .../widgets/widgets/stylesheet/images/spindown.png | Bin 0 -> 276 bytes .../widgets/stylesheet/images/spindown_hover.png | Bin 0 -> 268 bytes .../widgets/stylesheet/images/spindown_off.png | Bin 0 -> 249 bytes .../widgets/stylesheet/images/spindown_pressed.png | Bin 0 -> 264 bytes .../widgets/widgets/stylesheet/images/spinup.png | Bin 0 -> 283 bytes .../widgets/stylesheet/images/spinup_hover.png | Bin 0 -> 277 bytes .../widgets/stylesheet/images/spinup_off.png | Bin 0 -> 274 bytes .../widgets/stylesheet/images/spinup_pressed.png | Bin 0 -> 277 bytes .../widgets/widgets/stylesheet/images/up_arrow.png | Bin 0 -> 197 bytes .../stylesheet/images/up_arrow_disabled.png | Bin 0 -> 172 bytes .../widgets/widgets/stylesheet/layouts/default.ui | 329 +++++ .../widgets/widgets/stylesheet/layouts/pagefold.ui | 349 +++++ examples/widgets/widgets/stylesheet/main.cpp | 53 + examples/widgets/widgets/stylesheet/mainwindow.cpp | 74 + examples/widgets/widgets/stylesheet/mainwindow.h | 66 + examples/widgets/widgets/stylesheet/mainwindow.ui | 356 +++++ examples/widgets/widgets/stylesheet/qss/coffee.qss | 112 ++ .../widgets/widgets/stylesheet/qss/default.qss | 1 + .../widgets/widgets/stylesheet/qss/pagefold.qss | 299 ++++ .../widgets/widgets/stylesheet/stylesheet.desktop | 11 + examples/widgets/widgets/stylesheet/stylesheet.pro | 18 + examples/widgets/widgets/stylesheet/stylesheet.qrc | 39 + .../widgets/stylesheet/stylesheeteditor.cpp | 93 ++ .../widgets/widgets/stylesheet/stylesheeteditor.h | 67 + .../widgets/widgets/stylesheet/stylesheeteditor.ui | 171 +++ examples/widgets/widgets/tablet/main.cpp | 59 + examples/widgets/widgets/tablet/mainwindow.cpp | 274 ++++ examples/widgets/widgets/tablet/mainwindow.h | 113 ++ examples/widgets/widgets/tablet/tablet.desktop | 11 + examples/widgets/widgets/tablet/tablet.pro | 17 + .../widgets/widgets/tablet/tabletapplication.cpp | 56 + .../widgets/widgets/tablet/tabletapplication.h | 66 + examples/widgets/widgets/tablet/tabletcanvas.cpp | 275 ++++ examples/widgets/widgets/tablet/tabletcanvas.h | 114 ++ examples/widgets/widgets/tetrix/main.cpp | 54 + examples/widgets/widgets/tetrix/tetrix.desktop | 11 + examples/widgets/widgets/tetrix/tetrix.pro | 16 + examples/widgets/widgets/tetrix/tetrixboard.cpp | 408 ++++++ examples/widgets/widgets/tetrix/tetrixboard.h | 116 ++ examples/widgets/widgets/tetrix/tetrixpiece.cpp | 145 ++ examples/widgets/widgets/tetrix/tetrixpiece.h | 75 + examples/widgets/widgets/tetrix/tetrixwindow.cpp | 115 ++ examples/widgets/widgets/tetrix/tetrixwindow.h | 76 + .../widgets/widgets/tooltips/images/circle.png | Bin 0 -> 165 bytes .../widgets/widgets/tooltips/images/square.png | Bin 0 -> 94 bytes .../widgets/widgets/tooltips/images/triangle.png | Bin 0 -> 170 bytes examples/widgets/widgets/tooltips/main.cpp | 54 + examples/widgets/widgets/tooltips/shapeitem.cpp | 99 ++ examples/widgets/widgets/tooltips/shapeitem.h | 70 + examples/widgets/widgets/tooltips/sortingbox.cpp | 301 ++++ examples/widgets/widgets/tooltips/sortingbox.h | 106 ++ examples/widgets/widgets/tooltips/tooltips.desktop | 11 + examples/widgets/widgets/tooltips/tooltips.pro | 14 + examples/widgets/widgets/tooltips/tooltips.qrc | 7 + examples/widgets/widgets/validators/ledoff.png | Bin 0 -> 562 bytes examples/widgets/widgets/validators/ledon.png | Bin 0 -> 486 bytes examples/widgets/widgets/validators/ledwidget.cpp | 62 + examples/widgets/widgets/validators/ledwidget.h | 64 + .../widgets/widgets/validators/localeselector.cpp | 312 +++++ .../widgets/widgets/validators/localeselector.h | 60 + examples/widgets/widgets/validators/main.cpp | 136 ++ .../widgets/widgets/validators/validators.desktop | 11 + examples/widgets/widgets/validators/validators.pro | 15 + examples/widgets/widgets/validators/validators.qrc | 6 + examples/widgets/widgets/validators/validators.ui | 468 +++++++ examples/widgets/widgets/widgets.pro | 34 + examples/widgets/widgets/wiggly/dialog.cpp | 81 ++ examples/widgets/widgets/wiggly/dialog.h | 56 + examples/widgets/widgets/wiggly/main.cpp | 58 + examples/widgets/widgets/wiggly/wiggly.desktop | 11 + examples/widgets/widgets/wiggly/wiggly.pro | 13 + examples/widgets/widgets/wiggly/wigglywidget.cpp | 100 ++ examples/widgets/widgets/wiggly/wigglywidget.h | 69 + .../widgets/windowflags/controllerwindow.cpp | 220 +++ .../widgets/widgets/windowflags/controllerwindow.h | 104 ++ examples/widgets/widgets/windowflags/main.cpp | 51 + .../widgets/widgets/windowflags/previewwindow.cpp | 118 ++ .../widgets/widgets/windowflags/previewwindow.h | 67 + .../widgets/windowflags/windowflags.desktop | 11 + .../widgets/widgets/windowflags/windowflags.pro | 15 + examples/widgets/wiggly/dialog.cpp | 81 -- examples/widgets/wiggly/dialog.h | 56 - examples/widgets/wiggly/main.cpp | 58 - examples/widgets/wiggly/wiggly.desktop | 11 - examples/widgets/wiggly/wiggly.pro | 13 - examples/widgets/wiggly/wigglywidget.cpp | 100 -- examples/widgets/wiggly/wigglywidget.h | 69 - examples/widgets/windowflags/controllerwindow.cpp | 220 --- examples/widgets/windowflags/controllerwindow.h | 104 -- examples/widgets/windowflags/main.cpp | 51 - examples/widgets/windowflags/previewwindow.cpp | 118 -- examples/widgets/windowflags/previewwindow.h | 67 - examples/widgets/windowflags/windowflags.desktop | 11 - examples/widgets/windowflags/windowflags.pro | 15 - 2496 files changed, 100548 insertions(+), 81790 deletions(-) delete mode 100644 examples/animation/README delete mode 100644 examples/animation/animatedtiles/animatedtiles.desktop delete mode 100644 examples/animation/animatedtiles/animatedtiles.pro delete mode 100644 examples/animation/animatedtiles/animatedtiles.qrc delete mode 100644 examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg delete mode 100644 examples/animation/animatedtiles/images/centered.png delete mode 100644 examples/animation/animatedtiles/images/ellipse.png delete mode 100644 examples/animation/animatedtiles/images/figure8.png delete mode 100644 examples/animation/animatedtiles/images/kinetic.png delete mode 100644 examples/animation/animatedtiles/images/random.png delete mode 100644 examples/animation/animatedtiles/images/tile.png delete mode 100644 examples/animation/animatedtiles/main.cpp delete mode 100644 examples/animation/animation.pro delete mode 100644 examples/animation/appchooser/accessories-dictionary.png delete mode 100644 examples/animation/appchooser/akregator.png delete mode 100644 examples/animation/appchooser/appchooser.desktop delete mode 100644 examples/animation/appchooser/appchooser.pro delete mode 100644 examples/animation/appchooser/appchooser.qrc delete mode 100644 examples/animation/appchooser/digikam.png delete mode 100644 examples/animation/appchooser/k3b.png delete mode 100644 examples/animation/appchooser/main.cpp delete mode 100644 examples/animation/easing/animation.h delete mode 100644 examples/animation/easing/easing.desktop delete mode 100644 examples/animation/easing/easing.pro delete mode 100644 examples/animation/easing/easing.qrc delete mode 100644 examples/animation/easing/form.ui delete mode 100644 examples/animation/easing/images/qt-logo.png delete mode 100644 examples/animation/easing/main.cpp delete mode 100644 examples/animation/easing/window.cpp delete mode 100644 examples/animation/easing/window.h delete mode 100644 examples/animation/moveblocks/main.cpp delete mode 100644 examples/animation/moveblocks/moveblocks.desktop delete mode 100644 examples/animation/moveblocks/moveblocks.pro delete mode 100644 examples/animation/states/accessories-dictionary.png delete mode 100644 examples/animation/states/akregator.png delete mode 100644 examples/animation/states/digikam.png delete mode 100644 examples/animation/states/help-browser.png delete mode 100644 examples/animation/states/k3b.png delete mode 100644 examples/animation/states/kchart.png delete mode 100644 examples/animation/states/main.cpp delete mode 100644 examples/animation/states/states.desktop delete mode 100644 examples/animation/states/states.pro delete mode 100644 examples/animation/states/states.qrc delete mode 100644 examples/animation/stickman/animation.cpp delete mode 100644 examples/animation/stickman/animation.h delete mode 100644 examples/animation/stickman/animations/chilling.bin delete mode 100644 examples/animation/stickman/animations/dancing.bin delete mode 100644 examples/animation/stickman/animations/dead.bin delete mode 100644 examples/animation/stickman/animations/jumping.bin delete mode 100644 examples/animation/stickman/graphicsview.cpp delete mode 100644 examples/animation/stickman/graphicsview.h delete mode 100644 examples/animation/stickman/lifecycle.cpp delete mode 100644 examples/animation/stickman/lifecycle.h delete mode 100644 examples/animation/stickman/main.cpp delete mode 100644 examples/animation/stickman/node.cpp delete mode 100644 examples/animation/stickman/node.h delete mode 100644 examples/animation/stickman/rectbutton.cpp delete mode 100644 examples/animation/stickman/rectbutton.h delete mode 100644 examples/animation/stickman/stickman.cpp delete mode 100644 examples/animation/stickman/stickman.desktop delete mode 100644 examples/animation/stickman/stickman.h delete mode 100644 examples/animation/stickman/stickman.pro delete mode 100644 examples/animation/stickman/stickman.qrc delete mode 100644 examples/animation/sub-attaq/animationmanager.cpp delete mode 100644 examples/animation/sub-attaq/animationmanager.h delete mode 100644 examples/animation/sub-attaq/boat.cpp delete mode 100644 examples/animation/sub-attaq/boat.h delete mode 100644 examples/animation/sub-attaq/boat_p.h delete mode 100644 examples/animation/sub-attaq/bomb.cpp delete mode 100644 examples/animation/sub-attaq/bomb.h delete mode 100644 examples/animation/sub-attaq/data.xml delete mode 100644 examples/animation/sub-attaq/graphicsscene.cpp delete mode 100644 examples/animation/sub-attaq/graphicsscene.h delete mode 100644 examples/animation/sub-attaq/main.cpp delete mode 100644 examples/animation/sub-attaq/mainwindow.cpp delete mode 100644 examples/animation/sub-attaq/mainwindow.h delete mode 100644 examples/animation/sub-attaq/pics/big/background.png delete mode 100644 examples/animation/sub-attaq/pics/big/boat.png delete mode 100644 examples/animation/sub-attaq/pics/big/bomb.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step1.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step2.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step3.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step4.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png delete mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png delete mode 100644 examples/animation/sub-attaq/pics/big/submarine.png delete mode 100644 examples/animation/sub-attaq/pics/big/surface.png delete mode 100644 examples/animation/sub-attaq/pics/big/torpedo.png delete mode 100644 examples/animation/sub-attaq/pics/scalable/background-n810.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/background.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/boat.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/bomb.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/sand.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/see.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/sky.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/sub-attaq.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/submarine.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/surface.svg delete mode 100644 examples/animation/sub-attaq/pics/scalable/torpedo.svg delete mode 100644 examples/animation/sub-attaq/pics/small/background.png delete mode 100644 examples/animation/sub-attaq/pics/small/boat.png delete mode 100644 examples/animation/sub-attaq/pics/small/bomb.png delete mode 100644 examples/animation/sub-attaq/pics/small/submarine.png delete mode 100644 examples/animation/sub-attaq/pics/small/surface.png delete mode 100644 examples/animation/sub-attaq/pics/small/torpedo.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-a.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-a2.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-b.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-dash.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-excl.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-q.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-s.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-t.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-t2.png delete mode 100644 examples/animation/sub-attaq/pics/welcome/logo-u.png delete mode 100644 examples/animation/sub-attaq/pixmapitem.cpp delete mode 100644 examples/animation/sub-attaq/pixmapitem.h delete mode 100644 examples/animation/sub-attaq/progressitem.cpp delete mode 100644 examples/animation/sub-attaq/progressitem.h delete mode 100644 examples/animation/sub-attaq/qanimationstate.cpp delete mode 100644 examples/animation/sub-attaq/qanimationstate.h delete mode 100644 examples/animation/sub-attaq/states.cpp delete mode 100644 examples/animation/sub-attaq/states.h delete mode 100644 examples/animation/sub-attaq/sub-attaq.pro delete mode 100644 examples/animation/sub-attaq/subattaq.qrc delete mode 100644 examples/animation/sub-attaq/submarine.cpp delete mode 100644 examples/animation/sub-attaq/submarine.h delete mode 100644 examples/animation/sub-attaq/submarine_p.h delete mode 100644 examples/animation/sub-attaq/textinformationitem.cpp delete mode 100644 examples/animation/sub-attaq/textinformationitem.h delete mode 100644 examples/animation/sub-attaq/torpedo.cpp delete mode 100644 examples/animation/sub-attaq/torpedo.h delete mode 100644 examples/desktop/README delete mode 100644 examples/desktop/desktop.pro delete mode 100644 examples/desktop/screenshot/main.cpp delete mode 100644 examples/desktop/screenshot/screenshot.cpp delete mode 100644 examples/desktop/screenshot/screenshot.desktop delete mode 100644 examples/desktop/screenshot/screenshot.h delete mode 100644 examples/desktop/screenshot/screenshot.pro delete mode 100644 examples/desktop/systray/images/bad.png delete mode 100644 examples/desktop/systray/images/heart.png delete mode 100644 examples/desktop/systray/images/trash.png delete mode 100644 examples/desktop/systray/main.cpp delete mode 100644 examples/desktop/systray/systray.desktop delete mode 100644 examples/desktop/systray/systray.pro delete mode 100644 examples/desktop/systray/systray.qrc delete mode 100644 examples/desktop/systray/window.cpp delete mode 100644 examples/desktop/systray/window.h delete mode 100644 examples/dialogs/README delete mode 100644 examples/dialogs/classwizard/classwizard.cpp delete mode 100644 examples/dialogs/classwizard/classwizard.desktop delete mode 100644 examples/dialogs/classwizard/classwizard.h delete mode 100644 examples/dialogs/classwizard/classwizard.pro delete mode 100644 examples/dialogs/classwizard/classwizard.qrc delete mode 100644 examples/dialogs/classwizard/images/background.png delete mode 100644 examples/dialogs/classwizard/images/banner.png delete mode 100644 examples/dialogs/classwizard/images/logo1.png delete mode 100644 examples/dialogs/classwizard/images/logo2.png delete mode 100644 examples/dialogs/classwizard/images/logo3.png delete mode 100644 examples/dialogs/classwizard/images/watermark1.png delete mode 100644 examples/dialogs/classwizard/images/watermark2.png delete mode 100644 examples/dialogs/classwizard/main.cpp delete mode 100644 examples/dialogs/configdialog/configdialog.cpp delete mode 100644 examples/dialogs/configdialog/configdialog.desktop delete mode 100644 examples/dialogs/configdialog/configdialog.h delete mode 100644 examples/dialogs/configdialog/configdialog.pro delete mode 100644 examples/dialogs/configdialog/configdialog.qrc delete mode 100644 examples/dialogs/configdialog/images/config.png delete mode 100644 examples/dialogs/configdialog/images/query.png delete mode 100644 examples/dialogs/configdialog/images/update.png delete mode 100644 examples/dialogs/configdialog/main.cpp delete mode 100644 examples/dialogs/configdialog/pages.cpp delete mode 100644 examples/dialogs/configdialog/pages.h delete mode 100644 examples/dialogs/dialogs.pro delete mode 100644 examples/dialogs/extension/extension.desktop delete mode 100644 examples/dialogs/extension/extension.pro delete mode 100644 examples/dialogs/extension/finddialog.cpp delete mode 100644 examples/dialogs/extension/finddialog.h delete mode 100644 examples/dialogs/extension/main.cpp delete mode 100644 examples/dialogs/findfiles/findfiles.desktop delete mode 100644 examples/dialogs/findfiles/findfiles.pro delete mode 100644 examples/dialogs/findfiles/main.cpp delete mode 100644 examples/dialogs/findfiles/window.cpp delete mode 100644 examples/dialogs/findfiles/window.h delete mode 100644 examples/dialogs/licensewizard/images/logo.png delete mode 100644 examples/dialogs/licensewizard/images/watermark.png delete mode 100644 examples/dialogs/licensewizard/licensewizard.cpp delete mode 100644 examples/dialogs/licensewizard/licensewizard.desktop delete mode 100644 examples/dialogs/licensewizard/licensewizard.h delete mode 100644 examples/dialogs/licensewizard/licensewizard.pro delete mode 100644 examples/dialogs/licensewizard/licensewizard.qrc delete mode 100644 examples/dialogs/licensewizard/main.cpp delete mode 100644 examples/dialogs/sipdialog/dialog.cpp delete mode 100644 examples/dialogs/sipdialog/dialog.h delete mode 100644 examples/dialogs/sipdialog/main.cpp delete mode 100644 examples/dialogs/sipdialog/sipdialog.desktop delete mode 100644 examples/dialogs/sipdialog/sipdialog.pro delete mode 100644 examples/dialogs/standarddialogs/dialog.cpp delete mode 100644 examples/dialogs/standarddialogs/dialog.h delete mode 100644 examples/dialogs/standarddialogs/main.cpp delete mode 100644 examples/dialogs/standarddialogs/standarddialogs.desktop delete mode 100644 examples/dialogs/standarddialogs/standarddialogs.pro delete mode 100644 examples/dialogs/tabdialog/main.cpp delete mode 100644 examples/dialogs/tabdialog/tabdialog.cpp delete mode 100644 examples/dialogs/tabdialog/tabdialog.desktop delete mode 100644 examples/dialogs/tabdialog/tabdialog.h delete mode 100644 examples/dialogs/tabdialog/tabdialog.pro delete mode 100644 examples/dialogs/trivialwizard/trivialwizard.cpp delete mode 100644 examples/dialogs/trivialwizard/trivialwizard.desktop delete mode 100644 examples/dialogs/trivialwizard/trivialwizard.pro delete mode 100644 examples/draganddrop/README delete mode 100644 examples/draganddrop/delayedencoding/delayedencoding.desktop delete mode 100644 examples/draganddrop/draganddrop.pro delete mode 100644 examples/draganddrop/draggableicons/draggableicons.desktop delete mode 100644 examples/draganddrop/draggableicons/draggableicons.pro delete mode 100644 examples/draganddrop/draggableicons/draggableicons.qrc delete mode 100644 examples/draganddrop/draggableicons/dragwidget.cpp delete mode 100644 examples/draganddrop/draggableicons/dragwidget.h delete mode 100644 examples/draganddrop/draggableicons/images/boat.png delete mode 100644 examples/draganddrop/draggableicons/images/car.png delete mode 100644 examples/draganddrop/draggableicons/images/house.png delete mode 100644 examples/draganddrop/draggableicons/main.cpp delete mode 100644 examples/draganddrop/draggabletext/draggabletext.desktop delete mode 100644 examples/draganddrop/draggabletext/draggabletext.pro delete mode 100644 examples/draganddrop/draggabletext/draggabletext.qrc delete mode 100644 examples/draganddrop/draggabletext/draglabel.cpp delete mode 100644 examples/draganddrop/draggabletext/draglabel.h delete mode 100644 examples/draganddrop/draggabletext/dragwidget.cpp delete mode 100644 examples/draganddrop/draggabletext/dragwidget.h delete mode 100644 examples/draganddrop/draggabletext/main.cpp delete mode 100644 examples/draganddrop/draggabletext/words.txt delete mode 100644 examples/draganddrop/dropsite/droparea.cpp delete mode 100644 examples/draganddrop/dropsite/droparea.h delete mode 100644 examples/draganddrop/dropsite/dropsite.desktop delete mode 100644 examples/draganddrop/dropsite/dropsite.pro delete mode 100644 examples/draganddrop/dropsite/dropsitewindow.cpp delete mode 100644 examples/draganddrop/dropsite/dropsitewindow.h delete mode 100644 examples/draganddrop/dropsite/main.cpp delete mode 100644 examples/draganddrop/fridgemagnets/draglabel.cpp delete mode 100644 examples/draganddrop/fridgemagnets/draglabel.h delete mode 100644 examples/draganddrop/fridgemagnets/dragwidget.cpp delete mode 100644 examples/draganddrop/fridgemagnets/dragwidget.h delete mode 100644 examples/draganddrop/fridgemagnets/fridgemagnets.desktop delete mode 100644 examples/draganddrop/fridgemagnets/fridgemagnets.pro delete mode 100644 examples/draganddrop/fridgemagnets/fridgemagnets.qrc delete mode 100644 examples/draganddrop/fridgemagnets/main.cpp delete mode 100644 examples/draganddrop/fridgemagnets/words.txt delete mode 100644 examples/draganddrop/puzzle/example.jpg delete mode 100644 examples/draganddrop/puzzle/main.cpp delete mode 100644 examples/draganddrop/puzzle/mainwindow.cpp delete mode 100644 examples/draganddrop/puzzle/mainwindow.h delete mode 100644 examples/draganddrop/puzzle/pieceslist.cpp delete mode 100644 examples/draganddrop/puzzle/pieceslist.h delete mode 100644 examples/draganddrop/puzzle/puzzle.desktop delete mode 100644 examples/draganddrop/puzzle/puzzle.pro delete mode 100644 examples/draganddrop/puzzle/puzzle.qrc delete mode 100644 examples/draganddrop/puzzle/puzzlewidget.cpp delete mode 100644 examples/draganddrop/puzzle/puzzlewidget.h delete mode 100644 examples/effects/blurpicker/blureffect.cpp delete mode 100644 examples/effects/blurpicker/blureffect.h delete mode 100644 examples/effects/blurpicker/blurpicker.cpp delete mode 100644 examples/effects/blurpicker/blurpicker.desktop delete mode 100644 examples/effects/blurpicker/blurpicker.h delete mode 100644 examples/effects/blurpicker/blurpicker.pro delete mode 100644 examples/effects/blurpicker/blurpicker.qrc delete mode 100644 examples/effects/blurpicker/images/README.txt delete mode 100644 examples/effects/blurpicker/images/accessories-calculator.png delete mode 100644 examples/effects/blurpicker/images/accessories-text-editor.png delete mode 100644 examples/effects/blurpicker/images/background.jpg delete mode 100644 examples/effects/blurpicker/images/help-browser.png delete mode 100644 examples/effects/blurpicker/images/internet-group-chat.png delete mode 100644 examples/effects/blurpicker/images/internet-mail.png delete mode 100644 examples/effects/blurpicker/images/internet-web-browser.png delete mode 100644 examples/effects/blurpicker/images/office-calendar.png delete mode 100644 examples/effects/blurpicker/images/system-users.png delete mode 100644 examples/effects/blurpicker/main.cpp delete mode 100644 examples/effects/effects.pro delete mode 100644 examples/effects/fademessage/README.txt delete mode 100644 examples/effects/fademessage/background.jpg delete mode 100644 examples/effects/fademessage/fademessage.cpp delete mode 100644 examples/effects/fademessage/fademessage.desktop delete mode 100644 examples/effects/fademessage/fademessage.h delete mode 100644 examples/effects/fademessage/fademessage.pro delete mode 100644 examples/effects/fademessage/fademessage.qrc delete mode 100644 examples/effects/fademessage/main.cpp delete mode 100644 examples/effects/lighting/lighting.cpp delete mode 100644 examples/effects/lighting/lighting.desktop delete mode 100644 examples/effects/lighting/lighting.h delete mode 100644 examples/effects/lighting/lighting.pro delete mode 100644 examples/effects/lighting/main.cpp delete mode 100644 examples/graphicsview/README delete mode 100644 examples/graphicsview/anchorlayout/anchorlayout.desktop delete mode 100644 examples/graphicsview/anchorlayout/anchorlayout.pro delete mode 100644 examples/graphicsview/anchorlayout/main.cpp delete mode 100644 examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.desktop delete mode 100644 examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro delete mode 100644 examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.qrc delete mode 100644 examples/graphicsview/basicgraphicslayouts/images/block.png delete mode 100644 examples/graphicsview/basicgraphicslayouts/layoutitem.cpp delete mode 100644 examples/graphicsview/basicgraphicslayouts/layoutitem.h delete mode 100644 examples/graphicsview/basicgraphicslayouts/main.cpp delete mode 100644 examples/graphicsview/basicgraphicslayouts/window.cpp delete mode 100644 examples/graphicsview/basicgraphicslayouts/window.h delete mode 100644 examples/graphicsview/boxes/3rdparty/fbm.c delete mode 100644 examples/graphicsview/boxes/3rdparty/fbm.h delete mode 100644 examples/graphicsview/boxes/basic.fsh delete mode 100644 examples/graphicsview/boxes/basic.vsh delete mode 100644 examples/graphicsview/boxes/boxes.pro delete mode 100644 examples/graphicsview/boxes/boxes.qrc delete mode 100644 examples/graphicsview/boxes/cubemap_negx.jpg delete mode 100644 examples/graphicsview/boxes/cubemap_negy.jpg delete mode 100644 examples/graphicsview/boxes/cubemap_negz.jpg delete mode 100644 examples/graphicsview/boxes/cubemap_posx.jpg delete mode 100644 examples/graphicsview/boxes/cubemap_posy.jpg delete mode 100644 examples/graphicsview/boxes/cubemap_posz.jpg delete mode 100644 examples/graphicsview/boxes/dotted.fsh delete mode 100644 examples/graphicsview/boxes/fresnel.fsh delete mode 100644 examples/graphicsview/boxes/glass.fsh delete mode 100644 examples/graphicsview/boxes/glbuffers.cpp delete mode 100644 examples/graphicsview/boxes/glbuffers.h delete mode 100644 examples/graphicsview/boxes/glextensions.cpp delete mode 100644 examples/graphicsview/boxes/glextensions.h delete mode 100644 examples/graphicsview/boxes/gltrianglemesh.h delete mode 100644 examples/graphicsview/boxes/granite.fsh delete mode 100644 examples/graphicsview/boxes/main.cpp delete mode 100644 examples/graphicsview/boxes/marble.fsh delete mode 100644 examples/graphicsview/boxes/parameters.par delete mode 100644 examples/graphicsview/boxes/qt-logo.jpg delete mode 100644 examples/graphicsview/boxes/qt-logo.png delete mode 100644 examples/graphicsview/boxes/qtbox.cpp delete mode 100644 examples/graphicsview/boxes/qtbox.h delete mode 100644 examples/graphicsview/boxes/reflection.fsh delete mode 100644 examples/graphicsview/boxes/refraction.fsh delete mode 100644 examples/graphicsview/boxes/roundedbox.cpp delete mode 100644 examples/graphicsview/boxes/roundedbox.h delete mode 100644 examples/graphicsview/boxes/scene.cpp delete mode 100644 examples/graphicsview/boxes/scene.h delete mode 100644 examples/graphicsview/boxes/smiley.png delete mode 100644 examples/graphicsview/boxes/square.jpg delete mode 100644 examples/graphicsview/boxes/trackball.cpp delete mode 100644 examples/graphicsview/boxes/trackball.h delete mode 100644 examples/graphicsview/boxes/wood.fsh delete mode 100644 examples/graphicsview/chip/chip.cpp delete mode 100644 examples/graphicsview/chip/chip.h delete mode 100644 examples/graphicsview/chip/chip.pro delete mode 100644 examples/graphicsview/chip/fileprint.png delete mode 100644 examples/graphicsview/chip/images.qrc delete mode 100644 examples/graphicsview/chip/main.cpp delete mode 100644 examples/graphicsview/chip/mainwindow.cpp delete mode 100644 examples/graphicsview/chip/mainwindow.h delete mode 100644 examples/graphicsview/chip/qt4logo.png delete mode 100644 examples/graphicsview/chip/rotateleft.png delete mode 100644 examples/graphicsview/chip/rotateright.png delete mode 100644 examples/graphicsview/chip/view.cpp delete mode 100644 examples/graphicsview/chip/view.h delete mode 100644 examples/graphicsview/chip/zoomin.png delete mode 100644 examples/graphicsview/chip/zoomout.png delete mode 100644 examples/graphicsview/collidingmice/collidingmice.desktop delete mode 100644 examples/graphicsview/collidingmice/collidingmice.pro delete mode 100644 examples/graphicsview/collidingmice/images/cheese.jpg delete mode 100644 examples/graphicsview/collidingmice/main.cpp delete mode 100644 examples/graphicsview/collidingmice/mice.qrc delete mode 100644 examples/graphicsview/collidingmice/mouse.cpp delete mode 100644 examples/graphicsview/collidingmice/mouse.h delete mode 100644 examples/graphicsview/diagramscene/arrow.cpp delete mode 100644 examples/graphicsview/diagramscene/arrow.h delete mode 100644 examples/graphicsview/diagramscene/diagramitem.cpp delete mode 100644 examples/graphicsview/diagramscene/diagramitem.h delete mode 100644 examples/graphicsview/diagramscene/diagramscene.cpp delete mode 100644 examples/graphicsview/diagramscene/diagramscene.desktop delete mode 100644 examples/graphicsview/diagramscene/diagramscene.h delete mode 100644 examples/graphicsview/diagramscene/diagramscene.pro delete mode 100644 examples/graphicsview/diagramscene/diagramscene.qrc delete mode 100644 examples/graphicsview/diagramscene/diagramtextitem.cpp delete mode 100644 examples/graphicsview/diagramscene/diagramtextitem.h delete mode 100644 examples/graphicsview/diagramscene/images/background1.png delete mode 100644 examples/graphicsview/diagramscene/images/background2.png delete mode 100644 examples/graphicsview/diagramscene/images/background3.png delete mode 100644 examples/graphicsview/diagramscene/images/background4.png delete mode 100644 examples/graphicsview/diagramscene/images/bold.png delete mode 100644 examples/graphicsview/diagramscene/images/bringtofront.png delete mode 100644 examples/graphicsview/diagramscene/images/delete.png delete mode 100644 examples/graphicsview/diagramscene/images/floodfill.png delete mode 100644 examples/graphicsview/diagramscene/images/italic.png delete mode 100644 examples/graphicsview/diagramscene/images/linecolor.png delete mode 100644 examples/graphicsview/diagramscene/images/linepointer.png delete mode 100644 examples/graphicsview/diagramscene/images/pointer.png delete mode 100644 examples/graphicsview/diagramscene/images/sendtoback.png delete mode 100644 examples/graphicsview/diagramscene/images/textpointer.png delete mode 100644 examples/graphicsview/diagramscene/images/underline.png delete mode 100644 examples/graphicsview/diagramscene/main.cpp delete mode 100644 examples/graphicsview/diagramscene/mainwindow.cpp delete mode 100644 examples/graphicsview/diagramscene/mainwindow.h delete mode 100644 examples/graphicsview/dragdroprobot/coloritem.cpp delete mode 100644 examples/graphicsview/dragdroprobot/coloritem.h delete mode 100644 examples/graphicsview/dragdroprobot/dragdroprobot.desktop delete mode 100644 examples/graphicsview/dragdroprobot/dragdroprobot.pro delete mode 100644 examples/graphicsview/dragdroprobot/images/head.png delete mode 100644 examples/graphicsview/dragdroprobot/main.cpp delete mode 100644 examples/graphicsview/dragdroprobot/robot.cpp delete mode 100644 examples/graphicsview/dragdroprobot/robot.h delete mode 100644 examples/graphicsview/dragdroprobot/robot.qrc delete mode 100644 examples/graphicsview/elasticnodes/edge.cpp delete mode 100644 examples/graphicsview/elasticnodes/edge.h delete mode 100644 examples/graphicsview/elasticnodes/elasticnodes.desktop delete mode 100644 examples/graphicsview/elasticnodes/elasticnodes.pro delete mode 100644 examples/graphicsview/elasticnodes/graphwidget.cpp delete mode 100644 examples/graphicsview/elasticnodes/graphwidget.h delete mode 100644 examples/graphicsview/elasticnodes/main.cpp delete mode 100644 examples/graphicsview/elasticnodes/node.cpp delete mode 100644 examples/graphicsview/elasticnodes/node.h delete mode 100644 examples/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg delete mode 100644 examples/graphicsview/embeddeddialogs/customproxy.cpp delete mode 100644 examples/graphicsview/embeddeddialogs/customproxy.h delete mode 100644 examples/graphicsview/embeddeddialogs/embeddeddialog.cpp delete mode 100644 examples/graphicsview/embeddeddialogs/embeddeddialog.h delete mode 100644 examples/graphicsview/embeddeddialogs/embeddeddialog.ui delete mode 100644 examples/graphicsview/embeddeddialogs/embeddeddialogs.pro delete mode 100644 examples/graphicsview/embeddeddialogs/embeddeddialogs.qrc delete mode 100644 examples/graphicsview/embeddeddialogs/main.cpp delete mode 100644 examples/graphicsview/flowlayout/flowlayout.cpp delete mode 100644 examples/graphicsview/flowlayout/flowlayout.desktop delete mode 100644 examples/graphicsview/flowlayout/flowlayout.h delete mode 100644 examples/graphicsview/flowlayout/flowlayout.pro delete mode 100644 examples/graphicsview/flowlayout/main.cpp delete mode 100644 examples/graphicsview/flowlayout/window.cpp delete mode 100644 examples/graphicsview/flowlayout/window.h delete mode 100644 examples/graphicsview/graphicsview.pro delete mode 100644 examples/graphicsview/padnavigator/flippablepad.cpp delete mode 100644 examples/graphicsview/padnavigator/flippablepad.h delete mode 100644 examples/graphicsview/padnavigator/form.ui delete mode 100644 examples/graphicsview/padnavigator/images/artsfftscope.png delete mode 100644 examples/graphicsview/padnavigator/images/blue_angle_swirl.jpg delete mode 100644 examples/graphicsview/padnavigator/images/kontact_contacts.png delete mode 100644 examples/graphicsview/padnavigator/images/kontact_journal.png delete mode 100644 examples/graphicsview/padnavigator/images/kontact_mail.png delete mode 100644 examples/graphicsview/padnavigator/images/kontact_notes.png delete mode 100644 examples/graphicsview/padnavigator/images/kopeteavailable.png delete mode 100644 examples/graphicsview/padnavigator/images/metacontact_online.png delete mode 100644 examples/graphicsview/padnavigator/images/minitools.png delete mode 100644 examples/graphicsview/padnavigator/main.cpp delete mode 100644 examples/graphicsview/padnavigator/padnavigator.cpp delete mode 100644 examples/graphicsview/padnavigator/padnavigator.desktop delete mode 100644 examples/graphicsview/padnavigator/padnavigator.h delete mode 100644 examples/graphicsview/padnavigator/padnavigator.pro delete mode 100644 examples/graphicsview/padnavigator/padnavigator.qrc delete mode 100644 examples/graphicsview/padnavigator/roundrectitem.cpp delete mode 100644 examples/graphicsview/padnavigator/roundrectitem.h delete mode 100644 examples/graphicsview/padnavigator/splashitem.cpp delete mode 100644 examples/graphicsview/padnavigator/splashitem.h delete mode 100644 examples/graphicsview/portedasteroids/portedasteroids.desktop delete mode 100644 examples/graphicsview/portedcanvas/portedcanvas.desktop delete mode 100644 examples/graphicsview/simpleanchorlayout/main.cpp delete mode 100644 examples/graphicsview/simpleanchorlayout/simpleanchorlayout.desktop delete mode 100644 examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro delete mode 100644 examples/graphicsview/weatheranchorlayout/images/5days.jpg delete mode 100644 examples/graphicsview/weatheranchorlayout/images/details.jpg delete mode 100644 examples/graphicsview/weatheranchorlayout/images/place.jpg delete mode 100644 examples/graphicsview/weatheranchorlayout/images/tabbar.jpg delete mode 100644 examples/graphicsview/weatheranchorlayout/images/title.jpg delete mode 100644 examples/graphicsview/weatheranchorlayout/images/weather-few-clouds.png delete mode 100644 examples/graphicsview/weatheranchorlayout/main.cpp delete mode 100644 examples/graphicsview/weatheranchorlayout/weatheranchorlayout.desktop delete mode 100644 examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro delete mode 100644 examples/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc delete mode 100644 examples/itemviews/README delete mode 100644 examples/itemviews/addressbook/adddialog.cpp delete mode 100644 examples/itemviews/addressbook/adddialog.h delete mode 100644 examples/itemviews/addressbook/addressbook.desktop delete mode 100644 examples/itemviews/addressbook/addressbook.pro delete mode 100644 examples/itemviews/addressbook/addresswidget.cpp delete mode 100644 examples/itemviews/addressbook/addresswidget.h delete mode 100644 examples/itemviews/addressbook/main.cpp delete mode 100644 examples/itemviews/addressbook/mainwindow.cpp delete mode 100644 examples/itemviews/addressbook/mainwindow.h delete mode 100644 examples/itemviews/addressbook/newaddresstab.cpp delete mode 100644 examples/itemviews/addressbook/newaddresstab.h delete mode 100644 examples/itemviews/addressbook/tablemodel.cpp delete mode 100644 examples/itemviews/addressbook/tablemodel.h delete mode 100644 examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.desktop delete mode 100644 examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro delete mode 100644 examples/itemviews/basicsortfiltermodel/main.cpp delete mode 100644 examples/itemviews/basicsortfiltermodel/window.cpp delete mode 100644 examples/itemviews/basicsortfiltermodel/window.h delete mode 100644 examples/itemviews/chart/chart.desktop delete mode 100644 examples/itemviews/chart/chart.pro delete mode 100644 examples/itemviews/chart/chart.qrc delete mode 100644 examples/itemviews/chart/main.cpp delete mode 100644 examples/itemviews/chart/mainwindow.cpp delete mode 100644 examples/itemviews/chart/mainwindow.h delete mode 100644 examples/itemviews/chart/mydata.cht delete mode 100644 examples/itemviews/chart/pieview.cpp delete mode 100644 examples/itemviews/chart/pieview.h delete mode 100644 examples/itemviews/chart/qtdata.cht delete mode 100644 examples/itemviews/coloreditorfactory/coloreditorfactory.desktop delete mode 100644 examples/itemviews/coloreditorfactory/coloreditorfactory.pro delete mode 100644 examples/itemviews/coloreditorfactory/colorlisteditor.cpp delete mode 100644 examples/itemviews/coloreditorfactory/colorlisteditor.h delete mode 100644 examples/itemviews/coloreditorfactory/main.cpp delete mode 100644 examples/itemviews/coloreditorfactory/window.cpp delete mode 100644 examples/itemviews/coloreditorfactory/window.h delete mode 100644 examples/itemviews/combowidgetmapper/combowidgetmapper.desktop delete mode 100644 examples/itemviews/combowidgetmapper/combowidgetmapper.pro delete mode 100644 examples/itemviews/combowidgetmapper/main.cpp delete mode 100644 examples/itemviews/combowidgetmapper/window.cpp delete mode 100644 examples/itemviews/combowidgetmapper/window.h delete mode 100644 examples/itemviews/customsortfiltermodel/customsortfiltermodel.desktop delete mode 100644 examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro delete mode 100644 examples/itemviews/customsortfiltermodel/main.cpp delete mode 100644 examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp delete mode 100644 examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.h delete mode 100644 examples/itemviews/customsortfiltermodel/window.cpp delete mode 100644 examples/itemviews/customsortfiltermodel/window.h delete mode 100644 examples/itemviews/dirview/dirview.desktop delete mode 100644 examples/itemviews/dirview/dirview.pro delete mode 100644 examples/itemviews/dirview/main.cpp delete mode 100644 examples/itemviews/editabletreemodel/default.txt delete mode 100644 examples/itemviews/editabletreemodel/editabletreemodel.desktop delete mode 100644 examples/itemviews/editabletreemodel/editabletreemodel.pro delete mode 100644 examples/itemviews/editabletreemodel/editabletreemodel.qrc delete mode 100644 examples/itemviews/editabletreemodel/main.cpp delete mode 100644 examples/itemviews/editabletreemodel/mainwindow.cpp delete mode 100644 examples/itemviews/editabletreemodel/mainwindow.h delete mode 100644 examples/itemviews/editabletreemodel/mainwindow.ui delete mode 100644 examples/itemviews/editabletreemodel/treeitem.cpp delete mode 100644 examples/itemviews/editabletreemodel/treeitem.h delete mode 100644 examples/itemviews/editabletreemodel/treemodel.cpp delete mode 100644 examples/itemviews/editabletreemodel/treemodel.h delete mode 100644 examples/itemviews/fetchmore/fetchmore.desktop delete mode 100644 examples/itemviews/fetchmore/fetchmore.pro delete mode 100644 examples/itemviews/fetchmore/filelistmodel.cpp delete mode 100644 examples/itemviews/fetchmore/filelistmodel.h delete mode 100644 examples/itemviews/fetchmore/main.cpp delete mode 100644 examples/itemviews/fetchmore/window.cpp delete mode 100644 examples/itemviews/fetchmore/window.h delete mode 100644 examples/itemviews/frozencolumn/freezetablewidget.cpp delete mode 100644 examples/itemviews/frozencolumn/freezetablewidget.h delete mode 100644 examples/itemviews/frozencolumn/frozencolumn.desktop delete mode 100644 examples/itemviews/frozencolumn/frozencolumn.pro delete mode 100644 examples/itemviews/frozencolumn/grades.qrc delete mode 100644 examples/itemviews/frozencolumn/grades.txt delete mode 100644 examples/itemviews/frozencolumn/main.cpp delete mode 100644 examples/itemviews/interview/README delete mode 100644 examples/itemviews/interview/images/folder.png delete mode 100644 examples/itemviews/interview/images/interview.png delete mode 100644 examples/itemviews/interview/images/services.png delete mode 100644 examples/itemviews/interview/interview.pro delete mode 100644 examples/itemviews/interview/interview.qrc delete mode 100644 examples/itemviews/interview/main.cpp delete mode 100644 examples/itemviews/interview/model.cpp delete mode 100644 examples/itemviews/interview/model.h delete mode 100644 examples/itemviews/itemviews.pro delete mode 100644 examples/itemviews/pixelator/imagemodel.cpp delete mode 100644 examples/itemviews/pixelator/imagemodel.h delete mode 100644 examples/itemviews/pixelator/images.qrc delete mode 100644 examples/itemviews/pixelator/images/qt.png delete mode 100644 examples/itemviews/pixelator/main.cpp delete mode 100644 examples/itemviews/pixelator/mainwindow.cpp delete mode 100644 examples/itemviews/pixelator/mainwindow.h delete mode 100644 examples/itemviews/pixelator/pixelator.desktop delete mode 100644 examples/itemviews/pixelator/pixelator.pro delete mode 100644 examples/itemviews/pixelator/pixeldelegate.cpp delete mode 100644 examples/itemviews/pixelator/pixeldelegate.h delete mode 100644 examples/itemviews/puzzle/example.jpg delete mode 100644 examples/itemviews/puzzle/main.cpp delete mode 100644 examples/itemviews/puzzle/mainwindow.cpp delete mode 100644 examples/itemviews/puzzle/mainwindow.h delete mode 100644 examples/itemviews/puzzle/piecesmodel.cpp delete mode 100644 examples/itemviews/puzzle/piecesmodel.h delete mode 100644 examples/itemviews/puzzle/puzzle.desktop delete mode 100644 examples/itemviews/puzzle/puzzle.pro delete mode 100644 examples/itemviews/puzzle/puzzle.qrc delete mode 100644 examples/itemviews/puzzle/puzzlewidget.cpp delete mode 100644 examples/itemviews/puzzle/puzzlewidget.h delete mode 100644 examples/itemviews/simpledommodel/domitem.cpp delete mode 100644 examples/itemviews/simpledommodel/domitem.h delete mode 100644 examples/itemviews/simpledommodel/dommodel.cpp delete mode 100644 examples/itemviews/simpledommodel/dommodel.h delete mode 100644 examples/itemviews/simpledommodel/main.cpp delete mode 100644 examples/itemviews/simpledommodel/mainwindow.cpp delete mode 100644 examples/itemviews/simpledommodel/mainwindow.h delete mode 100644 examples/itemviews/simpledommodel/simpledommodel.desktop delete mode 100644 examples/itemviews/simpledommodel/simpledommodel.pro delete mode 100644 examples/itemviews/simpletreemodel/default.txt delete mode 100644 examples/itemviews/simpletreemodel/main.cpp delete mode 100644 examples/itemviews/simpletreemodel/simpletreemodel.desktop delete mode 100644 examples/itemviews/simpletreemodel/simpletreemodel.pro delete mode 100644 examples/itemviews/simpletreemodel/simpletreemodel.qrc delete mode 100644 examples/itemviews/simpletreemodel/treeitem.cpp delete mode 100644 examples/itemviews/simpletreemodel/treeitem.h delete mode 100644 examples/itemviews/simpletreemodel/treemodel.cpp delete mode 100644 examples/itemviews/simpletreemodel/treemodel.h delete mode 100644 examples/itemviews/simplewidgetmapper/main.cpp delete mode 100644 examples/itemviews/simplewidgetmapper/simplewidgetmapper.desktop delete mode 100644 examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro delete mode 100644 examples/itemviews/simplewidgetmapper/window.cpp delete mode 100644 examples/itemviews/simplewidgetmapper/window.h delete mode 100644 examples/itemviews/spinboxdelegate/delegate.cpp delete mode 100644 examples/itemviews/spinboxdelegate/delegate.h delete mode 100644 examples/itemviews/spinboxdelegate/main.cpp delete mode 100644 examples/itemviews/spinboxdelegate/spinboxdelegate.desktop delete mode 100644 examples/itemviews/spinboxdelegate/spinboxdelegate.pro delete mode 100644 examples/itemviews/spreadsheet/images/interview.png delete mode 100644 examples/itemviews/spreadsheet/main.cpp delete mode 100644 examples/itemviews/spreadsheet/printview.cpp delete mode 100644 examples/itemviews/spreadsheet/printview.h delete mode 100644 examples/itemviews/spreadsheet/spreadsheet.cpp delete mode 100644 examples/itemviews/spreadsheet/spreadsheet.h delete mode 100644 examples/itemviews/spreadsheet/spreadsheet.pro delete mode 100644 examples/itemviews/spreadsheet/spreadsheet.qrc delete mode 100644 examples/itemviews/spreadsheet/spreadsheetdelegate.cpp delete mode 100644 examples/itemviews/spreadsheet/spreadsheetdelegate.h delete mode 100644 examples/itemviews/spreadsheet/spreadsheetitem.cpp delete mode 100644 examples/itemviews/spreadsheet/spreadsheetitem.h delete mode 100644 examples/itemviews/stardelegate/main.cpp delete mode 100644 examples/itemviews/stardelegate/stardelegate.cpp delete mode 100644 examples/itemviews/stardelegate/stardelegate.desktop delete mode 100644 examples/itemviews/stardelegate/stardelegate.h delete mode 100644 examples/itemviews/stardelegate/stardelegate.pro delete mode 100644 examples/itemviews/stardelegate/stareditor.cpp delete mode 100644 examples/itemviews/stardelegate/stareditor.h delete mode 100644 examples/itemviews/stardelegate/starrating.cpp delete mode 100644 examples/itemviews/stardelegate/starrating.h delete mode 100644 examples/layouts/README delete mode 100644 examples/layouts/basiclayouts/basiclayouts.desktop delete mode 100644 examples/layouts/basiclayouts/basiclayouts.pro delete mode 100644 examples/layouts/basiclayouts/dialog.cpp delete mode 100644 examples/layouts/basiclayouts/dialog.h delete mode 100644 examples/layouts/basiclayouts/main.cpp delete mode 100644 examples/layouts/borderlayout/borderlayout.cpp delete mode 100644 examples/layouts/borderlayout/borderlayout.desktop delete mode 100644 examples/layouts/borderlayout/borderlayout.h delete mode 100644 examples/layouts/borderlayout/borderlayout.pro delete mode 100644 examples/layouts/borderlayout/main.cpp delete mode 100644 examples/layouts/borderlayout/window.cpp delete mode 100644 examples/layouts/borderlayout/window.h delete mode 100644 examples/layouts/dynamiclayouts/dialog.cpp delete mode 100644 examples/layouts/dynamiclayouts/dialog.h delete mode 100644 examples/layouts/dynamiclayouts/dynamiclayouts.desktop delete mode 100644 examples/layouts/dynamiclayouts/dynamiclayouts.pro delete mode 100644 examples/layouts/dynamiclayouts/main.cpp delete mode 100644 examples/layouts/flowlayout/flowlayout.cpp delete mode 100644 examples/layouts/flowlayout/flowlayout.desktop delete mode 100644 examples/layouts/flowlayout/flowlayout.h delete mode 100644 examples/layouts/flowlayout/flowlayout.pro delete mode 100644 examples/layouts/flowlayout/main.cpp delete mode 100644 examples/layouts/flowlayout/window.cpp delete mode 100644 examples/layouts/flowlayout/window.h delete mode 100644 examples/layouts/layouts.pro delete mode 100644 examples/mainwindows/README delete mode 100644 examples/mainwindows/application/application.desktop delete mode 100644 examples/mainwindows/application/application.pro delete mode 100644 examples/mainwindows/application/application.qrc delete mode 100644 examples/mainwindows/application/images/copy.png delete mode 100644 examples/mainwindows/application/images/cut.png delete mode 100644 examples/mainwindows/application/images/new.png delete mode 100644 examples/mainwindows/application/images/open.png delete mode 100644 examples/mainwindows/application/images/paste.png delete mode 100644 examples/mainwindows/application/images/save.png delete mode 100644 examples/mainwindows/application/main.cpp delete mode 100644 examples/mainwindows/application/mainwindow.cpp delete mode 100644 examples/mainwindows/application/mainwindow.h delete mode 100644 examples/mainwindows/dockwidgets/dockwidgets.desktop delete mode 100644 examples/mainwindows/dockwidgets/dockwidgets.pro delete mode 100644 examples/mainwindows/dockwidgets/dockwidgets.qrc delete mode 100644 examples/mainwindows/dockwidgets/images/new.png delete mode 100644 examples/mainwindows/dockwidgets/images/print.png delete mode 100644 examples/mainwindows/dockwidgets/images/save.png delete mode 100644 examples/mainwindows/dockwidgets/images/undo.png delete mode 100644 examples/mainwindows/dockwidgets/main.cpp delete mode 100644 examples/mainwindows/dockwidgets/mainwindow.cpp delete mode 100644 examples/mainwindows/dockwidgets/mainwindow.h delete mode 100644 examples/mainwindows/mainwindow/colorswatch.cpp delete mode 100644 examples/mainwindows/mainwindow/colorswatch.h delete mode 100644 examples/mainwindows/mainwindow/main.cpp delete mode 100644 examples/mainwindows/mainwindow/mainwindow.cpp delete mode 100644 examples/mainwindows/mainwindow/mainwindow.h delete mode 100644 examples/mainwindows/mainwindow/mainwindow.pro delete mode 100644 examples/mainwindows/mainwindow/mainwindow.qrc delete mode 100644 examples/mainwindows/mainwindow/qt.png delete mode 100644 examples/mainwindows/mainwindow/titlebarCenter.png delete mode 100644 examples/mainwindows/mainwindow/titlebarLeft.png delete mode 100644 examples/mainwindows/mainwindow/titlebarRight.png delete mode 100644 examples/mainwindows/mainwindow/toolbar.cpp delete mode 100644 examples/mainwindows/mainwindow/toolbar.h delete mode 100644 examples/mainwindows/mainwindows.pro delete mode 100644 examples/mainwindows/mdi/images/copy.png delete mode 100644 examples/mainwindows/mdi/images/cut.png delete mode 100644 examples/mainwindows/mdi/images/new.png delete mode 100644 examples/mainwindows/mdi/images/open.png delete mode 100644 examples/mainwindows/mdi/images/paste.png delete mode 100644 examples/mainwindows/mdi/images/save.png delete mode 100644 examples/mainwindows/mdi/main.cpp delete mode 100644 examples/mainwindows/mdi/mainwindow.cpp delete mode 100644 examples/mainwindows/mdi/mainwindow.h delete mode 100644 examples/mainwindows/mdi/mdi.desktop delete mode 100644 examples/mainwindows/mdi/mdi.pro delete mode 100644 examples/mainwindows/mdi/mdi.qrc delete mode 100644 examples/mainwindows/mdi/mdichild.cpp delete mode 100644 examples/mainwindows/mdi/mdichild.h delete mode 100644 examples/mainwindows/menus/main.cpp delete mode 100644 examples/mainwindows/menus/mainwindow.cpp delete mode 100644 examples/mainwindows/menus/mainwindow.h delete mode 100644 examples/mainwindows/menus/menus.desktop delete mode 100644 examples/mainwindows/menus/menus.pro delete mode 100644 examples/mainwindows/recentfiles/main.cpp delete mode 100644 examples/mainwindows/recentfiles/mainwindow.cpp delete mode 100644 examples/mainwindows/recentfiles/mainwindow.h delete mode 100644 examples/mainwindows/recentfiles/recentfiles.desktop delete mode 100644 examples/mainwindows/recentfiles/recentfiles.pro delete mode 100644 examples/mainwindows/sdi/images/copy.png delete mode 100644 examples/mainwindows/sdi/images/cut.png delete mode 100644 examples/mainwindows/sdi/images/new.png delete mode 100644 examples/mainwindows/sdi/images/open.png delete mode 100644 examples/mainwindows/sdi/images/paste.png delete mode 100644 examples/mainwindows/sdi/images/save.png delete mode 100644 examples/mainwindows/sdi/main.cpp delete mode 100644 examples/mainwindows/sdi/mainwindow.cpp delete mode 100644 examples/mainwindows/sdi/mainwindow.h delete mode 100644 examples/mainwindows/sdi/sdi.desktop delete mode 100644 examples/mainwindows/sdi/sdi.pro delete mode 100644 examples/mainwindows/sdi/sdi.qrc delete mode 100644 examples/painting/README delete mode 100644 examples/painting/affine/affine.pro delete mode 100644 examples/painting/affine/affine.qrc delete mode 100644 examples/painting/affine/bg1.jpg delete mode 100644 examples/painting/affine/main.cpp delete mode 100644 examples/painting/affine/xform.cpp delete mode 100644 examples/painting/affine/xform.h delete mode 100644 examples/painting/affine/xform.html delete mode 100644 examples/painting/basicdrawing/basicdrawing.desktop delete mode 100644 examples/painting/basicdrawing/basicdrawing.pro delete mode 100644 examples/painting/basicdrawing/basicdrawing.qrc delete mode 100644 examples/painting/basicdrawing/images/brick.png delete mode 100644 examples/painting/basicdrawing/images/qt-logo.png delete mode 100644 examples/painting/basicdrawing/main.cpp delete mode 100644 examples/painting/basicdrawing/renderarea.cpp delete mode 100644 examples/painting/basicdrawing/renderarea.h delete mode 100644 examples/painting/basicdrawing/window.cpp delete mode 100644 examples/painting/basicdrawing/window.h delete mode 100644 examples/painting/composition/composition.cpp delete mode 100644 examples/painting/composition/composition.h delete mode 100644 examples/painting/composition/composition.html delete mode 100644 examples/painting/composition/composition.pro delete mode 100644 examples/painting/composition/composition.qrc delete mode 100644 examples/painting/composition/flower.jpg delete mode 100644 examples/painting/composition/flower_alpha.jpg delete mode 100644 examples/painting/composition/main.cpp delete mode 100644 examples/painting/concentriccircles/circlewidget.cpp delete mode 100644 examples/painting/concentriccircles/circlewidget.h delete mode 100644 examples/painting/concentriccircles/concentriccircles.desktop delete mode 100644 examples/painting/concentriccircles/concentriccircles.pro delete mode 100644 examples/painting/concentriccircles/main.cpp delete mode 100644 examples/painting/concentriccircles/window.cpp delete mode 100644 examples/painting/concentriccircles/window.h delete mode 100644 examples/painting/deform/deform.pro delete mode 100644 examples/painting/deform/deform.qrc delete mode 100644 examples/painting/deform/main.cpp delete mode 100644 examples/painting/deform/pathdeform.cpp delete mode 100644 examples/painting/deform/pathdeform.h delete mode 100644 examples/painting/deform/pathdeform.html delete mode 100644 examples/painting/fontsampler/fontsampler.desktop delete mode 100644 examples/painting/fontsampler/fontsampler.pro delete mode 100644 examples/painting/fontsampler/main.cpp delete mode 100644 examples/painting/fontsampler/mainwindow.cpp delete mode 100644 examples/painting/fontsampler/mainwindow.h delete mode 100644 examples/painting/fontsampler/mainwindowbase.ui delete mode 100644 examples/painting/gradients/gradients.cpp delete mode 100644 examples/painting/gradients/gradients.h delete mode 100644 examples/painting/gradients/gradients.html delete mode 100644 examples/painting/gradients/gradients.pro delete mode 100644 examples/painting/gradients/gradients.qrc delete mode 100644 examples/painting/gradients/main.cpp delete mode 100644 examples/painting/imagecomposition/imagecomposer.cpp delete mode 100644 examples/painting/imagecomposition/imagecomposer.h delete mode 100644 examples/painting/imagecomposition/imagecomposition.desktop delete mode 100644 examples/painting/imagecomposition/imagecomposition.pro delete mode 100644 examples/painting/imagecomposition/imagecomposition.qrc delete mode 100644 examples/painting/imagecomposition/images/background.png delete mode 100644 examples/painting/imagecomposition/images/blackrectangle.png delete mode 100644 examples/painting/imagecomposition/images/butterfly.png delete mode 100644 examples/painting/imagecomposition/images/checker.png delete mode 100644 examples/painting/imagecomposition/main.cpp delete mode 100644 examples/painting/painterpaths/main.cpp delete mode 100644 examples/painting/painterpaths/painterpaths.desktop delete mode 100644 examples/painting/painterpaths/painterpaths.pro delete mode 100644 examples/painting/painterpaths/renderarea.cpp delete mode 100644 examples/painting/painterpaths/renderarea.h delete mode 100644 examples/painting/painterpaths/window.cpp delete mode 100644 examples/painting/painterpaths/window.h delete mode 100644 examples/painting/painting.pro delete mode 100644 examples/painting/pathstroke/main.cpp delete mode 100644 examples/painting/pathstroke/pathstroke.cpp delete mode 100644 examples/painting/pathstroke/pathstroke.h delete mode 100644 examples/painting/pathstroke/pathstroke.html delete mode 100644 examples/painting/pathstroke/pathstroke.pro delete mode 100644 examples/painting/pathstroke/pathstroke.qrc delete mode 100644 examples/painting/shared/arthurstyle.cpp delete mode 100644 examples/painting/shared/arthurstyle.h delete mode 100644 examples/painting/shared/arthurwidgets.cpp delete mode 100644 examples/painting/shared/arthurwidgets.h delete mode 100644 examples/painting/shared/hoverpoints.cpp delete mode 100644 examples/painting/shared/hoverpoints.h delete mode 100644 examples/painting/shared/images/bg_pattern.png delete mode 100644 examples/painting/shared/images/button_normal_cap_left.png delete mode 100644 examples/painting/shared/images/button_normal_cap_right.png delete mode 100644 examples/painting/shared/images/button_normal_stretch.png delete mode 100644 examples/painting/shared/images/button_pressed_cap_left.png delete mode 100644 examples/painting/shared/images/button_pressed_cap_right.png delete mode 100644 examples/painting/shared/images/button_pressed_stretch.png delete mode 100644 examples/painting/shared/images/curve_thing_edit-6.png delete mode 100644 examples/painting/shared/images/frame_bottom.png delete mode 100644 examples/painting/shared/images/frame_bottomleft.png delete mode 100644 examples/painting/shared/images/frame_bottomright.png delete mode 100644 examples/painting/shared/images/frame_left.png delete mode 100644 examples/painting/shared/images/frame_right.png delete mode 100644 examples/painting/shared/images/frame_top.png delete mode 100644 examples/painting/shared/images/frame_topleft.png delete mode 100644 examples/painting/shared/images/frame_topright.png delete mode 100644 examples/painting/shared/images/groupframe_bottom_left.png delete mode 100644 examples/painting/shared/images/groupframe_bottom_right.png delete mode 100644 examples/painting/shared/images/groupframe_bottom_stretch.png delete mode 100644 examples/painting/shared/images/groupframe_left_stretch.png delete mode 100644 examples/painting/shared/images/groupframe_right_stretch.png delete mode 100644 examples/painting/shared/images/groupframe_top_stretch.png delete mode 100644 examples/painting/shared/images/groupframe_topleft.png delete mode 100644 examples/painting/shared/images/groupframe_topright.png delete mode 100644 examples/painting/shared/images/line_dash_dot.png delete mode 100644 examples/painting/shared/images/line_dash_dot_dot.png delete mode 100644 examples/painting/shared/images/line_dashed.png delete mode 100644 examples/painting/shared/images/line_dotted.png delete mode 100644 examples/painting/shared/images/line_solid.png delete mode 100644 examples/painting/shared/images/radiobutton-off.png delete mode 100644 examples/painting/shared/images/radiobutton-on.png delete mode 100644 examples/painting/shared/images/radiobutton_off.png delete mode 100644 examples/painting/shared/images/radiobutton_on.png delete mode 100644 examples/painting/shared/images/slider_bar.png delete mode 100644 examples/painting/shared/images/slider_thumb_off.png delete mode 100644 examples/painting/shared/images/slider_thumb_on.png delete mode 100644 examples/painting/shared/images/title_cap_left.png delete mode 100644 examples/painting/shared/images/title_cap_right.png delete mode 100644 examples/painting/shared/images/title_stretch.png delete mode 100644 examples/painting/shared/shared.pri delete mode 100644 examples/painting/shared/shared.pro delete mode 100644 examples/painting/shared/shared.qrc delete mode 100644 examples/painting/svggenerator/svggenerator.desktop delete mode 100644 examples/painting/svgviewer/svgviewer.desktop delete mode 100644 examples/painting/transformations/main.cpp delete mode 100644 examples/painting/transformations/renderarea.cpp delete mode 100644 examples/painting/transformations/renderarea.h delete mode 100644 examples/painting/transformations/transformations.desktop delete mode 100644 examples/painting/transformations/transformations.pro delete mode 100644 examples/painting/transformations/window.cpp delete mode 100644 examples/painting/transformations/window.h delete mode 100644 examples/richtext/README delete mode 100644 examples/richtext/calendar/calendar.desktop delete mode 100644 examples/richtext/calendar/calendar.pro delete mode 100644 examples/richtext/calendar/main.cpp delete mode 100644 examples/richtext/calendar/mainwindow.cpp delete mode 100644 examples/richtext/calendar/mainwindow.h delete mode 100644 examples/richtext/orderform/detailsdialog.cpp delete mode 100644 examples/richtext/orderform/detailsdialog.h delete mode 100644 examples/richtext/orderform/main.cpp delete mode 100644 examples/richtext/orderform/mainwindow.cpp delete mode 100644 examples/richtext/orderform/mainwindow.h delete mode 100644 examples/richtext/orderform/orderform.desktop delete mode 100644 examples/richtext/orderform/orderform.pro delete mode 100644 examples/richtext/richtext.pro delete mode 100644 examples/richtext/syntaxhighlighter/highlighter.cpp delete mode 100644 examples/richtext/syntaxhighlighter/highlighter.h delete mode 100644 examples/richtext/syntaxhighlighter/main.cpp delete mode 100644 examples/richtext/syntaxhighlighter/mainwindow.cpp delete mode 100644 examples/richtext/syntaxhighlighter/mainwindow.h delete mode 100644 examples/richtext/syntaxhighlighter/syntaxhighlighter.desktop delete mode 100644 examples/richtext/syntaxhighlighter/syntaxhighlighter.pro delete mode 100644 examples/richtext/textedit/example.html delete mode 100644 examples/richtext/textedit/images/logo32.png delete mode 100644 examples/richtext/textedit/images/mac/editcopy.png delete mode 100644 examples/richtext/textedit/images/mac/editcut.png delete mode 100644 examples/richtext/textedit/images/mac/editpaste.png delete mode 100644 examples/richtext/textedit/images/mac/editredo.png delete mode 100644 examples/richtext/textedit/images/mac/editundo.png delete mode 100644 examples/richtext/textedit/images/mac/exportpdf.png delete mode 100644 examples/richtext/textedit/images/mac/filenew.png delete mode 100644 examples/richtext/textedit/images/mac/fileopen.png delete mode 100644 examples/richtext/textedit/images/mac/fileprint.png delete mode 100644 examples/richtext/textedit/images/mac/filesave.png delete mode 100644 examples/richtext/textedit/images/mac/textbold.png delete mode 100644 examples/richtext/textedit/images/mac/textcenter.png delete mode 100644 examples/richtext/textedit/images/mac/textitalic.png delete mode 100644 examples/richtext/textedit/images/mac/textjustify.png delete mode 100644 examples/richtext/textedit/images/mac/textleft.png delete mode 100644 examples/richtext/textedit/images/mac/textright.png delete mode 100644 examples/richtext/textedit/images/mac/textunder.png delete mode 100644 examples/richtext/textedit/images/mac/zoomin.png delete mode 100644 examples/richtext/textedit/images/mac/zoomout.png delete mode 100644 examples/richtext/textedit/images/win/editcopy.png delete mode 100644 examples/richtext/textedit/images/win/editcut.png delete mode 100644 examples/richtext/textedit/images/win/editpaste.png delete mode 100644 examples/richtext/textedit/images/win/editredo.png delete mode 100644 examples/richtext/textedit/images/win/editundo.png delete mode 100644 examples/richtext/textedit/images/win/exportpdf.png delete mode 100644 examples/richtext/textedit/images/win/filenew.png delete mode 100644 examples/richtext/textedit/images/win/fileopen.png delete mode 100644 examples/richtext/textedit/images/win/fileprint.png delete mode 100644 examples/richtext/textedit/images/win/filesave.png delete mode 100644 examples/richtext/textedit/images/win/textbold.png delete mode 100644 examples/richtext/textedit/images/win/textcenter.png delete mode 100644 examples/richtext/textedit/images/win/textitalic.png delete mode 100644 examples/richtext/textedit/images/win/textjustify.png delete mode 100644 examples/richtext/textedit/images/win/textleft.png delete mode 100644 examples/richtext/textedit/images/win/textright.png delete mode 100644 examples/richtext/textedit/images/win/textunder.png delete mode 100644 examples/richtext/textedit/images/win/zoomin.png delete mode 100644 examples/richtext/textedit/images/win/zoomout.png delete mode 100644 examples/richtext/textedit/main.cpp delete mode 100644 examples/richtext/textedit/textedit.cpp delete mode 100644 examples/richtext/textedit/textedit.h delete mode 100644 examples/richtext/textedit/textedit.pro delete mode 100644 examples/richtext/textedit/textedit.qdoc delete mode 100644 examples/richtext/textedit/textedit.qrc delete mode 100644 examples/scroller/graphicsview/graphicsview.pro delete mode 100644 examples/scroller/graphicsview/main.cpp delete mode 100644 examples/scroller/scroller.pro delete mode 100644 examples/statemachine/README delete mode 100644 examples/statemachine/eventtransitions/eventtransitions.desktop delete mode 100644 examples/statemachine/eventtransitions/eventtransitions.pro delete mode 100644 examples/statemachine/eventtransitions/main.cpp delete mode 100644 examples/statemachine/factorial/factorial.desktop delete mode 100644 examples/statemachine/factorial/factorial.pro delete mode 100644 examples/statemachine/factorial/main.cpp delete mode 100644 examples/statemachine/pingpong/main.cpp delete mode 100644 examples/statemachine/pingpong/pingpong.desktop delete mode 100644 examples/statemachine/pingpong/pingpong.pro delete mode 100644 examples/statemachine/rogue/main.cpp delete mode 100644 examples/statemachine/rogue/movementtransition.h delete mode 100644 examples/statemachine/rogue/rogue.desktop delete mode 100644 examples/statemachine/rogue/rogue.pro delete mode 100644 examples/statemachine/rogue/window.cpp delete mode 100644 examples/statemachine/rogue/window.h delete mode 100644 examples/statemachine/statemachine.pro delete mode 100644 examples/statemachine/trafficlight/main.cpp delete mode 100644 examples/statemachine/trafficlight/trafficlight.desktop delete mode 100644 examples/statemachine/trafficlight/trafficlight.pro delete mode 100644 examples/statemachine/twowaybutton/main.cpp delete mode 100644 examples/statemachine/twowaybutton/twowaybutton.desktop delete mode 100644 examples/statemachine/twowaybutton/twowaybutton.pro delete mode 100644 examples/widgets/README delete mode 100644 examples/widgets/analogclock/analogclock.cpp delete mode 100644 examples/widgets/analogclock/analogclock.desktop delete mode 100644 examples/widgets/analogclock/analogclock.h delete mode 100644 examples/widgets/analogclock/analogclock.pro delete mode 100644 examples/widgets/analogclock/main.cpp create mode 100644 examples/widgets/animation/README create mode 100644 examples/widgets/animation/animatedtiles/animatedtiles.desktop create mode 100644 examples/widgets/animation/animatedtiles/animatedtiles.pro create mode 100644 examples/widgets/animation/animatedtiles/animatedtiles.qrc create mode 100644 examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg create mode 100644 examples/widgets/animation/animatedtiles/images/centered.png create mode 100644 examples/widgets/animation/animatedtiles/images/ellipse.png create mode 100644 examples/widgets/animation/animatedtiles/images/figure8.png create mode 100644 examples/widgets/animation/animatedtiles/images/kinetic.png create mode 100644 examples/widgets/animation/animatedtiles/images/random.png create mode 100644 examples/widgets/animation/animatedtiles/images/tile.png create mode 100644 examples/widgets/animation/animatedtiles/main.cpp create mode 100644 examples/widgets/animation/animation.pro create mode 100644 examples/widgets/animation/appchooser/accessories-dictionary.png create mode 100644 examples/widgets/animation/appchooser/akregator.png create mode 100644 examples/widgets/animation/appchooser/appchooser.desktop create mode 100644 examples/widgets/animation/appchooser/appchooser.pro create mode 100644 examples/widgets/animation/appchooser/appchooser.qrc create mode 100644 examples/widgets/animation/appchooser/digikam.png create mode 100644 examples/widgets/animation/appchooser/k3b.png create mode 100644 examples/widgets/animation/appchooser/main.cpp create mode 100644 examples/widgets/animation/easing/animation.h create mode 100644 examples/widgets/animation/easing/easing.desktop create mode 100644 examples/widgets/animation/easing/easing.pro create mode 100644 examples/widgets/animation/easing/easing.qrc create mode 100644 examples/widgets/animation/easing/form.ui create mode 100644 examples/widgets/animation/easing/images/qt-logo.png create mode 100644 examples/widgets/animation/easing/main.cpp create mode 100644 examples/widgets/animation/easing/window.cpp create mode 100644 examples/widgets/animation/easing/window.h create mode 100644 examples/widgets/animation/moveblocks/main.cpp create mode 100644 examples/widgets/animation/moveblocks/moveblocks.desktop create mode 100644 examples/widgets/animation/moveblocks/moveblocks.pro create mode 100644 examples/widgets/animation/states/accessories-dictionary.png create mode 100644 examples/widgets/animation/states/akregator.png create mode 100644 examples/widgets/animation/states/digikam.png create mode 100644 examples/widgets/animation/states/help-browser.png create mode 100644 examples/widgets/animation/states/k3b.png create mode 100644 examples/widgets/animation/states/kchart.png create mode 100644 examples/widgets/animation/states/main.cpp create mode 100644 examples/widgets/animation/states/states.desktop create mode 100644 examples/widgets/animation/states/states.pro create mode 100644 examples/widgets/animation/states/states.qrc create mode 100644 examples/widgets/animation/stickman/animation.cpp create mode 100644 examples/widgets/animation/stickman/animation.h create mode 100644 examples/widgets/animation/stickman/animations/chilling.bin create mode 100644 examples/widgets/animation/stickman/animations/dancing.bin create mode 100644 examples/widgets/animation/stickman/animations/dead.bin create mode 100644 examples/widgets/animation/stickman/animations/jumping.bin create mode 100644 examples/widgets/animation/stickman/graphicsview.cpp create mode 100644 examples/widgets/animation/stickman/graphicsview.h create mode 100644 examples/widgets/animation/stickman/lifecycle.cpp create mode 100644 examples/widgets/animation/stickman/lifecycle.h create mode 100644 examples/widgets/animation/stickman/main.cpp create mode 100644 examples/widgets/animation/stickman/node.cpp create mode 100644 examples/widgets/animation/stickman/node.h create mode 100644 examples/widgets/animation/stickman/rectbutton.cpp create mode 100644 examples/widgets/animation/stickman/rectbutton.h create mode 100644 examples/widgets/animation/stickman/stickman.cpp create mode 100644 examples/widgets/animation/stickman/stickman.desktop create mode 100644 examples/widgets/animation/stickman/stickman.h create mode 100644 examples/widgets/animation/stickman/stickman.pro create mode 100644 examples/widgets/animation/stickman/stickman.qrc create mode 100644 examples/widgets/animation/sub-attaq/animationmanager.cpp create mode 100644 examples/widgets/animation/sub-attaq/animationmanager.h create mode 100644 examples/widgets/animation/sub-attaq/boat.cpp create mode 100644 examples/widgets/animation/sub-attaq/boat.h create mode 100644 examples/widgets/animation/sub-attaq/boat_p.h create mode 100644 examples/widgets/animation/sub-attaq/bomb.cpp create mode 100644 examples/widgets/animation/sub-attaq/bomb.h create mode 100644 examples/widgets/animation/sub-attaq/data.xml create mode 100644 examples/widgets/animation/sub-attaq/graphicsscene.cpp create mode 100644 examples/widgets/animation/sub-attaq/graphicsscene.h create mode 100644 examples/widgets/animation/sub-attaq/main.cpp create mode 100644 examples/widgets/animation/sub-attaq/mainwindow.cpp create mode 100644 examples/widgets/animation/sub-attaq/mainwindow.h create mode 100644 examples/widgets/animation/sub-attaq/pics/big/background.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/boat.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/bomb.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/submarine.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/surface.png create mode 100644 examples/widgets/animation/sub-attaq/pics/big/torpedo.png create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/background.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/boat.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/sand.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/see.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/sky.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/surface.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg create mode 100644 examples/widgets/animation/sub-attaq/pics/small/background.png create mode 100644 examples/widgets/animation/sub-attaq/pics/small/boat.png create mode 100644 examples/widgets/animation/sub-attaq/pics/small/bomb.png create mode 100644 examples/widgets/animation/sub-attaq/pics/small/submarine.png create mode 100644 examples/widgets/animation/sub-attaq/pics/small/surface.png create mode 100644 examples/widgets/animation/sub-attaq/pics/small/torpedo.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png create mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png create mode 100644 examples/widgets/animation/sub-attaq/pixmapitem.cpp create mode 100644 examples/widgets/animation/sub-attaq/pixmapitem.h create mode 100644 examples/widgets/animation/sub-attaq/progressitem.cpp create mode 100644 examples/widgets/animation/sub-attaq/progressitem.h create mode 100644 examples/widgets/animation/sub-attaq/qanimationstate.cpp create mode 100644 examples/widgets/animation/sub-attaq/qanimationstate.h create mode 100644 examples/widgets/animation/sub-attaq/states.cpp create mode 100644 examples/widgets/animation/sub-attaq/states.h create mode 100644 examples/widgets/animation/sub-attaq/sub-attaq.pro create mode 100644 examples/widgets/animation/sub-attaq/subattaq.qrc create mode 100644 examples/widgets/animation/sub-attaq/submarine.cpp create mode 100644 examples/widgets/animation/sub-attaq/submarine.h create mode 100644 examples/widgets/animation/sub-attaq/submarine_p.h create mode 100644 examples/widgets/animation/sub-attaq/textinformationitem.cpp create mode 100644 examples/widgets/animation/sub-attaq/textinformationitem.h create mode 100644 examples/widgets/animation/sub-attaq/torpedo.cpp create mode 100644 examples/widgets/animation/sub-attaq/torpedo.h delete mode 100644 examples/widgets/applicationicon/applicationicon.desktop delete mode 100644 examples/widgets/applicationicon/applicationicon.png delete mode 100644 examples/widgets/applicationicon/applicationicon.pro delete mode 100644 examples/widgets/applicationicon/applicationicon.svg delete mode 100644 examples/widgets/applicationicon/main.cpp delete mode 100644 examples/widgets/calculator/button.cpp delete mode 100644 examples/widgets/calculator/button.h delete mode 100644 examples/widgets/calculator/calculator.cpp delete mode 100644 examples/widgets/calculator/calculator.desktop delete mode 100644 examples/widgets/calculator/calculator.h delete mode 100644 examples/widgets/calculator/calculator.pro delete mode 100644 examples/widgets/calculator/main.cpp delete mode 100644 examples/widgets/calculator/releasenotes.txt delete mode 100644 examples/widgets/calendarwidget/calendarwidget.desktop delete mode 100644 examples/widgets/calendarwidget/calendarwidget.pro delete mode 100644 examples/widgets/calendarwidget/main.cpp delete mode 100644 examples/widgets/calendarwidget/window.cpp delete mode 100644 examples/widgets/calendarwidget/window.h delete mode 100644 examples/widgets/charactermap/charactermap.desktop delete mode 100644 examples/widgets/charactermap/charactermap.pro delete mode 100644 examples/widgets/charactermap/characterwidget.cpp delete mode 100644 examples/widgets/charactermap/characterwidget.h delete mode 100644 examples/widgets/charactermap/main.cpp delete mode 100644 examples/widgets/charactermap/mainwindow.cpp delete mode 100644 examples/widgets/charactermap/mainwindow.h delete mode 100644 examples/widgets/codeeditor/codeeditor.cpp delete mode 100644 examples/widgets/codeeditor/codeeditor.desktop delete mode 100644 examples/widgets/codeeditor/codeeditor.h delete mode 100644 examples/widgets/codeeditor/codeeditor.pro delete mode 100644 examples/widgets/codeeditor/main.cpp create mode 100644 examples/widgets/desktop/README create mode 100644 examples/widgets/desktop/desktop.pro create mode 100644 examples/widgets/desktop/screenshot/main.cpp create mode 100644 examples/widgets/desktop/screenshot/screenshot.cpp create mode 100644 examples/widgets/desktop/screenshot/screenshot.desktop create mode 100644 examples/widgets/desktop/screenshot/screenshot.h create mode 100644 examples/widgets/desktop/screenshot/screenshot.pro create mode 100644 examples/widgets/desktop/systray/images/bad.png create mode 100644 examples/widgets/desktop/systray/images/heart.png create mode 100644 examples/widgets/desktop/systray/images/trash.png create mode 100644 examples/widgets/desktop/systray/main.cpp create mode 100644 examples/widgets/desktop/systray/systray.desktop create mode 100644 examples/widgets/desktop/systray/systray.pro create mode 100644 examples/widgets/desktop/systray/systray.qrc create mode 100644 examples/widgets/desktop/systray/window.cpp create mode 100644 examples/widgets/desktop/systray/window.h create mode 100644 examples/widgets/dialogs/README create mode 100644 examples/widgets/dialogs/classwizard/classwizard.cpp create mode 100644 examples/widgets/dialogs/classwizard/classwizard.desktop create mode 100644 examples/widgets/dialogs/classwizard/classwizard.h create mode 100644 examples/widgets/dialogs/classwizard/classwizard.pro create mode 100644 examples/widgets/dialogs/classwizard/classwizard.qrc create mode 100644 examples/widgets/dialogs/classwizard/images/background.png create mode 100644 examples/widgets/dialogs/classwizard/images/banner.png create mode 100644 examples/widgets/dialogs/classwizard/images/logo1.png create mode 100644 examples/widgets/dialogs/classwizard/images/logo2.png create mode 100644 examples/widgets/dialogs/classwizard/images/logo3.png create mode 100644 examples/widgets/dialogs/classwizard/images/watermark1.png create mode 100644 examples/widgets/dialogs/classwizard/images/watermark2.png create mode 100644 examples/widgets/dialogs/classwizard/main.cpp create mode 100644 examples/widgets/dialogs/configdialog/configdialog.cpp create mode 100644 examples/widgets/dialogs/configdialog/configdialog.desktop create mode 100644 examples/widgets/dialogs/configdialog/configdialog.h create mode 100644 examples/widgets/dialogs/configdialog/configdialog.pro create mode 100644 examples/widgets/dialogs/configdialog/configdialog.qrc create mode 100644 examples/widgets/dialogs/configdialog/images/config.png create mode 100644 examples/widgets/dialogs/configdialog/images/query.png create mode 100644 examples/widgets/dialogs/configdialog/images/update.png create mode 100644 examples/widgets/dialogs/configdialog/main.cpp create mode 100644 examples/widgets/dialogs/configdialog/pages.cpp create mode 100644 examples/widgets/dialogs/configdialog/pages.h create mode 100644 examples/widgets/dialogs/dialogs.pro create mode 100644 examples/widgets/dialogs/extension/extension.desktop create mode 100644 examples/widgets/dialogs/extension/extension.pro create mode 100644 examples/widgets/dialogs/extension/finddialog.cpp create mode 100644 examples/widgets/dialogs/extension/finddialog.h create mode 100644 examples/widgets/dialogs/extension/main.cpp create mode 100644 examples/widgets/dialogs/findfiles/findfiles.desktop create mode 100644 examples/widgets/dialogs/findfiles/findfiles.pro create mode 100644 examples/widgets/dialogs/findfiles/main.cpp create mode 100644 examples/widgets/dialogs/findfiles/window.cpp create mode 100644 examples/widgets/dialogs/findfiles/window.h create mode 100644 examples/widgets/dialogs/licensewizard/images/logo.png create mode 100644 examples/widgets/dialogs/licensewizard/images/watermark.png create mode 100644 examples/widgets/dialogs/licensewizard/licensewizard.cpp create mode 100644 examples/widgets/dialogs/licensewizard/licensewizard.desktop create mode 100644 examples/widgets/dialogs/licensewizard/licensewizard.h create mode 100644 examples/widgets/dialogs/licensewizard/licensewizard.pro create mode 100644 examples/widgets/dialogs/licensewizard/licensewizard.qrc create mode 100644 examples/widgets/dialogs/licensewizard/main.cpp create mode 100644 examples/widgets/dialogs/sipdialog/dialog.cpp create mode 100644 examples/widgets/dialogs/sipdialog/dialog.h create mode 100644 examples/widgets/dialogs/sipdialog/main.cpp create mode 100644 examples/widgets/dialogs/sipdialog/sipdialog.desktop create mode 100644 examples/widgets/dialogs/sipdialog/sipdialog.pro create mode 100644 examples/widgets/dialogs/standarddialogs/dialog.cpp create mode 100644 examples/widgets/dialogs/standarddialogs/dialog.h create mode 100644 examples/widgets/dialogs/standarddialogs/main.cpp create mode 100644 examples/widgets/dialogs/standarddialogs/standarddialogs.desktop create mode 100644 examples/widgets/dialogs/standarddialogs/standarddialogs.pro create mode 100644 examples/widgets/dialogs/tabdialog/main.cpp create mode 100644 examples/widgets/dialogs/tabdialog/tabdialog.cpp create mode 100644 examples/widgets/dialogs/tabdialog/tabdialog.desktop create mode 100644 examples/widgets/dialogs/tabdialog/tabdialog.h create mode 100644 examples/widgets/dialogs/tabdialog/tabdialog.pro create mode 100644 examples/widgets/dialogs/trivialwizard/trivialwizard.cpp create mode 100644 examples/widgets/dialogs/trivialwizard/trivialwizard.desktop create mode 100644 examples/widgets/dialogs/trivialwizard/trivialwizard.pro delete mode 100644 examples/widgets/digitalclock/digitalclock.cpp delete mode 100644 examples/widgets/digitalclock/digitalclock.desktop delete mode 100644 examples/widgets/digitalclock/digitalclock.h delete mode 100644 examples/widgets/digitalclock/digitalclock.pro delete mode 100644 examples/widgets/digitalclock/main.cpp create mode 100644 examples/widgets/doc/addressbook.qdoc create mode 100644 examples/widgets/doc/affine.qdoc create mode 100644 examples/widgets/doc/analogclock.qdoc create mode 100644 examples/widgets/doc/animatedtiles.qdoc create mode 100644 examples/widgets/doc/appchooser.qdoc create mode 100644 examples/widgets/doc/application.qdoc create mode 100644 examples/widgets/doc/basicdrawing.qdoc create mode 100644 examples/widgets/doc/basicgraphicslayouts.qdoc create mode 100644 examples/widgets/doc/basiclayouts.qdoc create mode 100644 examples/widgets/doc/basicsortfiltermodel.qdoc create mode 100644 examples/widgets/doc/blurpicker.qdoc create mode 100644 examples/widgets/doc/borderlayout.qdoc create mode 100644 examples/widgets/doc/boxes.qdoc create mode 100644 examples/widgets/doc/calculator.qdoc create mode 100644 examples/widgets/doc/calendar.qdoc create mode 100644 examples/widgets/doc/calendarwidget.qdoc create mode 100644 examples/widgets/doc/charactermap.qdoc create mode 100644 examples/widgets/doc/chart.qdoc create mode 100644 examples/widgets/doc/chip.qdoc create mode 100644 examples/widgets/doc/classwizard.qdoc create mode 100644 examples/widgets/doc/codeeditor.qdoc create mode 100644 examples/widgets/doc/coloreditorfactory.qdoc create mode 100644 examples/widgets/doc/combowidgetmapper.qdoc create mode 100644 examples/widgets/doc/composition.qdoc create mode 100644 examples/widgets/doc/concentriccircles.qdoc create mode 100644 examples/widgets/doc/configdialog.qdoc create mode 100644 examples/widgets/doc/customsortfiltermodel.qdoc create mode 100644 examples/widgets/doc/deform.qdoc create mode 100644 examples/widgets/doc/diagramscene.qdoc create mode 100644 examples/widgets/doc/digitalclock.qdoc create mode 100644 examples/widgets/doc/dirview.qdoc create mode 100644 examples/widgets/doc/dockwidgets.qdoc create mode 100644 examples/widgets/doc/dragdroprobot.qdoc create mode 100644 examples/widgets/doc/dynamiclayouts.qdoc create mode 100644 examples/widgets/doc/easing.qdoc create mode 100644 examples/widgets/doc/editabletreemodel.qdoc create mode 100644 examples/widgets/doc/elasticnodes.qdoc create mode 100644 examples/widgets/doc/elidedlabel.qdoc create mode 100644 examples/widgets/doc/embeddeddialogs.qdoc create mode 100644 examples/widgets/doc/eventtransitions.qdoc create mode 100644 examples/widgets/doc/extension.qdoc create mode 100644 examples/widgets/doc/factorial.qdoc create mode 100644 examples/widgets/doc/fademessage.qdoc create mode 100644 examples/widgets/doc/fetchmore.qdoc create mode 100644 examples/widgets/doc/findfiles.qdoc create mode 100644 examples/widgets/doc/flowlayout.qdoc create mode 100644 examples/widgets/doc/fontsampler.qdoc create mode 100644 examples/widgets/doc/frozencolumn.qdoc create mode 100644 examples/widgets/doc/gradients.qdoc create mode 100644 examples/widgets/doc/groupbox.qdoc create mode 100644 examples/widgets/doc/icons.qdoc create mode 100644 examples/widgets/doc/imagecomposition.qdoc create mode 100644 examples/widgets/doc/imageviewer.qdoc create mode 100644 examples/widgets/doc/interview.qdoc create mode 100644 examples/widgets/doc/licensewizard.qdoc create mode 100644 examples/widgets/doc/lighting.qdoc create mode 100644 examples/widgets/doc/lineedits.qdoc create mode 100644 examples/widgets/doc/mainwindow.qdoc create mode 100644 examples/widgets/doc/mdi.qdoc create mode 100644 examples/widgets/doc/menus.qdoc create mode 100644 examples/widgets/doc/moveblocks.qdoc create mode 100644 examples/widgets/doc/movie.qdoc create mode 100644 examples/widgets/doc/orderform.qdoc create mode 100644 examples/widgets/doc/padnavigator.qdoc create mode 100644 examples/widgets/doc/painterpaths.qdoc create mode 100644 examples/widgets/doc/pathstroke.qdoc create mode 100644 examples/widgets/doc/pingpong.qdoc create mode 100644 examples/widgets/doc/pixelator.qdoc create mode 100644 examples/widgets/doc/recentfiles.qdoc create mode 100644 examples/widgets/doc/rogue.qdoc create mode 100644 examples/widgets/doc/screenshot.qdoc create mode 100644 examples/widgets/doc/scribble.qdoc create mode 100644 examples/widgets/doc/sdi.qdoc create mode 100644 examples/widgets/doc/shapedclock.qdoc create mode 100644 examples/widgets/doc/simpledommodel.qdoc create mode 100644 examples/widgets/doc/simpletreemodel.qdoc create mode 100644 examples/widgets/doc/simplewidgetmapper.qdoc create mode 100644 examples/widgets/doc/sipdialog.qdoc create mode 100644 examples/widgets/doc/sliders.qdoc create mode 100644 examples/widgets/doc/spinboxdelegate.qdoc create mode 100644 examples/widgets/doc/spinboxes.qdoc create mode 100644 examples/widgets/doc/spreadsheet.qdoc create mode 100644 examples/widgets/doc/standarddialogs.qdoc create mode 100644 examples/widgets/doc/stardelegate.qdoc create mode 100644 examples/widgets/doc/states.qdoc create mode 100644 examples/widgets/doc/stickman.qdoc create mode 100644 examples/widgets/doc/styles.qdoc create mode 100644 examples/widgets/doc/stylesheet.qdoc create mode 100644 examples/widgets/doc/sub-attaq.qdoc create mode 100644 examples/widgets/doc/syntaxhighlighter.qdoc create mode 100644 examples/widgets/doc/tabdialog.qdoc create mode 100644 examples/widgets/doc/tablet.qdoc create mode 100644 examples/widgets/doc/tetrix.qdoc create mode 100644 examples/widgets/doc/textedit.qdoc create mode 100644 examples/widgets/doc/tooltips.qdoc create mode 100644 examples/widgets/doc/trafficlight.qdoc create mode 100644 examples/widgets/doc/transformations.qdoc create mode 100644 examples/widgets/doc/trivialwizard.qdoc create mode 100644 examples/widgets/doc/twowaybutton.qdoc create mode 100644 examples/widgets/doc/wiggly.qdoc create mode 100644 examples/widgets/doc/windowflags.qdoc create mode 100644 examples/widgets/draganddrop/README create mode 100644 examples/widgets/draganddrop/delayedencoding/delayedencoding.desktop create mode 100644 examples/widgets/draganddrop/draganddrop.pro create mode 100644 examples/widgets/draganddrop/draggableicons/draggableicons.desktop create mode 100644 examples/widgets/draganddrop/draggableicons/draggableicons.pro create mode 100644 examples/widgets/draganddrop/draggableicons/draggableicons.qrc create mode 100644 examples/widgets/draganddrop/draggableicons/dragwidget.cpp create mode 100644 examples/widgets/draganddrop/draggableicons/dragwidget.h create mode 100644 examples/widgets/draganddrop/draggableicons/images/boat.png create mode 100644 examples/widgets/draganddrop/draggableicons/images/car.png create mode 100644 examples/widgets/draganddrop/draggableicons/images/house.png create mode 100644 examples/widgets/draganddrop/draggableicons/main.cpp create mode 100644 examples/widgets/draganddrop/draggabletext/draggabletext.desktop create mode 100644 examples/widgets/draganddrop/draggabletext/draggabletext.pro create mode 100644 examples/widgets/draganddrop/draggabletext/draggabletext.qrc create mode 100644 examples/widgets/draganddrop/draggabletext/draglabel.cpp create mode 100644 examples/widgets/draganddrop/draggabletext/draglabel.h create mode 100644 examples/widgets/draganddrop/draggabletext/dragwidget.cpp create mode 100644 examples/widgets/draganddrop/draggabletext/dragwidget.h create mode 100644 examples/widgets/draganddrop/draggabletext/main.cpp create mode 100644 examples/widgets/draganddrop/draggabletext/words.txt create mode 100644 examples/widgets/draganddrop/dropsite/droparea.cpp create mode 100644 examples/widgets/draganddrop/dropsite/droparea.h create mode 100644 examples/widgets/draganddrop/dropsite/dropsite.desktop create mode 100644 examples/widgets/draganddrop/dropsite/dropsite.pro create mode 100644 examples/widgets/draganddrop/dropsite/dropsitewindow.cpp create mode 100644 examples/widgets/draganddrop/dropsite/dropsitewindow.h create mode 100644 examples/widgets/draganddrop/dropsite/main.cpp create mode 100644 examples/widgets/draganddrop/fridgemagnets/draglabel.cpp create mode 100644 examples/widgets/draganddrop/fridgemagnets/draglabel.h create mode 100644 examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp create mode 100644 examples/widgets/draganddrop/fridgemagnets/dragwidget.h create mode 100644 examples/widgets/draganddrop/fridgemagnets/fridgemagnets.desktop create mode 100644 examples/widgets/draganddrop/fridgemagnets/fridgemagnets.pro create mode 100644 examples/widgets/draganddrop/fridgemagnets/fridgemagnets.qrc create mode 100644 examples/widgets/draganddrop/fridgemagnets/main.cpp create mode 100644 examples/widgets/draganddrop/fridgemagnets/words.txt create mode 100644 examples/widgets/draganddrop/puzzle/example.jpg create mode 100644 examples/widgets/draganddrop/puzzle/main.cpp create mode 100644 examples/widgets/draganddrop/puzzle/mainwindow.cpp create mode 100644 examples/widgets/draganddrop/puzzle/mainwindow.h create mode 100644 examples/widgets/draganddrop/puzzle/pieceslist.cpp create mode 100644 examples/widgets/draganddrop/puzzle/pieceslist.h create mode 100644 examples/widgets/draganddrop/puzzle/puzzle.desktop create mode 100644 examples/widgets/draganddrop/puzzle/puzzle.pro create mode 100644 examples/widgets/draganddrop/puzzle/puzzle.qrc create mode 100644 examples/widgets/draganddrop/puzzle/puzzlewidget.cpp create mode 100644 examples/widgets/draganddrop/puzzle/puzzlewidget.h create mode 100644 examples/widgets/effects/blurpicker/blureffect.cpp create mode 100644 examples/widgets/effects/blurpicker/blureffect.h create mode 100644 examples/widgets/effects/blurpicker/blurpicker.cpp create mode 100644 examples/widgets/effects/blurpicker/blurpicker.desktop create mode 100644 examples/widgets/effects/blurpicker/blurpicker.h create mode 100644 examples/widgets/effects/blurpicker/blurpicker.pro create mode 100644 examples/widgets/effects/blurpicker/blurpicker.qrc create mode 100644 examples/widgets/effects/blurpicker/images/README.txt create mode 100644 examples/widgets/effects/blurpicker/images/accessories-calculator.png create mode 100644 examples/widgets/effects/blurpicker/images/accessories-text-editor.png create mode 100644 examples/widgets/effects/blurpicker/images/background.jpg create mode 100644 examples/widgets/effects/blurpicker/images/help-browser.png create mode 100644 examples/widgets/effects/blurpicker/images/internet-group-chat.png create mode 100644 examples/widgets/effects/blurpicker/images/internet-mail.png create mode 100644 examples/widgets/effects/blurpicker/images/internet-web-browser.png create mode 100644 examples/widgets/effects/blurpicker/images/office-calendar.png create mode 100644 examples/widgets/effects/blurpicker/images/system-users.png create mode 100644 examples/widgets/effects/blurpicker/main.cpp create mode 100644 examples/widgets/effects/effects.pro create mode 100644 examples/widgets/effects/fademessage/README.txt create mode 100644 examples/widgets/effects/fademessage/background.jpg create mode 100644 examples/widgets/effects/fademessage/fademessage.cpp create mode 100644 examples/widgets/effects/fademessage/fademessage.desktop create mode 100644 examples/widgets/effects/fademessage/fademessage.h create mode 100644 examples/widgets/effects/fademessage/fademessage.pro create mode 100644 examples/widgets/effects/fademessage/fademessage.qrc create mode 100644 examples/widgets/effects/fademessage/main.cpp create mode 100644 examples/widgets/effects/lighting/lighting.cpp create mode 100644 examples/widgets/effects/lighting/lighting.desktop create mode 100644 examples/widgets/effects/lighting/lighting.h create mode 100644 examples/widgets/effects/lighting/lighting.pro create mode 100644 examples/widgets/effects/lighting/main.cpp delete mode 100644 examples/widgets/elidedlabel/elidedlabel.cpp delete mode 100644 examples/widgets/elidedlabel/elidedlabel.desktop delete mode 100644 examples/widgets/elidedlabel/elidedlabel.h delete mode 100644 examples/widgets/elidedlabel/elidedlabel.pro delete mode 100644 examples/widgets/elidedlabel/main.cpp delete mode 100644 examples/widgets/elidedlabel/testwidget.cpp delete mode 100644 examples/widgets/elidedlabel/testwidget.h create mode 100644 examples/widgets/graphicsview/README create mode 100644 examples/widgets/graphicsview/anchorlayout/anchorlayout.desktop create mode 100644 examples/widgets/graphicsview/anchorlayout/anchorlayout.pro create mode 100644 examples/widgets/graphicsview/anchorlayout/main.cpp create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/basicgraphicslayouts.desktop create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/basicgraphicslayouts.qrc create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/images/block.png create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.cpp create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.h create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/main.cpp create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/window.cpp create mode 100644 examples/widgets/graphicsview/basicgraphicslayouts/window.h create mode 100644 examples/widgets/graphicsview/boxes/3rdparty/fbm.c create mode 100644 examples/widgets/graphicsview/boxes/3rdparty/fbm.h create mode 100644 examples/widgets/graphicsview/boxes/basic.fsh create mode 100644 examples/widgets/graphicsview/boxes/basic.vsh create mode 100644 examples/widgets/graphicsview/boxes/boxes.pro create mode 100644 examples/widgets/graphicsview/boxes/boxes.qrc create mode 100644 examples/widgets/graphicsview/boxes/cubemap_negx.jpg create mode 100644 examples/widgets/graphicsview/boxes/cubemap_negy.jpg create mode 100644 examples/widgets/graphicsview/boxes/cubemap_negz.jpg create mode 100644 examples/widgets/graphicsview/boxes/cubemap_posx.jpg create mode 100644 examples/widgets/graphicsview/boxes/cubemap_posy.jpg create mode 100644 examples/widgets/graphicsview/boxes/cubemap_posz.jpg create mode 100644 examples/widgets/graphicsview/boxes/dotted.fsh create mode 100644 examples/widgets/graphicsview/boxes/fresnel.fsh create mode 100644 examples/widgets/graphicsview/boxes/glass.fsh create mode 100644 examples/widgets/graphicsview/boxes/glbuffers.cpp create mode 100644 examples/widgets/graphicsview/boxes/glbuffers.h create mode 100644 examples/widgets/graphicsview/boxes/glextensions.cpp create mode 100644 examples/widgets/graphicsview/boxes/glextensions.h create mode 100644 examples/widgets/graphicsview/boxes/gltrianglemesh.h create mode 100644 examples/widgets/graphicsview/boxes/granite.fsh create mode 100644 examples/widgets/graphicsview/boxes/main.cpp create mode 100644 examples/widgets/graphicsview/boxes/marble.fsh create mode 100644 examples/widgets/graphicsview/boxes/parameters.par create mode 100644 examples/widgets/graphicsview/boxes/qt-logo.jpg create mode 100644 examples/widgets/graphicsview/boxes/qt-logo.png create mode 100644 examples/widgets/graphicsview/boxes/qtbox.cpp create mode 100644 examples/widgets/graphicsview/boxes/qtbox.h create mode 100644 examples/widgets/graphicsview/boxes/reflection.fsh create mode 100644 examples/widgets/graphicsview/boxes/refraction.fsh create mode 100644 examples/widgets/graphicsview/boxes/roundedbox.cpp create mode 100644 examples/widgets/graphicsview/boxes/roundedbox.h create mode 100644 examples/widgets/graphicsview/boxes/scene.cpp create mode 100644 examples/widgets/graphicsview/boxes/scene.h create mode 100644 examples/widgets/graphicsview/boxes/smiley.png create mode 100644 examples/widgets/graphicsview/boxes/square.jpg create mode 100644 examples/widgets/graphicsview/boxes/trackball.cpp create mode 100644 examples/widgets/graphicsview/boxes/trackball.h create mode 100644 examples/widgets/graphicsview/boxes/wood.fsh create mode 100644 examples/widgets/graphicsview/chip/chip.cpp create mode 100644 examples/widgets/graphicsview/chip/chip.h create mode 100644 examples/widgets/graphicsview/chip/chip.pro create mode 100644 examples/widgets/graphicsview/chip/fileprint.png create mode 100644 examples/widgets/graphicsview/chip/images.qrc create mode 100644 examples/widgets/graphicsview/chip/main.cpp create mode 100644 examples/widgets/graphicsview/chip/mainwindow.cpp create mode 100644 examples/widgets/graphicsview/chip/mainwindow.h create mode 100644 examples/widgets/graphicsview/chip/qt4logo.png create mode 100644 examples/widgets/graphicsview/chip/rotateleft.png create mode 100644 examples/widgets/graphicsview/chip/rotateright.png create mode 100644 examples/widgets/graphicsview/chip/view.cpp create mode 100644 examples/widgets/graphicsview/chip/view.h create mode 100644 examples/widgets/graphicsview/chip/zoomin.png create mode 100644 examples/widgets/graphicsview/chip/zoomout.png create mode 100644 examples/widgets/graphicsview/collidingmice/collidingmice.desktop create mode 100644 examples/widgets/graphicsview/collidingmice/collidingmice.pro create mode 100644 examples/widgets/graphicsview/collidingmice/images/cheese.jpg create mode 100644 examples/widgets/graphicsview/collidingmice/main.cpp create mode 100644 examples/widgets/graphicsview/collidingmice/mice.qrc create mode 100644 examples/widgets/graphicsview/collidingmice/mouse.cpp create mode 100644 examples/widgets/graphicsview/collidingmice/mouse.h create mode 100644 examples/widgets/graphicsview/diagramscene/arrow.cpp create mode 100644 examples/widgets/graphicsview/diagramscene/arrow.h create mode 100644 examples/widgets/graphicsview/diagramscene/diagramitem.cpp create mode 100644 examples/widgets/graphicsview/diagramscene/diagramitem.h create mode 100644 examples/widgets/graphicsview/diagramscene/diagramscene.cpp create mode 100644 examples/widgets/graphicsview/diagramscene/diagramscene.desktop create mode 100644 examples/widgets/graphicsview/diagramscene/diagramscene.h create mode 100644 examples/widgets/graphicsview/diagramscene/diagramscene.pro create mode 100644 examples/widgets/graphicsview/diagramscene/diagramscene.qrc create mode 100644 examples/widgets/graphicsview/diagramscene/diagramtextitem.cpp create mode 100644 examples/widgets/graphicsview/diagramscene/diagramtextitem.h create mode 100644 examples/widgets/graphicsview/diagramscene/images/background1.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/background2.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/background3.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/background4.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/bold.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/bringtofront.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/delete.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/floodfill.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/italic.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/linecolor.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/linepointer.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/pointer.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/sendtoback.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/textpointer.png create mode 100644 examples/widgets/graphicsview/diagramscene/images/underline.png create mode 100644 examples/widgets/graphicsview/diagramscene/main.cpp create mode 100644 examples/widgets/graphicsview/diagramscene/mainwindow.cpp create mode 100644 examples/widgets/graphicsview/diagramscene/mainwindow.h create mode 100644 examples/widgets/graphicsview/dragdroprobot/coloritem.cpp create mode 100644 examples/widgets/graphicsview/dragdroprobot/coloritem.h create mode 100644 examples/widgets/graphicsview/dragdroprobot/dragdroprobot.desktop create mode 100644 examples/widgets/graphicsview/dragdroprobot/dragdroprobot.pro create mode 100644 examples/widgets/graphicsview/dragdroprobot/images/head.png create mode 100644 examples/widgets/graphicsview/dragdroprobot/main.cpp create mode 100644 examples/widgets/graphicsview/dragdroprobot/robot.cpp create mode 100644 examples/widgets/graphicsview/dragdroprobot/robot.h create mode 100644 examples/widgets/graphicsview/dragdroprobot/robot.qrc create mode 100644 examples/widgets/graphicsview/elasticnodes/edge.cpp create mode 100644 examples/widgets/graphicsview/elasticnodes/edge.h create mode 100644 examples/widgets/graphicsview/elasticnodes/elasticnodes.desktop create mode 100644 examples/widgets/graphicsview/elasticnodes/elasticnodes.pro create mode 100644 examples/widgets/graphicsview/elasticnodes/graphwidget.cpp create mode 100644 examples/widgets/graphicsview/elasticnodes/graphwidget.h create mode 100644 examples/widgets/graphicsview/elasticnodes/main.cpp create mode 100644 examples/widgets/graphicsview/elasticnodes/node.cpp create mode 100644 examples/widgets/graphicsview/elasticnodes/node.h create mode 100644 examples/widgets/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg create mode 100644 examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp create mode 100644 examples/widgets/graphicsview/embeddeddialogs/customproxy.h create mode 100644 examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp create mode 100644 examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h create mode 100644 examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.ui create mode 100644 examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.pro create mode 100644 examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.qrc create mode 100644 examples/widgets/graphicsview/embeddeddialogs/main.cpp create mode 100644 examples/widgets/graphicsview/flowlayout/flowlayout.cpp create mode 100644 examples/widgets/graphicsview/flowlayout/flowlayout.desktop create mode 100644 examples/widgets/graphicsview/flowlayout/flowlayout.h create mode 100644 examples/widgets/graphicsview/flowlayout/flowlayout.pro create mode 100644 examples/widgets/graphicsview/flowlayout/main.cpp create mode 100644 examples/widgets/graphicsview/flowlayout/window.cpp create mode 100644 examples/widgets/graphicsview/flowlayout/window.h create mode 100644 examples/widgets/graphicsview/graphicsview.pro create mode 100644 examples/widgets/graphicsview/padnavigator/flippablepad.cpp create mode 100644 examples/widgets/graphicsview/padnavigator/flippablepad.h create mode 100644 examples/widgets/graphicsview/padnavigator/form.ui create mode 100644 examples/widgets/graphicsview/padnavigator/images/artsfftscope.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/blue_angle_swirl.jpg create mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_contacts.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_journal.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_mail.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_notes.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/kopeteavailable.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/metacontact_online.png create mode 100644 examples/widgets/graphicsview/padnavigator/images/minitools.png create mode 100644 examples/widgets/graphicsview/padnavigator/main.cpp create mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.cpp create mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.desktop create mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.h create mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.pro create mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.qrc create mode 100644 examples/widgets/graphicsview/padnavigator/roundrectitem.cpp create mode 100644 examples/widgets/graphicsview/padnavigator/roundrectitem.h create mode 100644 examples/widgets/graphicsview/padnavigator/splashitem.cpp create mode 100644 examples/widgets/graphicsview/padnavigator/splashitem.h create mode 100644 examples/widgets/graphicsview/portedasteroids/portedasteroids.desktop create mode 100644 examples/widgets/graphicsview/portedcanvas/portedcanvas.desktop create mode 100644 examples/widgets/graphicsview/simpleanchorlayout/main.cpp create mode 100644 examples/widgets/graphicsview/simpleanchorlayout/simpleanchorlayout.desktop create mode 100644 examples/widgets/graphicsview/simpleanchorlayout/simpleanchorlayout.pro create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/images/5days.jpg create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/images/details.jpg create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/images/place.jpg create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/images/tabbar.jpg create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/images/title.jpg create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/images/weather-few-clouds.png create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/main.cpp create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.desktop create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.pro create mode 100644 examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc delete mode 100644 examples/widgets/groupbox/groupbox.desktop delete mode 100644 examples/widgets/groupbox/groupbox.pro delete mode 100644 examples/widgets/groupbox/main.cpp delete mode 100644 examples/widgets/groupbox/window.cpp delete mode 100644 examples/widgets/groupbox/window.h delete mode 100644 examples/widgets/icons/iconpreviewarea.cpp delete mode 100644 examples/widgets/icons/iconpreviewarea.h delete mode 100644 examples/widgets/icons/icons.desktop delete mode 100644 examples/widgets/icons/icons.pro delete mode 100644 examples/widgets/icons/iconsizespinbox.cpp delete mode 100644 examples/widgets/icons/iconsizespinbox.h delete mode 100644 examples/widgets/icons/imagedelegate.cpp delete mode 100644 examples/widgets/icons/imagedelegate.h delete mode 100644 examples/widgets/icons/images/designer.png delete mode 100644 examples/widgets/icons/images/find_disabled.png delete mode 100644 examples/widgets/icons/images/find_normal.png delete mode 100644 examples/widgets/icons/images/monkey_off_128x128.png delete mode 100644 examples/widgets/icons/images/monkey_off_16x16.png delete mode 100644 examples/widgets/icons/images/monkey_off_32x32.png delete mode 100644 examples/widgets/icons/images/monkey_off_64x64.png delete mode 100644 examples/widgets/icons/images/monkey_on_128x128.png delete mode 100644 examples/widgets/icons/images/monkey_on_16x16.png delete mode 100644 examples/widgets/icons/images/monkey_on_32x32.png delete mode 100644 examples/widgets/icons/images/monkey_on_64x64.png delete mode 100644 examples/widgets/icons/images/qt_extended_16x16.png delete mode 100644 examples/widgets/icons/images/qt_extended_32x32.png delete mode 100644 examples/widgets/icons/images/qt_extended_48x48.png delete mode 100644 examples/widgets/icons/main.cpp delete mode 100644 examples/widgets/icons/mainwindow.cpp delete mode 100644 examples/widgets/icons/mainwindow.h delete mode 100644 examples/widgets/imageviewer/imageviewer.cpp delete mode 100644 examples/widgets/imageviewer/imageviewer.desktop delete mode 100644 examples/widgets/imageviewer/imageviewer.h delete mode 100644 examples/widgets/imageviewer/imageviewer.pro delete mode 100644 examples/widgets/imageviewer/main.cpp create mode 100644 examples/widgets/itemviews/README create mode 100644 examples/widgets/itemviews/addressbook/adddialog.cpp create mode 100644 examples/widgets/itemviews/addressbook/adddialog.h create mode 100644 examples/widgets/itemviews/addressbook/addressbook.desktop create mode 100644 examples/widgets/itemviews/addressbook/addressbook.pro create mode 100644 examples/widgets/itemviews/addressbook/addresswidget.cpp create mode 100644 examples/widgets/itemviews/addressbook/addresswidget.h create mode 100644 examples/widgets/itemviews/addressbook/main.cpp create mode 100644 examples/widgets/itemviews/addressbook/mainwindow.cpp create mode 100644 examples/widgets/itemviews/addressbook/mainwindow.h create mode 100644 examples/widgets/itemviews/addressbook/newaddresstab.cpp create mode 100644 examples/widgets/itemviews/addressbook/newaddresstab.h create mode 100644 examples/widgets/itemviews/addressbook/tablemodel.cpp create mode 100644 examples/widgets/itemviews/addressbook/tablemodel.h create mode 100644 examples/widgets/itemviews/basicsortfiltermodel/basicsortfiltermodel.desktop create mode 100644 examples/widgets/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro create mode 100644 examples/widgets/itemviews/basicsortfiltermodel/main.cpp create mode 100644 examples/widgets/itemviews/basicsortfiltermodel/window.cpp create mode 100644 examples/widgets/itemviews/basicsortfiltermodel/window.h create mode 100644 examples/widgets/itemviews/chart/chart.desktop create mode 100644 examples/widgets/itemviews/chart/chart.pro create mode 100644 examples/widgets/itemviews/chart/chart.qrc create mode 100644 examples/widgets/itemviews/chart/main.cpp create mode 100644 examples/widgets/itemviews/chart/mainwindow.cpp create mode 100644 examples/widgets/itemviews/chart/mainwindow.h create mode 100644 examples/widgets/itemviews/chart/mydata.cht create mode 100644 examples/widgets/itemviews/chart/pieview.cpp create mode 100644 examples/widgets/itemviews/chart/pieview.h create mode 100644 examples/widgets/itemviews/chart/qtdata.cht create mode 100644 examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.desktop create mode 100644 examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro create mode 100644 examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp create mode 100644 examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h create mode 100644 examples/widgets/itemviews/coloreditorfactory/main.cpp create mode 100644 examples/widgets/itemviews/coloreditorfactory/window.cpp create mode 100644 examples/widgets/itemviews/coloreditorfactory/window.h create mode 100644 examples/widgets/itemviews/combowidgetmapper/combowidgetmapper.desktop create mode 100644 examples/widgets/itemviews/combowidgetmapper/combowidgetmapper.pro create mode 100644 examples/widgets/itemviews/combowidgetmapper/main.cpp create mode 100644 examples/widgets/itemviews/combowidgetmapper/window.cpp create mode 100644 examples/widgets/itemviews/combowidgetmapper/window.h create mode 100644 examples/widgets/itemviews/customsortfiltermodel/customsortfiltermodel.desktop create mode 100644 examples/widgets/itemviews/customsortfiltermodel/customsortfiltermodel.pro create mode 100644 examples/widgets/itemviews/customsortfiltermodel/main.cpp create mode 100644 examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp create mode 100644 examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h create mode 100644 examples/widgets/itemviews/customsortfiltermodel/window.cpp create mode 100644 examples/widgets/itemviews/customsortfiltermodel/window.h create mode 100644 examples/widgets/itemviews/dirview/dirview.desktop create mode 100644 examples/widgets/itemviews/dirview/dirview.pro create mode 100644 examples/widgets/itemviews/dirview/main.cpp create mode 100644 examples/widgets/itemviews/editabletreemodel/default.txt create mode 100644 examples/widgets/itemviews/editabletreemodel/editabletreemodel.desktop create mode 100644 examples/widgets/itemviews/editabletreemodel/editabletreemodel.pro create mode 100644 examples/widgets/itemviews/editabletreemodel/editabletreemodel.qrc create mode 100644 examples/widgets/itemviews/editabletreemodel/main.cpp create mode 100644 examples/widgets/itemviews/editabletreemodel/mainwindow.cpp create mode 100644 examples/widgets/itemviews/editabletreemodel/mainwindow.h create mode 100644 examples/widgets/itemviews/editabletreemodel/mainwindow.ui create mode 100644 examples/widgets/itemviews/editabletreemodel/treeitem.cpp create mode 100644 examples/widgets/itemviews/editabletreemodel/treeitem.h create mode 100644 examples/widgets/itemviews/editabletreemodel/treemodel.cpp create mode 100644 examples/widgets/itemviews/editabletreemodel/treemodel.h create mode 100644 examples/widgets/itemviews/fetchmore/fetchmore.desktop create mode 100644 examples/widgets/itemviews/fetchmore/fetchmore.pro create mode 100644 examples/widgets/itemviews/fetchmore/filelistmodel.cpp create mode 100644 examples/widgets/itemviews/fetchmore/filelistmodel.h create mode 100644 examples/widgets/itemviews/fetchmore/main.cpp create mode 100644 examples/widgets/itemviews/fetchmore/window.cpp create mode 100644 examples/widgets/itemviews/fetchmore/window.h create mode 100644 examples/widgets/itemviews/frozencolumn/freezetablewidget.cpp create mode 100644 examples/widgets/itemviews/frozencolumn/freezetablewidget.h create mode 100644 examples/widgets/itemviews/frozencolumn/frozencolumn.desktop create mode 100644 examples/widgets/itemviews/frozencolumn/frozencolumn.pro create mode 100644 examples/widgets/itemviews/frozencolumn/grades.qrc create mode 100644 examples/widgets/itemviews/frozencolumn/grades.txt create mode 100644 examples/widgets/itemviews/frozencolumn/main.cpp create mode 100644 examples/widgets/itemviews/interview/README create mode 100644 examples/widgets/itemviews/interview/images/folder.png create mode 100644 examples/widgets/itemviews/interview/images/interview.png create mode 100644 examples/widgets/itemviews/interview/images/services.png create mode 100644 examples/widgets/itemviews/interview/interview.pro create mode 100644 examples/widgets/itemviews/interview/interview.qrc create mode 100644 examples/widgets/itemviews/interview/main.cpp create mode 100644 examples/widgets/itemviews/interview/model.cpp create mode 100644 examples/widgets/itemviews/interview/model.h create mode 100644 examples/widgets/itemviews/itemviews.pro create mode 100644 examples/widgets/itemviews/pixelator/imagemodel.cpp create mode 100644 examples/widgets/itemviews/pixelator/imagemodel.h create mode 100644 examples/widgets/itemviews/pixelator/images.qrc create mode 100644 examples/widgets/itemviews/pixelator/images/qt.png create mode 100644 examples/widgets/itemviews/pixelator/main.cpp create mode 100644 examples/widgets/itemviews/pixelator/mainwindow.cpp create mode 100644 examples/widgets/itemviews/pixelator/mainwindow.h create mode 100644 examples/widgets/itemviews/pixelator/pixelator.desktop create mode 100644 examples/widgets/itemviews/pixelator/pixelator.pro create mode 100644 examples/widgets/itemviews/pixelator/pixeldelegate.cpp create mode 100644 examples/widgets/itemviews/pixelator/pixeldelegate.h create mode 100644 examples/widgets/itemviews/puzzle/example.jpg create mode 100644 examples/widgets/itemviews/puzzle/main.cpp create mode 100644 examples/widgets/itemviews/puzzle/mainwindow.cpp create mode 100644 examples/widgets/itemviews/puzzle/mainwindow.h create mode 100644 examples/widgets/itemviews/puzzle/piecesmodel.cpp create mode 100644 examples/widgets/itemviews/puzzle/piecesmodel.h create mode 100644 examples/widgets/itemviews/puzzle/puzzle.desktop create mode 100644 examples/widgets/itemviews/puzzle/puzzle.pro create mode 100644 examples/widgets/itemviews/puzzle/puzzle.qrc create mode 100644 examples/widgets/itemviews/puzzle/puzzlewidget.cpp create mode 100644 examples/widgets/itemviews/puzzle/puzzlewidget.h create mode 100644 examples/widgets/itemviews/simpledommodel/domitem.cpp create mode 100644 examples/widgets/itemviews/simpledommodel/domitem.h create mode 100644 examples/widgets/itemviews/simpledommodel/dommodel.cpp create mode 100644 examples/widgets/itemviews/simpledommodel/dommodel.h create mode 100644 examples/widgets/itemviews/simpledommodel/main.cpp create mode 100644 examples/widgets/itemviews/simpledommodel/mainwindow.cpp create mode 100644 examples/widgets/itemviews/simpledommodel/mainwindow.h create mode 100644 examples/widgets/itemviews/simpledommodel/simpledommodel.desktop create mode 100644 examples/widgets/itemviews/simpledommodel/simpledommodel.pro create mode 100644 examples/widgets/itemviews/simpletreemodel/default.txt create mode 100644 examples/widgets/itemviews/simpletreemodel/main.cpp create mode 100644 examples/widgets/itemviews/simpletreemodel/simpletreemodel.desktop create mode 100644 examples/widgets/itemviews/simpletreemodel/simpletreemodel.pro create mode 100644 examples/widgets/itemviews/simpletreemodel/simpletreemodel.qrc create mode 100644 examples/widgets/itemviews/simpletreemodel/treeitem.cpp create mode 100644 examples/widgets/itemviews/simpletreemodel/treeitem.h create mode 100644 examples/widgets/itemviews/simpletreemodel/treemodel.cpp create mode 100644 examples/widgets/itemviews/simpletreemodel/treemodel.h create mode 100644 examples/widgets/itemviews/simplewidgetmapper/main.cpp create mode 100644 examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.desktop create mode 100644 examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.pro create mode 100644 examples/widgets/itemviews/simplewidgetmapper/window.cpp create mode 100644 examples/widgets/itemviews/simplewidgetmapper/window.h create mode 100644 examples/widgets/itemviews/spinboxdelegate/delegate.cpp create mode 100644 examples/widgets/itemviews/spinboxdelegate/delegate.h create mode 100644 examples/widgets/itemviews/spinboxdelegate/main.cpp create mode 100644 examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.desktop create mode 100644 examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pro create mode 100644 examples/widgets/itemviews/spreadsheet/images/interview.png create mode 100644 examples/widgets/itemviews/spreadsheet/main.cpp create mode 100644 examples/widgets/itemviews/spreadsheet/printview.cpp create mode 100644 examples/widgets/itemviews/spreadsheet/printview.h create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheet.cpp create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheet.h create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheet.pro create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheet.qrc create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheetitem.cpp create mode 100644 examples/widgets/itemviews/spreadsheet/spreadsheetitem.h create mode 100644 examples/widgets/itemviews/stardelegate/main.cpp create mode 100644 examples/widgets/itemviews/stardelegate/stardelegate.cpp create mode 100644 examples/widgets/itemviews/stardelegate/stardelegate.desktop create mode 100644 examples/widgets/itemviews/stardelegate/stardelegate.h create mode 100644 examples/widgets/itemviews/stardelegate/stardelegate.pro create mode 100644 examples/widgets/itemviews/stardelegate/stareditor.cpp create mode 100644 examples/widgets/itemviews/stardelegate/stareditor.h create mode 100644 examples/widgets/itemviews/stardelegate/starrating.cpp create mode 100644 examples/widgets/itemviews/stardelegate/starrating.h create mode 100644 examples/widgets/layouts/README create mode 100644 examples/widgets/layouts/basiclayouts/basiclayouts.desktop create mode 100644 examples/widgets/layouts/basiclayouts/basiclayouts.pro create mode 100644 examples/widgets/layouts/basiclayouts/dialog.cpp create mode 100644 examples/widgets/layouts/basiclayouts/dialog.h create mode 100644 examples/widgets/layouts/basiclayouts/main.cpp create mode 100644 examples/widgets/layouts/borderlayout/borderlayout.cpp create mode 100644 examples/widgets/layouts/borderlayout/borderlayout.desktop create mode 100644 examples/widgets/layouts/borderlayout/borderlayout.h create mode 100644 examples/widgets/layouts/borderlayout/borderlayout.pro create mode 100644 examples/widgets/layouts/borderlayout/main.cpp create mode 100644 examples/widgets/layouts/borderlayout/window.cpp create mode 100644 examples/widgets/layouts/borderlayout/window.h create mode 100644 examples/widgets/layouts/dynamiclayouts/dialog.cpp create mode 100644 examples/widgets/layouts/dynamiclayouts/dialog.h create mode 100644 examples/widgets/layouts/dynamiclayouts/dynamiclayouts.desktop create mode 100644 examples/widgets/layouts/dynamiclayouts/dynamiclayouts.pro create mode 100644 examples/widgets/layouts/dynamiclayouts/main.cpp create mode 100644 examples/widgets/layouts/flowlayout/flowlayout.cpp create mode 100644 examples/widgets/layouts/flowlayout/flowlayout.desktop create mode 100644 examples/widgets/layouts/flowlayout/flowlayout.h create mode 100644 examples/widgets/layouts/flowlayout/flowlayout.pro create mode 100644 examples/widgets/layouts/flowlayout/main.cpp create mode 100644 examples/widgets/layouts/flowlayout/window.cpp create mode 100644 examples/widgets/layouts/flowlayout/window.h create mode 100644 examples/widgets/layouts/layouts.pro delete mode 100644 examples/widgets/lineedits/lineedits.desktop delete mode 100644 examples/widgets/lineedits/lineedits.pro delete mode 100644 examples/widgets/lineedits/main.cpp delete mode 100644 examples/widgets/lineedits/window.cpp delete mode 100644 examples/widgets/lineedits/window.h create mode 100644 examples/widgets/mainwindows/README create mode 100644 examples/widgets/mainwindows/application/application.desktop create mode 100644 examples/widgets/mainwindows/application/application.pro create mode 100644 examples/widgets/mainwindows/application/application.qrc create mode 100644 examples/widgets/mainwindows/application/images/copy.png create mode 100644 examples/widgets/mainwindows/application/images/cut.png create mode 100644 examples/widgets/mainwindows/application/images/new.png create mode 100644 examples/widgets/mainwindows/application/images/open.png create mode 100644 examples/widgets/mainwindows/application/images/paste.png create mode 100644 examples/widgets/mainwindows/application/images/save.png create mode 100644 examples/widgets/mainwindows/application/main.cpp create mode 100644 examples/widgets/mainwindows/application/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/application/mainwindow.h create mode 100644 examples/widgets/mainwindows/dockwidgets/dockwidgets.desktop create mode 100644 examples/widgets/mainwindows/dockwidgets/dockwidgets.pro create mode 100644 examples/widgets/mainwindows/dockwidgets/dockwidgets.qrc create mode 100644 examples/widgets/mainwindows/dockwidgets/images/new.png create mode 100644 examples/widgets/mainwindows/dockwidgets/images/print.png create mode 100644 examples/widgets/mainwindows/dockwidgets/images/save.png create mode 100644 examples/widgets/mainwindows/dockwidgets/images/undo.png create mode 100644 examples/widgets/mainwindows/dockwidgets/main.cpp create mode 100644 examples/widgets/mainwindows/dockwidgets/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/dockwidgets/mainwindow.h create mode 100644 examples/widgets/mainwindows/mainwindow/colorswatch.cpp create mode 100644 examples/widgets/mainwindows/mainwindow/colorswatch.h create mode 100644 examples/widgets/mainwindows/mainwindow/main.cpp create mode 100644 examples/widgets/mainwindows/mainwindow/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/mainwindow/mainwindow.h create mode 100644 examples/widgets/mainwindows/mainwindow/mainwindow.pro create mode 100644 examples/widgets/mainwindows/mainwindow/mainwindow.qrc create mode 100644 examples/widgets/mainwindows/mainwindow/qt.png create mode 100644 examples/widgets/mainwindows/mainwindow/titlebarCenter.png create mode 100644 examples/widgets/mainwindows/mainwindow/titlebarLeft.png create mode 100644 examples/widgets/mainwindows/mainwindow/titlebarRight.png create mode 100644 examples/widgets/mainwindows/mainwindow/toolbar.cpp create mode 100644 examples/widgets/mainwindows/mainwindow/toolbar.h create mode 100644 examples/widgets/mainwindows/mainwindows.pro create mode 100644 examples/widgets/mainwindows/mdi/images/copy.png create mode 100644 examples/widgets/mainwindows/mdi/images/cut.png create mode 100644 examples/widgets/mainwindows/mdi/images/new.png create mode 100644 examples/widgets/mainwindows/mdi/images/open.png create mode 100644 examples/widgets/mainwindows/mdi/images/paste.png create mode 100644 examples/widgets/mainwindows/mdi/images/save.png create mode 100644 examples/widgets/mainwindows/mdi/main.cpp create mode 100644 examples/widgets/mainwindows/mdi/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/mdi/mainwindow.h create mode 100644 examples/widgets/mainwindows/mdi/mdi.desktop create mode 100644 examples/widgets/mainwindows/mdi/mdi.pro create mode 100644 examples/widgets/mainwindows/mdi/mdi.qrc create mode 100644 examples/widgets/mainwindows/mdi/mdichild.cpp create mode 100644 examples/widgets/mainwindows/mdi/mdichild.h create mode 100644 examples/widgets/mainwindows/menus/main.cpp create mode 100644 examples/widgets/mainwindows/menus/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/menus/mainwindow.h create mode 100644 examples/widgets/mainwindows/menus/menus.desktop create mode 100644 examples/widgets/mainwindows/menus/menus.pro create mode 100644 examples/widgets/mainwindows/recentfiles/main.cpp create mode 100644 examples/widgets/mainwindows/recentfiles/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/recentfiles/mainwindow.h create mode 100644 examples/widgets/mainwindows/recentfiles/recentfiles.desktop create mode 100644 examples/widgets/mainwindows/recentfiles/recentfiles.pro create mode 100644 examples/widgets/mainwindows/sdi/images/copy.png create mode 100644 examples/widgets/mainwindows/sdi/images/cut.png create mode 100644 examples/widgets/mainwindows/sdi/images/new.png create mode 100644 examples/widgets/mainwindows/sdi/images/open.png create mode 100644 examples/widgets/mainwindows/sdi/images/paste.png create mode 100644 examples/widgets/mainwindows/sdi/images/save.png create mode 100644 examples/widgets/mainwindows/sdi/main.cpp create mode 100644 examples/widgets/mainwindows/sdi/mainwindow.cpp create mode 100644 examples/widgets/mainwindows/sdi/mainwindow.h create mode 100644 examples/widgets/mainwindows/sdi/sdi.desktop create mode 100644 examples/widgets/mainwindows/sdi/sdi.pro create mode 100644 examples/widgets/mainwindows/sdi/sdi.qrc delete mode 100644 examples/widgets/mousebuttons/buttontester.cpp delete mode 100644 examples/widgets/mousebuttons/buttontester.h delete mode 100644 examples/widgets/mousebuttons/main.cpp delete mode 100644 examples/widgets/mousebuttons/mousebuttons.pro delete mode 100644 examples/widgets/movie/animation.gif delete mode 100644 examples/widgets/movie/main.cpp delete mode 100644 examples/widgets/movie/movie.desktop delete mode 100644 examples/widgets/movie/movie.pro delete mode 100644 examples/widgets/movie/movieplayer.cpp delete mode 100644 examples/widgets/movie/movieplayer.h delete mode 100644 examples/widgets/orientation/image_a.png delete mode 100644 examples/widgets/orientation/image_b.png delete mode 100644 examples/widgets/orientation/image_c.png delete mode 100644 examples/widgets/orientation/images.qrc delete mode 100644 examples/widgets/orientation/landscape.ui delete mode 100644 examples/widgets/orientation/main.cpp delete mode 100644 examples/widgets/orientation/mainwindow.cpp delete mode 100644 examples/widgets/orientation/mainwindow.h delete mode 100644 examples/widgets/orientation/orientation.desktop delete mode 100644 examples/widgets/orientation/orientation.pro delete mode 100644 examples/widgets/orientation/portrait.ui create mode 100644 examples/widgets/painting/README create mode 100644 examples/widgets/painting/affine/affine.pro create mode 100644 examples/widgets/painting/affine/affine.qrc create mode 100644 examples/widgets/painting/affine/bg1.jpg create mode 100644 examples/widgets/painting/affine/main.cpp create mode 100644 examples/widgets/painting/affine/xform.cpp create mode 100644 examples/widgets/painting/affine/xform.h create mode 100644 examples/widgets/painting/affine/xform.html create mode 100644 examples/widgets/painting/basicdrawing/basicdrawing.desktop create mode 100644 examples/widgets/painting/basicdrawing/basicdrawing.pro create mode 100644 examples/widgets/painting/basicdrawing/basicdrawing.qrc create mode 100644 examples/widgets/painting/basicdrawing/images/brick.png create mode 100644 examples/widgets/painting/basicdrawing/images/qt-logo.png create mode 100644 examples/widgets/painting/basicdrawing/main.cpp create mode 100644 examples/widgets/painting/basicdrawing/renderarea.cpp create mode 100644 examples/widgets/painting/basicdrawing/renderarea.h create mode 100644 examples/widgets/painting/basicdrawing/window.cpp create mode 100644 examples/widgets/painting/basicdrawing/window.h create mode 100644 examples/widgets/painting/composition/composition.cpp create mode 100644 examples/widgets/painting/composition/composition.h create mode 100644 examples/widgets/painting/composition/composition.html create mode 100644 examples/widgets/painting/composition/composition.pro create mode 100644 examples/widgets/painting/composition/composition.qrc create mode 100644 examples/widgets/painting/composition/flower.jpg create mode 100644 examples/widgets/painting/composition/flower_alpha.jpg create mode 100644 examples/widgets/painting/composition/main.cpp create mode 100644 examples/widgets/painting/concentriccircles/circlewidget.cpp create mode 100644 examples/widgets/painting/concentriccircles/circlewidget.h create mode 100644 examples/widgets/painting/concentriccircles/concentriccircles.desktop create mode 100644 examples/widgets/painting/concentriccircles/concentriccircles.pro create mode 100644 examples/widgets/painting/concentriccircles/main.cpp create mode 100644 examples/widgets/painting/concentriccircles/window.cpp create mode 100644 examples/widgets/painting/concentriccircles/window.h create mode 100644 examples/widgets/painting/deform/deform.pro create mode 100644 examples/widgets/painting/deform/deform.qrc create mode 100644 examples/widgets/painting/deform/main.cpp create mode 100644 examples/widgets/painting/deform/pathdeform.cpp create mode 100644 examples/widgets/painting/deform/pathdeform.h create mode 100644 examples/widgets/painting/deform/pathdeform.html create mode 100644 examples/widgets/painting/fontsampler/fontsampler.desktop create mode 100644 examples/widgets/painting/fontsampler/fontsampler.pro create mode 100644 examples/widgets/painting/fontsampler/main.cpp create mode 100644 examples/widgets/painting/fontsampler/mainwindow.cpp create mode 100644 examples/widgets/painting/fontsampler/mainwindow.h create mode 100644 examples/widgets/painting/fontsampler/mainwindowbase.ui create mode 100644 examples/widgets/painting/gradients/gradients.cpp create mode 100644 examples/widgets/painting/gradients/gradients.h create mode 100644 examples/widgets/painting/gradients/gradients.html create mode 100644 examples/widgets/painting/gradients/gradients.pro create mode 100644 examples/widgets/painting/gradients/gradients.qrc create mode 100644 examples/widgets/painting/gradients/main.cpp create mode 100644 examples/widgets/painting/imagecomposition/imagecomposer.cpp create mode 100644 examples/widgets/painting/imagecomposition/imagecomposer.h create mode 100644 examples/widgets/painting/imagecomposition/imagecomposition.desktop create mode 100644 examples/widgets/painting/imagecomposition/imagecomposition.pro create mode 100644 examples/widgets/painting/imagecomposition/imagecomposition.qrc create mode 100644 examples/widgets/painting/imagecomposition/images/background.png create mode 100644 examples/widgets/painting/imagecomposition/images/blackrectangle.png create mode 100644 examples/widgets/painting/imagecomposition/images/butterfly.png create mode 100644 examples/widgets/painting/imagecomposition/images/checker.png create mode 100644 examples/widgets/painting/imagecomposition/main.cpp create mode 100644 examples/widgets/painting/painterpaths/main.cpp create mode 100644 examples/widgets/painting/painterpaths/painterpaths.desktop create mode 100644 examples/widgets/painting/painterpaths/painterpaths.pro create mode 100644 examples/widgets/painting/painterpaths/renderarea.cpp create mode 100644 examples/widgets/painting/painterpaths/renderarea.h create mode 100644 examples/widgets/painting/painterpaths/window.cpp create mode 100644 examples/widgets/painting/painterpaths/window.h create mode 100644 examples/widgets/painting/painting.pro create mode 100644 examples/widgets/painting/pathstroke/main.cpp create mode 100644 examples/widgets/painting/pathstroke/pathstroke.cpp create mode 100644 examples/widgets/painting/pathstroke/pathstroke.h create mode 100644 examples/widgets/painting/pathstroke/pathstroke.html create mode 100644 examples/widgets/painting/pathstroke/pathstroke.pro create mode 100644 examples/widgets/painting/pathstroke/pathstroke.qrc create mode 100644 examples/widgets/painting/shared/arthurstyle.cpp create mode 100644 examples/widgets/painting/shared/arthurstyle.h create mode 100644 examples/widgets/painting/shared/arthurwidgets.cpp create mode 100644 examples/widgets/painting/shared/arthurwidgets.h create mode 100644 examples/widgets/painting/shared/hoverpoints.cpp create mode 100644 examples/widgets/painting/shared/hoverpoints.h create mode 100644 examples/widgets/painting/shared/images/bg_pattern.png create mode 100644 examples/widgets/painting/shared/images/button_normal_cap_left.png create mode 100644 examples/widgets/painting/shared/images/button_normal_cap_right.png create mode 100644 examples/widgets/painting/shared/images/button_normal_stretch.png create mode 100644 examples/widgets/painting/shared/images/button_pressed_cap_left.png create mode 100644 examples/widgets/painting/shared/images/button_pressed_cap_right.png create mode 100644 examples/widgets/painting/shared/images/button_pressed_stretch.png create mode 100644 examples/widgets/painting/shared/images/curve_thing_edit-6.png create mode 100644 examples/widgets/painting/shared/images/frame_bottom.png create mode 100644 examples/widgets/painting/shared/images/frame_bottomleft.png create mode 100644 examples/widgets/painting/shared/images/frame_bottomright.png create mode 100644 examples/widgets/painting/shared/images/frame_left.png create mode 100644 examples/widgets/painting/shared/images/frame_right.png create mode 100644 examples/widgets/painting/shared/images/frame_top.png create mode 100644 examples/widgets/painting/shared/images/frame_topleft.png create mode 100644 examples/widgets/painting/shared/images/frame_topright.png create mode 100644 examples/widgets/painting/shared/images/groupframe_bottom_left.png create mode 100644 examples/widgets/painting/shared/images/groupframe_bottom_right.png create mode 100644 examples/widgets/painting/shared/images/groupframe_bottom_stretch.png create mode 100644 examples/widgets/painting/shared/images/groupframe_left_stretch.png create mode 100644 examples/widgets/painting/shared/images/groupframe_right_stretch.png create mode 100644 examples/widgets/painting/shared/images/groupframe_top_stretch.png create mode 100644 examples/widgets/painting/shared/images/groupframe_topleft.png create mode 100644 examples/widgets/painting/shared/images/groupframe_topright.png create mode 100644 examples/widgets/painting/shared/images/line_dash_dot.png create mode 100644 examples/widgets/painting/shared/images/line_dash_dot_dot.png create mode 100644 examples/widgets/painting/shared/images/line_dashed.png create mode 100644 examples/widgets/painting/shared/images/line_dotted.png create mode 100644 examples/widgets/painting/shared/images/line_solid.png create mode 100644 examples/widgets/painting/shared/images/radiobutton-off.png create mode 100644 examples/widgets/painting/shared/images/radiobutton-on.png create mode 100644 examples/widgets/painting/shared/images/radiobutton_off.png create mode 100644 examples/widgets/painting/shared/images/radiobutton_on.png create mode 100644 examples/widgets/painting/shared/images/slider_bar.png create mode 100644 examples/widgets/painting/shared/images/slider_thumb_off.png create mode 100644 examples/widgets/painting/shared/images/slider_thumb_on.png create mode 100644 examples/widgets/painting/shared/images/title_cap_left.png create mode 100644 examples/widgets/painting/shared/images/title_cap_right.png create mode 100644 examples/widgets/painting/shared/images/title_stretch.png create mode 100644 examples/widgets/painting/shared/shared.pri create mode 100644 examples/widgets/painting/shared/shared.pro create mode 100644 examples/widgets/painting/shared/shared.qrc create mode 100644 examples/widgets/painting/svggenerator/svggenerator.desktop create mode 100644 examples/widgets/painting/svgviewer/svgviewer.desktop create mode 100644 examples/widgets/painting/transformations/main.cpp create mode 100644 examples/widgets/painting/transformations/renderarea.cpp create mode 100644 examples/widgets/painting/transformations/renderarea.h create mode 100644 examples/widgets/painting/transformations/transformations.desktop create mode 100644 examples/widgets/painting/transformations/transformations.pro create mode 100644 examples/widgets/painting/transformations/window.cpp create mode 100644 examples/widgets/painting/transformations/window.h create mode 100644 examples/widgets/richtext/README create mode 100644 examples/widgets/richtext/calendar/calendar.desktop create mode 100644 examples/widgets/richtext/calendar/calendar.pro create mode 100644 examples/widgets/richtext/calendar/main.cpp create mode 100644 examples/widgets/richtext/calendar/mainwindow.cpp create mode 100644 examples/widgets/richtext/calendar/mainwindow.h create mode 100644 examples/widgets/richtext/orderform/detailsdialog.cpp create mode 100644 examples/widgets/richtext/orderform/detailsdialog.h create mode 100644 examples/widgets/richtext/orderform/main.cpp create mode 100644 examples/widgets/richtext/orderform/mainwindow.cpp create mode 100644 examples/widgets/richtext/orderform/mainwindow.h create mode 100644 examples/widgets/richtext/orderform/orderform.desktop create mode 100644 examples/widgets/richtext/orderform/orderform.pro create mode 100644 examples/widgets/richtext/richtext.pro create mode 100644 examples/widgets/richtext/syntaxhighlighter/highlighter.cpp create mode 100644 examples/widgets/richtext/syntaxhighlighter/highlighter.h create mode 100644 examples/widgets/richtext/syntaxhighlighter/main.cpp create mode 100644 examples/widgets/richtext/syntaxhighlighter/mainwindow.cpp create mode 100644 examples/widgets/richtext/syntaxhighlighter/mainwindow.h create mode 100644 examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.desktop create mode 100644 examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.pro create mode 100644 examples/widgets/richtext/textedit/example.html create mode 100644 examples/widgets/richtext/textedit/images/logo32.png create mode 100644 examples/widgets/richtext/textedit/images/mac/editcopy.png create mode 100644 examples/widgets/richtext/textedit/images/mac/editcut.png create mode 100644 examples/widgets/richtext/textedit/images/mac/editpaste.png create mode 100644 examples/widgets/richtext/textedit/images/mac/editredo.png create mode 100644 examples/widgets/richtext/textedit/images/mac/editundo.png create mode 100644 examples/widgets/richtext/textedit/images/mac/exportpdf.png create mode 100644 examples/widgets/richtext/textedit/images/mac/filenew.png create mode 100644 examples/widgets/richtext/textedit/images/mac/fileopen.png create mode 100644 examples/widgets/richtext/textedit/images/mac/fileprint.png create mode 100644 examples/widgets/richtext/textedit/images/mac/filesave.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textbold.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textcenter.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textitalic.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textjustify.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textleft.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textright.png create mode 100644 examples/widgets/richtext/textedit/images/mac/textunder.png create mode 100644 examples/widgets/richtext/textedit/images/mac/zoomin.png create mode 100644 examples/widgets/richtext/textedit/images/mac/zoomout.png create mode 100644 examples/widgets/richtext/textedit/images/win/editcopy.png create mode 100644 examples/widgets/richtext/textedit/images/win/editcut.png create mode 100644 examples/widgets/richtext/textedit/images/win/editpaste.png create mode 100644 examples/widgets/richtext/textedit/images/win/editredo.png create mode 100644 examples/widgets/richtext/textedit/images/win/editundo.png create mode 100644 examples/widgets/richtext/textedit/images/win/exportpdf.png create mode 100644 examples/widgets/richtext/textedit/images/win/filenew.png create mode 100644 examples/widgets/richtext/textedit/images/win/fileopen.png create mode 100644 examples/widgets/richtext/textedit/images/win/fileprint.png create mode 100644 examples/widgets/richtext/textedit/images/win/filesave.png create mode 100644 examples/widgets/richtext/textedit/images/win/textbold.png create mode 100644 examples/widgets/richtext/textedit/images/win/textcenter.png create mode 100644 examples/widgets/richtext/textedit/images/win/textitalic.png create mode 100644 examples/widgets/richtext/textedit/images/win/textjustify.png create mode 100644 examples/widgets/richtext/textedit/images/win/textleft.png create mode 100644 examples/widgets/richtext/textedit/images/win/textright.png create mode 100644 examples/widgets/richtext/textedit/images/win/textunder.png create mode 100644 examples/widgets/richtext/textedit/images/win/zoomin.png create mode 100644 examples/widgets/richtext/textedit/images/win/zoomout.png create mode 100644 examples/widgets/richtext/textedit/main.cpp create mode 100644 examples/widgets/richtext/textedit/textedit.cpp create mode 100644 examples/widgets/richtext/textedit/textedit.h create mode 100644 examples/widgets/richtext/textedit/textedit.pro create mode 100644 examples/widgets/richtext/textedit/textedit.qdoc create mode 100644 examples/widgets/richtext/textedit/textedit.qrc delete mode 100644 examples/widgets/scribble/main.cpp delete mode 100644 examples/widgets/scribble/mainwindow.cpp delete mode 100644 examples/widgets/scribble/mainwindow.h delete mode 100644 examples/widgets/scribble/scribble.desktop delete mode 100644 examples/widgets/scribble/scribble.pro delete mode 100644 examples/widgets/scribble/scribblearea.cpp delete mode 100644 examples/widgets/scribble/scribblearea.h create mode 100644 examples/widgets/scroller/graphicsview/graphicsview.pro create mode 100644 examples/widgets/scroller/graphicsview/main.cpp create mode 100644 examples/widgets/scroller/scroller.pro delete mode 100644 examples/widgets/shapedclock/main.cpp delete mode 100644 examples/widgets/shapedclock/shapedclock.cpp delete mode 100644 examples/widgets/shapedclock/shapedclock.desktop delete mode 100644 examples/widgets/shapedclock/shapedclock.h delete mode 100644 examples/widgets/shapedclock/shapedclock.pro delete mode 100644 examples/widgets/sliders/main.cpp delete mode 100644 examples/widgets/sliders/sliders.desktop delete mode 100644 examples/widgets/sliders/sliders.pro delete mode 100644 examples/widgets/sliders/slidersgroup.cpp delete mode 100644 examples/widgets/sliders/slidersgroup.h delete mode 100644 examples/widgets/sliders/window.cpp delete mode 100644 examples/widgets/sliders/window.h delete mode 100644 examples/widgets/softkeys/main.cpp delete mode 100644 examples/widgets/softkeys/softkeys.cpp delete mode 100644 examples/widgets/softkeys/softkeys.desktop delete mode 100644 examples/widgets/softkeys/softkeys.h delete mode 100644 examples/widgets/softkeys/softkeys.pro delete mode 100644 examples/widgets/spinboxes/main.cpp delete mode 100644 examples/widgets/spinboxes/spinboxes.desktop delete mode 100644 examples/widgets/spinboxes/spinboxes.pro delete mode 100644 examples/widgets/spinboxes/window.cpp delete mode 100644 examples/widgets/spinboxes/window.h create mode 100644 examples/widgets/statemachine/README create mode 100644 examples/widgets/statemachine/eventtransitions/eventtransitions.desktop create mode 100644 examples/widgets/statemachine/eventtransitions/eventtransitions.pro create mode 100644 examples/widgets/statemachine/eventtransitions/main.cpp create mode 100644 examples/widgets/statemachine/factorial/factorial.desktop create mode 100644 examples/widgets/statemachine/factorial/factorial.pro create mode 100644 examples/widgets/statemachine/factorial/main.cpp create mode 100644 examples/widgets/statemachine/pingpong/main.cpp create mode 100644 examples/widgets/statemachine/pingpong/pingpong.desktop create mode 100644 examples/widgets/statemachine/pingpong/pingpong.pro create mode 100644 examples/widgets/statemachine/rogue/main.cpp create mode 100644 examples/widgets/statemachine/rogue/movementtransition.h create mode 100644 examples/widgets/statemachine/rogue/rogue.desktop create mode 100644 examples/widgets/statemachine/rogue/rogue.pro create mode 100644 examples/widgets/statemachine/rogue/window.cpp create mode 100644 examples/widgets/statemachine/rogue/window.h create mode 100644 examples/widgets/statemachine/statemachine.pro create mode 100644 examples/widgets/statemachine/trafficlight/main.cpp create mode 100644 examples/widgets/statemachine/trafficlight/trafficlight.desktop create mode 100644 examples/widgets/statemachine/trafficlight/trafficlight.pro create mode 100644 examples/widgets/statemachine/twowaybutton/main.cpp create mode 100644 examples/widgets/statemachine/twowaybutton/twowaybutton.desktop create mode 100644 examples/widgets/statemachine/twowaybutton/twowaybutton.pro delete mode 100644 examples/widgets/styles/images/woodbackground.png delete mode 100644 examples/widgets/styles/images/woodbutton.png delete mode 100644 examples/widgets/styles/main.cpp delete mode 100644 examples/widgets/styles/norwegianwoodstyle.cpp delete mode 100644 examples/widgets/styles/norwegianwoodstyle.h delete mode 100644 examples/widgets/styles/styles.desktop delete mode 100644 examples/widgets/styles/styles.pro delete mode 100644 examples/widgets/styles/styles.qrc delete mode 100644 examples/widgets/styles/widgetgallery.cpp delete mode 100644 examples/widgets/styles/widgetgallery.h delete mode 100644 examples/widgets/stylesheet/images/checkbox_checked.png delete mode 100644 examples/widgets/stylesheet/images/checkbox_checked_hover.png delete mode 100644 examples/widgets/stylesheet/images/checkbox_checked_pressed.png delete mode 100644 examples/widgets/stylesheet/images/checkbox_unchecked.png delete mode 100644 examples/widgets/stylesheet/images/checkbox_unchecked_hover.png delete mode 100644 examples/widgets/stylesheet/images/checkbox_unchecked_pressed.png delete mode 100644 examples/widgets/stylesheet/images/down_arrow.png delete mode 100644 examples/widgets/stylesheet/images/down_arrow_disabled.png delete mode 100644 examples/widgets/stylesheet/images/frame.png delete mode 100644 examples/widgets/stylesheet/images/pagefold.png delete mode 100644 examples/widgets/stylesheet/images/pushbutton.png delete mode 100644 examples/widgets/stylesheet/images/pushbutton_hover.png delete mode 100644 examples/widgets/stylesheet/images/pushbutton_pressed.png delete mode 100644 examples/widgets/stylesheet/images/radiobutton_checked.png delete mode 100644 examples/widgets/stylesheet/images/radiobutton_checked_hover.png delete mode 100644 examples/widgets/stylesheet/images/radiobutton_checked_pressed.png delete mode 100644 examples/widgets/stylesheet/images/radiobutton_unchecked.png delete mode 100644 examples/widgets/stylesheet/images/radiobutton_unchecked_hover.png delete mode 100644 examples/widgets/stylesheet/images/radiobutton_unchecked_pressed.png delete mode 100644 examples/widgets/stylesheet/images/sizegrip.png delete mode 100644 examples/widgets/stylesheet/images/spindown.png delete mode 100644 examples/widgets/stylesheet/images/spindown_hover.png delete mode 100644 examples/widgets/stylesheet/images/spindown_off.png delete mode 100644 examples/widgets/stylesheet/images/spindown_pressed.png delete mode 100644 examples/widgets/stylesheet/images/spinup.png delete mode 100644 examples/widgets/stylesheet/images/spinup_hover.png delete mode 100644 examples/widgets/stylesheet/images/spinup_off.png delete mode 100644 examples/widgets/stylesheet/images/spinup_pressed.png delete mode 100644 examples/widgets/stylesheet/images/up_arrow.png delete mode 100644 examples/widgets/stylesheet/images/up_arrow_disabled.png delete mode 100644 examples/widgets/stylesheet/layouts/default.ui delete mode 100644 examples/widgets/stylesheet/layouts/pagefold.ui delete mode 100644 examples/widgets/stylesheet/main.cpp delete mode 100644 examples/widgets/stylesheet/mainwindow.cpp delete mode 100644 examples/widgets/stylesheet/mainwindow.h delete mode 100644 examples/widgets/stylesheet/mainwindow.ui delete mode 100644 examples/widgets/stylesheet/qss/coffee.qss delete mode 100644 examples/widgets/stylesheet/qss/default.qss delete mode 100644 examples/widgets/stylesheet/qss/pagefold.qss delete mode 100644 examples/widgets/stylesheet/stylesheet.desktop delete mode 100644 examples/widgets/stylesheet/stylesheet.pro delete mode 100644 examples/widgets/stylesheet/stylesheet.qrc delete mode 100644 examples/widgets/stylesheet/stylesheeteditor.cpp delete mode 100644 examples/widgets/stylesheet/stylesheeteditor.h delete mode 100644 examples/widgets/stylesheet/stylesheeteditor.ui delete mode 100644 examples/widgets/tablet/main.cpp delete mode 100644 examples/widgets/tablet/mainwindow.cpp delete mode 100644 examples/widgets/tablet/mainwindow.h delete mode 100644 examples/widgets/tablet/tablet.desktop delete mode 100644 examples/widgets/tablet/tablet.pro delete mode 100644 examples/widgets/tablet/tabletapplication.cpp delete mode 100644 examples/widgets/tablet/tabletapplication.h delete mode 100644 examples/widgets/tablet/tabletcanvas.cpp delete mode 100644 examples/widgets/tablet/tabletcanvas.h delete mode 100644 examples/widgets/tetrix/main.cpp delete mode 100644 examples/widgets/tetrix/tetrix.desktop delete mode 100644 examples/widgets/tetrix/tetrix.pro delete mode 100644 examples/widgets/tetrix/tetrixboard.cpp delete mode 100644 examples/widgets/tetrix/tetrixboard.h delete mode 100644 examples/widgets/tetrix/tetrixpiece.cpp delete mode 100644 examples/widgets/tetrix/tetrixpiece.h delete mode 100644 examples/widgets/tetrix/tetrixwindow.cpp delete mode 100644 examples/widgets/tetrix/tetrixwindow.h delete mode 100644 examples/widgets/tooltips/images/circle.png delete mode 100644 examples/widgets/tooltips/images/square.png delete mode 100644 examples/widgets/tooltips/images/triangle.png delete mode 100644 examples/widgets/tooltips/main.cpp delete mode 100644 examples/widgets/tooltips/shapeitem.cpp delete mode 100644 examples/widgets/tooltips/shapeitem.h delete mode 100644 examples/widgets/tooltips/sortingbox.cpp delete mode 100644 examples/widgets/tooltips/sortingbox.h delete mode 100644 examples/widgets/tooltips/tooltips.desktop delete mode 100644 examples/widgets/tooltips/tooltips.pro delete mode 100644 examples/widgets/tooltips/tooltips.qrc delete mode 100644 examples/widgets/validators/ledoff.png delete mode 100644 examples/widgets/validators/ledon.png delete mode 100644 examples/widgets/validators/ledwidget.cpp delete mode 100644 examples/widgets/validators/ledwidget.h delete mode 100644 examples/widgets/validators/localeselector.cpp delete mode 100644 examples/widgets/validators/localeselector.h delete mode 100644 examples/widgets/validators/main.cpp delete mode 100644 examples/widgets/validators/validators.desktop delete mode 100644 examples/widgets/validators/validators.pro delete mode 100644 examples/widgets/validators/validators.qrc delete mode 100644 examples/widgets/validators/validators.ui create mode 100644 examples/widgets/widgets/README create mode 100644 examples/widgets/widgets/analogclock/analogclock.cpp create mode 100644 examples/widgets/widgets/analogclock/analogclock.desktop create mode 100644 examples/widgets/widgets/analogclock/analogclock.h create mode 100644 examples/widgets/widgets/analogclock/analogclock.pro create mode 100644 examples/widgets/widgets/analogclock/main.cpp create mode 100644 examples/widgets/widgets/applicationicon/applicationicon.desktop create mode 100644 examples/widgets/widgets/applicationicon/applicationicon.png create mode 100644 examples/widgets/widgets/applicationicon/applicationicon.pro create mode 100644 examples/widgets/widgets/applicationicon/applicationicon.svg create mode 100644 examples/widgets/widgets/applicationicon/main.cpp create mode 100644 examples/widgets/widgets/calculator/button.cpp create mode 100644 examples/widgets/widgets/calculator/button.h create mode 100644 examples/widgets/widgets/calculator/calculator.cpp create mode 100644 examples/widgets/widgets/calculator/calculator.desktop create mode 100644 examples/widgets/widgets/calculator/calculator.h create mode 100644 examples/widgets/widgets/calculator/calculator.pro create mode 100644 examples/widgets/widgets/calculator/main.cpp create mode 100644 examples/widgets/widgets/calculator/releasenotes.txt create mode 100644 examples/widgets/widgets/calendarwidget/calendarwidget.desktop create mode 100644 examples/widgets/widgets/calendarwidget/calendarwidget.pro create mode 100644 examples/widgets/widgets/calendarwidget/main.cpp create mode 100644 examples/widgets/widgets/calendarwidget/window.cpp create mode 100644 examples/widgets/widgets/calendarwidget/window.h create mode 100644 examples/widgets/widgets/charactermap/charactermap.desktop create mode 100644 examples/widgets/widgets/charactermap/charactermap.pro create mode 100644 examples/widgets/widgets/charactermap/characterwidget.cpp create mode 100644 examples/widgets/widgets/charactermap/characterwidget.h create mode 100644 examples/widgets/widgets/charactermap/main.cpp create mode 100644 examples/widgets/widgets/charactermap/mainwindow.cpp create mode 100644 examples/widgets/widgets/charactermap/mainwindow.h create mode 100644 examples/widgets/widgets/codeeditor/codeeditor.cpp create mode 100644 examples/widgets/widgets/codeeditor/codeeditor.desktop create mode 100644 examples/widgets/widgets/codeeditor/codeeditor.h create mode 100644 examples/widgets/widgets/codeeditor/codeeditor.pro create mode 100644 examples/widgets/widgets/codeeditor/main.cpp create mode 100644 examples/widgets/widgets/digitalclock/digitalclock.cpp create mode 100644 examples/widgets/widgets/digitalclock/digitalclock.desktop create mode 100644 examples/widgets/widgets/digitalclock/digitalclock.h create mode 100644 examples/widgets/widgets/digitalclock/digitalclock.pro create mode 100644 examples/widgets/widgets/digitalclock/main.cpp create mode 100644 examples/widgets/widgets/elidedlabel/elidedlabel.cpp create mode 100644 examples/widgets/widgets/elidedlabel/elidedlabel.desktop create mode 100644 examples/widgets/widgets/elidedlabel/elidedlabel.h create mode 100644 examples/widgets/widgets/elidedlabel/elidedlabel.pro create mode 100644 examples/widgets/widgets/elidedlabel/main.cpp create mode 100644 examples/widgets/widgets/elidedlabel/testwidget.cpp create mode 100644 examples/widgets/widgets/elidedlabel/testwidget.h create mode 100644 examples/widgets/widgets/groupbox/groupbox.desktop create mode 100644 examples/widgets/widgets/groupbox/groupbox.pro create mode 100644 examples/widgets/widgets/groupbox/main.cpp create mode 100644 examples/widgets/widgets/groupbox/window.cpp create mode 100644 examples/widgets/widgets/groupbox/window.h create mode 100644 examples/widgets/widgets/icons/iconpreviewarea.cpp create mode 100644 examples/widgets/widgets/icons/iconpreviewarea.h create mode 100644 examples/widgets/widgets/icons/icons.desktop create mode 100644 examples/widgets/widgets/icons/icons.pro create mode 100644 examples/widgets/widgets/icons/iconsizespinbox.cpp create mode 100644 examples/widgets/widgets/icons/iconsizespinbox.h create mode 100644 examples/widgets/widgets/icons/imagedelegate.cpp create mode 100644 examples/widgets/widgets/icons/imagedelegate.h create mode 100644 examples/widgets/widgets/icons/images/designer.png create mode 100644 examples/widgets/widgets/icons/images/find_disabled.png create mode 100644 examples/widgets/widgets/icons/images/find_normal.png create mode 100644 examples/widgets/widgets/icons/images/monkey_off_128x128.png create mode 100644 examples/widgets/widgets/icons/images/monkey_off_16x16.png create mode 100644 examples/widgets/widgets/icons/images/monkey_off_32x32.png create mode 100644 examples/widgets/widgets/icons/images/monkey_off_64x64.png create mode 100644 examples/widgets/widgets/icons/images/monkey_on_128x128.png create mode 100644 examples/widgets/widgets/icons/images/monkey_on_16x16.png create mode 100644 examples/widgets/widgets/icons/images/monkey_on_32x32.png create mode 100644 examples/widgets/widgets/icons/images/monkey_on_64x64.png create mode 100644 examples/widgets/widgets/icons/images/qt_extended_16x16.png create mode 100644 examples/widgets/widgets/icons/images/qt_extended_32x32.png create mode 100644 examples/widgets/widgets/icons/images/qt_extended_48x48.png create mode 100644 examples/widgets/widgets/icons/main.cpp create mode 100644 examples/widgets/widgets/icons/mainwindow.cpp create mode 100644 examples/widgets/widgets/icons/mainwindow.h create mode 100644 examples/widgets/widgets/imageviewer/imageviewer.cpp create mode 100644 examples/widgets/widgets/imageviewer/imageviewer.desktop create mode 100644 examples/widgets/widgets/imageviewer/imageviewer.h create mode 100644 examples/widgets/widgets/imageviewer/imageviewer.pro create mode 100644 examples/widgets/widgets/imageviewer/main.cpp create mode 100644 examples/widgets/widgets/lineedits/lineedits.desktop create mode 100644 examples/widgets/widgets/lineedits/lineedits.pro create mode 100644 examples/widgets/widgets/lineedits/main.cpp create mode 100644 examples/widgets/widgets/lineedits/window.cpp create mode 100644 examples/widgets/widgets/lineedits/window.h create mode 100644 examples/widgets/widgets/mousebuttons/buttontester.cpp create mode 100644 examples/widgets/widgets/mousebuttons/buttontester.h create mode 100644 examples/widgets/widgets/mousebuttons/main.cpp create mode 100644 examples/widgets/widgets/mousebuttons/mousebuttons.pro create mode 100644 examples/widgets/widgets/movie/animation.gif create mode 100644 examples/widgets/widgets/movie/main.cpp create mode 100644 examples/widgets/widgets/movie/movie.desktop create mode 100644 examples/widgets/widgets/movie/movie.pro create mode 100644 examples/widgets/widgets/movie/movieplayer.cpp create mode 100644 examples/widgets/widgets/movie/movieplayer.h create mode 100644 examples/widgets/widgets/orientation/image_a.png create mode 100644 examples/widgets/widgets/orientation/image_b.png create mode 100644 examples/widgets/widgets/orientation/image_c.png create mode 100644 examples/widgets/widgets/orientation/images.qrc create mode 100644 examples/widgets/widgets/orientation/landscape.ui create mode 100644 examples/widgets/widgets/orientation/main.cpp create mode 100644 examples/widgets/widgets/orientation/mainwindow.cpp create mode 100644 examples/widgets/widgets/orientation/mainwindow.h create mode 100644 examples/widgets/widgets/orientation/orientation.desktop create mode 100644 examples/widgets/widgets/orientation/orientation.pro create mode 100644 examples/widgets/widgets/orientation/portrait.ui create mode 100644 examples/widgets/widgets/scribble/main.cpp create mode 100644 examples/widgets/widgets/scribble/mainwindow.cpp create mode 100644 examples/widgets/widgets/scribble/mainwindow.h create mode 100644 examples/widgets/widgets/scribble/scribble.desktop create mode 100644 examples/widgets/widgets/scribble/scribble.pro create mode 100644 examples/widgets/widgets/scribble/scribblearea.cpp create mode 100644 examples/widgets/widgets/scribble/scribblearea.h create mode 100644 examples/widgets/widgets/shapedclock/main.cpp create mode 100644 examples/widgets/widgets/shapedclock/shapedclock.cpp create mode 100644 examples/widgets/widgets/shapedclock/shapedclock.desktop create mode 100644 examples/widgets/widgets/shapedclock/shapedclock.h create mode 100644 examples/widgets/widgets/shapedclock/shapedclock.pro create mode 100644 examples/widgets/widgets/sliders/main.cpp create mode 100644 examples/widgets/widgets/sliders/sliders.desktop create mode 100644 examples/widgets/widgets/sliders/sliders.pro create mode 100644 examples/widgets/widgets/sliders/slidersgroup.cpp create mode 100644 examples/widgets/widgets/sliders/slidersgroup.h create mode 100644 examples/widgets/widgets/sliders/window.cpp create mode 100644 examples/widgets/widgets/sliders/window.h create mode 100644 examples/widgets/widgets/softkeys/main.cpp create mode 100644 examples/widgets/widgets/softkeys/softkeys.cpp create mode 100644 examples/widgets/widgets/softkeys/softkeys.desktop create mode 100644 examples/widgets/widgets/softkeys/softkeys.h create mode 100644 examples/widgets/widgets/softkeys/softkeys.pro create mode 100644 examples/widgets/widgets/spinboxes/main.cpp create mode 100644 examples/widgets/widgets/spinboxes/spinboxes.desktop create mode 100644 examples/widgets/widgets/spinboxes/spinboxes.pro create mode 100644 examples/widgets/widgets/spinboxes/window.cpp create mode 100644 examples/widgets/widgets/spinboxes/window.h create mode 100644 examples/widgets/widgets/styles/images/woodbackground.png create mode 100644 examples/widgets/widgets/styles/images/woodbutton.png create mode 100644 examples/widgets/widgets/styles/main.cpp create mode 100644 examples/widgets/widgets/styles/norwegianwoodstyle.cpp create mode 100644 examples/widgets/widgets/styles/norwegianwoodstyle.h create mode 100644 examples/widgets/widgets/styles/styles.desktop create mode 100644 examples/widgets/widgets/styles/styles.pro create mode 100644 examples/widgets/widgets/styles/styles.qrc create mode 100644 examples/widgets/widgets/styles/widgetgallery.cpp create mode 100644 examples/widgets/widgets/styles/widgetgallery.h create mode 100644 examples/widgets/widgets/stylesheet/images/checkbox_checked.png create mode 100644 examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png create mode 100644 examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/down_arrow.png create mode 100644 examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png create mode 100644 examples/widgets/widgets/stylesheet/images/frame.png create mode 100644 examples/widgets/widgets/stylesheet/images/pagefold.png create mode 100644 examples/widgets/widgets/stylesheet/images/pushbutton.png create mode 100644 examples/widgets/widgets/stylesheet/images/pushbutton_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/radiobutton_checked.png create mode 100644 examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png create mode 100644 examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/sizegrip.png create mode 100644 examples/widgets/widgets/stylesheet/images/spindown.png create mode 100644 examples/widgets/widgets/stylesheet/images/spindown_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/spindown_off.png create mode 100644 examples/widgets/widgets/stylesheet/images/spindown_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/spinup.png create mode 100644 examples/widgets/widgets/stylesheet/images/spinup_hover.png create mode 100644 examples/widgets/widgets/stylesheet/images/spinup_off.png create mode 100644 examples/widgets/widgets/stylesheet/images/spinup_pressed.png create mode 100644 examples/widgets/widgets/stylesheet/images/up_arrow.png create mode 100644 examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png create mode 100644 examples/widgets/widgets/stylesheet/layouts/default.ui create mode 100644 examples/widgets/widgets/stylesheet/layouts/pagefold.ui create mode 100644 examples/widgets/widgets/stylesheet/main.cpp create mode 100644 examples/widgets/widgets/stylesheet/mainwindow.cpp create mode 100644 examples/widgets/widgets/stylesheet/mainwindow.h create mode 100644 examples/widgets/widgets/stylesheet/mainwindow.ui create mode 100644 examples/widgets/widgets/stylesheet/qss/coffee.qss create mode 100644 examples/widgets/widgets/stylesheet/qss/default.qss create mode 100644 examples/widgets/widgets/stylesheet/qss/pagefold.qss create mode 100644 examples/widgets/widgets/stylesheet/stylesheet.desktop create mode 100644 examples/widgets/widgets/stylesheet/stylesheet.pro create mode 100644 examples/widgets/widgets/stylesheet/stylesheet.qrc create mode 100644 examples/widgets/widgets/stylesheet/stylesheeteditor.cpp create mode 100644 examples/widgets/widgets/stylesheet/stylesheeteditor.h create mode 100644 examples/widgets/widgets/stylesheet/stylesheeteditor.ui create mode 100644 examples/widgets/widgets/tablet/main.cpp create mode 100644 examples/widgets/widgets/tablet/mainwindow.cpp create mode 100644 examples/widgets/widgets/tablet/mainwindow.h create mode 100644 examples/widgets/widgets/tablet/tablet.desktop create mode 100644 examples/widgets/widgets/tablet/tablet.pro create mode 100644 examples/widgets/widgets/tablet/tabletapplication.cpp create mode 100644 examples/widgets/widgets/tablet/tabletapplication.h create mode 100644 examples/widgets/widgets/tablet/tabletcanvas.cpp create mode 100644 examples/widgets/widgets/tablet/tabletcanvas.h create mode 100644 examples/widgets/widgets/tetrix/main.cpp create mode 100644 examples/widgets/widgets/tetrix/tetrix.desktop create mode 100644 examples/widgets/widgets/tetrix/tetrix.pro create mode 100644 examples/widgets/widgets/tetrix/tetrixboard.cpp create mode 100644 examples/widgets/widgets/tetrix/tetrixboard.h create mode 100644 examples/widgets/widgets/tetrix/tetrixpiece.cpp create mode 100644 examples/widgets/widgets/tetrix/tetrixpiece.h create mode 100644 examples/widgets/widgets/tetrix/tetrixwindow.cpp create mode 100644 examples/widgets/widgets/tetrix/tetrixwindow.h create mode 100644 examples/widgets/widgets/tooltips/images/circle.png create mode 100644 examples/widgets/widgets/tooltips/images/square.png create mode 100644 examples/widgets/widgets/tooltips/images/triangle.png create mode 100644 examples/widgets/widgets/tooltips/main.cpp create mode 100644 examples/widgets/widgets/tooltips/shapeitem.cpp create mode 100644 examples/widgets/widgets/tooltips/shapeitem.h create mode 100644 examples/widgets/widgets/tooltips/sortingbox.cpp create mode 100644 examples/widgets/widgets/tooltips/sortingbox.h create mode 100644 examples/widgets/widgets/tooltips/tooltips.desktop create mode 100644 examples/widgets/widgets/tooltips/tooltips.pro create mode 100644 examples/widgets/widgets/tooltips/tooltips.qrc create mode 100644 examples/widgets/widgets/validators/ledoff.png create mode 100644 examples/widgets/widgets/validators/ledon.png create mode 100644 examples/widgets/widgets/validators/ledwidget.cpp create mode 100644 examples/widgets/widgets/validators/ledwidget.h create mode 100644 examples/widgets/widgets/validators/localeselector.cpp create mode 100644 examples/widgets/widgets/validators/localeselector.h create mode 100644 examples/widgets/widgets/validators/main.cpp create mode 100644 examples/widgets/widgets/validators/validators.desktop create mode 100644 examples/widgets/widgets/validators/validators.pro create mode 100644 examples/widgets/widgets/validators/validators.qrc create mode 100644 examples/widgets/widgets/validators/validators.ui create mode 100644 examples/widgets/widgets/widgets.pro create mode 100644 examples/widgets/widgets/wiggly/dialog.cpp create mode 100644 examples/widgets/widgets/wiggly/dialog.h create mode 100644 examples/widgets/widgets/wiggly/main.cpp create mode 100644 examples/widgets/widgets/wiggly/wiggly.desktop create mode 100644 examples/widgets/widgets/wiggly/wiggly.pro create mode 100644 examples/widgets/widgets/wiggly/wigglywidget.cpp create mode 100644 examples/widgets/widgets/wiggly/wigglywidget.h create mode 100644 examples/widgets/widgets/windowflags/controllerwindow.cpp create mode 100644 examples/widgets/widgets/windowflags/controllerwindow.h create mode 100644 examples/widgets/widgets/windowflags/main.cpp create mode 100644 examples/widgets/widgets/windowflags/previewwindow.cpp create mode 100644 examples/widgets/widgets/windowflags/previewwindow.h create mode 100644 examples/widgets/widgets/windowflags/windowflags.desktop create mode 100644 examples/widgets/widgets/windowflags/windowflags.pro delete mode 100644 examples/widgets/wiggly/dialog.cpp delete mode 100644 examples/widgets/wiggly/dialog.h delete mode 100644 examples/widgets/wiggly/main.cpp delete mode 100644 examples/widgets/wiggly/wiggly.desktop delete mode 100644 examples/widgets/wiggly/wiggly.pro delete mode 100644 examples/widgets/wiggly/wigglywidget.cpp delete mode 100644 examples/widgets/wiggly/wigglywidget.h delete mode 100644 examples/widgets/windowflags/controllerwindow.cpp delete mode 100644 examples/widgets/windowflags/controllerwindow.h delete mode 100644 examples/widgets/windowflags/main.cpp delete mode 100644 examples/widgets/windowflags/previewwindow.cpp delete mode 100644 examples/widgets/windowflags/previewwindow.h delete mode 100644 examples/widgets/windowflags/windowflags.desktop delete mode 100644 examples/widgets/windowflags/windowflags.pro (limited to 'examples') diff --git a/examples/animation/README b/examples/animation/README deleted file mode 100644 index e723a28722..0000000000 --- a/examples/animation/README +++ /dev/null @@ -1,8 +0,0 @@ -The animation framework aims to provide an easy way for creating animated and -smooth GUI's. By animating Qt properties, the framework provides great freedom -for animating widgets and other QObjects. The framework can also be used with -the Graphics View framework. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/animation/animatedtiles/animatedtiles.desktop b/examples/animation/animatedtiles/animatedtiles.desktop deleted file mode 100644 index 97e646fdf8..0000000000 --- a/examples/animation/animatedtiles/animatedtiles.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Animated Tiles -Exec=/opt/usr/bin/animatedtiles -Icon=animatedtiles -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/animation/animatedtiles/animatedtiles.pro b/examples/animation/animatedtiles/animatedtiles.pro deleted file mode 100644 index 1bba99449c..0000000000 --- a/examples/animation/animatedtiles/animatedtiles.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES = main.cpp -RESOURCES = animatedtiles.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/animatedtiles -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animatedtiles.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/animatedtiles -INSTALLS += target sources - -QT += widgets diff --git a/examples/animation/animatedtiles/animatedtiles.qrc b/examples/animation/animatedtiles/animatedtiles.qrc deleted file mode 100644 index c43a979723..0000000000 --- a/examples/animation/animatedtiles/animatedtiles.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - images/Time-For-Lunch-2.jpg - images/centered.png - images/ellipse.png - images/figure8.png - images/kinetic.png - images/random.png - images/tile.png - - diff --git a/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg b/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg deleted file mode 100644 index c57a555490..0000000000 Binary files a/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg and /dev/null differ diff --git a/examples/animation/animatedtiles/images/centered.png b/examples/animation/animatedtiles/images/centered.png deleted file mode 100644 index e416156a0e..0000000000 Binary files a/examples/animation/animatedtiles/images/centered.png and /dev/null differ diff --git a/examples/animation/animatedtiles/images/ellipse.png b/examples/animation/animatedtiles/images/ellipse.png deleted file mode 100644 index 2c3ba881c5..0000000000 Binary files a/examples/animation/animatedtiles/images/ellipse.png and /dev/null differ diff --git a/examples/animation/animatedtiles/images/figure8.png b/examples/animation/animatedtiles/images/figure8.png deleted file mode 100644 index 6b058041c4..0000000000 Binary files a/examples/animation/animatedtiles/images/figure8.png and /dev/null differ diff --git a/examples/animation/animatedtiles/images/kinetic.png b/examples/animation/animatedtiles/images/kinetic.png deleted file mode 100644 index 55cfa5515f..0000000000 Binary files a/examples/animation/animatedtiles/images/kinetic.png and /dev/null differ diff --git a/examples/animation/animatedtiles/images/random.png b/examples/animation/animatedtiles/images/random.png deleted file mode 100644 index 415d96f856..0000000000 Binary files a/examples/animation/animatedtiles/images/random.png and /dev/null differ diff --git a/examples/animation/animatedtiles/images/tile.png b/examples/animation/animatedtiles/images/tile.png deleted file mode 100644 index c8f39d8d40..0000000000 Binary files a/examples/animation/animatedtiles/images/tile.png and /dev/null differ diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp deleted file mode 100644 index 50bd33860e..0000000000 --- a/examples/animation/animatedtiles/main.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include - -class Pixmap : public QObject, public QGraphicsPixmapItem -{ - Q_OBJECT - Q_PROPERTY(QPointF pos READ pos WRITE setPos) -public: - Pixmap(const QPixmap &pix) - : QObject(), QGraphicsPixmapItem(pix) - { - setCacheMode(DeviceCoordinateCache); - } -}; - -class Button : public QGraphicsWidget -{ - Q_OBJECT -public: - Button(const QPixmap &pixmap, QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), _pix(pixmap) - { - setAcceptHoverEvents(true); - setCacheMode(DeviceCoordinateCache); - } - - QRectF boundingRect() const - { - return QRectF(-65, -65, 130, 130); - } - - QPainterPath shape() const - { - QPainterPath path; - path.addEllipse(boundingRect()); - return path; - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) - { - bool down = option->state & QStyle::State_Sunken; - QRectF r = boundingRect(); - QLinearGradient grad(r.topLeft(), r.bottomRight()); - grad.setColorAt(down ? 1 : 0, option->state & QStyle::State_MouseOver ? Qt::white : Qt::lightGray); - grad.setColorAt(down ? 0 : 1, Qt::darkGray); - painter->setPen(Qt::darkGray); - painter->setBrush(grad); - painter->drawEllipse(r); - QLinearGradient grad2(r.topLeft(), r.bottomRight()); - grad.setColorAt(down ? 1 : 0, Qt::darkGray); - grad.setColorAt(down ? 0 : 1, Qt::lightGray); - painter->setPen(Qt::NoPen); - painter->setBrush(grad); - if (down) - painter->translate(2, 2); - painter->drawEllipse(r.adjusted(5, 5, -5, -5)); - painter->drawPixmap(-_pix.width()/2, -_pix.height()/2, _pix); - } - -signals: - void pressed(); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *) - { - emit pressed(); - update(); - } - - void mouseReleaseEvent(QGraphicsSceneMouseEvent *) - { - update(); - } - -private: - QPixmap _pix; -}; - -class View : public QGraphicsView -{ -public: - View(QGraphicsScene *scene) : QGraphicsView(scene) { } - -protected: - void resizeEvent(QResizeEvent *event) - { - QGraphicsView::resizeEvent(event); - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(animatedtiles); - - QApplication app(argc, argv); - - QPixmap kineticPix(":/images/kinetic.png"); - QPixmap bgPix(":/images/Time-For-Lunch-2.jpg"); - - QGraphicsScene scene(-350, -350, 700, 700); - - QList items; - for (int i = 0; i < 64; ++i) { - Pixmap *item = new Pixmap(kineticPix); - item->setOffset(-kineticPix.width()/2, -kineticPix.height()/2); - item->setZValue(i); - items << item; - scene.addItem(item); - } - - // Buttons - QGraphicsItem *buttonParent = new QGraphicsRectItem; - Button *ellipseButton = new Button(QPixmap(":/images/ellipse.png"), buttonParent); - Button *figure8Button = new Button(QPixmap(":/images/figure8.png"), buttonParent); - Button *randomButton = new Button(QPixmap(":/images/random.png"), buttonParent); - Button *tiledButton = new Button(QPixmap(":/images/tile.png"), buttonParent); - Button *centeredButton = new Button(QPixmap(":/images/centered.png"), buttonParent); - - ellipseButton->setPos(-100, -100); - figure8Button->setPos(100, -100); - randomButton->setPos(0, 0); - tiledButton->setPos(-100, 100); - centeredButton->setPos(100, 100); - - scene.addItem(buttonParent); - buttonParent->setTransform(QTransform::fromScale(0.75, 0.75), true); - buttonParent->setPos(200, 200); - buttonParent->setZValue(65); - - // States - QState *rootState = new QState; - QState *ellipseState = new QState(rootState); - QState *figure8State = new QState(rootState); - QState *randomState = new QState(rootState); - QState *tiledState = new QState(rootState); - QState *centeredState = new QState(rootState); - - // Values - for (int i = 0; i < items.count(); ++i) { - Pixmap *item = items.at(i); - // Ellipse - ellipseState->assignProperty(item, "pos", - QPointF(cos((i / 63.0) * 6.28) * 250, - sin((i / 63.0) * 6.28) * 250)); - - // Figure 8 - figure8State->assignProperty(item, "pos", - QPointF(sin((i / 63.0) * 6.28) * 250, - sin(((i * 2)/63.0) * 6.28) * 250)); - - // Random - randomState->assignProperty(item, "pos", - QPointF(-250 + qrand() % 500, - -250 + qrand() % 500)); - - // Tiled - tiledState->assignProperty(item, "pos", - QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2, - ((i / 8) - 4) * kineticPix.height() + kineticPix.height() / 2)); - - // Centered - centeredState->assignProperty(item, "pos", QPointF()); - } - - // Ui - View *view = new View(&scene); - view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Animated Tiles")); - view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - view->setBackgroundBrush(bgPix); - view->setCacheMode(QGraphicsView::CacheBackground); - view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - view->show(); - - QStateMachine states; - states.addState(rootState); - states.setInitialState(rootState); - rootState->setInitialState(centeredState); - - QParallelAnimationGroup *group = new QParallelAnimationGroup; - for (int i = 0; i < items.count(); ++i) { - QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); - anim->setDuration(750 + i * 25); - anim->setEasingCurve(QEasingCurve::InOutBack); - group->addAnimation(anim); - } - QAbstractTransition *trans = rootState->addTransition(ellipseButton, SIGNAL(pressed()), ellipseState); - trans->addAnimation(group); - - trans = rootState->addTransition(figure8Button, SIGNAL(pressed()), figure8State); - trans->addAnimation(group); - - trans = rootState->addTransition(randomButton, SIGNAL(pressed()), randomState); - trans->addAnimation(group); - - trans = rootState->addTransition(tiledButton, SIGNAL(pressed()), tiledState); - trans->addAnimation(group); - - trans = rootState->addTransition(centeredButton, SIGNAL(pressed()), centeredState); - trans->addAnimation(group); - - QTimer timer; - timer.start(125); - timer.setSingleShot(true); - trans = rootState->addTransition(&timer, SIGNAL(timeout()), ellipseState); - trans->addAnimation(group); - - states.start(); - -#ifdef QT_KEYPAD_NAVIGATION - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif - return app.exec(); -} - -#include "main.moc" diff --git a/examples/animation/animation.pro b/examples/animation/animation.pro deleted file mode 100644 index b17aa0e0fe..0000000000 --- a/examples/animation/animation.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = \ - subdirs -SUBDIRS += \ - animatedtiles \ - appchooser \ - easing \ - moveblocks \ - states \ - stickman \ - sub-attaq \ - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animation.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation -INSTALLS += target sources -QT += widgets diff --git a/examples/animation/appchooser/accessories-dictionary.png b/examples/animation/appchooser/accessories-dictionary.png deleted file mode 100644 index e9bd55d918..0000000000 Binary files a/examples/animation/appchooser/accessories-dictionary.png and /dev/null differ diff --git a/examples/animation/appchooser/akregator.png b/examples/animation/appchooser/akregator.png deleted file mode 100644 index a086f45ab6..0000000000 Binary files a/examples/animation/appchooser/akregator.png and /dev/null differ diff --git a/examples/animation/appchooser/appchooser.desktop b/examples/animation/appchooser/appchooser.desktop deleted file mode 100644 index 8e413e96c2..0000000000 --- a/examples/animation/appchooser/appchooser.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Application Chooser -Exec=/opt/usr/bin/appchooser -Icon=appchooser -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/animation/appchooser/appchooser.pro b/examples/animation/appchooser/appchooser.pro deleted file mode 100644 index 158a0eca9f..0000000000 --- a/examples/animation/appchooser/appchooser.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES = main.cpp -RESOURCES = appchooser.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/appchooser -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS appchooser.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/appchooser -INSTALLS += target sources - -QT += widgets diff --git a/examples/animation/appchooser/appchooser.qrc b/examples/animation/appchooser/appchooser.qrc deleted file mode 100644 index 28a3e1c4c1..0000000000 --- a/examples/animation/appchooser/appchooser.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - accessories-dictionary.png - akregator.png - digikam.png - k3b.png - - diff --git a/examples/animation/appchooser/digikam.png b/examples/animation/appchooser/digikam.png deleted file mode 100644 index 9de9fb2f80..0000000000 Binary files a/examples/animation/appchooser/digikam.png and /dev/null differ diff --git a/examples/animation/appchooser/k3b.png b/examples/animation/appchooser/k3b.png deleted file mode 100644 index bbcafcfba1..0000000000 Binary files a/examples/animation/appchooser/k3b.png and /dev/null differ diff --git a/examples/animation/appchooser/main.cpp b/examples/animation/appchooser/main.cpp deleted file mode 100644 index c8e60c0641..0000000000 --- a/examples/animation/appchooser/main.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include - - -class Pixmap : public QGraphicsWidget -{ - Q_OBJECT - -public: - Pixmap(const QPixmap &pix, QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), orig(pix), p(pix) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) - { - painter->drawPixmap(QPointF(), p); - } - - virtual void mousePressEvent(QGraphicsSceneMouseEvent * ) - { - emit clicked(); - } - - virtual void setGeometry(const QRectF &rect) - { - QGraphicsWidget::setGeometry(rect); - - if (rect.size().width() > orig.size().width()) - p = orig.scaled(rect.size().toSize()); - else - p = orig; - } - -Q_SIGNALS: - void clicked(); - -private: - QPixmap orig; - QPixmap p; -}; - -class GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(QGraphicsScene *scene, QWidget *parent = 0) : QGraphicsView(scene, parent) - { - } - - virtual void resizeEvent(QResizeEvent *) - { - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - - -void createStates(const QObjectList &objects, - const QRect &selectedRect, QState *parent) -{ - for (int i = 0; i < objects.size(); ++i) { - QState *state = new QState(parent); - state->assignProperty(objects.at(i), "geometry", selectedRect); - parent->addTransition(objects.at(i), SIGNAL(clicked()), state); - } -} - -void createAnimations(const QObjectList &objects, QStateMachine *machine) -{ - for (int i=0; iaddDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry")); -} - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(appchooser); - - QApplication app(argc, argv); - - Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); - Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); - Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); - Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); - - p1->setObjectName("p1"); - p2->setObjectName("p2"); - p3->setObjectName("p3"); - p4->setObjectName("p4"); - - p1->setGeometry(QRectF( 0.0, 0.0, 64.0, 64.0)); - p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0)); - p3->setGeometry(QRectF(236.0, 236.0, 64.0, 64.0)); - p4->setGeometry(QRectF( 0.0, 236.0, 64.0, 64.0)); - - QGraphicsScene scene(0, 0, 300, 300); - scene.setBackgroundBrush(Qt::white); - scene.addItem(p1); - scene.addItem(p2); - scene.addItem(p3); - scene.addItem(p4); - - GraphicsView window(&scene); - window.setFrameStyle(0); - window.setAlignment(Qt::AlignLeft | Qt::AlignTop); - window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - QStateMachine machine; - machine.setGlobalRestorePolicy(QState::RestoreProperties); - - QState *group = new QState(&machine); - group->setObjectName("group"); - - QRect selectedRect(86, 86, 128, 128); - - QState *idleState = new QState(group); - group->setInitialState(idleState); - - QObjectList objects; - objects << p1 << p2 << p3 << p4; - createStates(objects, selectedRect, group); - createAnimations(objects, &machine); - - machine.setInitialState(group); - machine.start(); - - window.resize(300, 300); - window.show(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/animation/easing/animation.h b/examples/animation/easing/animation.h deleted file mode 100644 index 35cbed4555..0000000000 --- a/examples/animation/easing/animation.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 ANIMATION_H -#define ANIMATION_H - -#include - -#include - -class Animation : public QPropertyAnimation { -public: - enum PathType { - LinearPath, - CirclePath, - NPathTypes - }; - Animation(QObject *target, const QByteArray &prop) - : QPropertyAnimation(target, prop) - { - setPathType(LinearPath); - } - - void setPathType(PathType pathType) - { - if (pathType >= NPathTypes) - qWarning("Unknown pathType %d", pathType); - - m_pathType = pathType; - m_path = QPainterPath(); - } - - void updateCurrentTime(int currentTime) - { - if (m_pathType == CirclePath) { - if (m_path.isEmpty()) { - QPointF to = endValue().toPointF(); - QPointF from = startValue().toPointF(); - m_path.moveTo(from); - m_path.addEllipse(QRectF(from, to)); - } - int dura = duration(); - const qreal progress = ((dura == 0) ? 1 : ((((currentTime - 1) % dura) + 1) / qreal(dura))); - - qreal easedProgress = easingCurve().valueForProgress(progress); - if (easedProgress > 1.0) { - easedProgress -= 1.0; - } else if (easedProgress < 0) { - easedProgress += 1.0; - } - QPointF pt = m_path.pointAtPercent(easedProgress); - updateCurrentValue(pt); - emit valueChanged(pt); - } else { - QPropertyAnimation::updateCurrentTime(currentTime); - } - } - - QPainterPath m_path; - PathType m_pathType; -}; - -#endif // ANIMATION_H diff --git a/examples/animation/easing/easing.desktop b/examples/animation/easing/easing.desktop deleted file mode 100644 index 56d122217a..0000000000 --- a/examples/animation/easing/easing.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Easing Curves -Exec=/opt/usr/bin/easing -Icon=easing -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/animation/easing/easing.pro b/examples/animation/easing/easing.pro deleted file mode 100644 index 155d17d9b9..0000000000 --- a/examples/animation/easing/easing.pro +++ /dev/null @@ -1,17 +0,0 @@ -HEADERS = window.h \ - animation.h -SOURCES = main.cpp \ - window.cpp - -FORMS = form.ui - -RESOURCES = easing.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/easing -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS easing.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/easing -INSTALLS += target sources - -QT += widgets - diff --git a/examples/animation/easing/easing.qrc b/examples/animation/easing/easing.qrc deleted file mode 100644 index 7e112d3a9d..0000000000 --- a/examples/animation/easing/easing.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/qt-logo.png - - \ No newline at end of file diff --git a/examples/animation/easing/form.ui b/examples/animation/easing/form.ui deleted file mode 100644 index 364aebeda6..0000000000 --- a/examples/animation/easing/form.ui +++ /dev/null @@ -1,270 +0,0 @@ - - - Form - - - - 0 - 0 - 545 - 471 - - - - Easing curves - - - - - - - 0 - 0 - - - - - 16777215 - 120 - - - - Qt::ScrollBarAlwaysOff - - - QListView::Static - - - false - - - QListView::IconMode - - - false - - - - - - - - - - 16777215 - 16777215 - - - - Path type - - - - - - - 16777215 - 40 - - - - Qt::LeftToRight - - - Line - - - true - - - buttonGroup - - - - - - - - 16777215 - 40 - - - - Circle - - - buttonGroup - - - - - - - - - - - 0 - 0 - - - - Properties - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - - 0 - 0 - - - - - 0 - 30 - - - - Period - - - - - - - false - - - - 0 - 0 - - - - - 0 - 30 - - - - -1.000000000000000 - - - 0.100000000000000 - - - -1.000000000000000 - - - - - - - false - - - - 0 - 30 - - - - -1.000000000000000 - - - 0.100000000000000 - - - -1.000000000000000 - - - - - - - - 0 - 30 - - - - Overshoot - - - - - - - false - - - - 0 - 30 - - - - -1.000000000000000 - - - 0.100000000000000 - - - -1.000000000000000 - - - - - - - - 0 - 30 - - - - Amplitude - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - diff --git a/examples/animation/easing/images/qt-logo.png b/examples/animation/easing/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/animation/easing/images/qt-logo.png and /dev/null differ diff --git a/examples/animation/easing/main.cpp b/examples/animation/easing/main.cpp deleted file mode 100644 index 05d4014fc2..0000000000 --- a/examples/animation/easing/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include "window.h" - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(easing); - QApplication app(argc, argv); - Window w; - - w.resize(400, 400); - w.show(); - - return app.exec(); -} diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp deleted file mode 100644 index 33468db59c..0000000000 --- a/examples/animation/easing/window.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "window.h" - -Window::Window(QWidget *parent) - : QWidget(parent), - m_iconSize(64, 64) -{ - m_ui.setupUi(this); - QButtonGroup *buttonGroup = findChild(); // ### workaround for uic in 4.4 - m_ui.easingCurvePicker->setIconSize(m_iconSize); - m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); - buttonGroup->setId(m_ui.lineRadio, 0); - buttonGroup->setId(m_ui.circleRadio, 1); - - QEasingCurve dummy; - m_ui.periodSpinBox->setValue(dummy.period()); - m_ui.amplitudeSpinBox->setValue(dummy.amplitude()); - m_ui.overshootSpinBox->setValue(dummy.overshoot()); - - connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int))); - connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int))); - connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double))); - connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double))); - connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double))); - createCurveIcons(); - - QPixmap pix(QLatin1String(":/images/qt-logo.png")); - m_item = new PixmapItem(pix); - m_scene.addItem(m_item); - m_ui.graphicsView->setScene(&m_scene); - - m_anim = new Animation(m_item, "pos"); - m_anim->setEasingCurve(QEasingCurve::OutBounce); - m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce)); - - startAnimation(); -} - -void Window::createCurveIcons() -{ - QPixmap pix(m_iconSize); - QPainter painter(&pix); - QLinearGradient gradient(0,0, 0, m_iconSize.height()); - gradient.setColorAt(0.0, QColor(240, 240, 240)); - gradient.setColorAt(1.0, QColor(224, 224, 224)); - QBrush brush(gradient); - const QMetaObject &mo = QEasingCurve::staticMetaObject; - QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type")); - // Skip QEasingCurve::Custom - for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { - painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); - QEasingCurve curve((QEasingCurve::Type)i); - painter.setPen(QColor(0, 0, 255, 64)); - qreal xAxis = m_iconSize.height()/1.5; - qreal yAxis = m_iconSize.width()/3; - painter.drawLine(0, xAxis, m_iconSize.width(), xAxis); - painter.drawLine(yAxis, 0, yAxis, m_iconSize.height()); - - qreal curveScale = m_iconSize.height()/2; - - painter.setPen(Qt::NoPen); - - // start point - painter.setBrush(Qt::red); - QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0)); - painter.drawRect(start.x() - 1, start.y() - 1, 3, 3); - - // end point - painter.setBrush(Qt::blue); - QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1)); - painter.drawRect(end.x() - 1, end.y() - 1, 3, 3); - - QPainterPath curvePath; - curvePath.moveTo(start); - for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) { - QPoint to; - to.setX(yAxis + curveScale * t); - to.setY(xAxis - curveScale * curve.valueForProgress(t)); - curvePath.lineTo(to); - } - painter.setRenderHint(QPainter::Antialiasing, true); - painter.strokePath(curvePath, QColor(32, 32, 32)); - painter.setRenderHint(QPainter::Antialiasing, false); - QListWidgetItem *item = new QListWidgetItem; - item->setIcon(QIcon(pix)); - item->setText(metaEnum.key(i)); - m_ui.easingCurvePicker->addItem(item); - } -} - -void Window::startAnimation() -{ - m_anim->setStartValue(QPointF(0, 0)); - m_anim->setEndValue(QPointF(100, 100)); - m_anim->setDuration(2000); - m_anim->setLoopCount(-1); // forever - m_anim->start(); -} - -void Window::curveChanged(int row) -{ - QEasingCurve::Type curveType = (QEasingCurve::Type)row; - m_anim->setEasingCurve(curveType); - m_anim->setCurrentTime(0); - - bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic; - bool isBounce = curveType >= QEasingCurve::InBounce && curveType <= QEasingCurve::OutInBounce; - m_ui.periodSpinBox->setEnabled(isElastic); - m_ui.amplitudeSpinBox->setEnabled(isElastic || isBounce); - m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack); -} - -void Window::pathChanged(int index) -{ - m_anim->setPathType((Animation::PathType)index); -} - -void Window::periodChanged(double value) -{ - QEasingCurve curve = m_anim->easingCurve(); - curve.setPeriod(value); - m_anim->setEasingCurve(curve); -} - -void Window::amplitudeChanged(double value) -{ - QEasingCurve curve = m_anim->easingCurve(); - curve.setAmplitude(value); - m_anim->setEasingCurve(curve); -} - -void Window::overshootChanged(double value) -{ - QEasingCurve curve = m_anim->easingCurve(); - curve.setOvershoot(value); - m_anim->setEasingCurve(curve); -} - diff --git a/examples/animation/easing/window.h b/examples/animation/easing/window.h deleted file mode 100644 index bf5014c0cc..0000000000 --- a/examples/animation/easing/window.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 - -#include "ui_form.h" -#include "animation.h" - -class PixmapItem : public QObject, public QGraphicsPixmapItem -{ - Q_OBJECT - Q_PROPERTY(QPointF pos READ pos WRITE setPos) -public: - PixmapItem(const QPixmap &pix) : QGraphicsPixmapItem(pix) - { - } -}; - -class Window : public QWidget { - Q_OBJECT -public: - Window(QWidget *parent = 0); -private slots: - void curveChanged(int row); - void pathChanged(int index); - void periodChanged(double); - void amplitudeChanged(double); - void overshootChanged(double); - -private: - void createCurveIcons(); - void startAnimation(); - - Ui::Form m_ui; - QGraphicsScene m_scene; - PixmapItem *m_item; - Animation *m_anim; - QSize m_iconSize; -}; diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp deleted file mode 100644 index d807bb63d9..0000000000 --- a/examples/animation/moveblocks/main.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include - -//![15] -class StateSwitchEvent: public QEvent -{ -public: - StateSwitchEvent() - : QEvent(Type(StateSwitchType)) - { - } - - explicit StateSwitchEvent(int rand) - : QEvent(Type(StateSwitchType)), - m_rand(rand) - { - } - - enum { StateSwitchType = QEvent::User + 256 }; - - int rand() const { return m_rand; } - -private: - int m_rand; -}; -//![15] - -//![16] -class QGraphicsRectWidget : public QGraphicsWidget -{ -public: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, - QWidget *) - { - painter->fillRect(rect(), Qt::blue); - } -}; -//![16] - -class StateSwitchTransition: public QAbstractTransition -{ -public: - StateSwitchTransition(int rand) - : QAbstractTransition(), - m_rand(rand) - { - } - -protected: -//![14] - virtual bool eventTest(QEvent *event) - { - return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) - && (static_cast(event)->rand() == m_rand); - } -//![14] - - virtual void onTransition(QEvent *) {} - -private: - int m_rand; -}; - -//![10] -class StateSwitcher : public QState -{ - Q_OBJECT -public: - StateSwitcher(QStateMachine *machine) - : QState(machine), m_stateCount(0), m_lastIndex(0) - { } -//![10] - -//![11] - virtual void onEntry(QEvent *) - { - int n; - while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex) - { } - m_lastIndex = n; - machine()->postEvent(new StateSwitchEvent(n)); - } - virtual void onExit(QEvent *) {} -//![11] - -//![12] - void addState(QState *state, QAbstractAnimation *animation) { - StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount); - trans->setTargetState(state); - addTransition(trans); - trans->addAnimation(animation); - } -//![12] - -private: - int m_stateCount; - int m_lastIndex; -}; - -//![13] -QState *createGeometryState(QObject *w1, const QRect &rect1, - QObject *w2, const QRect &rect2, - QObject *w3, const QRect &rect3, - QObject *w4, const QRect &rect4, - QState *parent) -{ - QState *result = new QState(parent); - result->assignProperty(w1, "geometry", rect1); - result->assignProperty(w2, "geometry", rect2); - result->assignProperty(w3, "geometry", rect3); - result->assignProperty(w4, "geometry", rect4); - - return result; -} -//![13] - - -class GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(QGraphicsScene *scene, QWidget *parent = NULL) : QGraphicsView(scene, parent) - { - } - -protected: - virtual void resizeEvent(QResizeEvent *event) - { - fitInView(scene()->sceneRect()); - QGraphicsView::resizeEvent(event); - } -}; - - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - -//![1] - QGraphicsRectWidget *button1 = new QGraphicsRectWidget; - QGraphicsRectWidget *button2 = new QGraphicsRectWidget; - QGraphicsRectWidget *button3 = new QGraphicsRectWidget; - QGraphicsRectWidget *button4 = new QGraphicsRectWidget; - button2->setZValue(1); - button3->setZValue(2); - button4->setZValue(3); - QGraphicsScene scene(0, 0, 300, 300); - scene.setBackgroundBrush(Qt::black); - scene.addItem(button1); - scene.addItem(button2); - scene.addItem(button3); - scene.addItem(button4); -//![1] - GraphicsView window(&scene); - window.setFrameStyle(0); - window.setAlignment(Qt::AlignLeft | Qt::AlignTop); - window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -//![2] - QStateMachine machine; - - QState *group = new QState(); - group->setObjectName("group"); - QTimer timer; - timer.setInterval(1250); - timer.setSingleShot(true); - QObject::connect(group, SIGNAL(entered()), &timer, SLOT(start())); -//![2] - -//![3] - QState *state1; - QState *state2; - QState *state3; - QState *state4; - QState *state5; - QState *state6; - QState *state7; - - state1 = createGeometryState(button1, QRect(100, 0, 50, 50), - button2, QRect(150, 0, 50, 50), - button3, QRect(200, 0, 50, 50), - button4, QRect(250, 0, 50, 50), - group); -//![3] - state2 = createGeometryState(button1, QRect(250, 100, 50, 50), - button2, QRect(250, 150, 50, 50), - button3, QRect(250, 200, 50, 50), - button4, QRect(250, 250, 50, 50), - group); - state3 = createGeometryState(button1, QRect(150, 250, 50, 50), - button2, QRect(100, 250, 50, 50), - button3, QRect(50, 250, 50, 50), - button4, QRect(0, 250, 50, 50), - group); - state4 = createGeometryState(button1, QRect(0, 150, 50, 50), - button2, QRect(0, 100, 50, 50), - button3, QRect(0, 50, 50, 50), - button4, QRect(0, 0, 50, 50), - group); - state5 = createGeometryState(button1, QRect(100, 100, 50, 50), - button2, QRect(150, 100, 50, 50), - button3, QRect(100, 150, 50, 50), - button4, QRect(150, 150, 50, 50), - group); - state6 = createGeometryState(button1, QRect(50, 50, 50, 50), - button2, QRect(200, 50, 50, 50), - button3, QRect(50, 200, 50, 50), - button4, QRect(200, 200, 50, 50), - group); -//![4] - state7 = createGeometryState(button1, QRect(0, 0, 50, 50), - button2, QRect(250, 0, 50, 50), - button3, QRect(0, 250, 50, 50), - button4, QRect(250, 250, 50, 50), - group); - group->setInitialState(state1); -//![4] - -//![5] - QParallelAnimationGroup animationGroup; - QSequentialAnimationGroup *subGroup; - - QPropertyAnimation *anim = new QPropertyAnimation(button4, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - animationGroup.addAnimation(anim); -//![5] - -//![6] - subGroup = new QSequentialAnimationGroup(&animationGroup); - subGroup->addPause(100); - anim = new QPropertyAnimation(button3, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - subGroup->addAnimation(anim); -//![6] - - subGroup = new QSequentialAnimationGroup(&animationGroup); - subGroup->addPause(150); - anim = new QPropertyAnimation(button2, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - subGroup->addAnimation(anim); - - subGroup = new QSequentialAnimationGroup(&animationGroup); - subGroup->addPause(200); - anim = new QPropertyAnimation(button1, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - subGroup->addAnimation(anim); - -//![7] - StateSwitcher *stateSwitcher = new StateSwitcher(&machine); - stateSwitcher->setObjectName("stateSwitcher"); - group->addTransition(&timer, SIGNAL(timeout()), stateSwitcher); - stateSwitcher->addState(state1, &animationGroup); - stateSwitcher->addState(state2, &animationGroup); -//![7] - stateSwitcher->addState(state3, &animationGroup); - stateSwitcher->addState(state4, &animationGroup); - stateSwitcher->addState(state5, &animationGroup); - stateSwitcher->addState(state6, &animationGroup); -//![8] - stateSwitcher->addState(state7, &animationGroup); -//![8] - -//![9] - machine.addState(group); - machine.setInitialState(group); - machine.start(); -//![9] - - window.resize(300, 300); - window.show(); - - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/animation/moveblocks/moveblocks.desktop b/examples/animation/moveblocks/moveblocks.desktop deleted file mode 100644 index 4100f448df..0000000000 --- a/examples/animation/moveblocks/moveblocks.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Move Blocks -Exec=/opt/usr/bin/moveblocks -Icon=moveblocks -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/animation/moveblocks/moveblocks.pro b/examples/animation/moveblocks/moveblocks.pro deleted file mode 100644 index 7c242e31e6..0000000000 --- a/examples/animation/moveblocks/moveblocks.pro +++ /dev/null @@ -1,9 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/moveblocks -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS moveblocks.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/moveblocks -INSTALLS += target sources - -QT += widgets diff --git a/examples/animation/states/accessories-dictionary.png b/examples/animation/states/accessories-dictionary.png deleted file mode 100644 index e9bd55d918..0000000000 Binary files a/examples/animation/states/accessories-dictionary.png and /dev/null differ diff --git a/examples/animation/states/akregator.png b/examples/animation/states/akregator.png deleted file mode 100644 index a086f45ab6..0000000000 Binary files a/examples/animation/states/akregator.png and /dev/null differ diff --git a/examples/animation/states/digikam.png b/examples/animation/states/digikam.png deleted file mode 100644 index 9de9fb2f80..0000000000 Binary files a/examples/animation/states/digikam.png and /dev/null differ diff --git a/examples/animation/states/help-browser.png b/examples/animation/states/help-browser.png deleted file mode 100644 index db92faa4e7..0000000000 Binary files a/examples/animation/states/help-browser.png and /dev/null differ diff --git a/examples/animation/states/k3b.png b/examples/animation/states/k3b.png deleted file mode 100644 index bbcafcfba1..0000000000 Binary files a/examples/animation/states/k3b.png and /dev/null differ diff --git a/examples/animation/states/kchart.png b/examples/animation/states/kchart.png deleted file mode 100644 index 1dd115be87..0000000000 Binary files a/examples/animation/states/kchart.png and /dev/null differ diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp deleted file mode 100644 index faa97ccbd0..0000000000 --- a/examples/animation/states/main.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 - -class Pixmap : public QGraphicsObject -{ - Q_OBJECT -public: - Pixmap(const QPixmap &pix) : QGraphicsObject(), p(pix) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) - { - painter->drawPixmap(QPointF(), p); - } - - QRectF boundingRect() const - { - return QRectF( QPointF(0, 0), p.size()); - } - -private: - QPixmap p; -}; - -class GraphicsView : public QGraphicsView -{ -public: - GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene) - { - } - - virtual void resizeEvent(QResizeEvent *) - { - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(states); - - QApplication app(argc, argv); - - // Text edit and button - QTextEdit *edit = new QTextEdit; - edit->setText("asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " - "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " - "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " - "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!"); - - QPushButton *button = new QPushButton; - QGraphicsProxyWidget *buttonProxy = new QGraphicsProxyWidget; - buttonProxy->setWidget(button); - QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget; - editProxy->setWidget(edit); - - QGroupBox *box = new QGroupBox; - box->setFlat(true); - box->setTitle("Options"); - - QVBoxLayout *layout2 = new QVBoxLayout; - box->setLayout(layout2); - layout2->addWidget(new QRadioButton("Herring")); - layout2->addWidget(new QRadioButton("Blue Parrot")); - layout2->addWidget(new QRadioButton("Petunias")); - layout2->addStretch(); - - QGraphicsProxyWidget *boxProxy = new QGraphicsProxyWidget; - boxProxy->setWidget(box); - - // Parent widget - QGraphicsWidget *widget = new QGraphicsWidget; - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, widget); - layout->addItem(editProxy); - layout->addItem(buttonProxy); - widget->setLayout(layout); - - Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); - Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); - Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); - Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); - Pixmap *p5 = new Pixmap(QPixmap(":/help-browser.png")); - Pixmap *p6 = new Pixmap(QPixmap(":/kchart.png")); - - QGraphicsScene scene(0, 0, 400, 300); - scene.setBackgroundBrush(scene.palette().window()); - scene.addItem(widget); - scene.addItem(boxProxy); - scene.addItem(p1); - scene.addItem(p2); - scene.addItem(p3); - scene.addItem(p4); - scene.addItem(p5); - scene.addItem(p6); - - QStateMachine machine; - QState *state1 = new QState(&machine); - QState *state2 = new QState(&machine); - QState *state3 = new QState(&machine); - machine.setInitialState(state1); - - // State 1 - state1->assignProperty(button, "text", "Switch to state 2"); - state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150)); - state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150)); - state1->assignProperty(p1, "pos", QPointF(68, 200)); // 185)); - state1->assignProperty(p2, "pos", QPointF(168, 200)); // 185)); - state1->assignProperty(p3, "pos", QPointF(268, 200)); // 185)); - state1->assignProperty(p4, "pos", QPointF(68 - 150, 48 - 150)); - state1->assignProperty(p5, "pos", QPointF(168, 48 - 150)); - state1->assignProperty(p6, "pos", QPointF(268 + 150, 48 - 150)); - state1->assignProperty(p1, "rotation", qreal(0)); - state1->assignProperty(p2, "rotation", qreal(0)); - state1->assignProperty(p3, "rotation", qreal(0)); - state1->assignProperty(p4, "rotation", qreal(-270)); - state1->assignProperty(p5, "rotation", qreal(-90)); - state1->assignProperty(p6, "rotation", qreal(270)); - state1->assignProperty(boxProxy, "opacity", qreal(0)); - state1->assignProperty(p1, "opacity", qreal(1)); - state1->assignProperty(p2, "opacity", qreal(1)); - state1->assignProperty(p3, "opacity", qreal(1)); - state1->assignProperty(p4, "opacity", qreal(0)); - state1->assignProperty(p5, "opacity", qreal(0)); - state1->assignProperty(p6, "opacity", qreal(0)); - - // State 2 - state2->assignProperty(button, "text", "Switch to state 3"); - state2->assignProperty(widget, "geometry", QRectF(200, 150, 200, 150)); - state2->assignProperty(box, "geometry", QRect(9, 150, 190, 150)); - state2->assignProperty(p1, "pos", QPointF(68 - 150, 185 + 150)); - state2->assignProperty(p2, "pos", QPointF(168, 185 + 150)); - state2->assignProperty(p3, "pos", QPointF(268 + 150, 185 + 150)); - state2->assignProperty(p4, "pos", QPointF(64, 48)); - state2->assignProperty(p5, "pos", QPointF(168, 48)); - state2->assignProperty(p6, "pos", QPointF(268, 48)); - state2->assignProperty(p1, "rotation", qreal(-270)); - state2->assignProperty(p2, "rotation", qreal(90)); - state2->assignProperty(p3, "rotation", qreal(270)); - state2->assignProperty(p4, "rotation", qreal(0)); - state2->assignProperty(p5, "rotation", qreal(0)); - state2->assignProperty(p6, "rotation", qreal(0)); - state2->assignProperty(boxProxy, "opacity", qreal(1)); - state2->assignProperty(p1, "opacity", qreal(0)); - state2->assignProperty(p2, "opacity", qreal(0)); - state2->assignProperty(p3, "opacity", qreal(0)); - state2->assignProperty(p4, "opacity", qreal(1)); - state2->assignProperty(p5, "opacity", qreal(1)); - state2->assignProperty(p6, "opacity", qreal(1)); - - // State 3 - state3->assignProperty(button, "text", "Switch to state 1"); - state3->assignProperty(p1, "pos", QPointF(0, 5)); - state3->assignProperty(p2, "pos", QPointF(0, 5 + 64 + 5)); - state3->assignProperty(p3, "pos", QPointF(5, 5 + (64 + 5) + 64)); - state3->assignProperty(p4, "pos", QPointF(5 + 64 + 5, 5)); - state3->assignProperty(p5, "pos", QPointF(5 + 64 + 5, 5 + 64 + 5)); - state3->assignProperty(p6, "pos", QPointF(5 + 64 + 5, 5 + (64 + 5) + 64)); - state3->assignProperty(widget, "geometry", QRectF(138, 5, 400 - 138, 200)); - state3->assignProperty(box, "geometry", QRect(5, 205, 400, 90)); - state3->assignProperty(p1, "opacity", qreal(1)); - state3->assignProperty(p2, "opacity", qreal(1)); - state3->assignProperty(p3, "opacity", qreal(1)); - state3->assignProperty(p4, "opacity", qreal(1)); - state3->assignProperty(p5, "opacity", qreal(1)); - state3->assignProperty(p6, "opacity", qreal(1)); - - QAbstractTransition *t1 = state1->addTransition(button, SIGNAL(clicked()), state2); - QSequentialAnimationGroup *animation1SubGroup = new QSequentialAnimationGroup; - animation1SubGroup->addPause(250); - animation1SubGroup->addAnimation(new QPropertyAnimation(box, "geometry")); - t1->addAnimation(animation1SubGroup); - t1->addAnimation(new QPropertyAnimation(widget, "geometry")); - t1->addAnimation(new QPropertyAnimation(p1, "pos")); - t1->addAnimation(new QPropertyAnimation(p2, "pos")); - t1->addAnimation(new QPropertyAnimation(p3, "pos")); - t1->addAnimation(new QPropertyAnimation(p4, "pos")); - t1->addAnimation(new QPropertyAnimation(p5, "pos")); - t1->addAnimation(new QPropertyAnimation(p6, "pos")); - t1->addAnimation(new QPropertyAnimation(p1, "rotation")); - t1->addAnimation(new QPropertyAnimation(p2, "rotation")); - t1->addAnimation(new QPropertyAnimation(p3, "rotation")); - t1->addAnimation(new QPropertyAnimation(p4, "rotation")); - t1->addAnimation(new QPropertyAnimation(p5, "rotation")); - t1->addAnimation(new QPropertyAnimation(p6, "rotation")); - t1->addAnimation(new QPropertyAnimation(p1, "opacity")); - t1->addAnimation(new QPropertyAnimation(p2, "opacity")); - t1->addAnimation(new QPropertyAnimation(p3, "opacity")); - t1->addAnimation(new QPropertyAnimation(p4, "opacity")); - t1->addAnimation(new QPropertyAnimation(p5, "opacity")); - t1->addAnimation(new QPropertyAnimation(p6, "opacity")); - - QAbstractTransition *t2 = state2->addTransition(button, SIGNAL(clicked()), state3); - t2->addAnimation(new QPropertyAnimation(box, "geometry")); - t2->addAnimation(new QPropertyAnimation(widget, "geometry")); - t2->addAnimation(new QPropertyAnimation(p1, "pos")); - t2->addAnimation(new QPropertyAnimation(p2, "pos")); - t2->addAnimation(new QPropertyAnimation(p3, "pos")); - t2->addAnimation(new QPropertyAnimation(p4, "pos")); - t2->addAnimation(new QPropertyAnimation(p5, "pos")); - t2->addAnimation(new QPropertyAnimation(p6, "pos")); - t2->addAnimation(new QPropertyAnimation(p1, "rotation")); - t2->addAnimation(new QPropertyAnimation(p2, "rotation")); - t2->addAnimation(new QPropertyAnimation(p3, "rotation")); - t2->addAnimation(new QPropertyAnimation(p4, "rotation")); - t2->addAnimation(new QPropertyAnimation(p5, "rotation")); - t2->addAnimation(new QPropertyAnimation(p6, "rotation")); - t2->addAnimation(new QPropertyAnimation(p1, "opacity")); - t2->addAnimation(new QPropertyAnimation(p2, "opacity")); - t2->addAnimation(new QPropertyAnimation(p3, "opacity")); - t2->addAnimation(new QPropertyAnimation(p4, "opacity")); - t2->addAnimation(new QPropertyAnimation(p5, "opacity")); - t2->addAnimation(new QPropertyAnimation(p6, "opacity")); - - QAbstractTransition *t3 = state3->addTransition(button, SIGNAL(clicked()), state1); - t3->addAnimation(new QPropertyAnimation(box, "geometry")); - t3->addAnimation(new QPropertyAnimation(widget, "geometry")); - t3->addAnimation(new QPropertyAnimation(p1, "pos")); - t3->addAnimation(new QPropertyAnimation(p2, "pos")); - t3->addAnimation(new QPropertyAnimation(p3, "pos")); - t3->addAnimation(new QPropertyAnimation(p4, "pos")); - t3->addAnimation(new QPropertyAnimation(p5, "pos")); - t3->addAnimation(new QPropertyAnimation(p6, "pos")); - t3->addAnimation(new QPropertyAnimation(p1, "rotation")); - t3->addAnimation(new QPropertyAnimation(p2, "rotation")); - t3->addAnimation(new QPropertyAnimation(p3, "rotation")); - t3->addAnimation(new QPropertyAnimation(p4, "rotation")); - t3->addAnimation(new QPropertyAnimation(p5, "rotation")); - t3->addAnimation(new QPropertyAnimation(p6, "rotation")); - t3->addAnimation(new QPropertyAnimation(p1, "opacity")); - t3->addAnimation(new QPropertyAnimation(p2, "opacity")); - t3->addAnimation(new QPropertyAnimation(p3, "opacity")); - t3->addAnimation(new QPropertyAnimation(p4, "opacity")); - t3->addAnimation(new QPropertyAnimation(p5, "opacity")); - t3->addAnimation(new QPropertyAnimation(p6, "opacity")); - - machine.start(); - - GraphicsView view(&scene); - - view.show(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/animation/states/states.desktop b/examples/animation/states/states.desktop deleted file mode 100644 index 8429979f23..0000000000 --- a/examples/animation/states/states.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=States -Exec=/opt/usr/bin/states -Icon=states -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/animation/states/states.pro b/examples/animation/states/states.pro deleted file mode 100644 index adf0e8d58c..0000000000 --- a/examples/animation/states/states.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES += main.cpp -RESOURCES += states.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/states -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS states.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/states -INSTALLS += target sources - -QT += widgets diff --git a/examples/animation/states/states.qrc b/examples/animation/states/states.qrc deleted file mode 100644 index 60ab3f7a60..0000000000 --- a/examples/animation/states/states.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - accessories-dictionary.png - akregator.png - digikam.png - help-browser.png - k3b.png - kchart.png - - diff --git a/examples/animation/stickman/animation.cpp b/examples/animation/stickman/animation.cpp deleted file mode 100644 index afdfae6eca..0000000000 --- a/examples/animation/stickman/animation.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "animation.h" - -#include -#include -#include -#include - -class Frame -{ -public: - Frame() { - } - - int nodeCount() const - { - return m_nodePositions.size(); - } - - void setNodeCount(int nodeCount) - { - m_nodePositions.resize(nodeCount); - } - - QPointF nodePos(int idx) const - { - return m_nodePositions.at(idx); - } - - void setNodePos(int idx, const QPointF &pos) - { - m_nodePositions[idx] = pos; - } - -private: - QVector m_nodePositions; -}; - -Animation::Animation() -{ - m_currentFrame = 0; - m_frames.append(new Frame); -} - -Animation::~Animation() -{ - qDeleteAll(m_frames); -} - -void Animation::setTotalFrames(int totalFrames) -{ - while (m_frames.size() < totalFrames) - m_frames.append(new Frame); - - while (totalFrames < m_frames.size()) - delete m_frames.takeLast(); -} - -int Animation::totalFrames() const -{ - return m_frames.size(); -} - -void Animation::setCurrentFrame(int currentFrame) -{ - m_currentFrame = qMax(qMin(currentFrame, totalFrames()-1), 0); -} - -int Animation::currentFrame() const -{ - return m_currentFrame; -} - -void Animation::setNodeCount(int nodeCount) -{ - Frame *frame = m_frames.at(m_currentFrame); - frame->setNodeCount(nodeCount); -} - -int Animation::nodeCount() const -{ - Frame *frame = m_frames.at(m_currentFrame); - return frame->nodeCount(); -} - -void Animation::setNodePos(int idx, const QPointF &pos) -{ - Frame *frame = m_frames.at(m_currentFrame); - frame->setNodePos(idx, pos); -} - -QPointF Animation::nodePos(int idx) const -{ - Frame *frame = m_frames.at(m_currentFrame); - return frame->nodePos(idx); -} - -QString Animation::name() const -{ - return m_name; -} - -void Animation::setName(const QString &name) -{ - m_name = name; -} - -void Animation::save(QIODevice *device) const -{ - QDataStream stream(device); - stream << m_name; - stream << m_frames.size(); - foreach (Frame *frame, m_frames) { - stream << frame->nodeCount(); - for (int i=0; inodeCount(); ++i) - stream << frame->nodePos(i); - } -} - -void Animation::load(QIODevice *device) -{ - if (!m_frames.isEmpty()) - qDeleteAll(m_frames); - - m_frames.clear(); - - QDataStream stream(device); - stream >> m_name; - - int frameCount; - stream >> frameCount; - - for (int i=0; i> nodeCount; - - Frame *frame = new Frame; - frame->setNodeCount(nodeCount); - - for (int j=0; j> pos; - - frame->setNodePos(j, pos); - } - - m_frames.append(frame); - } -} diff --git a/examples/animation/stickman/animation.h b/examples/animation/stickman/animation.h deleted file mode 100644 index d5dab530e6..0000000000 --- a/examples/animation/stickman/animation.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 ANIMATION_H -#define ANIMATION_H - -#include -#include -#include - -class Frame; -QT_BEGIN_NAMESPACE -class QIODevice; -QT_END_NAMESPACE -class Animation -{ -public: - Animation(); - ~Animation(); - - void setTotalFrames(int totalFrames); - int totalFrames() const; - - void setCurrentFrame(int currentFrame); - int currentFrame() const; - - void setNodeCount(int nodeCount); - int nodeCount() const; - - void setNodePos(int idx, const QPointF &pos); - QPointF nodePos(int idx) const; - - QString name() const; - void setName(const QString &name); - - void save(QIODevice *device) const; - void load(QIODevice *device); - -private: - QString m_name; - QList m_frames; - int m_currentFrame; -}; - -#endif diff --git a/examples/animation/stickman/animations/chilling.bin b/examples/animation/stickman/animations/chilling.bin deleted file mode 100644 index a81fc7a18c..0000000000 Binary files a/examples/animation/stickman/animations/chilling.bin and /dev/null differ diff --git a/examples/animation/stickman/animations/dancing.bin b/examples/animation/stickman/animations/dancing.bin deleted file mode 100644 index 462f66f89b..0000000000 Binary files a/examples/animation/stickman/animations/dancing.bin and /dev/null differ diff --git a/examples/animation/stickman/animations/dead.bin b/examples/animation/stickman/animations/dead.bin deleted file mode 100644 index 9859b4b4cd..0000000000 Binary files a/examples/animation/stickman/animations/dead.bin and /dev/null differ diff --git a/examples/animation/stickman/animations/jumping.bin b/examples/animation/stickman/animations/jumping.bin deleted file mode 100644 index 12661a15f8..0000000000 Binary files a/examples/animation/stickman/animations/jumping.bin and /dev/null differ diff --git a/examples/animation/stickman/graphicsview.cpp b/examples/animation/stickman/graphicsview.cpp deleted file mode 100644 index 134fb8acf1..0000000000 --- a/examples/animation/stickman/graphicsview.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "graphicsview.h" -#include "stickman.h" - -#include -#include -#include - -GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent), m_editor(0) {} - -void GraphicsView::keyPressEvent(QKeyEvent *e) -{ - if (e->key() == Qt::Key_Escape) - close(); - emit keyPressed(Qt::Key(e->key())); -} - -void GraphicsView::resizeEvent(QResizeEvent *) -{ - fitInView(scene()->sceneRect()); -} diff --git a/examples/animation/stickman/graphicsview.h b/examples/animation/stickman/graphicsview.h deleted file mode 100644 index 38bf6e1eb6..0000000000 --- a/examples/animation/stickman/graphicsview.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 GRAPHICSVIEW_H -#define GRAPHICSVIEW - -#include - -class MainWindow; -class GraphicsView: public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(QWidget *parent = 0); - -protected: - virtual void resizeEvent(QResizeEvent *event); - void keyPressEvent(QKeyEvent *); - -signals: - void keyPressed(int key); - -private: - MainWindow *m_editor; -}; - -#endif diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp deleted file mode 100644 index 53249ccd6f..0000000000 --- a/examples/animation/stickman/lifecycle.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "lifecycle.h" -#include "stickman.h" -#include "node.h" -#include "animation.h" -#include "graphicsview.h" - -#include -#include - -class KeyPressTransition: public QSignalTransition -{ -public: - KeyPressTransition(GraphicsView *receiver, Qt::Key key) - : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) - { - } - KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target) - : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) - { - setTargetState(target); - } - - virtual bool eventTest(QEvent *e) - { - if (QSignalTransition::eventTest(e)) { - QVariant key = static_cast(e)->arguments().at(0); - return (key.toInt() == int(m_key)); - } - - return false; - } -private: - Qt::Key m_key; -}; - -//! [4] -class LightningStrikesTransition: public QEventTransition -{ -public: - LightningStrikesTransition(QAbstractState *target) - : QEventTransition(this, QEvent::Timer) - { - setTargetState(target); - qsrand((uint)QDateTime::currentDateTime().toTime_t()); - startTimer(1000); - } - - virtual bool eventTest(QEvent *e) - { - return QEventTransition::eventTest(e) && ((qrand() % 50) == 0); - } -}; -//! [4] - -LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) - : m_stickMan(stickMan), m_keyReceiver(keyReceiver) -{ - // Create animation group to be used for all transitions - m_animationGroup = new QParallelAnimationGroup(); - const int stickManNodeCount = m_stickMan->nodeCount(); - for (int i=0; inode(i), "pos"); - m_animationGroup->addAnimation(pa); - } - - // Set up initial state graph -//! [3] - m_machine = new QStateMachine(); - m_machine->addDefaultAnimation(m_animationGroup); -//! [3] - - m_alive = new QState(m_machine); - m_alive->setObjectName("alive"); - - // Make it blink when lightning strikes before entering dead animation - QState *lightningBlink = new QState(m_machine); - lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::white); - lightningBlink->assignProperty(m_stickMan, "penColor", Qt::black); - lightningBlink->assignProperty(m_stickMan, "fillColor", Qt::white); - lightningBlink->assignProperty(m_stickMan, "isDead", true); - -//! [5] - QTimer *timer = new QTimer(lightningBlink); - timer->setSingleShot(true); - timer->setInterval(100); - QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start())); - QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop())); -//! [5] - - m_dead = new QState(m_machine); - m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::black); - m_dead->assignProperty(m_stickMan, "penColor", Qt::white); - m_dead->assignProperty(m_stickMan, "fillColor", Qt::black); - m_dead->setObjectName("dead"); - - // Idle state (sets no properties) - m_idle = new QState(m_alive); - m_idle->setObjectName("idle"); - - m_alive->setInitialState(m_idle); - - // Lightning strikes at random - m_alive->addTransition(new LightningStrikesTransition(lightningBlink)); -//! [0] - lightningBlink->addTransition(timer, SIGNAL(timeout()), m_dead); -//! [0] - - m_machine->setInitialState(m_alive); -} - -void LifeCycle::setDeathAnimation(const QString &fileName) -{ - QState *deathAnimation = makeState(m_dead, fileName); - m_dead->setInitialState(deathAnimation); -} - -void LifeCycle::start() -{ - m_machine->start(); -} - -void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sender, const char *signal) -{ - QState *state = makeState(m_alive, fileName); - m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state)); - - if((sender != NULL) || (signal != NULL)) { - m_alive->addTransition(sender, signal, state); - } -} - -QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName) -{ - QState *topLevel = new QState(parentState); - - Animation animation; - { - QFile file(animationFileName); - if (file.open(QIODevice::ReadOnly)) - animation.load(&file); - } - - const int frameCount = animation.totalFrames(); - QState *previousState = 0; - for (int i=0; iassignProperty(m_stickMan->node(j), "pos", animation.nodePos(j)); -//! [1] - - frameState->setObjectName(QString::fromLatin1("frame %0").arg(i)); - if (previousState == 0) - topLevel->setInitialState(frameState); - else -//! [2] - previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState); -//! [2] - - previousState = frameState; - } - - // Loop - previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState()); - - return topLevel; - -} - -LifeCycle::~LifeCycle() -{ - delete m_machine; - delete m_animationGroup; -} diff --git a/examples/animation/stickman/lifecycle.h b/examples/animation/stickman/lifecycle.h deleted file mode 100644 index 8e8bb50659..0000000000 --- a/examples/animation/stickman/lifecycle.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 LIFECYCLE_H -#define LIFECYCLE_H - -#include - -class StickMan; -QT_BEGIN_NAMESPACE -class QStateMachine; -class QAnimationGroup; -class QState; -class QAbstractState; -class QAbstractTransition; -class QObject; -QT_END_NAMESPACE -class GraphicsView; -class LifeCycle -{ -public: - LifeCycle(StickMan *stickMan, GraphicsView *keyEventReceiver); - ~LifeCycle(); - - void setDeathAnimation(const QString &fileName); - void addActivity(const QString &fileName, Qt::Key key, QObject *sender = NULL, const char *signal = NULL); - - void start(); - -private: - QState *makeState(QState *parentState, const QString &animationFileName); - - StickMan *m_stickMan; - QStateMachine *m_machine; - QAnimationGroup *m_animationGroup; - GraphicsView *m_keyReceiver; - - QState *m_alive; - QState *m_dead; - QState *m_idle; -}; - -#endif diff --git a/examples/animation/stickman/main.cpp b/examples/animation/stickman/main.cpp deleted file mode 100644 index 3e49da8de3..0000000000 --- a/examples/animation/stickman/main.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "animation.h" -#include "node.h" -#include "lifecycle.h" -#include "stickman.h" -#include "graphicsview.h" -#include "rectbutton.h" - -#include -#include - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(stickman); - QApplication app(argc, argv); - - StickMan *stickMan = new StickMan; - stickMan->setDrawSticks(false); - - QGraphicsTextItem *textItem = new QGraphicsTextItem(); - textItem->setHtml("Stickman" - "

" - "Tell the stickman what to do!" - "

" - "

" - "

  • Press J to make the stickman jump.
  • " - "
  • Press D to make the stickman dance.
  • " - "
  • Press C to make him chill out.
  • " - "
  • When you are done, press Escape.
  • " - "

    " - "

    If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again." - "

    "); - qreal w = textItem->boundingRect().width(); - QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect(); - textItem->setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0); - - QGraphicsScene scene; - scene.addItem(stickMan); - - scene.addItem(textItem); - scene.setBackgroundBrush(Qt::black); - - GraphicsView view; - view.setRenderHints(QPainter::Antialiasing); - view.setTransformationAnchor(QGraphicsView::NoAnchor); - view.setScene(&scene); - - QRectF sceneRect = scene.sceneRect(); - // making enough room in the scene for stickman to jump and die - view.resize(sceneRect.width() + 100, sceneRect.height() + 100); - view.setSceneRect(sceneRect); - - view.show(); - view.setFocus(); - - LifeCycle cycle(stickMan, &view); - cycle.setDeathAnimation(":/animations/dead.bin"); - - cycle.addActivity(":/animations/jumping.bin", Qt::Key_J); - cycle.addActivity(":/animations/dancing.bin", Qt::Key_D); - cycle.addActivity(":/animations/chilling.bin", Qt::Key_C); - - cycle.start(); - - - return app.exec(); -} diff --git a/examples/animation/stickman/node.cpp b/examples/animation/stickman/node.cpp deleted file mode 100644 index 2de34b379c..0000000000 --- a/examples/animation/stickman/node.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "node.h" -#include "stickman.h" - -#include -#include -#include - -Node::Node(const QPointF &pos, QGraphicsItem *parent) - : QGraphicsObject(parent), m_dragging(false) -{ - setPos(pos); - setFlag(QGraphicsItem::ItemSendsGeometryChanges); -} - -Node::~Node() -{ -} - -QRectF Node::boundingRect() const -{ - return QRectF(-6.0, -6.0, 12.0, 12.0); -} - -void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - painter->setPen(Qt::white); - painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0); -} - -QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == QGraphicsItem::ItemPositionChange) - emit positionChanged(); - - return QGraphicsObject::itemChange(change, value); -} - -void Node::mousePressEvent(QGraphicsSceneMouseEvent *) -{ - m_dragging = true; -} - -void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (m_dragging) - setPos(mapToParent(event->pos())); -} - -void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *) -{ - m_dragging = false; -} diff --git a/examples/animation/stickman/node.h b/examples/animation/stickman/node.h deleted file mode 100644 index ae6e2a3ed0..0000000000 --- a/examples/animation/stickman/node.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 NODE_H -#define NODE_H - -#include - -class Node: public QGraphicsObject -{ - Q_OBJECT -public: - Node(const QPointF &pos, QGraphicsItem *parent = 0); - ~Node(); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -signals: - void positionChanged(); - -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - void mousePressEvent(QGraphicsSceneMouseEvent *); - void mouseMoveEvent(QGraphicsSceneMouseEvent *); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *); - -private: - bool m_dragging; -}; - -#endif diff --git a/examples/animation/stickman/rectbutton.cpp b/examples/animation/stickman/rectbutton.cpp deleted file mode 100644 index 8b17600ef5..0000000000 --- a/examples/animation/stickman/rectbutton.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "rectbutton.h" -#include - -RectButton::RectButton(QString buttonText) : m_ButtonText(buttonText) -{ -} - - -RectButton::~RectButton() -{ -} - - -void RectButton::mousePressEvent (QGraphicsSceneMouseEvent *) -{ - emit clicked(); -} - - -QRectF RectButton::boundingRect() const -{ - return QRectF(0.0, 0.0, 90.0, 40.0); -} - - -void RectButton::paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */) -{ - painter->setBrush(Qt::gray); - painter->drawRoundedRect(boundingRect(), 5, 5); - - painter->setPen(Qt::white); - painter->drawText(20, 25, m_ButtonText); -} diff --git a/examples/animation/stickman/rectbutton.h b/examples/animation/stickman/rectbutton.h deleted file mode 100644 index ead8f21420..0000000000 --- a/examples/animation/stickman/rectbutton.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 RECTBUTTON_H -#define RECTBUTTON_H - -#include - -class RectButton : public QGraphicsObject -{ - Q_OBJECT -public: - RectButton(QString buttonText); - ~RectButton(); - - virtual QRectF boundingRect() const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -protected: - QString m_ButtonText; - - virtual void mousePressEvent (QGraphicsSceneMouseEvent *event); - -signals: - void clicked(); -}; - -#endif // RECTBUTTON_H diff --git a/examples/animation/stickman/stickman.cpp b/examples/animation/stickman/stickman.cpp deleted file mode 100644 index 667ed7d141..0000000000 --- a/examples/animation/stickman/stickman.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 "stickman.h" -#include "node.h" - -#include -#include - -#define _USE_MATH_DEFINES -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -static const qreal Coords[NodeCount * 2] = { - 0.0, -150.0, // head, #0 - - 0.0, -100.0, // body pentagon, top->bottom, left->right, #1 - 5 - -50.0, -50.0, - 50.0, -50.0, - -25.0, 50.0, - 25.0, 50.0, - - -100.0, 0.0, // right arm, #6 - 7 - -125.0, 50.0, - - 100.0, 0.0, // left arm, #8 - 9 - 125.0, 50.0, - - -35.0, 75.0, // lower body, #10 - 11 - 35.0, 75.0, - - -25.0, 200.0, // right leg, #12 - 13 - -30.0, 300.0, - - 25.0, 200.0, // left leg, #14 - 15 - 30.0, 300.0 - -}; - -static const int Bones[BoneCount * 2] = { - 0, 1, // neck - - 1, 2, // body - 1, 3, - 1, 4, - 1, 5, - 2, 3, - 2, 4, - 2, 5, - 3, 4, - 3, 5, - 4, 5, - - 2, 6, // right arm - 6, 7, - - 3, 8, // left arm - 8, 9, - - 4, 10, // lower body - 4, 11, - 5, 10, - 5, 11, - 10, 11, - - 10, 12, // right leg - 12, 13, - - 11, 14, // left leg - 14, 15 - -}; - -StickMan::StickMan() -{ - m_sticks = true; - m_isDead = false; - m_pixmap = QPixmap("images/head.png"); - m_penColor = Qt::white; - m_fillColor = Qt::black; - - // Set up start position of limbs - for (int i=0; ipos() - node2->pos(); - m_perfectBoneLengths[i] = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); - } - - startTimer(10); -} - -StickMan::~StickMan() -{ -} - -void StickMan::childPositionChanged() -{ - prepareGeometryChange(); -} - -void StickMan::setDrawSticks(bool on) -{ - m_sticks = on; - for (int i=0;isetVisible(on); - } -} - -QRectF StickMan::boundingRect() const -{ - // account for head radius=50.0 plus pen which is 5.0 - return childrenBoundingRect().adjusted(-55.0, -55.0, 55.0, 55.0); -} - -int StickMan::nodeCount() const -{ - return NodeCount; -} - -Node *StickMan::node(int idx) const -{ - if (idx >= 0 && idx < NodeCount) - return m_nodes[idx]; - else - return 0; -} - -void StickMan::timerEvent(QTimerEvent *) -{ - update(); -} - -void StickMan::stabilize() -{ - static const qreal threshold = 0.001; - - for (int i=0; ipos(); - QPointF pos2 = node2->pos(); - - QPointF dist = pos1 - pos2; - qreal length = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); - qreal diff = (length - m_perfectBoneLengths[i]) / length; - - QPointF p = dist * (0.5 * diff); - if (p.x() > threshold && p.y() > threshold) { - pos1 -= p; - pos2 += p; - - node1->setPos(pos1); - node2->setPos(pos2); - } - } -} - -QPointF StickMan::posFor(int idx) const -{ - return m_nodes[idx]->pos(); -} - -//#include -void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - /* static int frames = 0; - static QTime time; - if (frames++ % 100 == 0) { - frames = 1; - time.restart(); - } - - if (time.elapsed() > 0) { - painter->setPen(Qt::white); - painter->drawText(0, 0, QString::number(frames / (time.elapsed() / 1000.0))); - }*/ - - stabilize(); - if (m_sticks) { - painter->setPen(Qt::white); - for (int i=0; idrawLine(node1->pos(), node2->pos()); - } - } else { - // first bone is neck and will be used for head - - QPainterPath path; - path.moveTo(posFor(0)); - path.lineTo(posFor(1)); - - // right arm - path.lineTo(posFor(2)); - path.lineTo(posFor(6)); - path.lineTo(posFor(7)); - - // left arm - path.moveTo(posFor(3)); - path.lineTo(posFor(8)); - path.lineTo(posFor(9)); - - // body - path.moveTo(posFor(2)); - path.lineTo(posFor(4)); - path.lineTo(posFor(10)); - path.lineTo(posFor(11)); - path.lineTo(posFor(5)); - path.lineTo(posFor(3)); - path.lineTo(posFor(1)); - - // right leg - path.moveTo(posFor(10)); - path.lineTo(posFor(12)); - path.lineTo(posFor(13)); - - // left leg - path.moveTo(posFor(11)); - path.lineTo(posFor(14)); - path.lineTo(posFor(15)); - - painter->setPen(QPen(m_penColor, 5.0, Qt::SolidLine, Qt::RoundCap)); - painter->drawPath(path); - - { - int n1 = Bones[0]; - int n2 = Bones[1]; - Node *node1 = m_nodes[n1]; - Node *node2 = m_nodes[n2]; - - QPointF dist = node2->pos() - node1->pos(); - - qreal sinAngle = dist.x() / sqrt(pow(dist.x(), 2) + pow(dist.y(), 2)); - qreal angle = asin(sinAngle) * 180.0 / M_PI; - - QPointF headPos = node1->pos(); - painter->translate(headPos); - painter->rotate(-angle); - - painter->setBrush(m_fillColor); - painter->drawEllipse(QPointF(0,0), 50.0, 50.0); - - painter->setBrush(m_penColor); - painter->setPen(QPen(m_penColor, 2.5, Qt::SolidLine, Qt::RoundCap)); - - // eyes - if (m_isDead) { - painter->drawLine(-30.0, -30.0, -20.0, -20.0); - painter->drawLine(-20.0, -30.0, -30.0, -20.0); - - painter->drawLine(20.0, -30.0, 30.0, -20.0); - painter->drawLine(30.0, -30.0, 20.0, -20.0); - } else { - painter->drawChord(QRectF(-30.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16); - painter->drawChord(QRectF(5.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16); - } - - // mouth - if (m_isDead) { - painter->drawLine(-28.0, 2.0, 29.0, 2.0); - } else { - painter->setBrush(QColor(128, 0, 64 )); - painter->drawChord(QRectF(-28.0, 2.0-55.0/2.0, 57.0, 55.0), 0.0, -180.0*16); - } - - // pupils - if (!m_isDead) { - painter->setPen(QPen(m_fillColor, 1.0, Qt::SolidLine, Qt::RoundCap)); - painter->setBrush(m_fillColor); - painter->drawEllipse(QPointF(-12.0, -25.0), 5.0, 5.0); - painter->drawEllipse(QPointF(22.0, -25.0), 5.0, 5.0); - } - } - } -} - - - diff --git a/examples/animation/stickman/stickman.desktop b/examples/animation/stickman/stickman.desktop deleted file mode 100644 index 1722d4db3e..0000000000 --- a/examples/animation/stickman/stickman.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Stickman -Exec=/opt/usr/bin/stickman -Icon=stickman -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/animation/stickman/stickman.h b/examples/animation/stickman/stickman.h deleted file mode 100644 index f50ed1a6c2..0000000000 --- a/examples/animation/stickman/stickman.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 STICKMAN_H -#define STICKMAN_H - -#include - -static const int NodeCount = 16; -static const int BoneCount = 24; - -class Node; -QT_BEGIN_NAMESPACE -QT_END_NAMESPACE -class StickMan: public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY(QColor penColor WRITE setPenColor READ penColor) - Q_PROPERTY(QColor fillColor WRITE setFillColor READ fillColor) - Q_PROPERTY(bool isDead WRITE setIsDead READ isDead) -public: - StickMan(); - ~StickMan(); - - virtual QRectF boundingRect() const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - - int nodeCount() const; - Node *node(int idx) const; - - void setDrawSticks(bool on); - bool drawSticks() const { return m_sticks; } - - QColor penColor() const { return m_penColor; } - void setPenColor(const QColor &color) { m_penColor = color; } - - QColor fillColor() const { return m_fillColor; } - void setFillColor(const QColor &color) { m_fillColor = color; } - - bool isDead() const { return m_isDead; } - void setIsDead(bool isDead) { m_isDead = isDead; } - -public slots: - void stabilize(); - void childPositionChanged(); - -protected: - void timerEvent(QTimerEvent *e); - -private: - - QPointF posFor(int idx) const; - - Node *m_nodes[NodeCount]; - qreal m_perfectBoneLengths[BoneCount]; - - uint m_sticks : 1; - uint m_isDead : 1; - uint m_reserved : 30; - - QPixmap m_pixmap; - QColor m_penColor; - QColor m_fillColor; -}; - -#endif // STICKMAN_H diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro deleted file mode 100644 index 43aaec113d..0000000000 --- a/examples/animation/stickman/stickman.pro +++ /dev/null @@ -1,23 +0,0 @@ -HEADERS += stickman.h \ - animation.h \ - node.h \ - lifecycle.h \ - graphicsview.h \ - rectbutton.h -SOURCES += main.cpp \ - stickman.cpp \ - animation.cpp \ - node.cpp \ - lifecycle.cpp \ - graphicsview.cpp \ - rectbutton.cpp - -RESOURCES += stickman.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/stickman -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS stickman.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/stickman -INSTALLS += target sources - -QT += widgets diff --git a/examples/animation/stickman/stickman.qrc b/examples/animation/stickman/stickman.qrc deleted file mode 100644 index 4cf3ba3828..0000000000 --- a/examples/animation/stickman/stickman.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - animations/chilling.bin - animations/dancing.bin - animations/dead.bin - animations/jumping.bin - - diff --git a/examples/animation/sub-attaq/animationmanager.cpp b/examples/animation/sub-attaq/animationmanager.cpp deleted file mode 100644 index 7dcb9dfb50..0000000000 --- a/examples/animation/sub-attaq/animationmanager.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "animationmanager.h" - -//Qt -#include -#include - -// the universe's only animation manager -AnimationManager *AnimationManager::instance = 0; - -AnimationManager::AnimationManager() -{ -} - -AnimationManager *AnimationManager::self() -{ - if (!instance) - instance = new AnimationManager; - return instance; -} - -void AnimationManager::registerAnimation(QAbstractAnimation *anim) -{ - QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); - animations.append(anim); -} - -void AnimationManager::unregisterAnimation_helper(QObject *obj) -{ - unregisterAnimation(static_cast(obj)); -} - -void AnimationManager::unregisterAnimation(QAbstractAnimation *anim) -{ - QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); - animations.removeAll(anim); -} - -void AnimationManager::unregisterAllAnimations() -{ - animations.clear(); -} - -void AnimationManager::pauseAll() -{ - foreach (QAbstractAnimation* animation, animations) { - if (animation->state() == QAbstractAnimation::Running) - animation->pause(); - } -} -void AnimationManager::resumeAll() -{ - foreach (QAbstractAnimation* animation, animations) { - if (animation->state() == QAbstractAnimation::Paused) - animation->resume(); - } -} diff --git a/examples/animation/sub-attaq/animationmanager.h b/examples/animation/sub-attaq/animationmanager.h deleted file mode 100644 index 6587e39b14..0000000000 --- a/examples/animation/sub-attaq/animationmanager.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ANIMATIONMANAGER_H -#define ANIMATIONMANAGER_H - -#include - -QT_BEGIN_NAMESPACE -class QAbstractAnimation; -QT_END_NAMESPACE - -class AnimationManager : public QObject -{ -Q_OBJECT -public: - AnimationManager(); - void registerAnimation(QAbstractAnimation *anim); - void unregisterAnimation(QAbstractAnimation *anim); - void unregisterAllAnimations(); - static AnimationManager *self(); - -public slots: - void pauseAll(); - void resumeAll(); - -private slots: - void unregisterAnimation_helper(QObject *obj); - -private: - static AnimationManager *instance; - QList animations; -}; - -#endif // ANIMATIONMANAGER_H diff --git a/examples/animation/sub-attaq/boat.cpp b/examples/animation/sub-attaq/boat.cpp deleted file mode 100644 index 88332dbfe7..0000000000 --- a/examples/animation/sub-attaq/boat.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "boat.h" -#include "boat_p.h" -#include "bomb.h" -#include "pixmapitem.h" -#include "graphicsscene.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -//Qt -#include -#include -#include -#include -#include -#include - -static QAbstractAnimation *setupDestroyAnimation(Boat *boat) -{ - QSequentialAnimationGroup *group = new QSequentialAnimationGroup(boat); - for (int i = 1; i <= 4; i++) { - PixmapItem *step = new PixmapItem(QString("explosion/boat/step%1").arg(i),GraphicsScene::Big, boat); - step->setZValue(6); - step->setOpacity(0); - - //fade-in - QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity"); - anim->setEndValue(1); - anim->setDuration(100); - group->insertAnimation(i-1, anim); - - //and then fade-out - QPropertyAnimation *anim2 = new QPropertyAnimation(step, "opacity"); - anim2->setEndValue(0); - anim2->setDuration(100); - group->addAnimation(anim2); - } - - AnimationManager::self()->registerAnimation(group); - return group; -} - - - -Boat::Boat() : PixmapItem(QString("boat"), GraphicsScene::Big), - speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0) -{ - setZValue(4); - setFlags(QGraphicsItem::ItemIsFocusable); - - //The movement animation used to animate the boat - movementAnimation = new QPropertyAnimation(this, "pos"); - - //The destroy animation used to explode the boat - destroyAnimation = setupDestroyAnimation(this); - - //We setup the state machine of the boat - machine = new QStateMachine(this); - QState *moving = new QState(machine); - StopState *stopState = new StopState(this, moving); - machine->setInitialState(moving); - moving->setInitialState(stopState); - MoveStateRight *moveStateRight = new MoveStateRight(this, moving); - MoveStateLeft *moveStateLeft = new MoveStateLeft(this, moving); - LaunchStateRight *launchStateRight = new LaunchStateRight(this, machine); - LaunchStateLeft *launchStateLeft = new LaunchStateLeft(this, machine); - - //then setup the transitions for the rightMove state - KeyStopTransition *leftStopRight = new KeyStopTransition(this, QEvent::KeyPress, Qt::Key_Left); - leftStopRight->setTargetState(stopState); - KeyMoveTransition *leftMoveRight = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Left); - leftMoveRight->setTargetState(moveStateRight); - KeyMoveTransition *rightMoveRight = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightMoveRight->setTargetState(moveStateRight); - KeyMoveTransition *rightMoveStop = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightMoveStop->setTargetState(moveStateRight); - - //then setup the transitions for the leftMove state - KeyStopTransition *rightStopLeft = new KeyStopTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightStopLeft->setTargetState(stopState); - KeyMoveTransition *rightMoveLeft = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightMoveLeft->setTargetState(moveStateLeft); - KeyMoveTransition *leftMoveLeft = new KeyMoveTransition(this, QEvent::KeyPress,Qt::Key_Left); - leftMoveLeft->setTargetState(moveStateLeft); - KeyMoveTransition *leftMoveStop = new KeyMoveTransition(this, QEvent::KeyPress,Qt::Key_Left); - leftMoveStop->setTargetState(moveStateLeft); - - //We set up the right move state - moveStateRight->addTransition(leftStopRight); - moveStateRight->addTransition(leftMoveRight); - moveStateRight->addTransition(rightMoveRight); - stopState->addTransition(rightMoveStop); - - //We set up the left move state - moveStateLeft->addTransition(rightStopLeft); - moveStateLeft->addTransition(leftMoveLeft); - moveStateLeft->addTransition(rightMoveLeft); - stopState->addTransition(leftMoveStop); - - //The animation is finished, it means we reached the border of the screen, the boat is stopped so we move to the stop state - moveStateLeft->addTransition(movementAnimation, SIGNAL(finished()), stopState); - moveStateRight->addTransition(movementAnimation, SIGNAL(finished()), stopState); - - //We set up the keys for dropping bombs - KeyLaunchTransition *upFireLeft = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); - upFireLeft->setTargetState(launchStateRight); - KeyLaunchTransition *upFireRight = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); - upFireRight->setTargetState(launchStateRight); - KeyLaunchTransition *upFireStop = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); - upFireStop->setTargetState(launchStateRight); - KeyLaunchTransition *downFireLeft = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); - downFireLeft->setTargetState(launchStateLeft); - KeyLaunchTransition *downFireRight = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); - downFireRight->setTargetState(launchStateLeft); - KeyLaunchTransition *downFireMove = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); - downFireMove->setTargetState(launchStateLeft); - - //We set up transitions for fire up - moveStateRight->addTransition(upFireRight); - moveStateLeft->addTransition(upFireLeft); - stopState->addTransition(upFireStop); - - //We set up transitions for fire down - moveStateRight->addTransition(downFireRight); - moveStateLeft->addTransition(downFireLeft); - stopState->addTransition(downFireMove); - - //Finally the launch state should come back to its original state - QHistoryState *historyState = new QHistoryState(moving); - launchStateLeft->addTransition(historyState); - launchStateRight->addTransition(historyState); - - QFinalState *final = new QFinalState(machine); - - //This state play the destroyed animation - QAnimationState *destroyedState = new QAnimationState(machine); - destroyedState->setAnimation(destroyAnimation); - - //Play a nice animation when the boat is destroyed - moving->addTransition(this, SIGNAL(boatDestroyed()), destroyedState); - - //Transition to final state when the destroyed animation is finished - destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final); - - //The machine has finished to be executed, then the boat is dead - connect(machine,SIGNAL(finished()), this, SIGNAL(boatExecutionFinished())); - -} - -void Boat::run() -{ - //We register animations - AnimationManager::self()->registerAnimation(movementAnimation); - AnimationManager::self()->registerAnimation(destroyAnimation); - machine->start(); -} - -void Boat::stop() -{ - movementAnimation->stop(); - machine->stop(); -} - -void Boat::updateBoatMovement() -{ - if (speed == 0 || direction == Boat::None) { - movementAnimation->stop(); - return; - } - - movementAnimation->stop(); - - if (direction == Boat::Left) { - movementAnimation->setEndValue(QPointF(0,y())); - movementAnimation->setDuration(x()/speed*15); - } - else /*if (direction == Boat::Right)*/ { - movementAnimation->setEndValue(QPointF(scene()->width()-size().width(),y())); - movementAnimation->setDuration((scene()->width()-size().width()-x())/speed*15); - } - movementAnimation->start(); -} - -void Boat::destroy() -{ - movementAnimation->stop(); - emit boatDestroyed(); -} - -int Boat::bombsLaunched() const -{ - return bombsAlreadyLaunched; -} - -void Boat::setBombsLaunched(int number) -{ - if (number > MAX_BOMB) { - qWarning("Boat::setBombsLaunched : It impossible to launch that number of bombs"); - return; - } - bombsAlreadyLaunched = number; -} - -int Boat::currentSpeed() const -{ - return speed; -} - -void Boat::setCurrentSpeed(int speed) -{ - if (speed > 3 || speed < 0) { - qWarning("Boat::setCurrentSpeed: The boat can't run on that speed"); - return; - } - this->speed = speed; -} - -enum Boat::Movement Boat::currentDirection() const -{ - return direction; -} - -void Boat::setCurrentDirection(Movement direction) -{ - this->direction = direction; -} - -int Boat::type() const -{ - return Type; -} diff --git a/examples/animation/sub-attaq/boat.h b/examples/animation/sub-attaq/boat.h deleted file mode 100644 index 0b2fe5c8eb..0000000000 --- a/examples/animation/sub-attaq/boat.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __BOAT__H__ -#define __BOAT__H__ - -#include "pixmapitem.h" - -class Bomb; -QT_BEGIN_NAMESPACE -class QVariantAnimation; -class QAbstractAnimation; -class QStateMachine; -QT_END_NAMESPACE - -class Boat : public PixmapItem -{ -Q_OBJECT -public: - enum Movement { - None = 0, - Left, - Right - }; - enum { Type = UserType + 2 }; - Boat(); - void destroy(); - void run(); - void stop(); - - int bombsLaunched() const; - void setBombsLaunched(int number); - - int currentSpeed() const; - void setCurrentSpeed(int speed); - - enum Movement currentDirection() const; - void setCurrentDirection(Movement direction); - - void updateBoatMovement(); - - virtual int type() const; - -signals: - void boatDestroyed(); - void boatExecutionFinished(); - -private: - int speed; - int bombsAlreadyLaunched; - Movement direction; - QVariantAnimation *movementAnimation; - QAbstractAnimation *destroyAnimation; - QStateMachine *machine; -}; - -#endif //__BOAT__H__ diff --git a/examples/animation/sub-attaq/boat_p.h b/examples/animation/sub-attaq/boat_p.h deleted file mode 100644 index 38be985777..0000000000 --- a/examples/animation/sub-attaq/boat_p.h +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BOAT_P_H -#define BOAT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -//Own -#include "bomb.h" -#include "graphicsscene.h" - -// Qt -#include - -static const int MAX_BOMB = 5; - - -//These transtion test if we have to stop the boat (i.e current speed is 1) -class KeyStopTransition : public QKeyEventTransition -{ -public: - KeyStopTransition(Boat *b, QEvent::Type t, int k) - : QKeyEventTransition(b, t, k), boat(b), key(k) - { - } -protected: - virtual bool eventTest(QEvent *event) - { - if (!QKeyEventTransition::eventTest(event)) - return false; - return (boat->currentSpeed() == 1); - } -private: - Boat * boat; - int key; -}; - -//These transtion test if we have to move the boat (i.e current speed was 0 or another value) - class KeyMoveTransition : public QKeyEventTransition -{ -public: - KeyMoveTransition(Boat *b, QEvent::Type t, int k) - : QKeyEventTransition(b, t, k), boat(b), key(k) - { - } -protected: - virtual bool eventTest(QEvent *event) - { - if (!QKeyEventTransition::eventTest(event)) - return false; - return (boat->currentSpeed() >= 0); - } - void onTransition(QEvent *) - { - //We decrease the speed if needed - if (key == Qt::Key_Left && boat->currentDirection() == Boat::Right) - boat->setCurrentSpeed(boat->currentSpeed() - 1); - else if (key == Qt::Key_Right && boat->currentDirection() == Boat::Left) - boat->setCurrentSpeed(boat->currentSpeed() - 1); - else if (boat->currentSpeed() < 3) - boat->setCurrentSpeed(boat->currentSpeed() + 1); - boat->updateBoatMovement(); - } -private: - Boat * boat; - int key; -}; - -//This transition trigger the bombs launch - class KeyLaunchTransition : public QKeyEventTransition -{ -public: - KeyLaunchTransition(Boat *boat, QEvent::Type type, int key) - : QKeyEventTransition(boat, type, key), boat(boat), key(key) - { - } -protected: - virtual bool eventTest(QEvent *event) - { - if (!QKeyEventTransition::eventTest(event)) - return false; - //We have enough bomb? - return (boat->bombsLaunched() < MAX_BOMB); - } -private: - Boat * boat; - int key; -}; - -//This state is describing when the boat is moving right -class MoveStateRight : public QState -{ -public: - MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) - { - boat->setCurrentDirection(Boat::Right); - boat->updateBoatMovement(); - } -private: - Boat * boat; -}; - - //This state is describing when the boat is moving left -class MoveStateLeft : public QState -{ -public: - MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) - { - boat->setCurrentDirection(Boat::Left); - boat->updateBoatMovement(); - } -private: - Boat * boat; -}; - -//This state is describing when the boat is in a stand by position -class StopState : public QState -{ -public: - StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) - { - boat->setCurrentSpeed(0); - boat->setCurrentDirection(Boat::None); - boat->updateBoatMovement(); - } -private: - Boat * boat; -}; - -//This state is describing the launch of the torpedo on the right -class LaunchStateRight : public QState -{ -public: - LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) - { - Bomb *b = new Bomb(); - b->setPos(boat->x()+boat->size().width(),boat->y()); - GraphicsScene *scene = static_cast(boat->scene()); - scene->addItem(b); - b->launch(Bomb::Right); - boat->setBombsLaunched(boat->bombsLaunched() + 1); - } -private: - Boat * boat; -}; - -//This state is describing the launch of the torpedo on the left -class LaunchStateLeft : public QState -{ -public: - LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) - { - Bomb *b = new Bomb(); - b->setPos(boat->x() - b->size().width(), boat->y()); - GraphicsScene *scene = static_cast(boat->scene()); - scene->addItem(b); - b->launch(Bomb::Left); - boat->setBombsLaunched(boat->bombsLaunched() + 1); - } -private: - Boat * boat; -}; - -#endif // BOAT_P_H diff --git a/examples/animation/sub-attaq/bomb.cpp b/examples/animation/sub-attaq/bomb.cpp deleted file mode 100644 index e47e9423a9..0000000000 --- a/examples/animation/sub-attaq/bomb.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "bomb.h" -#include "submarine.h" -#include "pixmapitem.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -//Qt -#include -#include -#include -#include - -Bomb::Bomb() : PixmapItem(QString("bomb"), GraphicsScene::Big) -{ - setZValue(2); -} - -void Bomb::launch(Bomb::Direction direction) -{ - QSequentialAnimationGroup *launchAnimation = new QSequentialAnimationGroup; - AnimationManager::self()->registerAnimation(launchAnimation); - qreal delta = direction == Right ? 20 : - 20; - QPropertyAnimation *anim = new QPropertyAnimation(this, "pos"); - anim->setEndValue(QPointF(x() + delta,y() - 20)); - anim->setDuration(150); - launchAnimation->addAnimation(anim); - anim = new QPropertyAnimation(this, "pos"); - anim->setEndValue(QPointF(x() + delta*2, y() )); - anim->setDuration(150); - launchAnimation->addAnimation(anim); - anim = new QPropertyAnimation(this, "pos"); - anim->setEndValue(QPointF(x() + delta*2,scene()->height())); - anim->setDuration(y()/2*60); - launchAnimation->addAnimation(anim); - connect(anim,SIGNAL(valueChanged(QVariant)),this,SLOT(onAnimationLaunchValueChanged(QVariant))); - connect(this, SIGNAL(bombExploded()), launchAnimation, SLOT(stop())); - //We setup the state machine of the bomb - QStateMachine *machine = new QStateMachine(this); - - //This state is when the launch animation is playing - QAnimationState *launched = new QAnimationState(machine); - launched->setAnimation(launchAnimation); - - //End - QFinalState *final = new QFinalState(machine); - - machine->setInitialState(launched); - - //### Add a nice animation when the bomb is destroyed - launched->addTransition(this, SIGNAL(bombExploded()),final); - - //If the animation is finished, then we move to the final state - launched->addTransition(launched, SIGNAL(animationFinished()), final); - - //The machine has finished to be executed, then the boat is dead - connect(machine,SIGNAL(finished()),this, SIGNAL(bombExecutionFinished())); - - machine->start(); - -} - -void Bomb::onAnimationLaunchValueChanged(const QVariant &) -{ - foreach (QGraphicsItem * item , collidingItems(Qt::IntersectsItemBoundingRect)) { - if (item->type() == SubMarine::Type) { - SubMarine *s = static_cast(item); - destroy(); - s->destroy(); - } - } -} - -void Bomb::destroy() -{ - emit bombExploded(); -} diff --git a/examples/animation/sub-attaq/bomb.h b/examples/animation/sub-attaq/bomb.h deleted file mode 100644 index 74ed734caf..0000000000 --- a/examples/animation/sub-attaq/bomb.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __BOMB__H__ -#define __BOMB__H__ - -#include "pixmapitem.h" - -class Bomb : public PixmapItem -{ -Q_OBJECT -public: - enum Direction { - Left = 0, - Right - }; - Bomb(); - void launch(Direction direction); - void destroy(); - -signals: - void bombExploded(); - void bombExecutionFinished(); - -private slots: - void onAnimationLaunchValueChanged(const QVariant &); -}; - -#endif //__BOMB__H__ diff --git a/examples/animation/sub-attaq/data.xml b/examples/animation/sub-attaq/data.xml deleted file mode 100644 index 0f30515ddf..0000000000 --- a/examples/animation/sub-attaq/data.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/graphicsscene.cpp b/examples/animation/sub-attaq/graphicsscene.cpp deleted file mode 100644 index a2b3e2f101..0000000000 --- a/examples/animation/sub-attaq/graphicsscene.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "graphicsscene.h" -#include "states.h" -#include "boat.h" -#include "submarine.h" -#include "torpedo.h" -#include "bomb.h" -#include "pixmapitem.h" -#include "animationmanager.h" -#include "qanimationstate.h" -#include "progressitem.h" -#include "textinformationitem.h" - -//Qt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) - : QGraphicsScene(x , y, width, height), mode(mode), boat(new Boat) -{ - PixmapItem *backgroundItem = new PixmapItem(QString("background"),mode); - backgroundItem->setZValue(1); - backgroundItem->setPos(0,0); - addItem(backgroundItem); - - PixmapItem *surfaceItem = new PixmapItem(QString("surface"),mode); - surfaceItem->setZValue(3); - surfaceItem->setPos(0,sealLevel() - surfaceItem->boundingRect().height()/2); - addItem(surfaceItem); - - //The item that display score and level - progressItem = new ProgressItem(backgroundItem); - - textInformationItem = new TextInformationItem(backgroundItem); - textInformationItem->hide(); - //We create the boat - addItem(boat); - boat->setPos(this->width()/2, sealLevel() - boat->size().height()); - boat->hide(); - - //parse the xml that contain all data of the game - QXmlStreamReader reader; - QFile file(":data.xml"); - file.open(QIODevice::ReadOnly); - reader.setDevice(&file); - LevelDescription currentLevel; - while (!reader.atEnd()) { - reader.readNext(); - if (reader.tokenType() == QXmlStreamReader::StartElement) { - if (reader.name() == "submarine") { - SubmarineDescription desc; - desc.name = reader.attributes().value("name").toString(); - desc.points = reader.attributes().value("points").toString().toInt(); - desc.type = reader.attributes().value("type").toString().toInt(); - submarinesData.append(desc); - } else if (reader.name() == "level") { - currentLevel.id = reader.attributes().value("id").toString().toInt(); - currentLevel.name = reader.attributes().value("name").toString(); - } else if (reader.name() == "subinstance") { - currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(), reader.attributes().value("nb").toString().toInt())); - } - } else if (reader.tokenType() == QXmlStreamReader::EndElement) { - if (reader.name() == "level") { - levelsData.insert(currentLevel.id, currentLevel); - currentLevel.submarines.clear(); - } - } - } -} - -qreal GraphicsScene::sealLevel() const -{ - return (mode == Big) ? 220 : 160; -} - -void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction) -{ - static const int nLetters = 10; - static struct { - char const *pix; - qreal initX, initY; - qreal destX, destY; - } logoData[nLetters] = { - {"s", -1000, -1000, 300, 150 }, - {"u", -800, -1000, 350, 150 }, - {"b", -600, -1000, 400, 120 }, - {"dash", -400, -1000, 460, 150 }, - {"a", 1000, 2000, 350, 250 }, - {"t", 800, 2000, 400, 250 }, - {"t2", 600, 2000, 430, 250 }, - {"a2", 400, 2000, 465, 250 }, - {"q", 200, 2000, 510, 250 }, - {"excl", 0, 2000, 570, 220 } }; - - QSequentialAnimationGroup * lettersGroupMoving = new QSequentialAnimationGroup(this); - QParallelAnimationGroup * lettersGroupFading = new QParallelAnimationGroup(this); - - for (int i = 0; i < nLetters; ++i) { - PixmapItem *logo = new PixmapItem(QLatin1String(":/logo-") + logoData[i].pix, this); - logo->setPos(logoData[i].initX, logoData[i].initY); - logo->setZValue(i + 3); - //creation of the animations for moving letters - QPropertyAnimation *moveAnim = new QPropertyAnimation(logo, "pos", lettersGroupMoving); - moveAnim->setEndValue(QPointF(logoData[i].destX, logoData[i].destY)); - moveAnim->setDuration(200); - moveAnim->setEasingCurve(QEasingCurve::OutElastic); - lettersGroupMoving->addPause(50); - //creation of the animations for fading out the letters - QPropertyAnimation *fadeAnim = new QPropertyAnimation(logo, "opacity", lettersGroupFading); - fadeAnim->setDuration(800); - fadeAnim->setEndValue(0); - fadeAnim->setEasingCurve(QEasingCurve::OutQuad); - } - - QStateMachine *machine = new QStateMachine(this); - - //This state is when the player is playing - PlayState *gameState = new PlayState(this, machine); - - //Final state - QFinalState *final = new QFinalState(machine); - - //Animation when the player enter in the game - QAnimationState *lettersMovingState = new QAnimationState(machine); - lettersMovingState->setAnimation(lettersGroupMoving); - - //Animation when the welcome screen disappear - QAnimationState *lettersFadingState = new QAnimationState(machine); - lettersFadingState->setAnimation(lettersGroupFading); - - //if new game then we fade out the welcome screen and start playing - lettersMovingState->addTransition(newAction, SIGNAL(triggered()), lettersFadingState); - lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()), gameState); - - //New Game is triggered then player start playing - gameState->addTransition(newAction, SIGNAL(triggered()), gameState); - - //Wanna quit, then connect to CTRL+Q - gameState->addTransition(quitAction, SIGNAL(triggered()), final); - lettersMovingState->addTransition(quitAction, SIGNAL(triggered()), final); - - //Welcome screen is the initial state - machine->setInitialState(lettersMovingState); - - machine->start(); - - //We reach the final state, then we quit - connect(machine, SIGNAL(finished()), qApp, SLOT(quit())); -} - -void GraphicsScene::addItem(Bomb *bomb) -{ - bombs.insert(bomb); - connect(bomb,SIGNAL(bombExecutionFinished()),this, SLOT(onBombExecutionFinished())); - QGraphicsScene::addItem(bomb); -} - -void GraphicsScene::addItem(Torpedo *torpedo) -{ - torpedos.insert(torpedo); - connect(torpedo,SIGNAL(torpedoExecutionFinished()),this, SLOT(onTorpedoExecutionFinished())); - QGraphicsScene::addItem(torpedo); -} - -void GraphicsScene::addItem(SubMarine *submarine) -{ - submarines.insert(submarine); - connect(submarine,SIGNAL(subMarineExecutionFinished()),this, SLOT(onSubMarineExecutionFinished())); - QGraphicsScene::addItem(submarine); -} - -void GraphicsScene::addItem(QGraphicsItem *item) -{ - QGraphicsScene::addItem(item); -} - -void GraphicsScene::onBombExecutionFinished() -{ - Bomb *bomb = qobject_cast(sender()); - bombs.remove(bomb); - bomb->deleteLater(); - if (boat) - boat->setBombsLaunched(boat->bombsLaunched() - 1); -} - -void GraphicsScene::onTorpedoExecutionFinished() -{ - Torpedo *torpedo = qobject_cast(sender()); - torpedos.remove(torpedo); - torpedo->deleteLater(); -} - -void GraphicsScene::onSubMarineExecutionFinished() -{ - SubMarine *submarine = qobject_cast(sender()); - submarines.remove(submarine); - if (submarines.count() == 0) - emit allSubMarineDestroyed(submarine->points()); - else - emit subMarineDestroyed(submarine->points()); - submarine->deleteLater(); -} - -void GraphicsScene::clearScene() -{ - foreach (SubMarine *sub, submarines) { - sub->destroy(); - sub->deleteLater(); - } - - foreach (Torpedo *torpedo, torpedos) { - torpedo->destroy(); - torpedo->deleteLater(); - } - - foreach (Bomb *bomb, bombs) { - bomb->destroy(); - bomb->deleteLater(); - } - - submarines.clear(); - bombs.clear(); - torpedos.clear(); - - AnimationManager::self()->unregisterAllAnimations(); - - boat->stop(); - boat->hide(); - boat->setEnabled(true); -} diff --git a/examples/animation/sub-attaq/graphicsscene.h b/examples/animation/sub-attaq/graphicsscene.h deleted file mode 100644 index 3e571a878c..0000000000 --- a/examples/animation/sub-attaq/graphicsscene.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __GRAPHICSSCENE__H__ -#define __GRAPHICSSCENE__H__ - -//Qt -#include -#include -#include - - -class Boat; -class SubMarine; -class Torpedo; -class Bomb; -class PixmapItem; -class ProgressItem; -class TextInformationItem; -QT_BEGIN_NAMESPACE -class QAction; -QT_END_NAMESPACE - -class GraphicsScene : public QGraphicsScene -{ -Q_OBJECT -public: - enum Mode { - Big = 0, - Small - }; - - struct SubmarineDescription { - int type; - int points; - QString name; - }; - - struct LevelDescription { - int id; - QString name; - QList > submarines; - }; - - GraphicsScene(int x, int y, int width, int height, Mode mode = Big); - qreal sealLevel() const; - void setupScene(QAction *newAction, QAction *quitAction); - void addItem(Bomb *bomb); - void addItem(Torpedo *torpedo); - void addItem(SubMarine *submarine); - void addItem(QGraphicsItem *item); - void clearScene(); - -signals: - void subMarineDestroyed(int); - void allSubMarineDestroyed(int); - -private slots: - void onBombExecutionFinished(); - void onTorpedoExecutionFinished(); - void onSubMarineExecutionFinished(); - -private: - Mode mode; - ProgressItem *progressItem; - TextInformationItem *textInformationItem; - Boat *boat; - QSet submarines; - QSet bombs; - QSet torpedos; - QVector submarinesData; - QHash levelsData; - - friend class PauseState; - friend class PlayState; - friend class LevelState; - friend class LostState; - friend class WinState; - friend class WinTransition; - friend class UpdateScoreTransition; -}; - -#endif //__GRAPHICSSCENE__H__ - diff --git a/examples/animation/sub-attaq/main.cpp b/examples/animation/sub-attaq/main.cpp deleted file mode 100644 index df18c83435..0000000000 --- a/examples/animation/sub-attaq/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(subattaq); - - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); - - MainWindow w; - w.show(); - - return app.exec(); -} diff --git a/examples/animation/sub-attaq/mainwindow.cpp b/examples/animation/sub-attaq/mainwindow.cpp deleted file mode 100644 index 70f0303177..0000000000 --- a/examples/animation/sub-attaq/mainwindow.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "mainwindow.h" -#include "graphicsscene.h" - -//Qt -#include -#include -#include -#include -#include - -#ifndef QT_NO_OPENGL -# include -#endif - -MainWindow::MainWindow() : QMainWindow(0) -{ - QMenu *file = menuBar()->addMenu(tr("&File")); - - QAction *newAction = file->addAction(tr("New Game")); - newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); - QAction *quitAction = file->addAction(tr("Quit")); - quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); - - if (QApplication::arguments().contains("-fullscreen")) { - scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small); - setWindowState(Qt::WindowFullScreen); - } else { - scene = new GraphicsScene(0, 0, 880, 630); - layout()->setSizeConstraint(QLayout::SetFixedSize); - } - - view = new QGraphicsView(scene, this); - view->setAlignment(Qt::AlignLeft | Qt::AlignTop); - scene->setupScene(newAction, quitAction); -#ifndef QT_NO_OPENGL - view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); -#endif - - setCentralWidget(view); -} diff --git a/examples/animation/sub-attaq/mainwindow.h b/examples/animation/sub-attaq/mainwindow.h deleted file mode 100644 index 596157d38f..0000000000 --- a/examples/animation/sub-attaq/mainwindow.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __MAINWINDOW__H__ -#define __MAINWINDOW__H__ - -//Qt -#include -class GraphicsScene; -QT_BEGIN_NAMESPACE -class QGraphicsView; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ -Q_OBJECT -public: - MainWindow(); - -private: - GraphicsScene *scene; - QGraphicsView *view; -}; - -#endif //__MAINWINDOW__H__ diff --git a/examples/animation/sub-attaq/pics/big/background.png b/examples/animation/sub-attaq/pics/big/background.png deleted file mode 100644 index 9f581571fa..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/background.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/boat.png b/examples/animation/sub-attaq/pics/big/boat.png deleted file mode 100644 index be82dff62a..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/boat.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/bomb.png b/examples/animation/sub-attaq/pics/big/bomb.png deleted file mode 100644 index 3af5f2f29c..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/bomb.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step1.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step1.png deleted file mode 100644 index c9fd8b0984..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/boat/step1.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step2.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step2.png deleted file mode 100644 index 7528f2d2da..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/boat/step2.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step3.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step3.png deleted file mode 100644 index aae9c9c184..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/boat/step3.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step4.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step4.png deleted file mode 100644 index d697c1bae8..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/boat/step4.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png deleted file mode 100644 index 88ca5144b7..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png deleted file mode 100644 index 524f5890ee..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png deleted file mode 100644 index 2cca1e80fe..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png deleted file mode 100644 index 82100a8260..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/submarine.png b/examples/animation/sub-attaq/pics/big/submarine.png deleted file mode 100644 index df435dc47d..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/submarine.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/surface.png b/examples/animation/sub-attaq/pics/big/surface.png deleted file mode 100644 index 4eba29e9cd..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/surface.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/big/torpedo.png b/examples/animation/sub-attaq/pics/big/torpedo.png deleted file mode 100644 index f9c26873f1..0000000000 Binary files a/examples/animation/sub-attaq/pics/big/torpedo.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/scalable/background-n810.svg b/examples/animation/sub-attaq/pics/scalable/background-n810.svg deleted file mode 100644 index ece9f7aaf1..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/background-n810.svg +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/background.svg b/examples/animation/sub-attaq/pics/scalable/background.svg deleted file mode 100644 index 0be268010e..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/background.svg +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/boat.svg b/examples/animation/sub-attaq/pics/scalable/boat.svg deleted file mode 100644 index 5298821ba8..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/boat.svg +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/bomb.svg b/examples/animation/sub-attaq/pics/scalable/bomb.svg deleted file mode 100644 index 294771a6dd..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/bomb.svg +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/sand.svg b/examples/animation/sub-attaq/pics/scalable/sand.svg deleted file mode 100644 index 8af11b7a66..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/sand.svg +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/see.svg b/examples/animation/sub-attaq/pics/scalable/see.svg deleted file mode 100644 index 0666691215..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/see.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/sky.svg b/examples/animation/sub-attaq/pics/scalable/sky.svg deleted file mode 100644 index 1546c087a7..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/sky.svg +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/sub-attaq.svg b/examples/animation/sub-attaq/pics/scalable/sub-attaq.svg deleted file mode 100644 index b075179b46..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/sub-attaq.svg +++ /dev/null @@ -1,1473 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/submarine.svg b/examples/animation/sub-attaq/pics/scalable/submarine.svg deleted file mode 100644 index 8a0ffddbca..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/submarine.svg +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/surface.svg b/examples/animation/sub-attaq/pics/scalable/surface.svg deleted file mode 100644 index 40ed239638..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/surface.svg +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/scalable/torpedo.svg b/examples/animation/sub-attaq/pics/scalable/torpedo.svg deleted file mode 100644 index 48e429d2bf..0000000000 --- a/examples/animation/sub-attaq/pics/scalable/torpedo.svg +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/animation/sub-attaq/pics/small/background.png b/examples/animation/sub-attaq/pics/small/background.png deleted file mode 100644 index 5ad3db660a..0000000000 Binary files a/examples/animation/sub-attaq/pics/small/background.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/small/boat.png b/examples/animation/sub-attaq/pics/small/boat.png deleted file mode 100644 index 114ccc310e..0000000000 Binary files a/examples/animation/sub-attaq/pics/small/boat.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/small/bomb.png b/examples/animation/sub-attaq/pics/small/bomb.png deleted file mode 100644 index 3af5f2f29c..0000000000 Binary files a/examples/animation/sub-attaq/pics/small/bomb.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/small/submarine.png b/examples/animation/sub-attaq/pics/small/submarine.png deleted file mode 100644 index 0c0c350600..0000000000 Binary files a/examples/animation/sub-attaq/pics/small/submarine.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/small/surface.png b/examples/animation/sub-attaq/pics/small/surface.png deleted file mode 100644 index 06d0e47a5c..0000000000 Binary files a/examples/animation/sub-attaq/pics/small/surface.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/small/torpedo.png b/examples/animation/sub-attaq/pics/small/torpedo.png deleted file mode 100644 index f9c26873f1..0000000000 Binary files a/examples/animation/sub-attaq/pics/small/torpedo.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-a.png b/examples/animation/sub-attaq/pics/welcome/logo-a.png deleted file mode 100644 index 67dd76dac0..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-a.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-a2.png b/examples/animation/sub-attaq/pics/welcome/logo-a2.png deleted file mode 100644 index 17668b07de..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-a2.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-b.png b/examples/animation/sub-attaq/pics/welcome/logo-b.png deleted file mode 100644 index cf6c04560b..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-b.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-dash.png b/examples/animation/sub-attaq/pics/welcome/logo-dash.png deleted file mode 100644 index 219233ce6b..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-dash.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-excl.png b/examples/animation/sub-attaq/pics/welcome/logo-excl.png deleted file mode 100644 index 8dd0a2eb86..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-excl.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-q.png b/examples/animation/sub-attaq/pics/welcome/logo-q.png deleted file mode 100644 index 86e588d4d8..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-q.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-s.png b/examples/animation/sub-attaq/pics/welcome/logo-s.png deleted file mode 100644 index 7b6a36e93a..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-s.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-t.png b/examples/animation/sub-attaq/pics/welcome/logo-t.png deleted file mode 100644 index b2e3526bea..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-t.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-t2.png b/examples/animation/sub-attaq/pics/welcome/logo-t2.png deleted file mode 100644 index b11a77886e..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-t2.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-u.png b/examples/animation/sub-attaq/pics/welcome/logo-u.png deleted file mode 100644 index 24eede887a..0000000000 Binary files a/examples/animation/sub-attaq/pics/welcome/logo-u.png and /dev/null differ diff --git a/examples/animation/sub-attaq/pixmapitem.cpp b/examples/animation/sub-attaq/pixmapitem.cpp deleted file mode 100644 index 077151d708..0000000000 --- a/examples/animation/sub-attaq/pixmapitem.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "pixmapitem.h" - -//Qt -#include - -PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent) -{ - if (mode == GraphicsScene::Big) - pix = QPixmap(QStringLiteral(":/big/") + fileName); - else - pix = QPixmap(QStringLiteral(":/small/") + fileName); -} - -PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName) -{ - scene->addItem(this); -} - -QSizeF PixmapItem::size() const -{ - return pix.size(); -} - -QRectF PixmapItem::boundingRect() const -{ - return QRectF(QPointF(0, 0), pix.size()); -} - -void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - painter->drawPixmap(0, 0, pix); -} - - diff --git a/examples/animation/sub-attaq/pixmapitem.h b/examples/animation/sub-attaq/pixmapitem.h deleted file mode 100644 index 0a3b1287c7..0000000000 --- a/examples/animation/sub-attaq/pixmapitem.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __PIXMAPITEM__H__ -#define __PIXMAPITEM__H__ - -//Own -#include "graphicsscene.h" - -//Qt -#include - -class PixmapItem : public QGraphicsObject -{ -public: - PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0); - PixmapItem(const QString &fileName, QGraphicsScene *scene); - QSizeF size() const; - QRectF boundingRect() const; - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); -private: - QPixmap pix; -}; - -#endif //__PIXMAPITEM__H__ diff --git a/examples/animation/sub-attaq/progressitem.cpp b/examples/animation/sub-attaq/progressitem.cpp deleted file mode 100644 index bad9ceb471..0000000000 --- a/examples/animation/sub-attaq/progressitem.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "progressitem.h" -#include "pixmapitem.h" - -ProgressItem::ProgressItem (QGraphicsItem * parent) - : QGraphicsTextItem(parent), currentLevel(1), currentScore(0) -{ - setFont(QFont("Comic Sans MS")); - setPos(parentItem()->boundingRect().topRight() - QPointF(180, -5)); -} - -void ProgressItem::setLevel(int level) -{ - currentLevel = level; - updateProgress(); -} - -void ProgressItem::setScore(int score) -{ - currentScore = score; - updateProgress(); -} - -void ProgressItem::updateProgress() -{ - setHtml(QString("Level : %1 Score : %2").arg(currentLevel).arg(currentScore)); -} diff --git a/examples/animation/sub-attaq/progressitem.h b/examples/animation/sub-attaq/progressitem.h deleted file mode 100644 index dc6d7ba6bc..0000000000 --- a/examples/animation/sub-attaq/progressitem.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PROGRESSITEM_H -#define PROGRESSITEM_H - -//Qt -#include - -class ProgressItem : public QGraphicsTextItem -{ -public: - ProgressItem(QGraphicsItem * parent = 0); - void setLevel(int level); - void setScore(int score); - -private: - void updateProgress(); - int currentLevel; - int currentScore; -}; - -#endif // PROGRESSITEM_H diff --git a/examples/animation/sub-attaq/qanimationstate.cpp b/examples/animation/sub-attaq/qanimationstate.cpp deleted file mode 100644 index b122acc858..0000000000 --- a/examples/animation/sub-attaq/qanimationstate.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qanimationstate.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! -\class QAnimationState - -\brief The QAnimationState class provides state that handle an animation and emit -a signal when this animation is finished. - -\ingroup statemachine - -QAnimationState provides a state that handle an animation. It will start this animation -when the state is entered and stop it when it is leaved. When the animation has finished the -state emit animationFinished signal. -QAnimationState is part of \l{The State Machine Framework}. - -\code -QStateMachine machine; -QAnimationState *s = new QAnimationState(machine->rootState()); -QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); -s->setAnimation(animation); -QState *s2 = new QState(machine->rootState()); -s->addTransition(s, SIGNAL(animationFinished()), s2); -machine.start(); -\endcode - -\sa QState, {The Animation Framework} -*/ - - -#ifndef QT_NO_ANIMATION - -/*! - Constructs a new state with the given \a parent state. -*/ -QAnimationState::QAnimationState(QState *parent) - : QState(parent), m_animation(0) -{ -} - -/*! - Destroys the animation state. -*/ -QAnimationState::~QAnimationState() -{ -} - -/*! - Set an \a animation for this QAnimationState. If an animation was previously handle by this - state then it won't emit animationFinished for the old animation. The QAnimationState doesn't - take the ownership of the animation. -*/ -void QAnimationState::setAnimation(QAbstractAnimation *animation) -{ - if (animation == m_animation) - return; - - //Disconnect from the previous animation if exist - if(m_animation) - disconnect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); - - m_animation = animation; - - if (m_animation) { - //connect the new animation - connect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); - } -} - -/*! - Returns the animation handle by this animation state, or 0 if there is no animation. -*/ -QAbstractAnimation* QAnimationState::animation() const -{ - return m_animation; -} - -/*! - \reimp -*/ -void QAnimationState::onEntry(QEvent *) -{ - if (m_animation) - m_animation->start(); -} - -/*! - \reimp -*/ -void QAnimationState::onExit(QEvent *) -{ - if (m_animation) - m_animation->stop(); -} - -/*! - \reimp -*/ -bool QAnimationState::event(QEvent *e) -{ - return QState::event(e); -} - -QT_END_NAMESPACE - -#endif diff --git a/examples/animation/sub-attaq/qanimationstate.h b/examples/animation/sub-attaq/qanimationstate.h deleted file mode 100644 index 2672f640e4..0000000000 --- a/examples/animation/sub-attaq/qanimationstate.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANIMATIONSTATE_H -#define QANIMATIONSTATE_H - -#ifndef QT_STATEMACHINE_SOLUTION -# include -# include -#else -# include "qstate.h" -# include "qabstractanimation.h" -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_ANIMATION - -class QAbstractAnimation; - -class QAnimationState : public QState -{ - Q_OBJECT -public: - QAnimationState(QState *parent = 0); - ~QAnimationState(); - - void setAnimation(QAbstractAnimation *animation); - QAbstractAnimation* animation() const; - -signals: - void animationFinished(); - -protected: - void onEntry(QEvent *); - void onExit(QEvent *); - bool event(QEvent *e); - -private: - Q_DISABLE_COPY(QAnimationState) - QAbstractAnimation *m_animation; -}; - -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QANIMATIONSTATE_H diff --git a/examples/animation/sub-attaq/states.cpp b/examples/animation/sub-attaq/states.cpp deleted file mode 100644 index 32ad218693..0000000000 --- a/examples/animation/sub-attaq/states.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "states.h" -#include "graphicsscene.h" -#include "boat.h" -#include "submarine.h" -#include "torpedo.h" -#include "animationmanager.h" -#include "progressitem.h" -#include "textinformationitem.h" - -//Qt -#include -#include -#include -#include -#include - -PlayState::PlayState(GraphicsScene *scene, QState *parent) - : QState(parent), - scene(scene), - machine(0), - currentLevel(0), - score(0) -{ -} - -PlayState::~PlayState() -{ - delete machine; -} - -void PlayState::onEntry(QEvent *) -{ - //We are now playing? - if (machine) { - machine->stop(); - //we hide the information - scene->textInformationItem->hide(); - scene->clearScene(); - currentLevel = 0; - score = 0; - delete machine; - } - - machine = new QStateMachine; - - //This state is when player is playing - LevelState *levelState = new LevelState(scene, this, machine); - - //This state is when the player is actually playing but the game is not paused - QState *playingState = new QState(levelState); - levelState->setInitialState(playingState); - - //This state is when the game is paused - PauseState *pauseState = new PauseState(scene, levelState); - - //We have one view, it receive the key press event - QKeyEventTransition *pressPplay = new QKeyEventTransition(scene->views().at(0), QEvent::KeyPress, Qt::Key_P); - pressPplay->setTargetState(pauseState); - QKeyEventTransition *pressPpause = new QKeyEventTransition(scene->views().at(0), QEvent::KeyPress, Qt::Key_P); - pressPpause->setTargetState(playingState); - - //Pause "P" is triggered, the player pause the game - playingState->addTransition(pressPplay); - - //To get back playing when the game has been paused - pauseState->addTransition(pressPpause); - - //This state is when player have lost - LostState *lostState = new LostState(scene, this, machine); - - //This state is when player have won - WinState *winState = new WinState(scene, this, machine); - - //The boat has been destroyed then the game is finished - levelState->addTransition(scene->boat, SIGNAL(boatExecutionFinished()),lostState); - - //This transition check if we won or not - WinTransition *winTransition = new WinTransition(scene, this, winState); - - //The boat has been destroyed then the game is finished - levelState->addTransition(winTransition); - - //This state is an animation when the score changed - UpdateScoreState *scoreState = new UpdateScoreState(this, levelState); - - //This transition update the score when a submarine die - UpdateScoreTransition *scoreTransition = new UpdateScoreTransition(scene, this, levelState); - scoreTransition->setTargetState(scoreState); - - //The boat has been destroyed then the game is finished - playingState->addTransition(scoreTransition); - - //We go back to play state - scoreState->addTransition(playingState); - - //We start playing!!! - machine->setInitialState(levelState); - - //Final state - QFinalState *final = new QFinalState(machine); - - //This transition is triggered when the player press space after completing a level - CustomSpaceTransition *spaceTransition = new CustomSpaceTransition(scene->views().at(0), this, QEvent::KeyPress, Qt::Key_Space); - spaceTransition->setTargetState(levelState); - winState->addTransition(spaceTransition); - - //We lost we should reach the final state - lostState->addTransition(lostState, SIGNAL(finished()), final); - - machine->start(); -} - -LevelState::LevelState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) -{ -} -void LevelState::onEntry(QEvent *) -{ - initializeLevel(); -} - -void LevelState::initializeLevel() -{ - //we re-init the boat - scene->boat->setPos(scene->width()/2, scene->sealLevel() - scene->boat->size().height()); - scene->boat->setCurrentSpeed(0); - scene->boat->setCurrentDirection(Boat::None); - scene->boat->setBombsLaunched(0); - scene->boat->show(); - scene->setFocusItem(scene->boat, Qt::OtherFocusReason); - scene->boat->run(); - - scene->progressItem->setScore(game->score); - scene->progressItem->setLevel(game->currentLevel + 1); - - GraphicsScene::LevelDescription currentLevelDescription = scene->levelsData.value(game->currentLevel); - - for (int i = 0; i < currentLevelDescription.submarines.size(); ++i ) { - - QPair subContent = currentLevelDescription.submarines.at(i); - GraphicsScene::SubmarineDescription submarineDesc = scene->submarinesData.at(subContent.first); - - for (int j = 0; j < subContent.second; ++j ) { - SubMarine *sub = new SubMarine(submarineDesc.type, submarineDesc.name, submarineDesc.points); - scene->addItem(sub); - int random = (qrand() % 15 + 1); - qreal x = random == 13 || random == 5 ? 0 : scene->width() - sub->size().width(); - qreal y = scene->height() -(qrand() % 150 + 1) - sub->size().height(); - sub->setPos(x,y); - sub->setCurrentDirection(x == 0 ? SubMarine::Right : SubMarine::Left); - sub->setCurrentSpeed(qrand() % 3 + 1); - } - } -} - -/** Pause State */ -PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent),scene(scene) -{ -} -void PauseState::onEntry(QEvent *) -{ - AnimationManager::self()->pauseAll(); - scene->boat->setEnabled(false); -} -void PauseState::onExit(QEvent *) -{ - AnimationManager::self()->resumeAll(); - scene->boat->setEnabled(true); - scene->boat->setFocus(); -} - -/** Lost State */ -LostState::LostState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) -{ -} - -void LostState::onEntry(QEvent *) -{ - //The message to display - QString message = QString("You lose on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score); - - //We set the level back to 0 - game->currentLevel = 0; - - //We set the score back to 0 - game->score = 0; - - //We clear the scene - scene->clearScene(); - - //We inform the player - scene->textInformationItem->setMessage(message); - scene->textInformationItem->show(); -} - -void LostState::onExit(QEvent *) -{ - //we hide the information - scene->textInformationItem->hide(); -} - -/** Win State */ -WinState::WinState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) -{ -} - -void WinState::onEntry(QEvent *) -{ - //We clear the scene - scene->clearScene(); - - QString message; - if (scene->levelsData.size() - 1 != game->currentLevel) { - message = QString("You win the level %1. Your score is %2.\nPress Space to continue.").arg(game->currentLevel+1).arg(game->score); - //We increment the level number - game->currentLevel++; - } else { - message = QString("You finish the game on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score); - //We set the level back to 0 - game->currentLevel = 0; - //We set the score back to 0 - game->score = 0; - } - - //We inform the player - scene->textInformationItem->setMessage(message); - scene->textInformationItem->show(); -} - -void WinState::onExit(QEvent *) -{ - //we hide the information - scene->textInformationItem->hide(); -} - -/** UpdateScore State */ -UpdateScoreState::UpdateScoreState(PlayState *g, QState *parent) : QState(parent), game(g) -{ -} - -/** Win transition */ -UpdateScoreTransition::UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) - : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int))), - game(game), scene(scene) -{ - setTargetState(target); -} - -bool UpdateScoreTransition::eventTest(QEvent *event) -{ - if (!QSignalTransition::eventTest(event)) - return false; - QStateMachine::SignalEvent *se = static_cast(event); - game->score += se->arguments().at(0).toInt(); - scene->progressItem->setScore(game->score); - return true; -} - -/** Win transition */ -WinTransition::WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) - : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int))), - game(game), scene(scene) -{ - setTargetState(target); -} - -bool WinTransition::eventTest(QEvent *event) -{ - if (!QSignalTransition::eventTest(event)) - return false; - QStateMachine::SignalEvent *se = static_cast(event); - game->score += se->arguments().at(0).toInt(); - scene->progressItem->setScore(game->score); - return true; -} - -/** Space transition */ -CustomSpaceTransition::CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key) - : QKeyEventTransition(widget, type, key), - game(game) -{ -} - -bool CustomSpaceTransition::eventTest(QEvent *event) -{ - if (!QKeyEventTransition::eventTest(event)) - return false; - return (game->currentLevel != 0); -} diff --git a/examples/animation/sub-attaq/states.h b/examples/animation/sub-attaq/states.h deleted file mode 100644 index e43370302c..0000000000 --- a/examples/animation/sub-attaq/states.h +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STATES_H -#define STATES_H - -//Qt -#include -#include -#include -#include -#include - -class GraphicsScene; -class Boat; -class SubMarine; -QT_BEGIN_NAMESPACE -class QStateMachine; -QT_END_NAMESPACE - -class PlayState : public QState -{ -public: - PlayState(GraphicsScene *scene, QState *parent = 0); - ~PlayState(); - - protected: - void onEntry(QEvent *); - -private : - GraphicsScene *scene; - QStateMachine *machine; - int currentLevel; - int score; - QState *parallelChild; - - friend class UpdateScoreState; - friend class UpdateScoreTransition; - friend class WinTransition; - friend class CustomSpaceTransition; - friend class WinState; - friend class LostState; - friend class LevelState; -}; - -class LevelState : public QState -{ -public: - LevelState(GraphicsScene *scene, PlayState *game, QState *parent = 0); -protected: - void onEntry(QEvent *); -private : - void initializeLevel(); - GraphicsScene *scene; - PlayState *game; -}; - -class PauseState : public QState -{ -public: - PauseState(GraphicsScene *scene, QState *parent = 0); - -protected: - void onEntry(QEvent *); - void onExit(QEvent *); -private : - GraphicsScene *scene; - Boat *boat; -}; - -class LostState : public QState -{ -public: - LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0); - -protected: - void onEntry(QEvent *); - void onExit(QEvent *); -private : - GraphicsScene *scene; - PlayState *game; -}; - -class WinState : public QState -{ -public: - WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0); - -protected: - void onEntry(QEvent *); - void onExit(QEvent *); -private : - GraphicsScene *scene; - PlayState *game; -}; - -class UpdateScoreState : public QState -{ -public: - UpdateScoreState(PlayState *game, QState *parent); -private: - QPropertyAnimation *scoreAnimation; - PlayState *game; -}; - -//These transtion is used to update the score -class UpdateScoreTransition : public QSignalTransition -{ -public: - UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); -protected: - virtual bool eventTest(QEvent *event); -private: - PlayState * game; - GraphicsScene *scene; -}; - -//These transtion test if we have won the game -class WinTransition : public QSignalTransition -{ -public: - WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); -protected: - virtual bool eventTest(QEvent *event); -private: - PlayState * game; - GraphicsScene *scene; -}; - -//These transtion is true if one level has been completed and the player want to continue - class CustomSpaceTransition : public QKeyEventTransition -{ -public: - CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key); -protected: - virtual bool eventTest(QEvent *event); -private: - PlayState *game; - int key; -}; - -#endif // STATES_H diff --git a/examples/animation/sub-attaq/sub-attaq.pro b/examples/animation/sub-attaq/sub-attaq.pro deleted file mode 100644 index 6d9b3195ac..0000000000 --- a/examples/animation/sub-attaq/sub-attaq.pro +++ /dev/null @@ -1,42 +0,0 @@ -QT += widgets -contains(QT_CONFIG, opengl):QT += opengl -HEADERS += boat.h \ - bomb.h \ - mainwindow.h \ - submarine.h \ - torpedo.h \ - pixmapitem.h \ - graphicsscene.h \ - animationmanager.h \ - states.h \ - boat_p.h \ - submarine_p.h \ - qanimationstate.h \ - progressitem.h \ - textinformationitem.h -SOURCES += boat.cpp \ - bomb.cpp \ - main.cpp \ - mainwindow.cpp \ - submarine.cpp \ - torpedo.cpp \ - pixmapitem.cpp \ - graphicsscene.cpp \ - animationmanager.cpp \ - states.cpp \ - qanimationstate.cpp \ - progressitem.cpp \ - textinformationitem.cpp -RESOURCES += subattaq.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/sub-attaq -sources.files = $$SOURCES \ - $$HEADERS \ - $$RESOURCES \ - $$FORMS \ - sub-attaq.pro \ - pics -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/sub-attaq -INSTALLS += target \ - sources diff --git a/examples/animation/sub-attaq/subattaq.qrc b/examples/animation/sub-attaq/subattaq.qrc deleted file mode 100644 index 80a3af11cc..0000000000 --- a/examples/animation/sub-attaq/subattaq.qrc +++ /dev/null @@ -1,39 +0,0 @@ - - - pics/scalable/sub-attaq.svg - pics/scalable/submarine.svg - pics/scalable/boat.svg - pics/scalable/torpedo.svg - pics/welcome/logo-s.png - pics/welcome/logo-u.png - pics/welcome/logo-b.png - pics/welcome/logo-dash.png - pics/welcome/logo-a.png - pics/welcome/logo-t.png - pics/welcome/logo-t2.png - pics/welcome/logo-a2.png - pics/welcome/logo-q.png - pics/welcome/logo-excl.png - pics/big/background.png - pics/big/boat.png - pics/big/bomb.png - pics/big/submarine.png - pics/big/surface.png - pics/big/torpedo.png - pics/small/background.png - pics/small/boat.png - pics/small/bomb.png - pics/small/submarine.png - pics/small/surface.png - pics/small/torpedo.png - pics/big/explosion/boat/step1.png - pics/big/explosion/boat/step2.png - pics/big/explosion/boat/step3.png - pics/big/explosion/boat/step4.png - pics/big/explosion/submarine/step1.png - pics/big/explosion/submarine/step2.png - pics/big/explosion/submarine/step3.png - pics/big/explosion/submarine/step4.png - data.xml - - diff --git a/examples/animation/sub-attaq/submarine.cpp b/examples/animation/sub-attaq/submarine.cpp deleted file mode 100644 index 68eaf7ef38..0000000000 --- a/examples/animation/sub-attaq/submarine.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "submarine.h" -#include "submarine_p.h" -#include "torpedo.h" -#include "pixmapitem.h" -#include "graphicsscene.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -#include -#include -#include -#include - -static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub) -{ - QSequentialAnimationGroup *group = new QSequentialAnimationGroup(sub); - for (int i = 1; i <= 4; ++i) { - PixmapItem *step = new PixmapItem(QString::fromLatin1("explosion/submarine/step%1").arg(i), GraphicsScene::Big, sub); - step->setZValue(6); - step->setOpacity(0); - QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity", group); - anim->setDuration(100); - anim->setEndValue(1); - } - AnimationManager::self()->registerAnimation(group); - return group; -} - - -SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QString("submarine"), GraphicsScene::Big), - subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None) -{ - setZValue(5); - setTransformOriginPoint(boundingRect().center()); - - graphicsRotation = new QGraphicsRotation(this); - graphicsRotation->setAxis(Qt::YAxis); - graphicsRotation->setOrigin(QVector3D(size().width()/2, size().height()/2, 0)); - QList r; - r.append(graphicsRotation); - setTransformations(r); - - //We setup the state machine of the submarine - QStateMachine *machine = new QStateMachine(this); - - //This state is when the boat is moving/rotating - QState *moving = new QState(machine); - - //This state is when the boat is moving from left to right - MovementState *movement = new MovementState(this, moving); - - //This state is when the boat is moving from left to right - ReturnState *rotation = new ReturnState(this, moving); - - //This is the initial state of the moving root state - moving->setInitialState(movement); - - movement->addTransition(this, SIGNAL(subMarineStateChanged()), moving); - - //This is the initial state of the machine - machine->setInitialState(moving); - - //End - QFinalState *final = new QFinalState(machine); - - //If the moving animation is finished we move to the return state - movement->addTransition(movement, SIGNAL(animationFinished()), rotation); - - //If the return animation is finished we move to the moving state - rotation->addTransition(rotation, SIGNAL(animationFinished()), movement); - - //This state play the destroyed animation - QAnimationState *destroyedState = new QAnimationState(machine); - destroyedState->setAnimation(setupDestroyAnimation(this)); - - //Play a nice animation when the submarine is destroyed - moving->addTransition(this, SIGNAL(subMarineDestroyed()), destroyedState); - - //Transition to final state when the destroyed animation is finished - destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final); - - //The machine has finished to be executed, then the submarine is dead - connect(machine,SIGNAL(finished()),this, SIGNAL(subMarineExecutionFinished())); - - machine->start(); -} - -int SubMarine::points() const -{ - return subPoints; -} - -void SubMarine::setCurrentDirection(SubMarine::Movement direction) -{ - if (this->direction == direction) - return; - if (direction == SubMarine::Right && this->direction == SubMarine::None) { - graphicsRotation->setAngle(180); - } - this->direction = direction; -} - -enum SubMarine::Movement SubMarine::currentDirection() const -{ - return direction; -} - -void SubMarine::setCurrentSpeed(int speed) -{ - if (speed < 0 || speed > 3) { - qWarning("SubMarine::setCurrentSpeed : The speed is invalid"); - } - this->speed = speed; - emit subMarineStateChanged(); -} - -int SubMarine::currentSpeed() const -{ - return speed; -} - -void SubMarine::launchTorpedo(int speed) -{ - Torpedo * torp = new Torpedo(); - GraphicsScene *scene = static_cast(this->scene()); - scene->addItem(torp); - torp->setPos(pos()); - torp->setCurrentSpeed(speed); - torp->launch(); -} - -void SubMarine::destroy() -{ - emit subMarineDestroyed(); -} - -int SubMarine::type() const -{ - return Type; -} diff --git a/examples/animation/sub-attaq/submarine.h b/examples/animation/sub-attaq/submarine.h deleted file mode 100644 index b113bc8797..0000000000 --- a/examples/animation/sub-attaq/submarine.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __SUBMARINE__H__ -#define __SUBMARINE__H__ - -//Qt -#include - -#include "pixmapitem.h" - -class Torpedo; - -class SubMarine : public PixmapItem -{ -Q_OBJECT -public: - enum Movement { - None = 0, - Left, - Right - }; - enum { Type = UserType + 1 }; - SubMarine(int type, const QString &name, int points); - - int points() const; - - void setCurrentDirection(Movement direction); - enum Movement currentDirection() const; - - void setCurrentSpeed(int speed); - int currentSpeed() const; - - void launchTorpedo(int speed); - void destroy(); - - virtual int type() const; - - QGraphicsRotation *rotation() const { return graphicsRotation; } - -signals: - void subMarineDestroyed(); - void subMarineExecutionFinished(); - void subMarineStateChanged(); - -private: - int subType; - QString subName; - int subPoints; - int speed; - Movement direction; - QGraphicsRotation *graphicsRotation; -}; - -#endif //__SUBMARINE__H__ diff --git a/examples/animation/sub-attaq/submarine_p.h b/examples/animation/sub-attaq/submarine_p.h deleted file mode 100644 index f24487aa17..0000000000 --- a/examples/animation/sub-attaq/submarine_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SUBMARINE_P_H -#define SUBMARINE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -//Own -#include "animationmanager.h" -#include "submarine.h" -#include "qanimationstate.h" - -//Qt -#include -#include - -//This state is describing when the boat is moving right -class MovementState : public QAnimationState -{ -Q_OBJECT -public: - MovementState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) - { - movementAnimation = new QPropertyAnimation(submarine, "pos"); - connect(movementAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationMovementValueChanged(const QVariant &))); - setAnimation(movementAnimation); - AnimationManager::self()->registerAnimation(movementAnimation); - this->submarine = submarine; - } - -protected slots: - void onAnimationMovementValueChanged(const QVariant &) - { - if (qrand() % 200 + 1 == 3) - submarine->launchTorpedo(qrand() % 3 + 1); - } - -protected: - void onEntry(QEvent *e) - { - if (submarine->currentDirection() == SubMarine::Left) { - movementAnimation->setEndValue(QPointF(0,submarine->y())); - movementAnimation->setDuration(submarine->x()/submarine->currentSpeed()*12); - } - else /*if (submarine->currentDirection() == SubMarine::Right)*/ { - movementAnimation->setEndValue(QPointF(submarine->scene()->width()-submarine->size().width(),submarine->y())); - movementAnimation->setDuration((submarine->scene()->width()-submarine->size().width()-submarine->x())/submarine->currentSpeed()*12); - } - QAnimationState::onEntry(e); - } - -private: - SubMarine *submarine; - QPropertyAnimation *movementAnimation; -}; - -//This state is describing when the boat is moving right -class ReturnState : public QAnimationState -{ -public: - ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) - { - returnAnimation = new QPropertyAnimation(submarine->rotation(), "angle"); - returnAnimation->setDuration(500); - AnimationManager::self()->registerAnimation(returnAnimation); - setAnimation(returnAnimation); - this->submarine = submarine; - } - -protected: - void onEntry(QEvent *e) - { - returnAnimation->stop(); - returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.); - QAnimationState::onEntry(e); - } - - void onExit(QEvent *e) - { - submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right); - QAnimationState::onExit(e); - } - -private: - SubMarine *submarine; - QPropertyAnimation *returnAnimation; -}; - -#endif // SUBMARINE_P_H diff --git a/examples/animation/sub-attaq/textinformationitem.cpp b/examples/animation/sub-attaq/textinformationitem.cpp deleted file mode 100644 index ce2e297287..0000000000 --- a/examples/animation/sub-attaq/textinformationitem.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "textinformationitem.h" -#include "pixmapitem.h" - -TextInformationItem::TextInformationItem (QGraphicsItem * parent) - : QGraphicsTextItem(parent) -{ - setFont(QFont("Comic Sans MS", 15)); -} -#include -void TextInformationItem::setMessage(const QString& text) -{ - setHtml(text); - setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y()); -} diff --git a/examples/animation/sub-attaq/textinformationitem.h b/examples/animation/sub-attaq/textinformationitem.h deleted file mode 100644 index adad8be90b..0000000000 --- a/examples/animation/sub-attaq/textinformationitem.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTINFORMATIONITEM_H -#define TEXTINFORMATIONITEM_H - -//Qt -#include - -class TextInformationItem : public QGraphicsTextItem -{ -public: - TextInformationItem(QGraphicsItem * parent = 0); - void setMessage(const QString& text); -}; - -#endif // TEXTINFORMATIONITEM_H diff --git a/examples/animation/sub-attaq/torpedo.cpp b/examples/animation/sub-attaq/torpedo.cpp deleted file mode 100644 index 34c32fe059..0000000000 --- a/examples/animation/sub-attaq/torpedo.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Own -#include "torpedo.h" -#include "pixmapitem.h" -#include "boat.h" -#include "graphicsscene.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -#include -#include -#include - -Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big), - currentSpeed(0) -{ - setZValue(2); -} - -void Torpedo::launch() -{ - QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos"); - AnimationManager::self()->registerAnimation(launchAnimation); - launchAnimation->setEndValue(QPointF(x(),qobject_cast(scene())->sealLevel() - 15)); - launchAnimation->setEasingCurve(QEasingCurve::InQuad); - launchAnimation->setDuration(y()/currentSpeed*10); - connect(launchAnimation,SIGNAL(valueChanged(QVariant)),this,SLOT(onAnimationLaunchValueChanged(QVariant))); - connect(this,SIGNAL(torpedoExploded()), launchAnimation, SLOT(stop())); - - //We setup the state machine of the torpedo - QStateMachine *machine = new QStateMachine(this); - - //This state is when the launch animation is playing - QAnimationState *launched = new QAnimationState(machine); - launched->setAnimation(launchAnimation); - - //End - QFinalState *final = new QFinalState(machine); - - machine->setInitialState(launched); - - //### Add a nice animation when the torpedo is destroyed - launched->addTransition(this, SIGNAL(torpedoExploded()),final); - - //If the animation is finished, then we move to the final state - launched->addTransition(launched, SIGNAL(animationFinished()), final); - - //The machine has finished to be executed, then the boat is dead - connect(machine,SIGNAL(finished()),this, SIGNAL(torpedoExecutionFinished())); - - machine->start(); -} - -void Torpedo::setCurrentSpeed(int speed) -{ - if (speed < 0) { - qWarning("Torpedo::setCurrentSpeed : The speed is invalid"); - return; - } - currentSpeed = speed; -} - -void Torpedo::onAnimationLaunchValueChanged(const QVariant &) -{ - foreach (QGraphicsItem *item , collidingItems(Qt::IntersectsItemBoundingRect)) { - if (Boat *b = qgraphicsitem_cast(item)) - b->destroy(); - } -} - -void Torpedo::destroy() -{ - emit torpedoExploded(); -} diff --git a/examples/animation/sub-attaq/torpedo.h b/examples/animation/sub-attaq/torpedo.h deleted file mode 100644 index 59209e3d75..0000000000 --- a/examples/animation/sub-attaq/torpedo.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __TORPEDO__H__ -#define __TORPEDO__H__ - -#include "pixmapitem.h" - -class Torpedo : public PixmapItem -{ -Q_OBJECT -public: - Torpedo(); - void launch(); - void setCurrentSpeed(int speed); - void destroy(); - -signals: - void torpedoExploded(); - void torpedoExecutionFinished(); - -private slots: - void onAnimationLaunchValueChanged(const QVariant &); - -private: - int currentSpeed; -}; - -#endif //__TORPEDO__H__ diff --git a/examples/desktop/README b/examples/desktop/README deleted file mode 100644 index 4a949d1cf7..0000000000 --- a/examples/desktop/README +++ /dev/null @@ -1,10 +0,0 @@ -Qt provides features to enable applications to integrate with the user's -preferred desktop environment. - -Features such as system tray icons, access to the desktop widget, and -support for desktop services can be used to improve the appearance of -applications and take advantage of underlying desktop facilities. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/desktop/desktop.pro b/examples/desktop/desktop.pro deleted file mode 100644 index adfa51f130..0000000000 --- a/examples/desktop/desktop.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered -SUBDIRS = screenshot systray - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS desktop.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop -INSTALLS += target sources - -QT += widgets diff --git a/examples/desktop/screenshot/main.cpp b/examples/desktop/screenshot/main.cpp deleted file mode 100644 index 3f9b2e1126..0000000000 --- a/examples/desktop/screenshot/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "screenshot.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Screenshot screenshot; - screenshot.show(); - return app.exec(); -} diff --git a/examples/desktop/screenshot/screenshot.cpp b/examples/desktop/screenshot/screenshot.cpp deleted file mode 100644 index 12c6bee6d4..0000000000 --- a/examples/desktop/screenshot/screenshot.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "screenshot.h" - -//! [0] -Screenshot::Screenshot() -{ - screenshotLabel = new QLabel; - screenshotLabel->setSizePolicy(QSizePolicy::Expanding, - QSizePolicy::Expanding); - screenshotLabel->setAlignment(Qt::AlignCenter); - screenshotLabel->setMinimumSize(240, 160); - - createOptionsGroupBox(); - createButtonsLayout(); - - mainLayout = new QVBoxLayout; - mainLayout->addWidget(screenshotLabel); - mainLayout->addWidget(optionsGroupBox); - mainLayout->addLayout(buttonsLayout); - setLayout(mainLayout); - - shootScreen(); - delaySpinBox->setValue(5); - - setWindowTitle(tr("Screenshot")); - resize(300, 200); -} -//! [0] - -//! [1] -void Screenshot::resizeEvent(QResizeEvent * /* event */) -{ - QSize scaledSize = originalPixmap.size(); - scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio); - if (!screenshotLabel->pixmap() - || scaledSize != screenshotLabel->pixmap()->size()) - updateScreenshotLabel(); -} -//! [1] - -//! [2] -void Screenshot::newScreenshot() -{ - if (hideThisWindowCheckBox->isChecked()) - hide(); - newScreenshotButton->setDisabled(true); - - QTimer::singleShot(delaySpinBox->value() * 1000, this, SLOT(shootScreen())); -} -//! [2] - -//! [3] -void Screenshot::saveScreenshot() -{ - QString format = "png"; - QString initialPath = QDir::currentPath() + tr("/untitled.") + format; - - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), - initialPath, - tr("%1 Files (*.%2);;All Files (*)") - .arg(format.toUpper()) - .arg(format)); - if (!fileName.isEmpty()) - originalPixmap.save(fileName, format.toLatin1().constData()); -} -//! [3] - -//! [4] -void Screenshot::shootScreen() -{ - if (delaySpinBox->value() != 0) - qApp->beep(); -//! [4] - originalPixmap = QPixmap(); // clear image for low memory situations - // on embedded devices. -//! [5] - QScreen *screen = QGuiApplication::primaryScreen(); - if (screen) - originalPixmap = screen->grabWindow(0); - updateScreenshotLabel(); - - newScreenshotButton->setDisabled(false); - if (hideThisWindowCheckBox->isChecked()) - show(); -} -//! [5] - -//! [6] -void Screenshot::updateCheckBox() -{ - if (delaySpinBox->value() == 0) { - hideThisWindowCheckBox->setDisabled(true); - hideThisWindowCheckBox->setChecked(false); - } - else - hideThisWindowCheckBox->setDisabled(false); -} -//! [6] - -//! [7] -void Screenshot::createOptionsGroupBox() -{ - optionsGroupBox = new QGroupBox(tr("Options")); - - delaySpinBox = new QSpinBox; - delaySpinBox->setSuffix(tr(" s")); - delaySpinBox->setMaximum(60); - connect(delaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateCheckBox())); - - delaySpinBoxLabel = new QLabel(tr("Screenshot Delay:")); - - hideThisWindowCheckBox = new QCheckBox(tr("Hide This Window")); - - optionsGroupBoxLayout = new QGridLayout; - optionsGroupBoxLayout->addWidget(delaySpinBoxLabel, 0, 0); - optionsGroupBoxLayout->addWidget(delaySpinBox, 0, 1); - optionsGroupBoxLayout->addWidget(hideThisWindowCheckBox, 1, 0, 1, 2); - optionsGroupBox->setLayout(optionsGroupBoxLayout); -} -//! [7] - -//! [8] -void Screenshot::createButtonsLayout() -{ - newScreenshotButton = createButton(tr("New Screenshot"), - this, SLOT(newScreenshot())); - - saveScreenshotButton = createButton(tr("Save Screenshot"), - this, SLOT(saveScreenshot())); - - quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close())); - - buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(); - buttonsLayout->addWidget(newScreenshotButton); - buttonsLayout->addWidget(saveScreenshotButton); - buttonsLayout->addWidget(quitScreenshotButton); -} -//! [8] - -//! [9] -QPushButton *Screenshot::createButton(const QString &text, QWidget *receiver, - const char *member) -{ - QPushButton *button = new QPushButton(text); - button->connect(button, SIGNAL(clicked()), receiver, member); - return button; -} -//! [9] - -//! [10] -void Screenshot::updateScreenshotLabel() -{ - screenshotLabel->setPixmap(originalPixmap.scaled(screenshotLabel->size(), - Qt::KeepAspectRatio, - Qt::SmoothTransformation)); -} -//! [10] diff --git a/examples/desktop/screenshot/screenshot.desktop b/examples/desktop/screenshot/screenshot.desktop deleted file mode 100644 index 236d360123..0000000000 --- a/examples/desktop/screenshot/screenshot.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Screenshot -Exec=/opt/usr/bin/screenshot -Icon=screenshot -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/desktop/screenshot/screenshot.h b/examples/desktop/screenshot/screenshot.h deleted file mode 100644 index 98251f3428..0000000000 --- a/examples/desktop/screenshot/screenshot.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 SCREENSHOT_H -#define SCREENSHOT_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QGridLayout; -class QGroupBox; -class QHBoxLayout; -class QLabel; -class QPushButton; -class QSpinBox; -class QVBoxLayout; -QT_END_NAMESPACE - -//! [0] -class Screenshot : public QWidget -{ - Q_OBJECT - -public: - Screenshot(); - -protected: - void resizeEvent(QResizeEvent *event); - -private slots: - void newScreenshot(); - void saveScreenshot(); - void shootScreen(); - void updateCheckBox(); - -private: - void createOptionsGroupBox(); - void createButtonsLayout(); - QPushButton *createButton(const QString &text, QWidget *receiver, - const char *member); - void updateScreenshotLabel(); - - QPixmap originalPixmap; - - QLabel *screenshotLabel; - QGroupBox *optionsGroupBox; - QSpinBox *delaySpinBox; - QLabel *delaySpinBoxLabel; - QCheckBox *hideThisWindowCheckBox; - QPushButton *newScreenshotButton; - QPushButton *saveScreenshotButton; - QPushButton *quitScreenshotButton; - - QVBoxLayout *mainLayout; - QGridLayout *optionsGroupBoxLayout; - QHBoxLayout *buttonsLayout; -}; -//! [0] - -#endif diff --git a/examples/desktop/screenshot/screenshot.pro b/examples/desktop/screenshot/screenshot.pro deleted file mode 100644 index e9f53f7450..0000000000 --- a/examples/desktop/screenshot/screenshot.pro +++ /dev/null @@ -1,12 +0,0 @@ -HEADERS = screenshot.h -SOURCES = main.cpp \ - screenshot.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop/screenshot -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS screenshot.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop/screenshot -INSTALLS += target sources - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/desktop/systray/images/bad.png b/examples/desktop/systray/images/bad.png deleted file mode 100644 index c8701a241a..0000000000 Binary files a/examples/desktop/systray/images/bad.png and /dev/null differ diff --git a/examples/desktop/systray/images/heart.png b/examples/desktop/systray/images/heart.png deleted file mode 100644 index cee1302b7d..0000000000 Binary files a/examples/desktop/systray/images/heart.png and /dev/null differ diff --git a/examples/desktop/systray/images/trash.png b/examples/desktop/systray/images/trash.png deleted file mode 100644 index 4c24db926d..0000000000 Binary files a/examples/desktop/systray/images/trash.png and /dev/null differ diff --git a/examples/desktop/systray/main.cpp b/examples/desktop/systray/main.cpp deleted file mode 100644 index 6695113f71..0000000000 --- a/examples/desktop/systray/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#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.desktop b/examples/desktop/systray/systray.desktop deleted file mode 100644 index 0490e71548..0000000000 --- a/examples/desktop/systray/systray.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=System Tray Icon -Exec=/opt/usr/bin/systray -Icon=systray -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/desktop/systray/systray.pro b/examples/desktop/systray/systray.pro deleted file mode 100644 index 5fdcf1f9c8..0000000000 --- a/examples/desktop/systray/systray.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp -RESOURCES = systray.qrc - -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop/systray -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS systray.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop/systray -INSTALLS += target sources - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/desktop/systray/systray.qrc b/examples/desktop/systray/systray.qrc deleted file mode 100644 index a8b6535849..0000000000 --- a/examples/desktop/systray/systray.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/bad.png - images/heart.png - images/trash.png - - diff --git a/examples/desktop/systray/window.cpp b/examples/desktop/systray/window.cpp deleted file mode 100644 index c75e3590ba..0000000000 --- a/examples/desktop/systray/window.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "window.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//! [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 Quit 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.png"), tr("Bad")); - iconComboBox->addItem(QIcon(":/images/heart.png"), tr("Heart")); - iconComboBox->addItem(QIcon(":/images/trash.png"), 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 deleted file mode 100644 index 80b7a20754..0000000000 --- a/examples/desktop/systray/window.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -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/dialogs/README b/examples/dialogs/README deleted file mode 100644 index 090b011061..0000000000 --- a/examples/dialogs/README +++ /dev/null @@ -1,9 +0,0 @@ -Qt includes standard dialogs for many common operations, such as file -selection, printing, and color selection. - -Custom dialogs can also be created for specialized modal or modeless -interactions with users. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/dialogs/classwizard/classwizard.cpp b/examples/dialogs/classwizard/classwizard.cpp deleted file mode 100644 index eeb1fab55b..0000000000 --- a/examples/dialogs/classwizard/classwizard.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "classwizard.h" - -//! [0] //! [1] -ClassWizard::ClassWizard(QWidget *parent) - : QWizard(parent) -{ - addPage(new IntroPage); - addPage(new ClassInfoPage); - addPage(new CodeStylePage); - addPage(new OutputFilesPage); - addPage(new ConclusionPage); -//! [0] - - setPixmap(QWizard::BannerPixmap, QPixmap(":/images/banner.png")); - setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/background.png")); - - setWindowTitle(tr("Class Wizard")); -//! [2] -} -//! [1] //! [2] - -//! [3] -void ClassWizard::accept() -//! [3] //! [4] -{ - QByteArray className = field("className").toByteArray(); - QByteArray baseClass = field("baseClass").toByteArray(); - QByteArray macroName = field("macroName").toByteArray(); - QByteArray baseInclude = field("baseInclude").toByteArray(); - - QString outputDir = field("outputDir").toString(); - QString header = field("header").toString(); - QString implementation = field("implementation").toString(); -//! [4] - - QByteArray block; - - if (field("comment").toBool()) { - block += "/*\n"; - block += " " + header.toLatin1() + "\n"; - block += "*/\n"; - block += "\n"; - } - if (field("protect").toBool()) { - block += "#ifndef " + macroName + "\n"; - block += "#define " + macroName + "\n"; - block += "\n"; - } - if (field("includeBase").toBool()) { - block += "#include " + baseInclude + "\n"; - block += "\n"; - } - - block += "class " + className; - if (!baseClass.isEmpty()) - block += " : public " + baseClass; - block += "\n"; - block += "{\n"; - - /* qmake ignore Q_OBJECT */ - - if (field("qobjectMacro").toBool()) { - block += " Q_OBJECT\n"; - block += "\n"; - } - block += "public:\n"; - - if (field("qobjectCtor").toBool()) { - block += " " + className + "(QObject *parent = 0);\n"; - } else if (field("qwidgetCtor").toBool()) { - block += " " + className + "(QWidget *parent = 0);\n"; - } else if (field("defaultCtor").toBool()) { - block += " " + className + "();\n"; - if (field("copyCtor").toBool()) { - block += " " + className + "(const " + className + " &other);\n"; - block += "\n"; - block += " " + className + " &operator=" + "(const " + className - + " &other);\n"; - } - } - block += "};\n"; - - if (field("protect").toBool()) { - block += "\n"; - block += "#endif\n"; - } - - QFile headerFile(outputDir + "/" + header); - if (!headerFile.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(0, QObject::tr("Simple Wizard"), - QObject::tr("Cannot write file %1:\n%2") - .arg(headerFile.fileName()) - .arg(headerFile.errorString())); - return; - } - headerFile.write(block); - - block.clear(); - - if (field("comment").toBool()) { - block += "/*\n"; - block += " " + implementation.toLatin1() + "\n"; - block += "*/\n"; - block += "\n"; - } - block += "#include \"" + header.toLatin1() + "\"\n"; - block += "\n"; - - if (field("qobjectCtor").toBool()) { - block += className + "::" + className + "(QObject *parent)\n"; - block += " : " + baseClass + "(parent)\n"; - block += "{\n"; - block += "}\n"; - } else if (field("qwidgetCtor").toBool()) { - block += className + "::" + className + "(QWidget *parent)\n"; - block += " : " + baseClass + "(parent)\n"; - block += "{\n"; - block += "}\n"; - } else if (field("defaultCtor").toBool()) { - block += className + "::" + className + "()\n"; - block += "{\n"; - block += " // missing code\n"; - block += "}\n"; - - if (field("copyCtor").toBool()) { - block += "\n"; - block += className + "::" + className + "(const " + className - + " &other)\n"; - block += "{\n"; - block += " *this = other;\n"; - block += "}\n"; - block += "\n"; - block += className + " &" + className + "::operator=(const " - + className + " &other)\n"; - block += "{\n"; - if (!baseClass.isEmpty()) - block += " " + baseClass + "::operator=(other);\n"; - block += " // missing code\n"; - block += " return *this;\n"; - block += "}\n"; - } - } - - QFile implementationFile(outputDir + "/" + implementation); - if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(0, QObject::tr("Simple Wizard"), - QObject::tr("Cannot write file %1:\n%2") - .arg(implementationFile.fileName()) - .arg(implementationFile.errorString())); - return; - } - implementationFile.write(block); - -//! [5] - QDialog::accept(); -//! [5] //! [6] -} -//! [6] - -//! [7] -IntroPage::IntroPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Introduction")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark1.png")); - - label = new QLabel(tr("This wizard will generate a skeleton C++ class " - "definition, including a few functions. You simply " - "need to specify the class name and set a few " - "options to produce a header file and an " - "implementation file for your new C++ class.")); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - setLayout(layout); -} -//! [7] - -//! [8] //! [9] -ClassInfoPage::ClassInfoPage(QWidget *parent) - : QWizardPage(parent) -{ -//! [8] - setTitle(tr("Class Information")); - setSubTitle(tr("Specify basic information about the class for which you " - "want to generate skeleton source code files.")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo1.png")); - -//! [10] - classNameLabel = new QLabel(tr("&Class name:")); - classNameLineEdit = new QLineEdit; - classNameLabel->setBuddy(classNameLineEdit); - - baseClassLabel = new QLabel(tr("B&ase class:")); - baseClassLineEdit = new QLineEdit; - baseClassLabel->setBuddy(baseClassLineEdit); - - qobjectMacroCheckBox = new QCheckBox(tr("Generate Q_OBJECT ¯o")); - -//! [10] - groupBox = new QGroupBox(tr("C&onstructor")); -//! [9] - - qobjectCtorRadioButton = new QRadioButton(tr("&QObject-style constructor")); - qwidgetCtorRadioButton = new QRadioButton(tr("Q&Widget-style constructor")); - defaultCtorRadioButton = new QRadioButton(tr("&Default constructor")); - copyCtorCheckBox = new QCheckBox(tr("&Generate copy constructor and " - "operator=")); - - defaultCtorRadioButton->setChecked(true); - - connect(defaultCtorRadioButton, SIGNAL(toggled(bool)), - copyCtorCheckBox, SLOT(setEnabled(bool))); - -//! [11] //! [12] - registerField("className*", classNameLineEdit); - registerField("baseClass", baseClassLineEdit); - registerField("qobjectMacro", qobjectMacroCheckBox); -//! [11] - registerField("qobjectCtor", qobjectCtorRadioButton); - registerField("qwidgetCtor", qwidgetCtorRadioButton); - registerField("defaultCtor", defaultCtorRadioButton); - registerField("copyCtor", copyCtorCheckBox); - - QVBoxLayout *groupBoxLayout = new QVBoxLayout; -//! [12] - groupBoxLayout->addWidget(qobjectCtorRadioButton); - groupBoxLayout->addWidget(qwidgetCtorRadioButton); - groupBoxLayout->addWidget(defaultCtorRadioButton); - groupBoxLayout->addWidget(copyCtorCheckBox); - groupBox->setLayout(groupBoxLayout); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(classNameLabel, 0, 0); - layout->addWidget(classNameLineEdit, 0, 1); - layout->addWidget(baseClassLabel, 1, 0); - layout->addWidget(baseClassLineEdit, 1, 1); - layout->addWidget(qobjectMacroCheckBox, 2, 0, 1, 2); - layout->addWidget(groupBox, 3, 0, 1, 2); - setLayout(layout); -//! [13] -} -//! [13] - -//! [14] -CodeStylePage::CodeStylePage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Code Style Options")); - setSubTitle(tr("Choose the formatting of the generated code.")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo2.png")); - - commentCheckBox = new QCheckBox(tr("&Start generated files with a " -//! [14] - "comment")); - commentCheckBox->setChecked(true); - - protectCheckBox = new QCheckBox(tr("&Protect header file against multiple " - "inclusions")); - protectCheckBox->setChecked(true); - - macroNameLabel = new QLabel(tr("&Macro name:")); - macroNameLineEdit = new QLineEdit; - macroNameLabel->setBuddy(macroNameLineEdit); - - includeBaseCheckBox = new QCheckBox(tr("&Include base class definition")); - baseIncludeLabel = new QLabel(tr("Base class include:")); - baseIncludeLineEdit = new QLineEdit; - baseIncludeLabel->setBuddy(baseIncludeLineEdit); - - connect(protectCheckBox, SIGNAL(toggled(bool)), - macroNameLabel, SLOT(setEnabled(bool))); - connect(protectCheckBox, SIGNAL(toggled(bool)), - macroNameLineEdit, SLOT(setEnabled(bool))); - connect(includeBaseCheckBox, SIGNAL(toggled(bool)), - baseIncludeLabel, SLOT(setEnabled(bool))); - connect(includeBaseCheckBox, SIGNAL(toggled(bool)), - baseIncludeLineEdit, SLOT(setEnabled(bool))); - - registerField("comment", commentCheckBox); - registerField("protect", protectCheckBox); - registerField("macroName", macroNameLineEdit); - registerField("includeBase", includeBaseCheckBox); - registerField("baseInclude", baseIncludeLineEdit); - - QGridLayout *layout = new QGridLayout; - layout->setColumnMinimumWidth(0, 20); - layout->addWidget(commentCheckBox, 0, 0, 1, 3); - layout->addWidget(protectCheckBox, 1, 0, 1, 3); - layout->addWidget(macroNameLabel, 2, 1); - layout->addWidget(macroNameLineEdit, 2, 2); - layout->addWidget(includeBaseCheckBox, 3, 0, 1, 3); - layout->addWidget(baseIncludeLabel, 4, 1); - layout->addWidget(baseIncludeLineEdit, 4, 2); -//! [15] - setLayout(layout); -} -//! [15] - -//! [16] -void CodeStylePage::initializePage() -{ - QString className = field("className").toString(); - macroNameLineEdit->setText(className.toUpper() + "_H"); - - QString baseClass = field("baseClass").toString(); - - includeBaseCheckBox->setChecked(!baseClass.isEmpty()); - includeBaseCheckBox->setEnabled(!baseClass.isEmpty()); - baseIncludeLabel->setEnabled(!baseClass.isEmpty()); - baseIncludeLineEdit->setEnabled(!baseClass.isEmpty()); - - if (baseClass.isEmpty()) { - baseIncludeLineEdit->clear(); - } else if (QRegExp("Q[A-Z].*").exactMatch(baseClass)) { - baseIncludeLineEdit->setText("<" + baseClass + ">"); - } else { - baseIncludeLineEdit->setText("\"" + baseClass.toLower() + ".h\""); - } -} -//! [16] - -OutputFilesPage::OutputFilesPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Output Files")); - setSubTitle(tr("Specify where you want the wizard to put the generated " - "skeleton code.")); - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo3.png")); - - outputDirLabel = new QLabel(tr("&Output directory:")); - outputDirLineEdit = new QLineEdit; - outputDirLabel->setBuddy(outputDirLineEdit); - - headerLabel = new QLabel(tr("&Header file name:")); - headerLineEdit = new QLineEdit; - headerLabel->setBuddy(headerLineEdit); - - implementationLabel = new QLabel(tr("&Implementation file name:")); - implementationLineEdit = new QLineEdit; - implementationLabel->setBuddy(implementationLineEdit); - - registerField("outputDir*", outputDirLineEdit); - registerField("header*", headerLineEdit); - registerField("implementation*", implementationLineEdit); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(outputDirLabel, 0, 0); - layout->addWidget(outputDirLineEdit, 0, 1); - layout->addWidget(headerLabel, 1, 0); - layout->addWidget(headerLineEdit, 1, 1); - layout->addWidget(implementationLabel, 2, 0); - layout->addWidget(implementationLineEdit, 2, 1); - setLayout(layout); -} - -//! [17] -void OutputFilesPage::initializePage() -{ - QString className = field("className").toString(); - headerLineEdit->setText(className.toLower() + ".h"); - implementationLineEdit->setText(className.toLower() + ".cpp"); - outputDirLineEdit->setText(QDir::toNativeSeparators(QDir::tempPath())); -} -//! [17] - -ConclusionPage::ConclusionPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Conclusion")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark2.png")); - - label = new QLabel; - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - setLayout(layout); -} - -void ConclusionPage::initializePage() -{ - QString finishText = wizard()->buttonText(QWizard::FinishButton); - finishText.remove('&'); - label->setText(tr("Click %1 to generate the class skeleton.") - .arg(finishText)); -} diff --git a/examples/dialogs/classwizard/classwizard.desktop b/examples/dialogs/classwizard/classwizard.desktop deleted file mode 100644 index 7f7d232092..0000000000 --- a/examples/dialogs/classwizard/classwizard.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Class Wizard -Exec=/opt/usr/bin/classwizard -Icon=classwizard -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/classwizard/classwizard.h b/examples/dialogs/classwizard/classwizard.h deleted file mode 100644 index 332025f207..0000000000 --- a/examples/dialogs/classwizard/classwizard.h +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 CLASSWIZARD_H -#define CLASSWIZARD_H - -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QRadioButton; -QT_END_NAMESPACE - -//! [0] -class ClassWizard : public QWizard -{ - Q_OBJECT - -public: - ClassWizard(QWidget *parent = 0); - - void accept(); -}; -//! [0] - -//! [1] -class IntroPage : public QWizardPage -{ - Q_OBJECT - -public: - IntroPage(QWidget *parent = 0); - -private: - QLabel *label; -}; -//! [1] - -//! [2] -class ClassInfoPage : public QWizardPage -{ - Q_OBJECT - -public: - ClassInfoPage(QWidget *parent = 0); - -private: - QLabel *classNameLabel; - QLabel *baseClassLabel; - QLineEdit *classNameLineEdit; - QLineEdit *baseClassLineEdit; - QCheckBox *qobjectMacroCheckBox; - QGroupBox *groupBox; - QRadioButton *qobjectCtorRadioButton; - QRadioButton *qwidgetCtorRadioButton; - QRadioButton *defaultCtorRadioButton; - QCheckBox *copyCtorCheckBox; -}; -//! [2] - -//! [3] -class CodeStylePage : public QWizardPage -{ - Q_OBJECT - -public: - CodeStylePage(QWidget *parent = 0); - -protected: - void initializePage(); - -private: - QCheckBox *commentCheckBox; - QCheckBox *protectCheckBox; - QCheckBox *includeBaseCheckBox; - QLabel *macroNameLabel; - QLabel *baseIncludeLabel; - QLineEdit *macroNameLineEdit; - QLineEdit *baseIncludeLineEdit; -}; -//! [3] - -class OutputFilesPage : public QWizardPage -{ - Q_OBJECT - -public: - OutputFilesPage(QWidget *parent = 0); - -protected: - void initializePage(); - -private: - QLabel *outputDirLabel; - QLabel *headerLabel; - QLabel *implementationLabel; - QLineEdit *outputDirLineEdit; - QLineEdit *headerLineEdit; - QLineEdit *implementationLineEdit; -}; - -class ConclusionPage : public QWizardPage -{ - Q_OBJECT - -public: - ConclusionPage(QWidget *parent = 0); - -protected: - void initializePage(); - -private: - QLabel *label; -}; - -#endif diff --git a/examples/dialogs/classwizard/classwizard.pro b/examples/dialogs/classwizard/classwizard.pro deleted file mode 100644 index d50ba675af..0000000000 --- a/examples/dialogs/classwizard/classwizard.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = classwizard.h -SOURCES = classwizard.cpp \ - main.cpp -RESOURCES = classwizard.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/classwizard -sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/classwizard -INSTALLS += target sources - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/dialogs/classwizard/classwizard.qrc b/examples/dialogs/classwizard/classwizard.qrc deleted file mode 100644 index 41a5ddc7d1..0000000000 --- a/examples/dialogs/classwizard/classwizard.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - images/background.png - images/banner.png - images/logo1.png - images/logo2.png - images/logo3.png - images/watermark1.png - images/watermark2.png - - diff --git a/examples/dialogs/classwizard/images/background.png b/examples/dialogs/classwizard/images/background.png deleted file mode 100644 index 44c7badb85..0000000000 Binary files a/examples/dialogs/classwizard/images/background.png and /dev/null differ diff --git a/examples/dialogs/classwizard/images/banner.png b/examples/dialogs/classwizard/images/banner.png deleted file mode 100644 index 3169152b8e..0000000000 Binary files a/examples/dialogs/classwizard/images/banner.png and /dev/null differ diff --git a/examples/dialogs/classwizard/images/logo1.png b/examples/dialogs/classwizard/images/logo1.png deleted file mode 100644 index f9b594aafc..0000000000 Binary files a/examples/dialogs/classwizard/images/logo1.png and /dev/null differ diff --git a/examples/dialogs/classwizard/images/logo2.png b/examples/dialogs/classwizard/images/logo2.png deleted file mode 100644 index 5dcbd4669d..0000000000 Binary files a/examples/dialogs/classwizard/images/logo2.png and /dev/null differ diff --git a/examples/dialogs/classwizard/images/logo3.png b/examples/dialogs/classwizard/images/logo3.png deleted file mode 100644 index 9fd3ea2358..0000000000 Binary files a/examples/dialogs/classwizard/images/logo3.png and /dev/null differ diff --git a/examples/dialogs/classwizard/images/watermark1.png b/examples/dialogs/classwizard/images/watermark1.png deleted file mode 100644 index 0091f5c17a..0000000000 Binary files a/examples/dialogs/classwizard/images/watermark1.png and /dev/null differ diff --git a/examples/dialogs/classwizard/images/watermark2.png b/examples/dialogs/classwizard/images/watermark2.png deleted file mode 100644 index 3b88f2e360..0000000000 Binary files a/examples/dialogs/classwizard/images/watermark2.png and /dev/null differ diff --git a/examples/dialogs/classwizard/main.cpp b/examples/dialogs/classwizard/main.cpp deleted file mode 100644 index 03dd625ae4..0000000000 --- a/examples/dialogs/classwizard/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -#include "classwizard.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(classwizard); - - QApplication app(argc, argv); - - QString translatorFileName = QLatin1String("qt_"); - translatorFileName += QLocale::system().name(); - QTranslator *translator = new QTranslator(&app); - if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app.installTranslator(translator); - - ClassWizard wizard; - wizard.show(); - return app.exec(); -} diff --git a/examples/dialogs/configdialog/configdialog.cpp b/examples/dialogs/configdialog/configdialog.cpp deleted file mode 100644 index 2f70c816c4..0000000000 --- a/examples/dialogs/configdialog/configdialog.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "configdialog.h" -#include "pages.h" - -ConfigDialog::ConfigDialog() -{ - contentsWidget = new QListWidget; - contentsWidget->setViewMode(QListView::IconMode); - contentsWidget->setIconSize(QSize(96, 84)); - contentsWidget->setMovement(QListView::Static); - contentsWidget->setMaximumWidth(128); - contentsWidget->setSpacing(12); - - pagesWidget = new QStackedWidget; - pagesWidget->addWidget(new ConfigurationPage); - pagesWidget->addWidget(new UpdatePage); - pagesWidget->addWidget(new QueryPage); - - QPushButton *closeButton = new QPushButton(tr("Close")); - - createIcons(); - contentsWidget->setCurrentRow(0); - - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); - - QHBoxLayout *horizontalLayout = new QHBoxLayout; - horizontalLayout->addWidget(contentsWidget); - horizontalLayout->addWidget(pagesWidget, 1); - - QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(closeButton); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout(horizontalLayout); - mainLayout->addStretch(1); - mainLayout->addSpacing(12); - mainLayout->addLayout(buttonsLayout); - setLayout(mainLayout); - - setWindowTitle(tr("Config Dialog")); -} - -void ConfigDialog::createIcons() -{ - QListWidgetItem *configButton = new QListWidgetItem(contentsWidget); - configButton->setIcon(QIcon(":/images/config.png")); - configButton->setText(tr("Configuration")); - configButton->setTextAlignment(Qt::AlignHCenter); - configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QListWidgetItem *updateButton = new QListWidgetItem(contentsWidget); - updateButton->setIcon(QIcon(":/images/update.png")); - updateButton->setText(tr("Update")); - updateButton->setTextAlignment(Qt::AlignHCenter); - updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget); - queryButton->setIcon(QIcon(":/images/query.png")); - queryButton->setText(tr("Query")); - queryButton->setTextAlignment(Qt::AlignHCenter); - queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - connect(contentsWidget, - SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*))); -} - -void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (!current) - current = previous; - - pagesWidget->setCurrentIndex(contentsWidget->row(current)); -} diff --git a/examples/dialogs/configdialog/configdialog.desktop b/examples/dialogs/configdialog/configdialog.desktop deleted file mode 100644 index 11a326813a..0000000000 --- a/examples/dialogs/configdialog/configdialog.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Config Dialog -Exec=/opt/usr/bin/configdialog -Icon=configdialog -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/configdialog/configdialog.h b/examples/dialogs/configdialog/configdialog.h deleted file mode 100644 index 5b79e416ab..0000000000 --- a/examples/dialogs/configdialog/configdialog.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 CONFIGDIALOG_H -#define CONFIGDIALOG_H - -#include - -QT_BEGIN_NAMESPACE -class QListWidget; -class QListWidgetItem; -class QStackedWidget; -QT_END_NAMESPACE - -class ConfigDialog : public QDialog -{ - Q_OBJECT - -public: - ConfigDialog(); - -public slots: - void changePage(QListWidgetItem *current, QListWidgetItem *previous); - -private: - void createIcons(); - - QListWidget *contentsWidget; - QStackedWidget *pagesWidget; -}; - -#endif diff --git a/examples/dialogs/configdialog/configdialog.pro b/examples/dialogs/configdialog/configdialog.pro deleted file mode 100644 index 643c2a238f..0000000000 --- a/examples/dialogs/configdialog/configdialog.pro +++ /dev/null @@ -1,17 +0,0 @@ -HEADERS = configdialog.h \ - pages.h -SOURCES = configdialog.cpp \ - main.cpp \ - pages.cpp -RESOURCES += configdialog.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/configdialog -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/configdialog -INSTALLS += target sources - -wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/dialogs/configdialog/configdialog.qrc b/examples/dialogs/configdialog/configdialog.qrc deleted file mode 100644 index 31d0d49666..0000000000 --- a/examples/dialogs/configdialog/configdialog.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/config.png - images/query.png - images/update.png - - diff --git a/examples/dialogs/configdialog/images/config.png b/examples/dialogs/configdialog/images/config.png deleted file mode 100644 index 5c14d5f470..0000000000 Binary files a/examples/dialogs/configdialog/images/config.png and /dev/null differ diff --git a/examples/dialogs/configdialog/images/query.png b/examples/dialogs/configdialog/images/query.png deleted file mode 100644 index ea9e291eeb..0000000000 Binary files a/examples/dialogs/configdialog/images/query.png and /dev/null differ diff --git a/examples/dialogs/configdialog/images/update.png b/examples/dialogs/configdialog/images/update.png deleted file mode 100644 index 3cb8ba6c77..0000000000 Binary files a/examples/dialogs/configdialog/images/update.png and /dev/null differ diff --git a/examples/dialogs/configdialog/main.cpp b/examples/dialogs/configdialog/main.cpp deleted file mode 100644 index 42f3cf2f43..0000000000 --- a/examples/dialogs/configdialog/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "configdialog.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(configdialog); - - QApplication app(argc, argv); - ConfigDialog dialog; - return dialog.exec(); -} diff --git a/examples/dialogs/configdialog/pages.cpp b/examples/dialogs/configdialog/pages.cpp deleted file mode 100644 index c89bc3c7c8..0000000000 --- a/examples/dialogs/configdialog/pages.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "pages.h" - -ConfigurationPage::ConfigurationPage(QWidget *parent) - : QWidget(parent) -{ - QGroupBox *configGroup = new QGroupBox(tr("Server configuration")); - - QLabel *serverLabel = new QLabel(tr("Server:")); - QComboBox *serverCombo = new QComboBox; - serverCombo->addItem(tr("Qt (Australia)")); - serverCombo->addItem(tr("Qt (Germany)")); - serverCombo->addItem(tr("Qt (Norway)")); - serverCombo->addItem(tr("Qt (People's Republic of China)")); - serverCombo->addItem(tr("Qt (USA)")); - - QHBoxLayout *serverLayout = new QHBoxLayout; - serverLayout->addWidget(serverLabel); - serverLayout->addWidget(serverCombo); - - QVBoxLayout *configLayout = new QVBoxLayout; - configLayout->addLayout(serverLayout); - configGroup->setLayout(configLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(configGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); -} - -UpdatePage::UpdatePage(QWidget *parent) - : QWidget(parent) -{ - QGroupBox *updateGroup = new QGroupBox(tr("Package selection")); - QCheckBox *systemCheckBox = new QCheckBox(tr("Update system")); - QCheckBox *appsCheckBox = new QCheckBox(tr("Update applications")); - QCheckBox *docsCheckBox = new QCheckBox(tr("Update documentation")); - - QGroupBox *packageGroup = new QGroupBox(tr("Existing packages")); - - QListWidget *packageList = new QListWidget; - QListWidgetItem *qtItem = new QListWidgetItem(packageList); - qtItem->setText(tr("Qt")); - QListWidgetItem *qsaItem = new QListWidgetItem(packageList); - qsaItem->setText(tr("QSA")); - QListWidgetItem *teamBuilderItem = new QListWidgetItem(packageList); - teamBuilderItem->setText(tr("Teambuilder")); - - QPushButton *startUpdateButton = new QPushButton(tr("Start update")); - - QVBoxLayout *updateLayout = new QVBoxLayout; - updateLayout->addWidget(systemCheckBox); - updateLayout->addWidget(appsCheckBox); - updateLayout->addWidget(docsCheckBox); - updateGroup->setLayout(updateLayout); - - QVBoxLayout *packageLayout = new QVBoxLayout; - packageLayout->addWidget(packageList); - packageGroup->setLayout(packageLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(updateGroup); - mainLayout->addWidget(packageGroup); - mainLayout->addSpacing(12); - mainLayout->addWidget(startUpdateButton); - mainLayout->addStretch(1); - setLayout(mainLayout); -} - -QueryPage::QueryPage(QWidget *parent) - : QWidget(parent) -{ - QGroupBox *packagesGroup = new QGroupBox(tr("Look for packages")); - - QLabel *nameLabel = new QLabel(tr("Name:")); - QLineEdit *nameEdit = new QLineEdit; - - QLabel *dateLabel = new QLabel(tr("Released after:")); - QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate()); - - QCheckBox *releasesCheckBox = new QCheckBox(tr("Releases")); - QCheckBox *upgradesCheckBox = new QCheckBox(tr("Upgrades")); - - QSpinBox *hitsSpinBox = new QSpinBox; - hitsSpinBox->setPrefix(tr("Return up to ")); - hitsSpinBox->setSuffix(tr(" results")); - hitsSpinBox->setSpecialValueText(tr("Return only the first result")); - hitsSpinBox->setMinimum(1); - hitsSpinBox->setMaximum(100); - hitsSpinBox->setSingleStep(10); - - QPushButton *startQueryButton = new QPushButton(tr("Start query")); - - QGridLayout *packagesLayout = new QGridLayout; - packagesLayout->addWidget(nameLabel, 0, 0); - packagesLayout->addWidget(nameEdit, 0, 1); - packagesLayout->addWidget(dateLabel, 1, 0); - packagesLayout->addWidget(dateEdit, 1, 1); - packagesLayout->addWidget(releasesCheckBox, 2, 0); - packagesLayout->addWidget(upgradesCheckBox, 3, 0); - packagesLayout->addWidget(hitsSpinBox, 4, 0, 1, 2); - packagesGroup->setLayout(packagesLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(packagesGroup); - mainLayout->addSpacing(12); - mainLayout->addWidget(startQueryButton); - mainLayout->addStretch(1); - setLayout(mainLayout); -} diff --git a/examples/dialogs/configdialog/pages.h b/examples/dialogs/configdialog/pages.h deleted file mode 100644 index 938a2a74f7..0000000000 --- a/examples/dialogs/configdialog/pages.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PAGES_H -#define PAGES_H - -#include - -class ConfigurationPage : public QWidget -{ -public: - ConfigurationPage(QWidget *parent = 0); -}; - -class QueryPage : public QWidget -{ -public: - QueryPage(QWidget *parent = 0); -}; - -class UpdatePage : public QWidget -{ -public: - UpdatePage(QWidget *parent = 0); -}; - -#endif diff --git a/examples/dialogs/dialogs.pro b/examples/dialogs/dialogs.pro deleted file mode 100644 index a59e480efa..0000000000 --- a/examples/dialogs/dialogs.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = classwizard \ - configdialog \ - standarddialogs \ - tabdialog \ - trivialwizard - -!wince*: SUBDIRS += licensewizard \ - extension \ - findfiles - -wince*: SUBDIRS += sipdialog - -# install -sources.files = README *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs -INSTALLS += sources - -QT += widgets diff --git a/examples/dialogs/extension/extension.desktop b/examples/dialogs/extension/extension.desktop deleted file mode 100644 index 374b1c8340..0000000000 --- a/examples/dialogs/extension/extension.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Extension -Exec=/opt/usr/bin/extension -Icon=extension -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/extension/extension.pro b/examples/dialogs/extension/extension.pro deleted file mode 100644 index 7e11dda4ab..0000000000 --- a/examples/dialogs/extension/extension.pro +++ /dev/null @@ -1,12 +0,0 @@ -HEADERS = finddialog.h -SOURCES = finddialog.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/extension -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/extension -INSTALLS += target sources - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/dialogs/extension/finddialog.cpp b/examples/dialogs/extension/finddialog.cpp deleted file mode 100644 index c21ebf67c5..0000000000 --- a/examples/dialogs/extension/finddialog.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "finddialog.h" - -//! [0] -FindDialog::FindDialog(QWidget *parent) - : QDialog(parent) -{ - label = new QLabel(tr("Find &what:")); - lineEdit = new QLineEdit; - label->setBuddy(lineEdit); - - caseCheckBox = new QCheckBox(tr("Match &case")); - fromStartCheckBox = new QCheckBox(tr("Search from &start")); - fromStartCheckBox->setChecked(true); - -//! [1] - findButton = new QPushButton(tr("&Find")); - findButton->setDefault(true); - - moreButton = new QPushButton(tr("&More")); - moreButton->setCheckable(true); -//! [0] - moreButton->setAutoDefault(false); - -//! [1] - -//! [2] - extension = new QWidget; - - wholeWordsCheckBox = new QCheckBox(tr("&Whole words")); - backwardCheckBox = new QCheckBox(tr("Search &backward")); - searchSelectionCheckBox = new QCheckBox(tr("Search se&lection")); -//! [2] - -//! [3] - buttonBox = new QDialogButtonBox(Qt::Vertical); - buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); - - connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool))); - - QVBoxLayout *extensionLayout = new QVBoxLayout; - extensionLayout->setMargin(0); - extensionLayout->addWidget(wholeWordsCheckBox); - extensionLayout->addWidget(backwardCheckBox); - extensionLayout->addWidget(searchSelectionCheckBox); - extension->setLayout(extensionLayout); -//! [3] - -//! [4] - QHBoxLayout *topLeftLayout = new QHBoxLayout; - topLeftLayout->addWidget(label); - topLeftLayout->addWidget(lineEdit); - - QVBoxLayout *leftLayout = new QVBoxLayout; - leftLayout->addLayout(topLeftLayout); - leftLayout->addWidget(caseCheckBox); - leftLayout->addWidget(fromStartCheckBox); - - QGridLayout *mainLayout = new QGridLayout; - mainLayout->setSizeConstraint(QLayout::SetFixedSize); - mainLayout->addLayout(leftLayout, 0, 0); - mainLayout->addWidget(buttonBox, 0, 1); - mainLayout->addWidget(extension, 1, 0, 1, 2); - mainLayout->setRowStretch(2, 1); - - setLayout(mainLayout); - - setWindowTitle(tr("Extension")); -//! [4] //! [5] - extension->hide(); -} -//! [5] diff --git a/examples/dialogs/extension/finddialog.h b/examples/dialogs/extension/finddialog.h deleted file mode 100644 index 5599ac2c09..0000000000 --- a/examples/dialogs/extension/finddialog.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 FINDDIALOG_H -#define FINDDIALOG_H - -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QDialogButtonBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -QT_END_NAMESPACE - -//! [0] -class FindDialog : public QDialog -{ - Q_OBJECT - -public: - FindDialog(QWidget *parent = 0); - -private: - QLabel *label; - QLineEdit *lineEdit; - QCheckBox *caseCheckBox; - QCheckBox *fromStartCheckBox; - QCheckBox *wholeWordsCheckBox; - QCheckBox *searchSelectionCheckBox; - QCheckBox *backwardCheckBox; - QDialogButtonBox *buttonBox; - QPushButton *findButton; - QPushButton *moreButton; - QWidget *extension; -}; -//! [0] - -#endif diff --git a/examples/dialogs/extension/main.cpp b/examples/dialogs/extension/main.cpp deleted file mode 100644 index f0eff079ed..0000000000 --- a/examples/dialogs/extension/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "finddialog.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - FindDialog dialog; - - dialog.show(); - - return app.exec(); -} diff --git a/examples/dialogs/findfiles/findfiles.desktop b/examples/dialogs/findfiles/findfiles.desktop deleted file mode 100644 index 04c91cd76d..0000000000 --- a/examples/dialogs/findfiles/findfiles.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Find Files -Exec=/opt/usr/bin/findfiles -Icon=findfiles -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/findfiles/findfiles.pro b/examples/dialogs/findfiles/findfiles.pro deleted file mode 100644 index 51d1c0eed1..0000000000 --- a/examples/dialogs/findfiles/findfiles.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/findfiles -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/findfiles -INSTALLS += target sources - -QT += widgets diff --git a/examples/dialogs/findfiles/main.cpp b/examples/dialogs/findfiles/main.cpp deleted file mode 100644 index dcbf1c0449..0000000000 --- a/examples/dialogs/findfiles/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/dialogs/findfiles/window.cpp b/examples/dialogs/findfiles/window.cpp deleted file mode 100644 index 6b89436dc8..0000000000 --- a/examples/dialogs/findfiles/window.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -//! [0] -Window::Window(QWidget *parent) - : QWidget(parent) -{ - browseButton = createButton(tr("&Browse..."), SLOT(browse())); - findButton = createButton(tr("&Find"), SLOT(find())); - - fileComboBox = createComboBox(tr("*")); - textComboBox = createComboBox(); - directoryComboBox = createComboBox(QDir::currentPath()); - - fileLabel = new QLabel(tr("Named:")); - textLabel = new QLabel(tr("Containing text:")); - directoryLabel = new QLabel(tr("In directory:")); - filesFoundLabel = new QLabel; - - createFilesTable(); -//! [0] - -//! [1] - QGridLayout *mainLayout = new QGridLayout; - mainLayout->setSizeConstraint(QLayout::SetNoConstraint); - mainLayout->addWidget(fileLabel, 0, 0); - mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); - mainLayout->addWidget(textLabel, 1, 0); - mainLayout->addWidget(textComboBox, 1, 1, 1, 2); - mainLayout->addWidget(directoryLabel, 2, 0); - mainLayout->addWidget(directoryComboBox, 2, 1); - mainLayout->addWidget(browseButton, 2, 2); - mainLayout->addWidget(filesTable, 3, 0, 1, 3); - mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2); - mainLayout->addWidget(findButton, 4, 2); - setLayout(mainLayout); - - setWindowTitle(tr("Find Files")); - resize(700, 300); -} -//! [1] - -//! [2] -void Window::browse() -{ - QString directory = QFileDialog::getExistingDirectory(this, - tr("Find Files"), QDir::currentPath()); - - if (!directory.isEmpty()) { - if (directoryComboBox->findText(directory) == -1) - directoryComboBox->addItem(directory); - directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory)); - } -} -//! [2] - -static void updateComboBox(QComboBox *comboBox) -{ - if (comboBox->findText(comboBox->currentText()) == -1) - comboBox->addItem(comboBox->currentText()); -} - -//! [3] -void Window::find() -{ - filesTable->setRowCount(0); - - QString fileName = fileComboBox->currentText(); - QString text = textComboBox->currentText(); - QString path = directoryComboBox->currentText(); -//! [3] - - updateComboBox(fileComboBox); - updateComboBox(textComboBox); - updateComboBox(directoryComboBox); - -//! [4] - currentDir = QDir(path); - QStringList files; - if (fileName.isEmpty()) - fileName = "*"; - files = currentDir.entryList(QStringList(fileName), - QDir::Files | QDir::NoSymLinks); - - if (!text.isEmpty()) - files = findFiles(files, text); - showFiles(files); -} -//! [4] - -//! [5] -QStringList Window::findFiles(const QStringList &files, const QString &text) -{ - QProgressDialog progressDialog(this); - progressDialog.setCancelButtonText(tr("&Cancel")); - progressDialog.setRange(0, files.size()); - progressDialog.setWindowTitle(tr("Find Files")); - -//! [5] //! [6] - QStringList foundFiles; - - for (int i = 0; i < files.size(); ++i) { - progressDialog.setValue(i); - progressDialog.setLabelText(tr("Searching file number %1 of %2...") - .arg(i).arg(files.size())); - qApp->processEvents(); -//! [6] - - if (progressDialog.wasCanceled()) - break; - -//! [7] - QFile file(currentDir.absoluteFilePath(files[i])); - - if (file.open(QIODevice::ReadOnly)) { - QString line; - QTextStream in(&file); - while (!in.atEnd()) { - if (progressDialog.wasCanceled()) - break; - line = in.readLine(); - if (line.contains(text)) { - foundFiles << files[i]; - break; - } - } - } - } - return foundFiles; -} -//! [7] - -//! [8] -void Window::showFiles(const QStringList &files) -{ - for (int i = 0; i < files.size(); ++i) { - QFile file(currentDir.absoluteFilePath(files[i])); - qint64 size = QFileInfo(file).size(); - - QTableWidgetItem *fileNameItem = new QTableWidgetItem(files[i]); - fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable); - QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("%1 KB") - .arg(int((size + 1023) / 1024))); - sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); - sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable); - - int row = filesTable->rowCount(); - filesTable->insertRow(row); - filesTable->setItem(row, 0, fileNameItem); - filesTable->setItem(row, 1, sizeItem); - } - filesFoundLabel->setText(tr("%1 file(s) found").arg(files.size()) + - (" (Double click on a file to open it)")); - filesFoundLabel->setWordWrap(true); -} -//! [8] - -//! [9] -QPushButton *Window::createButton(const QString &text, const char *member) -{ - QPushButton *button = new QPushButton(text); - connect(button, SIGNAL(clicked()), this, member); - return button; -} -//! [9] - -//! [10] -QComboBox *Window::createComboBox(const QString &text) -{ - QComboBox *comboBox = new QComboBox; - comboBox->setEditable(true); - comboBox->addItem(text); - comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - return comboBox; -} -//! [10] - -//! [11] -void Window::createFilesTable() -{ - filesTable = new QTableWidget(0, 2); - filesTable->setSelectionBehavior(QAbstractItemView::SelectRows); - - QStringList labels; - labels << tr("Filename") << tr("Size"); - filesTable->setHorizontalHeaderLabels(labels); - filesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); - filesTable->verticalHeader()->hide(); - filesTable->setShowGrid(false); - - connect(filesTable, SIGNAL(cellActivated(int,int)), - this, SLOT(openFileOfItem(int,int))); -} -//! [11] - -//! [12] - -void Window::openFileOfItem(int row, int /* column */) -{ - QTableWidgetItem *item = filesTable->item(row, 0); - - QDesktopServices::openUrl(QUrl::fromLocalFile(currentDir.absoluteFilePath(item->text()))); -} - -//! [12] - diff --git a/examples/dialogs/findfiles/window.h b/examples/dialogs/findfiles/window.h deleted file mode 100644 index 0203de8a17..0000000000 --- a/examples/dialogs/findfiles/window.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -QT_BEGIN_NAMESPACE -class QComboBox; -class QLabel; -class QPushButton; -class QTableWidget; -class QTableWidgetItem; -QT_END_NAMESPACE - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(QWidget *parent = 0); - -private slots: - void browse(); - void find(); - void openFileOfItem(int row, int column); - -private: - QStringList findFiles(const QStringList &files, const QString &text); - void showFiles(const QStringList &files); - QPushButton *createButton(const QString &text, const char *member); - QComboBox *createComboBox(const QString &text = QString()); - void createFilesTable(); - - QComboBox *fileComboBox; - QComboBox *textComboBox; - QComboBox *directoryComboBox; - QLabel *fileLabel; - QLabel *textLabel; - QLabel *directoryLabel; - QLabel *filesFoundLabel; - QPushButton *browseButton; - QPushButton *findButton; - QTableWidget *filesTable; - - QDir currentDir; -}; -//! [0] - -#endif diff --git a/examples/dialogs/licensewizard/images/logo.png b/examples/dialogs/licensewizard/images/logo.png deleted file mode 100644 index 56f17a3e5a..0000000000 Binary files a/examples/dialogs/licensewizard/images/logo.png and /dev/null differ diff --git a/examples/dialogs/licensewizard/images/watermark.png b/examples/dialogs/licensewizard/images/watermark.png deleted file mode 100644 index 124a05068b..0000000000 Binary files a/examples/dialogs/licensewizard/images/watermark.png and /dev/null differ diff --git a/examples/dialogs/licensewizard/licensewizard.cpp b/examples/dialogs/licensewizard/licensewizard.cpp deleted file mode 100644 index 501f8e310c..0000000000 --- a/examples/dialogs/licensewizard/licensewizard.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include - -#include "licensewizard.h" - -//! [0] //! [1] //! [2] -LicenseWizard::LicenseWizard(QWidget *parent) - : QWizard(parent) -{ -//! [0] - setPage(Page_Intro, new IntroPage); - setPage(Page_Evaluate, new EvaluatePage); - setPage(Page_Register, new RegisterPage); - setPage(Page_Details, new DetailsPage); - setPage(Page_Conclusion, new ConclusionPage); -//! [1] - - setStartId(Page_Intro); -//! [2] - -//! [3] -#ifndef Q_OS_MAC -//! [3] //! [4] - setWizardStyle(ModernStyle); -#endif -//! [4] //! [5] - setOption(HaveHelpButton, true); -//! [5] //! [6] - setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo.png")); - -//! [7] - connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp())); -//! [7] - - setWindowTitle(tr("License Wizard")); -//! [8] -} -//! [6] //! [8] - -//! [9] //! [10] -void LicenseWizard::showHelp() -//! [9] //! [11] -{ - static QString lastHelpMessage; - - QString message; - - switch (currentId()) { - case Page_Intro: - message = tr("The decision you make here will affect which page you " - "get to see next."); - break; -//! [10] //! [11] - case Page_Evaluate: - message = tr("Make sure to provide a valid email address, such as " - "toni.buddenbrook@example.de."); - break; - case Page_Register: - message = tr("If you don't provide an upgrade key, you will be " - "asked to fill in your details."); - break; - case Page_Details: - message = tr("Make sure to provide a valid email address, such as " - "thomas.gradgrind@example.co.uk."); - break; - case Page_Conclusion: - message = tr("You must accept the terms and conditions of the " - "license to proceed."); - break; -//! [12] //! [13] - default: - message = tr("This help is likely not to be of any help."); - } -//! [12] - - if (lastHelpMessage == message) - message = tr("Sorry, I already gave what help I could. " - "Maybe you should try asking a human?"); - -//! [14] - QMessageBox::information(this, tr("License Wizard Help"), message); -//! [14] - - lastHelpMessage = message; -//! [15] -} -//! [13] //! [15] - -//! [16] -IntroPage::IntroPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Introduction")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png")); - - topLabel = new QLabel(tr("This wizard will help you register your copy of " - "Super Product One™ or start " - "evaluating the product.")); - topLabel->setWordWrap(true); - - registerRadioButton = new QRadioButton(tr("&Register your copy")); - evaluateRadioButton = new QRadioButton(tr("&Evaluate the product for 30 " - "days")); - registerRadioButton->setChecked(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(topLabel); - layout->addWidget(registerRadioButton); - layout->addWidget(evaluateRadioButton); - setLayout(layout); -} -//! [16] //! [17] - -//! [18] -int IntroPage::nextId() const -//! [17] //! [19] -{ - if (evaluateRadioButton->isChecked()) { - return LicenseWizard::Page_Evaluate; - } else { - return LicenseWizard::Page_Register; - } -} -//! [18] //! [19] - -//! [20] -EvaluatePage::EvaluatePage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Evaluate Super Product One™")); - setSubTitle(tr("Please fill both fields. Make sure to provide a valid " - "email address (e.g., john.smith@example.com).")); - - nameLabel = new QLabel(tr("N&ame:")); - nameLineEdit = new QLineEdit; -//! [20] - nameLabel->setBuddy(nameLineEdit); - - emailLabel = new QLabel(tr("&Email address:")); - emailLineEdit = new QLineEdit; - emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); - emailLabel->setBuddy(emailLineEdit); - -//! [21] - registerField("evaluate.name*", nameLineEdit); - registerField("evaluate.email*", emailLineEdit); -//! [21] - - QGridLayout *layout = new QGridLayout; - layout->addWidget(nameLabel, 0, 0); - layout->addWidget(nameLineEdit, 0, 1); - layout->addWidget(emailLabel, 1, 0); - layout->addWidget(emailLineEdit, 1, 1); - setLayout(layout); -//! [22] -} -//! [22] - -//! [23] -int EvaluatePage::nextId() const -{ - return LicenseWizard::Page_Conclusion; -} -//! [23] - -RegisterPage::RegisterPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Register Your Copy of Super Product One™")); - setSubTitle(tr("If you have an upgrade key, please fill in " - "the appropriate field.")); - - nameLabel = new QLabel(tr("N&ame:")); - nameLineEdit = new QLineEdit; - nameLabel->setBuddy(nameLineEdit); - - upgradeKeyLabel = new QLabel(tr("&Upgrade key:")); - upgradeKeyLineEdit = new QLineEdit; - upgradeKeyLabel->setBuddy(upgradeKeyLineEdit); - - registerField("register.name*", nameLineEdit); - registerField("register.upgradeKey", upgradeKeyLineEdit); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(nameLabel, 0, 0); - layout->addWidget(nameLineEdit, 0, 1); - layout->addWidget(upgradeKeyLabel, 1, 0); - layout->addWidget(upgradeKeyLineEdit, 1, 1); - setLayout(layout); -} - -//! [24] -int RegisterPage::nextId() const -{ - if (upgradeKeyLineEdit->text().isEmpty()) { - return LicenseWizard::Page_Details; - } else { - return LicenseWizard::Page_Conclusion; - } -} -//! [24] - -DetailsPage::DetailsPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Fill In Your Details")); - setSubTitle(tr("Please fill all three fields. Make sure to provide a valid " - "email address (e.g., tanaka.aya@example.co.jp).")); - - companyLabel = new QLabel(tr("&Company name:")); - companyLineEdit = new QLineEdit; - companyLabel->setBuddy(companyLineEdit); - - emailLabel = new QLabel(tr("&Email address:")); - emailLineEdit = new QLineEdit; - emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); - emailLabel->setBuddy(emailLineEdit); - - postalLabel = new QLabel(tr("&Postal address:")); - postalLineEdit = new QLineEdit; - postalLabel->setBuddy(postalLineEdit); - - registerField("details.company*", companyLineEdit); - registerField("details.email*", emailLineEdit); - registerField("details.postal*", postalLineEdit); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(companyLabel, 0, 0); - layout->addWidget(companyLineEdit, 0, 1); - layout->addWidget(emailLabel, 1, 0); - layout->addWidget(emailLineEdit, 1, 1); - layout->addWidget(postalLabel, 2, 0); - layout->addWidget(postalLineEdit, 2, 1); - setLayout(layout); -} - -//! [25] -int DetailsPage::nextId() const -{ - return LicenseWizard::Page_Conclusion; -} -//! [25] - -ConclusionPage::ConclusionPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Complete Your Registration")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png")); - - bottomLabel = new QLabel; - bottomLabel->setWordWrap(true); - - agreeCheckBox = new QCheckBox(tr("I agree to the terms of the license")); - - registerField("conclusion.agree*", agreeCheckBox); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(bottomLabel); - layout->addWidget(agreeCheckBox); - setLayout(layout); -} - -//! [26] -int ConclusionPage::nextId() const -{ - return -1; -} -//! [26] - -//! [27] -void ConclusionPage::initializePage() -{ - QString licenseText; - - if (wizard()->hasVisitedPage(LicenseWizard::Page_Evaluate)) { - licenseText = tr("Evaluation License Agreement: " - "You can use this software for 30 days and make one " - "backup, but you are not allowed to distribute it."); - } else if (wizard()->hasVisitedPage(LicenseWizard::Page_Details)) { - licenseText = tr("First-Time License Agreement: " - "You can use this software subject to the license " - "you will receive by email."); - } else { - licenseText = tr("Upgrade License Agreement: " - "This software is licensed under the terms of your " - "current license."); - } - bottomLabel->setText(licenseText); -} -//! [27] - -//! [28] -void ConclusionPage::setVisible(bool visible) -{ - QWizardPage::setVisible(visible); - - if (visible) { -//! [29] - wizard()->setButtonText(QWizard::CustomButton1, tr("&Print")); - wizard()->setOption(QWizard::HaveCustomButton1, true); - connect(wizard(), SIGNAL(customButtonClicked(int)), - this, SLOT(printButtonClicked())); -//! [29] - } else { - wizard()->setOption(QWizard::HaveCustomButton1, false); - disconnect(wizard(), SIGNAL(customButtonClicked(int)), - this, SLOT(printButtonClicked())); - } -} -//! [28] - -void ConclusionPage::printButtonClicked() -{ -#ifndef QT_NO_PRINTER - QPrinter printer; - QPrintDialog dialog(&printer, this); - if (dialog.exec()) - QMessageBox::warning(this, tr("Print License"), - tr("As an environmentally friendly measure, the " - "license text will not actually be printed.")); -#endif -} diff --git a/examples/dialogs/licensewizard/licensewizard.desktop b/examples/dialogs/licensewizard/licensewizard.desktop deleted file mode 100644 index 423d81e9b3..0000000000 --- a/examples/dialogs/licensewizard/licensewizard.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=License Wizard -Exec=/opt/usr/bin/licensewizard -Icon=licensewizard -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/licensewizard/licensewizard.h b/examples/dialogs/licensewizard/licensewizard.h deleted file mode 100644 index 24ee45d6dd..0000000000 --- a/examples/dialogs/licensewizard/licensewizard.h +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 LICENSEWIZARD_H -#define LICENSEWIZARD_H - -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QLabel; -class QLineEdit; -class QRadioButton; -QT_END_NAMESPACE - -//! [0] //! [1] -class LicenseWizard : public QWizard -{ -//! [0] - Q_OBJECT - -public: -//! [2] - enum { Page_Intro, Page_Evaluate, Page_Register, Page_Details, - Page_Conclusion }; -//! [2] - - LicenseWizard(QWidget *parent = 0); - -private slots: - void showHelp(); -//! [3] -}; -//! [1] //! [3] - -//! [4] -class IntroPage : public QWizardPage -{ - Q_OBJECT - -public: - IntroPage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *topLabel; - QRadioButton *registerRadioButton; - QRadioButton *evaluateRadioButton; -}; -//! [4] - -//! [5] -class EvaluatePage : public QWizardPage -{ - Q_OBJECT - -public: - EvaluatePage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *nameLabel; - QLabel *emailLabel; - QLineEdit *nameLineEdit; - QLineEdit *emailLineEdit; -}; -//! [5] - -class RegisterPage : public QWizardPage -{ - Q_OBJECT - -public: - RegisterPage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *nameLabel; - QLabel *upgradeKeyLabel; - QLineEdit *nameLineEdit; - QLineEdit *upgradeKeyLineEdit; -}; - -class DetailsPage : public QWizardPage -{ - Q_OBJECT - -public: - DetailsPage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *companyLabel; - QLabel *emailLabel; - QLabel *postalLabel; - QLineEdit *companyLineEdit; - QLineEdit *emailLineEdit; - QLineEdit *postalLineEdit; -}; - -//! [6] -class ConclusionPage : public QWizardPage -{ - Q_OBJECT - -public: - ConclusionPage(QWidget *parent = 0); - - void initializePage(); - int nextId() const; - void setVisible(bool visible); - -private slots: - void printButtonClicked(); - -private: - QLabel *bottomLabel; - QCheckBox *agreeCheckBox; -}; -//! [6] - -#endif diff --git a/examples/dialogs/licensewizard/licensewizard.pro b/examples/dialogs/licensewizard/licensewizard.pro deleted file mode 100644 index c61325772e..0000000000 --- a/examples/dialogs/licensewizard/licensewizard.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = licensewizard.h -SOURCES = licensewizard.cpp \ - main.cpp -RESOURCES = licensewizard.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/licensewizard -sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/licensewizard -INSTALLS += target sources - -QT += widgets printsupport -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/dialogs/licensewizard/licensewizard.qrc b/examples/dialogs/licensewizard/licensewizard.qrc deleted file mode 100644 index b069938515..0000000000 --- a/examples/dialogs/licensewizard/licensewizard.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/logo.png - images/watermark.png - - diff --git a/examples/dialogs/licensewizard/main.cpp b/examples/dialogs/licensewizard/main.cpp deleted file mode 100644 index c7771d7676..0000000000 --- a/examples/dialogs/licensewizard/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -#include "licensewizard.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(licensewizard); - - QApplication app(argc, argv); - - QString translatorFileName = QLatin1String("qt_"); - translatorFileName += QLocale::system().name(); - QTranslator *translator = new QTranslator(&app); - if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app.installTranslator(translator); - - LicenseWizard wizard; - wizard.show(); - return app.exec(); -} diff --git a/examples/dialogs/sipdialog/dialog.cpp b/examples/dialogs/sipdialog/dialog.cpp deleted file mode 100644 index fdfbc94ca4..0000000000 --- a/examples/dialogs/sipdialog/dialog.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -//! [Dialog constructor part1] -Dialog::Dialog() -{ - desktopGeometry = QApplication::desktop()->availableGeometry(0); - - setWindowTitle(tr("SIP Dialog Example")); - QScrollArea *scrollArea = new QScrollArea(this); - QGroupBox *groupBox = new QGroupBox(scrollArea); - groupBox->setTitle(tr("SIP Dialog Example")); - QGridLayout *gridLayout = new QGridLayout(groupBox); - groupBox->setLayout(gridLayout); -//! [Dialog constructor part1] - -//! [Dialog constructor part2] - QLineEdit* lineEdit = new QLineEdit(groupBox); - lineEdit->setText(tr("Open and close the SIP")); - lineEdit->setMinimumWidth(220); - - QLabel* label = new QLabel(groupBox); - label->setText(tr("This dialog resizes if the SIP is opened")); - label->setMinimumWidth(220); - - QPushButton* button = new QPushButton(groupBox); - button->setText(tr("Close Dialog")); - button->setMinimumWidth(220); -//! [Dialog constructor part2] - -//! [Dialog constructor part3] - if (desktopGeometry.height() < 400) - gridLayout->setVerticalSpacing(80); - else - gridLayout->setVerticalSpacing(150); - - gridLayout->addWidget(label); - gridLayout->addWidget(lineEdit); - gridLayout->addWidget(button); -//! [Dialog constructor part3] - -//! [Dialog constructor part4] - scrollArea->setWidget(groupBox); - QHBoxLayout* layout = new QHBoxLayout(); - layout->addWidget(scrollArea); - setLayout(layout); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -//! [Dialog constructor part4] - -//! [Dialog constructor part5] - connect(button, SIGNAL(clicked()), - qApp, SLOT(closeAllWindows())); - connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), - this, SLOT(desktopResized(int))); -} -//! [Dialog constructor part5] - -//! [desktopResized() function] -void Dialog::desktopResized(int screen) -{ - if (screen != 0) - return; - reactToSIP(); -} -//! [desktopResized() function] - -//! [reactToSIP() function] -void Dialog::reactToSIP() -{ - QRect availableGeometry = QApplication::desktop()->availableGeometry(0); - - if (desktopGeometry != availableGeometry) { - if (windowState() | Qt::WindowMaximized) - setWindowState(windowState() & ~Qt::WindowMaximized); - - setGeometry(availableGeometry); - } - - desktopGeometry = availableGeometry; -} -//! [reactToSIP() function] diff --git a/examples/dialogs/sipdialog/dialog.h b/examples/dialogs/sipdialog/dialog.h deleted file mode 100644 index 18eb92d857..0000000000 --- a/examples/dialogs/sipdialog/dialog.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIALOG_H -#define DIALOG_H - -#include - -//! [Dialog header] -class Dialog : public QDialog -{ - Q_OBJECT - -public: - Dialog(); - void reactToSIP(); - -private: - QRect desktopGeometry; - -public slots: - void desktopResized(int screen); -}; -//! [Dialog header] - -#endif diff --git a/examples/dialogs/sipdialog/main.cpp b/examples/dialogs/sipdialog/main.cpp deleted file mode 100644 index 79fd956fb9..0000000000 --- a/examples/dialogs/sipdialog/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -//! [main() function] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Dialog dialog; - return dialog.exec(); -} -//! [main() function] diff --git a/examples/dialogs/sipdialog/sipdialog.desktop b/examples/dialogs/sipdialog/sipdialog.desktop deleted file mode 100644 index b9c9955339..0000000000 --- a/examples/dialogs/sipdialog/sipdialog.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=SIP Dialog -Exec=/opt/usr/bin/sipdialog -Icon=sipdialog -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/sipdialog/sipdialog.pro b/examples/dialogs/sipdialog/sipdialog.pro deleted file mode 100644 index 72db93f646..0000000000 --- a/examples/dialogs/sipdialog/sipdialog.pro +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS = dialog.h -SOURCES = main.cpp \ - dialog.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/sipdialog -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/sipdialog -INSTALLS += target sources - -wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/dialogs/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp deleted file mode 100644 index bde96c516b..0000000000 --- a/examples/dialogs/standarddialogs/dialog.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -#define MESSAGE \ - Dialog::tr("

    Message boxes have a caption, a text, " \ - "and any number of buttons, each with standard or custom texts." \ - "

    Click a button to close the message box. Pressing the Esc button " \ - "will activate the detected escape button (if any).") - - -class DialogOptionsWidget : public QGroupBox -{ -public: - explicit DialogOptionsWidget(QWidget *parent = 0); - - void addCheckBox(const QString &text, int value); - void addSpacer(); - int value() const; - -private: - typedef QPair CheckBoxEntry; - QVBoxLayout *layout; - QList checkBoxEntries; -}; - -DialogOptionsWidget::DialogOptionsWidget(QWidget *parent) : - QGroupBox(parent) , layout(new QVBoxLayout) -{ - setTitle(Dialog::tr("Options")); - setLayout(layout); -} - -void DialogOptionsWidget::addCheckBox(const QString &text, int value) -{ - QCheckBox *checkBox = new QCheckBox(text); - layout->addWidget(checkBox); - checkBoxEntries.append(CheckBoxEntry(checkBox, value)); -} - -void DialogOptionsWidget::addSpacer() -{ - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); -} - -int DialogOptionsWidget::value() const -{ - int result = 0; - foreach (const CheckBoxEntry &checkboxEntry, checkBoxEntries) - if (checkboxEntry.first->isChecked()) - result |= checkboxEntry.second; - return result; -} - -Dialog::Dialog(QWidget *parent) - : QWidget(parent) -{ - QVBoxLayout *mainLayout = new QVBoxLayout(this); - QToolBox *toolbox = new QToolBox; - mainLayout->addWidget(toolbox); - - errorMessageDialog = new QErrorMessage(this); - - int frameStyle = QFrame::Sunken | QFrame::Panel; - - integerLabel = new QLabel; - integerLabel->setFrameStyle(frameStyle); - QPushButton *integerButton = - new QPushButton(tr("QInputDialog::get&Int()")); - - doubleLabel = new QLabel; - doubleLabel->setFrameStyle(frameStyle); - QPushButton *doubleButton = - new QPushButton(tr("QInputDialog::get&Double()")); - - itemLabel = new QLabel; - itemLabel->setFrameStyle(frameStyle); - QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); - - textLabel = new QLabel; - textLabel->setFrameStyle(frameStyle); - QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); - - colorLabel = new QLabel; - colorLabel->setFrameStyle(frameStyle); - QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); - - fontLabel = new QLabel; - fontLabel->setFrameStyle(frameStyle); - QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); - - directoryLabel = new QLabel; - directoryLabel->setFrameStyle(frameStyle); - QPushButton *directoryButton = - new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); - - openFileNameLabel = new QLabel; - openFileNameLabel->setFrameStyle(frameStyle); - QPushButton *openFileNameButton = - new QPushButton(tr("QFileDialog::get&OpenFileName()")); - - openFileNamesLabel = new QLabel; - openFileNamesLabel->setFrameStyle(frameStyle); - QPushButton *openFileNamesButton = - new QPushButton(tr("QFileDialog::&getOpenFileNames()")); - - saveFileNameLabel = new QLabel; - saveFileNameLabel->setFrameStyle(frameStyle); - QPushButton *saveFileNameButton = - new QPushButton(tr("QFileDialog::get&SaveFileName()")); - - criticalLabel = new QLabel; - criticalLabel->setFrameStyle(frameStyle); - QPushButton *criticalButton = - new QPushButton(tr("QMessageBox::critica&l()")); - - informationLabel = new QLabel; - informationLabel->setFrameStyle(frameStyle); - QPushButton *informationButton = - new QPushButton(tr("QMessageBox::i&nformation()")); - - questionLabel = new QLabel; - questionLabel->setFrameStyle(frameStyle); - QPushButton *questionButton = - new QPushButton(tr("QMessageBox::&question()")); - - warningLabel = new QLabel; - warningLabel->setFrameStyle(frameStyle); - QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); - - errorLabel = new QLabel; - errorLabel->setFrameStyle(frameStyle); - QPushButton *errorButton = - new QPushButton(tr("QErrorMessage::showM&essage()")); - - connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); - connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); - connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); - connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); - connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); - connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); - connect(directoryButton, SIGNAL(clicked()), - this, SLOT(setExistingDirectory())); - connect(openFileNameButton, SIGNAL(clicked()), - this, SLOT(setOpenFileName())); - connect(openFileNamesButton, SIGNAL(clicked()), - this, SLOT(setOpenFileNames())); - connect(saveFileNameButton, SIGNAL(clicked()), - this, SLOT(setSaveFileName())); - connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); - connect(informationButton, SIGNAL(clicked()), - this, SLOT(informationMessage())); - connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); - connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); - connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); - - QWidget *page = new QWidget; - QGridLayout *layout = new QGridLayout(page); - layout->setColumnStretch(1, 1); - layout->setColumnMinimumWidth(1, 250); - layout->addWidget(integerButton, 0, 0); - layout->addWidget(integerLabel, 0, 1); - layout->addWidget(doubleButton, 1, 0); - layout->addWidget(doubleLabel, 1, 1); - layout->addWidget(itemButton, 2, 0); - layout->addWidget(itemLabel, 2, 1); - layout->addWidget(textButton, 3, 0); - layout->addWidget(textLabel, 3, 1); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0); - toolbox->addItem(page, tr("Input Dialogs")); - - const QString doNotUseNativeDialog = tr("Do not use native dialog"); - - page = new QWidget; - layout = new QGridLayout(page); - layout->setColumnStretch(1, 1); - layout->addWidget(colorButton, 0, 0); - layout->addWidget(colorLabel, 0, 1); - colorDialogOptionsWidget = new DialogOptionsWidget; - colorDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QColorDialog::DontUseNativeDialog); - colorDialogOptionsWidget->addCheckBox(tr("Show alpha channel") , QColorDialog::ShowAlphaChannel); - colorDialogOptionsWidget->addCheckBox(tr("No buttons") , QColorDialog::NoButtons); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); - layout->addWidget(colorDialogOptionsWidget, 2, 0, 1 ,2); - - toolbox->addItem(page, tr("Color Dialog")); - - page = new QWidget; - layout = new QGridLayout(page); - layout->setColumnStretch(1, 1); - layout->addWidget(fontButton, 0, 0); - layout->addWidget(fontLabel, 0, 1); - fontDialogOptionsWidget = new DialogOptionsWidget; - fontDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFontDialog::DontUseNativeDialog); - fontDialogOptionsWidget->addCheckBox(tr("No buttons") , QFontDialog::NoButtons); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); - layout->addWidget(fontDialogOptionsWidget, 2, 0, 1 ,2); - toolbox->addItem(page, tr("Font Dialog")); - - page = new QWidget; - layout = new QGridLayout(page); - layout->setColumnStretch(1, 1); - layout->addWidget(directoryButton, 0, 0); - layout->addWidget(directoryLabel, 0, 1); - layout->addWidget(openFileNameButton, 1, 0); - layout->addWidget(openFileNameLabel, 1, 1); - layout->addWidget(openFileNamesButton, 2, 0); - layout->addWidget(openFileNamesLabel, 2, 1); - layout->addWidget(saveFileNameButton, 3, 0); - layout->addWidget(saveFileNameLabel, 3, 1); - fileDialogOptionsWidget = new DialogOptionsWidget; - fileDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFileDialog::DontUseNativeDialog); - fileDialogOptionsWidget->addCheckBox(tr("Show directories only"), QFileDialog::ShowDirsOnly); - fileDialogOptionsWidget->addCheckBox(tr("Do not resolve symlinks"), QFileDialog::DontResolveSymlinks); - fileDialogOptionsWidget->addCheckBox(tr("Do not confirm overwrite"), QFileDialog::DontConfirmOverwrite); - fileDialogOptionsWidget->addCheckBox(tr("Do not use sheet"), QFileDialog::DontUseSheet); - fileDialogOptionsWidget->addCheckBox(tr("Readonly"), QFileDialog::ReadOnly); - fileDialogOptionsWidget->addCheckBox(tr("Hide name filter details"), QFileDialog::HideNameFilterDetails); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0); - layout->addWidget(fileDialogOptionsWidget, 5, 0, 1 ,2); - toolbox->addItem(page, tr("File Dialogs")); - - page = new QWidget; - layout = new QGridLayout(page); - layout->setColumnStretch(1, 1); - layout->addWidget(criticalButton, 0, 0); - layout->addWidget(criticalLabel, 0, 1); - layout->addWidget(informationButton, 1, 0); - layout->addWidget(informationLabel, 1, 1); - layout->addWidget(questionButton, 2, 0); - layout->addWidget(questionLabel, 2, 1); - layout->addWidget(warningButton, 3, 0); - layout->addWidget(warningLabel, 3, 1); - layout->addWidget(errorButton, 4, 0); - layout->addWidget(errorLabel, 4, 1); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); - toolbox->addItem(page, tr("Message Boxes")); - - setWindowTitle(tr("Standard Dialogs")); -} - -void Dialog::setInteger() -{ -//! [0] - bool ok; - int i = QInputDialog::getInt(this, tr("QInputDialog::getInteger()"), - tr("Percentage:"), 25, 0, 100, 1, &ok); - if (ok) - integerLabel->setText(tr("%1%").arg(i)); -//! [0] -} - -void Dialog::setDouble() -{ -//! [1] - bool ok; - double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"), - tr("Amount:"), 37.56, -10000, 10000, 2, &ok); - if (ok) - doubleLabel->setText(QString("$%1").arg(d)); -//! [1] -} - -void Dialog::setItem() -{ -//! [2] - QStringList items; - items << tr("Spring") << tr("Summer") << tr("Fall") << tr("Winter"); - - bool ok; - QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"), - tr("Season:"), items, 0, false, &ok); - if (ok && !item.isEmpty()) - itemLabel->setText(item); -//! [2] -} - -void Dialog::setText() -{ -//! [3] - bool ok; - QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"), - tr("User name:"), QLineEdit::Normal, - QDir::home().dirName(), &ok); - if (ok && !text.isEmpty()) - textLabel->setText(text); -//! [3] -} - -void Dialog::setColor() -{ - const QColorDialog::ColorDialogOptions options = QFlag(colorDialogOptionsWidget->value()); - const QColor color = QColorDialog::getColor(Qt::green, this, "Select Color", options); - - if (color.isValid()) { - colorLabel->setText(color.name()); - colorLabel->setPalette(QPalette(color)); - colorLabel->setAutoFillBackground(true); - } -} - -void Dialog::setFont() -{ - const QFontDialog::FontDialogOptions options = QFlag(fontDialogOptionsWidget->value()); - bool ok; - QFont font = QFontDialog::getFont(&ok, QFont(fontLabel->text()), this, "Select Font", options); - if (ok) { - fontLabel->setText(font.key()); - fontLabel->setFont(font); - } -} - -void Dialog::setExistingDirectory() -{ - QFileDialog::Options options = QFlag(fileDialogOptionsWidget->value()); - options |= QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly; - QString directory = QFileDialog::getExistingDirectory(this, - tr("QFileDialog::getExistingDirectory()"), - directoryLabel->text(), - options); - if (!directory.isEmpty()) - directoryLabel->setText(directory); -} - -void Dialog::setOpenFileName() -{ - const QFileDialog::Options options = QFlag(fileDialogOptionsWidget->value()); - QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName(this, - tr("QFileDialog::getOpenFileName()"), - openFileNameLabel->text(), - tr("All Files (*);;Text Files (*.txt)"), - &selectedFilter, - options); - if (!fileName.isEmpty()) - openFileNameLabel->setText(fileName); -} - -void Dialog::setOpenFileNames() -{ - const QFileDialog::Options options = QFlag(fileDialogOptionsWidget->value()); - QString selectedFilter; - QStringList files = QFileDialog::getOpenFileNames( - this, tr("QFileDialog::getOpenFileNames()"), - openFilesPath, - tr("All Files (*);;Text Files (*.txt)"), - &selectedFilter, - options); - if (files.count()) { - openFilesPath = files[0]; - openFileNamesLabel->setText(QString("[%1]").arg(files.join(", "))); - } -} - -void Dialog::setSaveFileName() -{ - const QFileDialog::Options options = QFlag(fileDialogOptionsWidget->value()); - QString selectedFilter; - QString fileName = QFileDialog::getSaveFileName(this, - tr("QFileDialog::getSaveFileName()"), - saveFileNameLabel->text(), - tr("All Files (*);;Text Files (*.txt)"), - &selectedFilter, - options); - if (!fileName.isEmpty()) - saveFileNameLabel->setText(fileName); -} - -void Dialog::criticalMessage() -{ - QMessageBox::StandardButton reply; - reply = QMessageBox::critical(this, tr("QMessageBox::critical()"), - MESSAGE, - QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore); - if (reply == QMessageBox::Abort) - criticalLabel->setText(tr("Abort")); - else if (reply == QMessageBox::Retry) - criticalLabel->setText(tr("Retry")); - else - criticalLabel->setText(tr("Ignore")); -} - -void Dialog::informationMessage() -{ - QMessageBox::StandardButton reply; - reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE); - if (reply == QMessageBox::Ok) - informationLabel->setText(tr("OK")); - else - informationLabel->setText(tr("Escape")); -} - -void Dialog::questionMessage() -{ - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this, tr("QMessageBox::question()"), - MESSAGE, - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); - if (reply == QMessageBox::Yes) - questionLabel->setText(tr("Yes")); - else if (reply == QMessageBox::No) - questionLabel->setText(tr("No")); - else - questionLabel->setText(tr("Cancel")); -} - -void Dialog::warningMessage() -{ - QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"), - MESSAGE, 0, this); - msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole); - msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole); - if (msgBox.exec() == QMessageBox::AcceptRole) - warningLabel->setText(tr("Save Again")); - else - warningLabel->setText(tr("Continue")); - -} - -void Dialog::errorMessage() -{ - errorMessageDialog->showMessage( - tr("This dialog shows and remembers error messages. " - "If the checkbox is checked (as it is by default), " - "the shown message will be shown again, " - "but if the user unchecks the box the message " - "will not appear again if QErrorMessage::showMessage() " - "is called with the same message.")); - errorLabel->setText(tr("If the box is unchecked, the message " - "won't appear again.")); -} diff --git a/examples/dialogs/standarddialogs/dialog.h b/examples/dialogs/standarddialogs/dialog.h deleted file mode 100644 index 2b14d793d6..0000000000 --- a/examples/dialogs/standarddialogs/dialog.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIALOG_H -#define DIALOG_H - -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QLabel; -class QErrorMessage; -QT_END_NAMESPACE - -class DialogOptionsWidget; - -class Dialog : public QWidget -{ - Q_OBJECT - -public: - Dialog(QWidget *parent = 0); - -private slots: - void setInteger(); - void setDouble(); - void setItem(); - void setText(); - void setColor(); - void setFont(); - void setExistingDirectory(); - void setOpenFileName(); - void setOpenFileNames(); - void setSaveFileName(); - void criticalMessage(); - void informationMessage(); - void questionMessage(); - void warningMessage(); - void errorMessage(); - -private: - QLabel *integerLabel; - QLabel *doubleLabel; - QLabel *itemLabel; - QLabel *textLabel; - QLabel *colorLabel; - QLabel *fontLabel; - QLabel *directoryLabel; - QLabel *openFileNameLabel; - QLabel *openFileNamesLabel; - QLabel *saveFileNameLabel; - QLabel *criticalLabel; - QLabel *informationLabel; - QLabel *questionLabel; - QLabel *warningLabel; - QLabel *errorLabel; - QErrorMessage *errorMessageDialog; - DialogOptionsWidget *fileDialogOptionsWidget; - DialogOptionsWidget *colorDialogOptionsWidget; - DialogOptionsWidget *fontDialogOptionsWidget; - QString openFilesPath; -}; - -#endif diff --git a/examples/dialogs/standarddialogs/main.cpp b/examples/dialogs/standarddialogs/main.cpp deleted file mode 100644 index 001239929e..0000000000 --- a/examples/dialogs/standarddialogs/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -#include "dialog.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QString translatorFileName = QLatin1String("qt_"); - translatorFileName += QLocale::system().name(); - QTranslator *translator = new QTranslator(&app); - if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app.installTranslator(translator); - - Dialog dialog; - dialog.show(); - - return app.exec(); -} diff --git a/examples/dialogs/standarddialogs/standarddialogs.desktop b/examples/dialogs/standarddialogs/standarddialogs.desktop deleted file mode 100644 index f74830317a..0000000000 --- a/examples/dialogs/standarddialogs/standarddialogs.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Standard Dialogs -Exec=/opt/usr/bin/standarddialogs -Icon=standarddialogs -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/standarddialogs/standarddialogs.pro b/examples/dialogs/standarddialogs/standarddialogs.pro deleted file mode 100644 index cbcb4d7302..0000000000 --- a/examples/dialogs/standarddialogs/standarddialogs.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = dialog.h -SOURCES = dialog.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/standarddialogs -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/standarddialogs -INSTALLS += target sources - -wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib - -QT += widgets diff --git a/examples/dialogs/tabdialog/main.cpp b/examples/dialogs/tabdialog/main.cpp deleted file mode 100644 index 119a4c272c..0000000000 --- a/examples/dialogs/tabdialog/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "tabdialog.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - QString fileName; - - if (argc >= 2) - fileName = argv[1]; - else - fileName = "."; - - TabDialog tabdialog(fileName); - tabdialog.show(); - - return app.exec(); -} diff --git a/examples/dialogs/tabdialog/tabdialog.cpp b/examples/dialogs/tabdialog/tabdialog.cpp deleted file mode 100644 index 00e3706c5c..0000000000 --- a/examples/dialogs/tabdialog/tabdialog.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "tabdialog.h" - -//! [0] -TabDialog::TabDialog(const QString &fileName, QWidget *parent) - : QDialog(parent) -{ - QFileInfo fileInfo(fileName); - - tabWidget = new QTabWidget; - tabWidget->addTab(new GeneralTab(fileInfo), tr("General")); - tabWidget->addTab(new PermissionsTab(fileInfo), tr("Permissions")); - tabWidget->addTab(new ApplicationsTab(fileInfo), tr("Applications")); -//! [0] - -//! [1] //! [2] - buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok -//! [1] //! [3] - | QDialogButtonBox::Cancel); - - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); -//! [2] //! [3] - -//! [4] - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->setSizeConstraint(QLayout::SetNoConstraint); - mainLayout->addWidget(tabWidget); - mainLayout->addWidget(buttonBox); - setLayout(mainLayout); -//! [4] - -//! [5] - setWindowTitle(tr("Tab Dialog")); -} -//! [5] - -//! [6] -GeneralTab::GeneralTab(const QFileInfo &fileInfo, QWidget *parent) - : QWidget(parent) -{ - QLabel *fileNameLabel = new QLabel(tr("File Name:")); - QLineEdit *fileNameEdit = new QLineEdit(fileInfo.fileName()); - - QLabel *pathLabel = new QLabel(tr("Path:")); - QLabel *pathValueLabel = new QLabel(fileInfo.absoluteFilePath()); - pathValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *sizeLabel = new QLabel(tr("Size:")); - qlonglong size = fileInfo.size()/1024; - QLabel *sizeValueLabel = new QLabel(tr("%1 K").arg(size)); - sizeValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *lastReadLabel = new QLabel(tr("Last Read:")); - QLabel *lastReadValueLabel = new QLabel(fileInfo.lastRead().toString()); - lastReadValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *lastModLabel = new QLabel(tr("Last Modified:")); - QLabel *lastModValueLabel = new QLabel(fileInfo.lastModified().toString()); - lastModValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(fileNameLabel); - mainLayout->addWidget(fileNameEdit); - mainLayout->addWidget(pathLabel); - mainLayout->addWidget(pathValueLabel); - mainLayout->addWidget(sizeLabel); - mainLayout->addWidget(sizeValueLabel); - mainLayout->addWidget(lastReadLabel); - mainLayout->addWidget(lastReadValueLabel); - mainLayout->addWidget(lastModLabel); - mainLayout->addWidget(lastModValueLabel); - mainLayout->addStretch(1); - setLayout(mainLayout); -} -//! [6] - -//! [7] -PermissionsTab::PermissionsTab(const QFileInfo &fileInfo, QWidget *parent) - : QWidget(parent) -{ - QGroupBox *permissionsGroup = new QGroupBox(tr("Permissions")); - - QCheckBox *readable = new QCheckBox(tr("Readable")); - if (fileInfo.isReadable()) - readable->setChecked(true); - - QCheckBox *writable = new QCheckBox(tr("Writable")); - if ( fileInfo.isWritable() ) - writable->setChecked(true); - - QCheckBox *executable = new QCheckBox(tr("Executable")); - if ( fileInfo.isExecutable() ) - executable->setChecked(true); - - QGroupBox *ownerGroup = new QGroupBox(tr("Ownership")); - - QLabel *ownerLabel = new QLabel(tr("Owner")); - QLabel *ownerValueLabel = new QLabel(fileInfo.owner()); - ownerValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QLabel *groupLabel = new QLabel(tr("Group")); - QLabel *groupValueLabel = new QLabel(fileInfo.group()); - groupValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - - QVBoxLayout *permissionsLayout = new QVBoxLayout; - permissionsLayout->addWidget(readable); - permissionsLayout->addWidget(writable); - permissionsLayout->addWidget(executable); - permissionsGroup->setLayout(permissionsLayout); - - QVBoxLayout *ownerLayout = new QVBoxLayout; - ownerLayout->addWidget(ownerLabel); - ownerLayout->addWidget(ownerValueLabel); - ownerLayout->addWidget(groupLabel); - ownerLayout->addWidget(groupValueLabel); - ownerGroup->setLayout(ownerLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(permissionsGroup); - mainLayout->addWidget(ownerGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); -} -//! [7] - -//! [8] -ApplicationsTab::ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent) - : QWidget(parent) -{ - QLabel *topLabel = new QLabel(tr("Open with:")); - - QListWidget *applicationsListBox = new QListWidget; - QStringList applications; - - for (int i = 1; i <= 30; ++i) - applications.append(tr("Application %1").arg(i)); - applicationsListBox->insertItems(0, applications); - - QCheckBox *alwaysCheckBox; - - if (fileInfo.suffix().isEmpty()) - alwaysCheckBox = new QCheckBox(tr("Always use this application to " - "open this type of file")); - else - alwaysCheckBox = new QCheckBox(tr("Always use this application to " - "open files with the extension '%1'").arg(fileInfo.suffix())); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(topLabel); - layout->addWidget(applicationsListBox); - layout->addWidget(alwaysCheckBox); - setLayout(layout); -} -//! [8] diff --git a/examples/dialogs/tabdialog/tabdialog.desktop b/examples/dialogs/tabdialog/tabdialog.desktop deleted file mode 100644 index 651f7d4068..0000000000 --- a/examples/dialogs/tabdialog/tabdialog.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Tab Dialog -Exec=/opt/usr/bin/tabdialog -Icon=tabdialog -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/tabdialog/tabdialog.h b/examples/dialogs/tabdialog/tabdialog.h deleted file mode 100644 index c2b46f0e92..0000000000 --- a/examples/dialogs/tabdialog/tabdialog.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 TABDIALOG_H -#define TABDIALOG_H - -#include - -QT_BEGIN_NAMESPACE -class QDialogButtonBox; -class QFileInfo; -class QTabWidget; -QT_END_NAMESPACE - -//! [0] -class GeneralTab : public QWidget -{ - Q_OBJECT - -public: - GeneralTab(const QFileInfo &fileInfo, QWidget *parent = 0); -}; -//! [0] - - -//! [1] -class PermissionsTab : public QWidget -{ - Q_OBJECT - -public: - PermissionsTab(const QFileInfo &fileInfo, QWidget *parent = 0); -}; -//! [1] - - -//! [2] -class ApplicationsTab : public QWidget -{ - Q_OBJECT - -public: - ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent = 0); -}; -//! [2] - - -//! [3] -class TabDialog : public QDialog -{ - Q_OBJECT - -public: - TabDialog(const QString &fileName, QWidget *parent = 0); - -private: - QTabWidget *tabWidget; - QDialogButtonBox *buttonBox; -}; -//! [3] - -#endif diff --git a/examples/dialogs/tabdialog/tabdialog.pro b/examples/dialogs/tabdialog/tabdialog.pro deleted file mode 100644 index 66ac14daf2..0000000000 --- a/examples/dialogs/tabdialog/tabdialog.pro +++ /dev/null @@ -1,12 +0,0 @@ -HEADERS = tabdialog.h -SOURCES = main.cpp \ - tabdialog.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/tabdialog -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/tabdialog -INSTALLS += target sources - -wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib -QT += widgets diff --git a/examples/dialogs/trivialwizard/trivialwizard.cpp b/examples/dialogs/trivialwizard/trivialwizard.cpp deleted file mode 100644 index f8209405d9..0000000000 --- a/examples/dialogs/trivialwizard/trivialwizard.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -//! [0] //! [1] -QWizardPage *createIntroPage() -{ - QWizardPage *page = new QWizardPage; - page->setTitle("Introduction"); - - QLabel *label = new QLabel("This wizard will help you register your copy " - "of Super Product Two."); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - page->setLayout(layout); - - return page; -} -//! [0] - -//! [2] -QWizardPage *createRegistrationPage() -//! [1] //! [3] -{ -//! [3] - QWizardPage *page = new QWizardPage; - page->setTitle("Registration"); - page->setSubTitle("Please fill both fields."); - - QLabel *nameLabel = new QLabel("Name:"); - QLineEdit *nameLineEdit = new QLineEdit; - - QLabel *emailLabel = new QLabel("Email address:"); - QLineEdit *emailLineEdit = new QLineEdit; - - QGridLayout *layout = new QGridLayout; - layout->addWidget(nameLabel, 0, 0); - layout->addWidget(nameLineEdit, 0, 1); - layout->addWidget(emailLabel, 1, 0); - layout->addWidget(emailLineEdit, 1, 1); - page->setLayout(layout); - - return page; -//! [4] -} -//! [2] //! [4] - -//! [5] //! [6] -QWizardPage *createConclusionPage() -//! [5] //! [7] -{ -//! [7] - QWizardPage *page = new QWizardPage; - page->setTitle("Conclusion"); - - QLabel *label = new QLabel("You are now successfully registered. Have a " - "nice day!"); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - page->setLayout(layout); - - return page; -//! [8] -} -//! [6] //! [8] - -//! [9] //! [10] -int main(int argc, char *argv[]) -//! [9] //! [11] -{ - QApplication app(argc, argv); - - QString translatorFileName = QLatin1String("qt_"); - translatorFileName += QLocale::system().name(); - QTranslator *translator = new QTranslator(&app); - if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app.installTranslator(translator); - - - QWizard wizard; - wizard.addPage(createIntroPage()); - wizard.addPage(createRegistrationPage()); - wizard.addPage(createConclusionPage()); - - wizard.setWindowTitle("Trivial Wizard"); - wizard.show(); - - return app.exec(); -} -//! [10] //! [11] diff --git a/examples/dialogs/trivialwizard/trivialwizard.desktop b/examples/dialogs/trivialwizard/trivialwizard.desktop deleted file mode 100644 index fad568ecc8..0000000000 --- a/examples/dialogs/trivialwizard/trivialwizard.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Trivial Wizard -Exec=/opt/usr/bin/trivialwizard -Icon=trivialwizard -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/dialogs/trivialwizard/trivialwizard.pro b/examples/dialogs/trivialwizard/trivialwizard.pro deleted file mode 100644 index 26d488d99d..0000000000 --- a/examples/dialogs/trivialwizard/trivialwizard.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES = trivialwizard.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/trivialwizard -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/trivialwizard -INSTALLS += target sources - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/draganddrop/README b/examples/draganddrop/README deleted file mode 100644 index 90dc55bf2f..0000000000 --- a/examples/draganddrop/README +++ /dev/null @@ -1,9 +0,0 @@ -Qt supports native drag and drop on all platforms via an extensible -MIME-based system that enables applications to send data to each other in the -most appropriate formats. - -Drag and drop can also be implemented for internal use by applications. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/draganddrop/delayedencoding/delayedencoding.desktop b/examples/draganddrop/delayedencoding/delayedencoding.desktop deleted file mode 100644 index 629c497b6b..0000000000 --- a/examples/draganddrop/delayedencoding/delayedencoding.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Delayed Encoding -Exec=/opt/usr/bin/delayedencoding -Icon=delayedencoding -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/draganddrop/draganddrop.pro b/examples/draganddrop/draganddrop.pro deleted file mode 100644 index a209ae31e4..0000000000 --- a/examples/draganddrop/draganddrop.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = draggableicons \ - draggabletext \ - dropsite \ - fridgemagnets \ - puzzle - -wince*: SUBDIRS -= dropsite -# install -sources.files = README *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop -INSTALLS += sources -QT += widgets diff --git a/examples/draganddrop/draggableicons/draggableicons.desktop b/examples/draganddrop/draggableicons/draggableicons.desktop deleted file mode 100644 index d14f758ce6..0000000000 --- a/examples/draganddrop/draggableicons/draggableicons.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Draggable Icons -Exec=/opt/usr/bin/draggableicons -Icon=draggableicons -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/draganddrop/draggableicons/draggableicons.pro b/examples/draganddrop/draggableicons/draggableicons.pro deleted file mode 100644 index 9f4156135f..0000000000 --- a/examples/draganddrop/draggableicons/draggableicons.pro +++ /dev/null @@ -1,12 +0,0 @@ -HEADERS = dragwidget.h -RESOURCES = draggableicons.qrc -SOURCES = dragwidget.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/draggableicons -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/draggableicons -INSTALLS += target sources - -QT += widgets diff --git a/examples/draganddrop/draggableicons/draggableicons.qrc b/examples/draganddrop/draggableicons/draggableicons.qrc deleted file mode 100644 index 63f84ac066..0000000000 --- a/examples/draganddrop/draggableicons/draggableicons.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/boat.png - images/car.png - images/house.png - - diff --git a/examples/draganddrop/draggableicons/dragwidget.cpp b/examples/draganddrop/draggableicons/dragwidget.cpp deleted file mode 100644 index 93a02a4647..0000000000 --- a/examples/draganddrop/draggableicons/dragwidget.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dragwidget.h" - -//! [0] -DragWidget::DragWidget(QWidget *parent) - : QFrame(parent) -{ - setMinimumSize(200, 200); - setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); - setAcceptDrops(true); - - QLabel *boatIcon = new QLabel(this); - boatIcon->setPixmap(QPixmap(":/images/boat.png")); - boatIcon->move(10, 10); - boatIcon->show(); - boatIcon->setAttribute(Qt::WA_DeleteOnClose); - - QLabel *carIcon = new QLabel(this); - carIcon->setPixmap(QPixmap(":/images/car.png")); - carIcon->move(100, 10); - carIcon->show(); - carIcon->setAttribute(Qt::WA_DeleteOnClose); - - QLabel *houseIcon = new QLabel(this); - houseIcon->setPixmap(QPixmap(":/images/house.png")); - houseIcon->move(10, 80); - houseIcon->show(); - houseIcon->setAttribute(Qt::WA_DeleteOnClose); -} -//! [0] - -void DragWidget::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-dnditemdata")) { - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } - } else { - event->ignore(); - } -} - -void DragWidget::dragMoveEvent(QDragMoveEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-dnditemdata")) { - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } - } else { - event->ignore(); - } -} - -void DragWidget::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-dnditemdata")) { - QByteArray itemData = event->mimeData()->data("application/x-dnditemdata"); - QDataStream dataStream(&itemData, QIODevice::ReadOnly); - - QPixmap pixmap; - QPoint offset; - dataStream >> pixmap >> offset; - - QLabel *newIcon = new QLabel(this); - newIcon->setPixmap(pixmap); - newIcon->move(event->pos() - offset); - newIcon->show(); - newIcon->setAttribute(Qt::WA_DeleteOnClose); - - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } - } else { - event->ignore(); - } -} - -//! [1] -void DragWidget::mousePressEvent(QMouseEvent *event) -{ - QLabel *child = static_cast(childAt(event->pos())); - if (!child) - return; - - QPixmap pixmap = *child->pixmap(); - - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - dataStream << pixmap << QPoint(event->pos() - child->pos()); -//! [1] - -//! [2] - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-dnditemdata", itemData); -//! [2] - -//! [3] - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setPixmap(pixmap); - drag->setHotSpot(event->pos() - child->pos()); -//! [3] - - QPixmap tempPixmap = pixmap; - QPainter painter; - painter.begin(&tempPixmap); - painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)); - painter.end(); - - child->setPixmap(tempPixmap); - - if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction) - child->close(); - else { - child->show(); - child->setPixmap(pixmap); - } -} diff --git a/examples/draganddrop/draggableicons/dragwidget.h b/examples/draganddrop/draggableicons/dragwidget.h deleted file mode 100644 index b2fae51c5e..0000000000 --- a/examples/draganddrop/draggableicons/dragwidget.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DRAGWIDGET_H -#define DRAGWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDropEvent; -QT_END_NAMESPACE - -//! [0] -class DragWidget : public QFrame -{ -public: - DragWidget(QWidget *parent=0); - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dropEvent(QDropEvent *event); - void mousePressEvent(QMouseEvent *event); -}; -//! [0] - -#endif diff --git a/examples/draganddrop/draggableicons/images/boat.png b/examples/draganddrop/draggableicons/images/boat.png deleted file mode 100644 index 46c894f06b..0000000000 Binary files a/examples/draganddrop/draggableicons/images/boat.png and /dev/null differ diff --git a/examples/draganddrop/draggableicons/images/car.png b/examples/draganddrop/draggableicons/images/car.png deleted file mode 100644 index 3cb35e56cb..0000000000 Binary files a/examples/draganddrop/draggableicons/images/car.png and /dev/null differ diff --git a/examples/draganddrop/draggableicons/images/house.png b/examples/draganddrop/draggableicons/images/house.png deleted file mode 100644 index ee9d5b1159..0000000000 Binary files a/examples/draganddrop/draggableicons/images/house.png and /dev/null differ diff --git a/examples/draganddrop/draggableicons/main.cpp b/examples/draganddrop/draggableicons/main.cpp deleted file mode 100644 index 5a7120c9d5..0000000000 --- a/examples/draganddrop/draggableicons/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include "dragwidget.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(draggableicons); - - QApplication app(argc, argv); - - QWidget mainWidget; - QHBoxLayout *horizontalLayout = new QHBoxLayout; - horizontalLayout->addWidget(new DragWidget); - horizontalLayout->addWidget(new DragWidget); - - mainWidget.setLayout(horizontalLayout); - mainWidget.setWindowTitle(QObject::tr("Draggable Icons")); - mainWidget.show(); - - return app.exec(); -} diff --git a/examples/draganddrop/draggabletext/draggabletext.desktop b/examples/draganddrop/draggabletext/draggabletext.desktop deleted file mode 100644 index ceda807604..0000000000 --- a/examples/draganddrop/draggabletext/draggabletext.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Draggable Text -Exec=/opt/usr/bin/draggabletext -Icon=draggabletext -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/draganddrop/draggabletext/draggabletext.pro b/examples/draganddrop/draggabletext/draggabletext.pro deleted file mode 100644 index 1fd8e5ce6e..0000000000 --- a/examples/draganddrop/draggabletext/draggabletext.pro +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS = draglabel.h \ - dragwidget.h -RESOURCES = draggabletext.qrc -SOURCES = draglabel.cpp \ - dragwidget.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/draggabletext -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.txt *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/draggabletext -INSTALLS += target sources - -QT += widgets - diff --git a/examples/draganddrop/draggabletext/draggabletext.qrc b/examples/draganddrop/draggabletext/draggabletext.qrc deleted file mode 100644 index b72217d701..0000000000 --- a/examples/draganddrop/draggabletext/draggabletext.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - words.txt - - diff --git a/examples/draganddrop/draggabletext/draglabel.cpp b/examples/draganddrop/draggabletext/draglabel.cpp deleted file mode 100644 index 803e659157..0000000000 --- a/examples/draganddrop/draggabletext/draglabel.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "draglabel.h" - -DragLabel::DragLabel(const QString &text, QWidget *parent) - : QLabel(text, parent) -{ - setAutoFillBackground(true); - setFrameShape(QFrame::Panel); - setFrameShadow(QFrame::Raised); -} diff --git a/examples/draganddrop/draggabletext/draglabel.h b/examples/draganddrop/draggabletext/draglabel.h deleted file mode 100644 index e067a37652..0000000000 --- a/examples/draganddrop/draggabletext/draglabel.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DRAGLABEL_H -#define DRAGLABEL_H - -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDragMoveEvent; -class QFrame; -QT_END_NAMESPACE - -class DragLabel : public QLabel -{ -public: - DragLabel(const QString &text, QWidget *parent); -}; - -#endif diff --git a/examples/draganddrop/draggabletext/dragwidget.cpp b/examples/draganddrop/draggabletext/dragwidget.cpp deleted file mode 100644 index 60d84ebb5b..0000000000 --- a/examples/draganddrop/draggabletext/dragwidget.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "draglabel.h" -#include "dragwidget.h" - -DragWidget::DragWidget(QWidget *parent) - : QWidget(parent) -{ - QFile dictionaryFile(":/dictionary/words.txt"); - dictionaryFile.open(QIODevice::ReadOnly); - QTextStream inputStream(&dictionaryFile); - - int x = 5; - int y = 5; - - while (!inputStream.atEnd()) { - QString word; - inputStream >> word; - if (!word.isEmpty()) { - DragLabel *wordLabel = new DragLabel(word, this); - wordLabel->move(x, y); - wordLabel->show(); - wordLabel->setAttribute(Qt::WA_DeleteOnClose); - x += wordLabel->width() + 2; - if (x >= 245) { - x = 5; - y += wordLabel->height() + 2; - } - } - } - - /* - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Window, Qt::white); - setPalette(newPalette); - */ - - setAcceptDrops(true); - setMinimumSize(400, qMax(200, y)); - setWindowTitle(tr("Draggable Text")); -} - -void DragWidget::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasText()) { - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } - } else { - event->ignore(); - } -} - -void DragWidget::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasText()) { - const QMimeData *mime = event->mimeData(); - QStringList pieces = mime->text().split(QRegExp("\\s+"), - QString::SkipEmptyParts); - QPoint position = event->pos(); - QPoint hotSpot; - - QList hotSpotPos = mime->data("application/x-hotspot").split(' '); - if (hotSpotPos.size() == 2) { - hotSpot.setX(hotSpotPos.first().toInt()); - hotSpot.setY(hotSpotPos.last().toInt()); - } - - foreach (QString piece, pieces) { - DragLabel *newLabel = new DragLabel(piece, this); - newLabel->move(position - hotSpot); - newLabel->show(); - newLabel->setAttribute(Qt::WA_DeleteOnClose); - - position += QPoint(newLabel->width(), 0); - } - - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } - } else { - event->ignore(); - } - foreach (QObject *child, children()) { - if (child->inherits("QWidget")) { - QWidget *widget = static_cast(child); - if (!widget->isVisible()) - widget->deleteLater(); - } - } -} - -void DragWidget::mousePressEvent(QMouseEvent *event) -{ - QLabel *child = static_cast(childAt(event->pos())); - if (!child) - return; - - QPoint hotSpot = event->pos() - child->pos(); - - QMimeData *mimeData = new QMimeData; - mimeData->setText(child->text()); - mimeData->setData("application/x-hotspot", - QByteArray::number(hotSpot.x()) - + " " + QByteArray::number(hotSpot.y())); - - QPixmap pixmap(child->size()); - child->render(&pixmap); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setPixmap(pixmap); - drag->setHotSpot(hotSpot); - - Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction); - - if (dropAction == Qt::MoveAction) - child->close(); -} diff --git a/examples/draganddrop/draggabletext/dragwidget.h b/examples/draganddrop/draggabletext/dragwidget.h deleted file mode 100644 index deef7fe4dd..0000000000 --- a/examples/draganddrop/draggabletext/dragwidget.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DRAGWIDGET_H -#define DRAGWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDropEvent; -QT_END_NAMESPACE - -class DragWidget : public QWidget -{ -public: - DragWidget(QWidget *parent = 0); - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - void mousePressEvent(QMouseEvent *event); -}; - -#endif diff --git a/examples/draganddrop/draggabletext/main.cpp b/examples/draganddrop/draggabletext/main.cpp deleted file mode 100644 index 3c57afff6a..0000000000 --- a/examples/draganddrop/draggabletext/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "dragwidget.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(draggabletext); - - QApplication app(argc, argv); - DragWidget window; - window.show(); - return app.exec(); -} diff --git a/examples/draganddrop/draggabletext/words.txt b/examples/draganddrop/draggabletext/words.txt deleted file mode 100644 index 19b8b0325b..0000000000 --- a/examples/draganddrop/draggabletext/words.txt +++ /dev/null @@ -1,41 +0,0 @@ -Qt -Quarterly -is -a -paper -based -newsletter -exclusively -available -to -Qt -customers -Every -quarter -we -mail -out -an -issue -that -we -hope -will -bring -added -insight -and -pleasure -to -your -Qt -programming -with -high -quality -technical -articles -written -by -Qt -experts diff --git a/examples/draganddrop/dropsite/droparea.cpp b/examples/draganddrop/dropsite/droparea.cpp deleted file mode 100644 index 95bbd3000c..0000000000 --- a/examples/draganddrop/dropsite/droparea.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "droparea.h" - -//! [DropArea constructor] -DropArea::DropArea(QWidget *parent) - : QLabel(parent) -{ - setMinimumSize(200, 200); - setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); - setAlignment(Qt::AlignCenter); - setAcceptDrops(true); - setAutoFillBackground(true); - clear(); -} -//! [DropArea constructor] - -//! [dragEnterEvent() function] -void DropArea::dragEnterEvent(QDragEnterEvent *event) -{ - setText(tr("")); - setBackgroundRole(QPalette::Highlight); - - event->acceptProposedAction(); - emit changed(event->mimeData()); -} -//! [dragEnterEvent() function] - -//! [dragMoveEvent() function] -void DropArea::dragMoveEvent(QDragMoveEvent *event) -{ - event->acceptProposedAction(); -} -//! [dragMoveEvent() function] - -//! [dropEvent() function part1] -void DropArea::dropEvent(QDropEvent *event) -{ - const QMimeData *mimeData = event->mimeData(); -//! [dropEvent() function part1] - -//! [dropEvent() function part2] - if (mimeData->hasImage()) { - setPixmap(qvariant_cast(mimeData->imageData())); - } else if (mimeData->hasHtml()) { - setText(mimeData->html()); - setTextFormat(Qt::RichText); - } else if (mimeData->hasText()) { - setText(mimeData->text()); - setTextFormat(Qt::PlainText); - } else if (mimeData->hasUrls()) { - QList urlList = mimeData->urls(); - QString text; - for (int i = 0; i < urlList.size() && i < 32; ++i) { - QString url = urlList.at(i).path(); - text += url + QString("\n"); - } - setText(text); - } else { - setText(tr("Cannot display data")); - } -//! [dropEvent() function part2] - -//! [dropEvent() function part3] - setBackgroundRole(QPalette::Dark); - event->acceptProposedAction(); -} -//! [dropEvent() function part3] - -//! [dragLeaveEvent() function] -void DropArea::dragLeaveEvent(QDragLeaveEvent *event) -{ - clear(); - event->accept(); -} -//! [dragLeaveEvent() function] - -//! [clear() function] -void DropArea::clear() -{ - setText(tr("")); - setBackgroundRole(QPalette::Dark); - - emit changed(); -} -//! [clear() function] diff --git a/examples/draganddrop/dropsite/droparea.h b/examples/draganddrop/dropsite/droparea.h deleted file mode 100644 index e1586990df..0000000000 --- a/examples/draganddrop/dropsite/droparea.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DROPAREA_H -#define DROPAREA_H - -#include - -QT_BEGIN_NAMESPACE -class QMimeData; -QT_END_NAMESPACE - -//! [DropArea header part1] -class DropArea : public QLabel -{ - Q_OBJECT - -public: - DropArea(QWidget *parent = 0); - -public slots: - void clear(); - -signals: - void changed(const QMimeData *mimeData = 0); -//! [DropArea header part1] - -//! [DropArea header part2] -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dropEvent(QDropEvent *event); - -private: - QLabel *label; -}; -//! [DropArea header part2] - -#endif diff --git a/examples/draganddrop/dropsite/dropsite.desktop b/examples/draganddrop/dropsite/dropsite.desktop deleted file mode 100644 index 70a192f2b1..0000000000 --- a/examples/draganddrop/dropsite/dropsite.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Drop Site -Exec=/opt/usr/bin/dropsite -Icon=dropsite -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/draganddrop/dropsite/dropsite.pro b/examples/draganddrop/dropsite/dropsite.pro deleted file mode 100644 index 8198b19e79..0000000000 --- a/examples/draganddrop/dropsite/dropsite.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = droparea.h \ - dropsitewindow.h -SOURCES = droparea.cpp \ - dropsitewindow.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/dropsite -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/dropsite -INSTALLS += target sources - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/draganddrop/dropsite/dropsitewindow.cpp b/examples/draganddrop/dropsite/dropsitewindow.cpp deleted file mode 100644 index f7fc5aa1ab..0000000000 --- a/examples/draganddrop/dropsite/dropsitewindow.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "droparea.h" -#include "dropsitewindow.h" - -//! [constructor part1] -DropSiteWindow::DropSiteWindow() -{ - abstractLabel = new QLabel(tr("This example accepts drags from other " - "applications and displays the MIME types " - "provided by the drag object.")); - abstractLabel->setWordWrap(true); - abstractLabel->adjustSize(); -//! [constructor part1] - -//! [constructor part2] - dropArea = new DropArea; - connect(dropArea, SIGNAL(changed(const QMimeData*)), - this, SLOT(updateFormatsTable(const QMimeData*))); -//! [constructor part2] - -//! [constructor part3] - QStringList labels; - labels << tr("Format") << tr("Content"); - - formatsTable = new QTableWidget; - formatsTable->setColumnCount(2); - formatsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - formatsTable->setHorizontalHeaderLabels(labels); - formatsTable->horizontalHeader()->setStretchLastSection(true); -//! [constructor part3] - -//! [constructor part4] - clearButton = new QPushButton(tr("Clear")); - quitButton = new QPushButton(tr("Quit")); - - buttonBox = new QDialogButtonBox; - buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - - connect(quitButton, SIGNAL(pressed()), this, SLOT(close())); - connect(clearButton, SIGNAL(pressed()), dropArea, SLOT(clear())); -//! [constructor part4] - -//! [constructor part5] - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(abstractLabel); - mainLayout->addWidget(dropArea); - mainLayout->addWidget(formatsTable); - mainLayout->addWidget(buttonBox); - setLayout(mainLayout); - - setWindowTitle(tr("Drop Site")); - setMinimumSize(350, 500); -} -//! [constructor part5] - -//! [updateFormatsTable() part1] -void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData) -{ - formatsTable->setRowCount(0); - if (!mimeData) - return; -//! [updateFormatsTable() part1] - -//! [updateFormatsTable() part2] - foreach (QString format, mimeData->formats()) { - QTableWidgetItem *formatItem = new QTableWidgetItem(format); - formatItem->setFlags(Qt::ItemIsEnabled); - formatItem->setTextAlignment(Qt::AlignTop | Qt::AlignLeft); -//! [updateFormatsTable() part2] - -//! [updateFormatsTable() part3] - QString text; - if (format == "text/plain") { - text = mimeData->text().simplified(); - } else if (format == "text/html") { - text = mimeData->html().simplified(); - } else if (format == "text/uri-list") { - QList urlList = mimeData->urls(); - for (int i = 0; i < urlList.size() && i < 32; ++i) - text.append(urlList[i].toString() + " "); - } else { - QByteArray data = mimeData->data(format); - for (int i = 0; i < data.size() && i < 32; ++i) { - QString hex = QString("%1").arg(uchar(data[i]), 2, 16, - QChar('0')) - .toUpper(); - text.append(hex + " "); - } - } -//! [updateFormatsTable() part3] - -//! [updateFormatsTable() part4] - int row = formatsTable->rowCount(); - formatsTable->insertRow(row); - formatsTable->setItem(row, 0, new QTableWidgetItem(format)); - formatsTable->setItem(row, 1, new QTableWidgetItem(text)); - } - - formatsTable->resizeColumnToContents(0); -} -//! [updateFormatsTable() part4] diff --git a/examples/draganddrop/dropsite/dropsitewindow.h b/examples/draganddrop/dropsite/dropsitewindow.h deleted file mode 100644 index 049e9593f4..0000000000 --- a/examples/draganddrop/dropsite/dropsitewindow.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DROPSITEWINDOW_H -#define DROPSITEWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -class QDialogButtonBox; -class QLabel; -class QMimeData; -class QPushButton; -class QTableWidget; -QT_END_NAMESPACE -class DropArea; - -//! [DropSiteWindow header] -class DropSiteWindow : public QWidget -{ - Q_OBJECT - -public: - DropSiteWindow(); - -public slots: - void updateFormatsTable(const QMimeData *mimeData); - -private: - DropArea *dropArea; - QLabel *abstractLabel; - QTableWidget *formatsTable; - - QPushButton *clearButton; - QPushButton *quitButton; - QDialogButtonBox *buttonBox; -}; -//! [DropSiteWindow header] - -#endif diff --git a/examples/draganddrop/dropsite/main.cpp b/examples/draganddrop/dropsite/main.cpp deleted file mode 100644 index f6220fa42e..0000000000 --- a/examples/draganddrop/dropsite/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dropsitewindow.h" - -//! [main() function] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - DropSiteWindow window; - window.show(); - return app.exec(); -} -//! [main() function] diff --git a/examples/draganddrop/fridgemagnets/draglabel.cpp b/examples/draganddrop/fridgemagnets/draglabel.cpp deleted file mode 100644 index a4e52ed635..0000000000 --- a/examples/draganddrop/fridgemagnets/draglabel.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "draglabel.h" - -//! [0] -DragLabel::DragLabel(const QString &text, QWidget *parent) - : QLabel(parent) -{ - QFontMetrics metric(font()); - QSize size = metric.size(Qt::TextSingleLine, text); - - QImage image(size.width() + 12, size.height() + 12, - QImage::Format_ARGB32_Premultiplied); - image.fill(qRgba(0, 0, 0, 0)); - - QFont font; - font.setStyleStrategy(QFont::ForceOutline); -//! [0] - -//! [1] - QLinearGradient gradient(0, 0, 0, image.height()-1); - gradient.setColorAt(0.0, Qt::white); - gradient.setColorAt(0.2, QColor(200, 200, 255)); - gradient.setColorAt(0.8, QColor(200, 200, 255)); - gradient.setColorAt(1.0, QColor(127, 127, 200)); - - QPainter painter; - painter.begin(&image); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(gradient); - painter.drawRoundedRect(QRectF(0.5, 0.5, image.width()-1, image.height()-1), - 25, 25, Qt::RelativeSize); - - painter.setFont(font); - painter.setBrush(Qt::black); - painter.drawText(QRect(QPoint(6, 6), size), Qt::AlignCenter, text); - painter.end(); -//! [1] - -//! [2] - setPixmap(QPixmap::fromImage(image)); - m_labelText = text; -} -//! [2] - -QString DragLabel::labelText() const -{ - return m_labelText; -} diff --git a/examples/draganddrop/fridgemagnets/draglabel.h b/examples/draganddrop/fridgemagnets/draglabel.h deleted file mode 100644 index ecbd02d896..0000000000 --- a/examples/draganddrop/fridgemagnets/draglabel.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DRAGLABEL_H -#define DRAGLABEL_H - -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDragMoveEvent; -class QFrame; -QT_END_NAMESPACE - -//! [0] -class DragLabel : public QLabel -{ -public: - DragLabel(const QString &text, QWidget *parent); - QString labelText() const; - -private: - QString m_labelText; -}; -//! [0] - -#endif diff --git a/examples/draganddrop/fridgemagnets/dragwidget.cpp b/examples/draganddrop/fridgemagnets/dragwidget.cpp deleted file mode 100644 index 434fcecb22..0000000000 --- a/examples/draganddrop/fridgemagnets/dragwidget.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "draglabel.h" -#include "dragwidget.h" - -//! [0] -DragWidget::DragWidget(QWidget *parent) - : QWidget(parent) -{ - QFile dictionaryFile(":/dictionary/words.txt"); - dictionaryFile.open(QFile::ReadOnly); - QTextStream inputStream(&dictionaryFile); -//! [0] - -//! [1] - int x = 5; - int y = 5; - - while (!inputStream.atEnd()) { - QString word; - inputStream >> word; - if (!word.isEmpty()) { - DragLabel *wordLabel = new DragLabel(word, this); - wordLabel->move(x, y); - wordLabel->show(); - wordLabel->setAttribute(Qt::WA_DeleteOnClose); - x += wordLabel->width() + 2; - if (x >= 245) { - x = 5; - y += wordLabel->height() + 2; - } - } - } -//! [1] - -//! [2] - //Fridge magnets is used for demoing Qt on S60 and themed backgrounds look better than white - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Window, Qt::white); - setPalette(newPalette); - - setMinimumSize(400, qMax(200, y)); - setWindowTitle(tr("Fridge Magnets")); -//! [2] //! [3] - setAcceptDrops(true); -} -//! [3] - -//! [4] -void DragWidget::dragEnterEvent(QDragEnterEvent *event) -{ -//! [4] //! [5] - if (event->mimeData()->hasFormat("application/x-fridgemagnet")) { - if (children().contains(event->source())) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); -//! [5] //! [6] - } -//! [6] //! [7] - } else if (event->mimeData()->hasText()) { - event->acceptProposedAction(); - } else { - event->ignore(); - } -} -//! [7] - -//! [8] -void DragWidget::dragMoveEvent(QDragMoveEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-fridgemagnet")) { - if (children().contains(event->source())) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } - } else if (event->mimeData()->hasText()) { - event->acceptProposedAction(); - } else { - event->ignore(); - } -} -//! [8] - -//! [9] -void DragWidget::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-fridgemagnet")) { - const QMimeData *mime = event->mimeData(); -//! [9] //! [10] - QByteArray itemData = mime->data("application/x-fridgemagnet"); - QDataStream dataStream(&itemData, QIODevice::ReadOnly); - - QString text; - QPoint offset; - dataStream >> text >> offset; -//! [10] -//! [11] - DragLabel *newLabel = new DragLabel(text, this); - newLabel->move(event->pos() - offset); - newLabel->show(); - newLabel->setAttribute(Qt::WA_DeleteOnClose); - - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - event->acceptProposedAction(); - } -//! [11] //! [12] - } else if (event->mimeData()->hasText()) { - QStringList pieces = event->mimeData()->text().split(QRegExp("\\s+"), - QString::SkipEmptyParts); - QPoint position = event->pos(); - - foreach (QString piece, pieces) { - DragLabel *newLabel = new DragLabel(piece, this); - newLabel->move(position); - newLabel->show(); - newLabel->setAttribute(Qt::WA_DeleteOnClose); - - position += QPoint(newLabel->width(), 0); - } - - event->acceptProposedAction(); - } else { - event->ignore(); - } -} -//! [12] - -//! [13] -void DragWidget::mousePressEvent(QMouseEvent *event) -{ -//! [13] -//! [14] - DragLabel *child = static_cast(childAt(event->pos())); - if (!child) - return; - - QPoint hotSpot = event->pos() - child->pos(); - - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - dataStream << child->labelText() << QPoint(hotSpot); -//! [14] - -//! [15] - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-fridgemagnet", itemData); - mimeData->setText(child->labelText()); -//! [15] - -//! [16] - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setPixmap(*child->pixmap()); - drag->setHotSpot(hotSpot); - - child->hide(); -//! [16] - -//! [17] - if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction) - child->close(); - else - child->show(); -} -//! [17] diff --git a/examples/draganddrop/fridgemagnets/dragwidget.h b/examples/draganddrop/fridgemagnets/dragwidget.h deleted file mode 100644 index a3e3ced25e..0000000000 --- a/examples/draganddrop/fridgemagnets/dragwidget.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DRAGWIDGET_H -#define DRAGWIDGET_H - -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDropEvent; -QT_END_NAMESPACE - -//! [0] -class DragWidget : public QWidget -{ -public: - DragWidget(QWidget *parent = 0); - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dropEvent(QDropEvent *event); - void mousePressEvent(QMouseEvent *event); -}; -//! [0] - -#endif diff --git a/examples/draganddrop/fridgemagnets/fridgemagnets.desktop b/examples/draganddrop/fridgemagnets/fridgemagnets.desktop deleted file mode 100644 index a240590c6b..0000000000 --- a/examples/draganddrop/fridgemagnets/fridgemagnets.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Fridge Magnets -Exec=/opt/usr/bin/fridgemagnets -Icon=fridgemagnets -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/draganddrop/fridgemagnets/fridgemagnets.pro b/examples/draganddrop/fridgemagnets/fridgemagnets.pro deleted file mode 100644 index 2bbfdf0b3a..0000000000 --- a/examples/draganddrop/fridgemagnets/fridgemagnets.pro +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS = draglabel.h \ - dragwidget.h -RESOURCES = fridgemagnets.qrc -SOURCES = draglabel.cpp \ - dragwidget.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/fridgemagnets -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.txt -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/fridgemagnets -INSTALLS += target sources - -QT += widgets - diff --git a/examples/draganddrop/fridgemagnets/fridgemagnets.qrc b/examples/draganddrop/fridgemagnets/fridgemagnets.qrc deleted file mode 100644 index b72217d701..0000000000 --- a/examples/draganddrop/fridgemagnets/fridgemagnets.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - words.txt - - diff --git a/examples/draganddrop/fridgemagnets/main.cpp b/examples/draganddrop/fridgemagnets/main.cpp deleted file mode 100644 index 692a5e394a..0000000000 --- a/examples/draganddrop/fridgemagnets/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "dragwidget.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(fridgemagnets); - - QApplication app(argc, argv); -#ifdef QT_KEYPAD_NAVIGATION - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif - DragWidget window; - - bool smallScreen = QApplication::arguments().contains("-small-screen"); - if (smallScreen) - window.showFullScreen(); - else - window.show(); - - return app.exec(); -} diff --git a/examples/draganddrop/fridgemagnets/words.txt b/examples/draganddrop/fridgemagnets/words.txt deleted file mode 100644 index a7e1632b09..0000000000 --- a/examples/draganddrop/fridgemagnets/words.txt +++ /dev/null @@ -1,48 +0,0 @@ -Colorless -green -ideas -sleep -furiously -A -colorless -green -idea -is -a -new -untried -idea -that -is -without -vividness -dull -and -unexciting -To -sleep -furiously -may -seem -a -puzzling -turn -of -phrase -but -the -mind -in -sleep -often -indeed -moves -furiously -with -ideas -and -images -flickering -in -and -out diff --git a/examples/draganddrop/puzzle/example.jpg b/examples/draganddrop/puzzle/example.jpg deleted file mode 100644 index e09fb70757..0000000000 Binary files a/examples/draganddrop/puzzle/example.jpg and /dev/null differ diff --git a/examples/draganddrop/puzzle/main.cpp b/examples/draganddrop/puzzle/main.cpp deleted file mode 100644 index 31b7142819..0000000000 --- a/examples/draganddrop/puzzle/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(puzzle); - - QApplication app(argc, argv); - MainWindow window; - window.openImage(":/images/example.jpg"); - window.show(); - return app.exec(); -} diff --git a/examples/draganddrop/puzzle/mainwindow.cpp b/examples/draganddrop/puzzle/mainwindow.cpp deleted file mode 100644 index 0540aaef9f..0000000000 --- a/examples/draganddrop/puzzle/mainwindow.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#include "mainwindow.h" -#include "pieceslist.h" -#include "puzzlewidget.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - setupMenus(); - setupWidgets(); - - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - setWindowTitle(tr("Puzzle")); -} - -void MainWindow::openImage(const QString &path) -{ - QString fileName = path; - - if (fileName.isNull()) - fileName = QFileDialog::getOpenFileName(this, - tr("Open Image"), "", "Image Files (*.png *.jpg *.bmp)"); - - if (!fileName.isEmpty()) { - QPixmap newImage; - if (!newImage.load(fileName)) { - QMessageBox::warning(this, tr("Open Image"), - tr("The image file could not be loaded."), - QMessageBox::Cancel); - return; - } - puzzleImage = newImage; - setupPuzzle(); - } -} - -void MainWindow::setCompleted() -{ - QMessageBox::information(this, tr("Puzzle Completed"), - tr("Congratulations! You have completed the puzzle!\n" - "Click OK to start again."), - QMessageBox::Ok); - - setupPuzzle(); -} - -void MainWindow::setupPuzzle() -{ - int size = qMin(puzzleImage.width(), puzzleImage.height()); - puzzleImage = puzzleImage.copy((puzzleImage.width() - size)/2, - (puzzleImage.height() - size)/2, size, size).scaled(puzzleWidget->width(), - puzzleWidget->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - piecesList->clear(); - - for (int y = 0; y < 5; ++y) { - for (int x = 0; x < 5; ++x) { - int pieceSize = puzzleWidget->pieceSize(); - QPixmap pieceImage = puzzleImage.copy(x * pieceSize, y * pieceSize, pieceSize, pieceSize); - piecesList->addPiece(pieceImage, QPoint(x, y)); - } - } - - qsrand(QCursor::pos().x() ^ QCursor::pos().y()); - - for (int i = 0; i < piecesList->count(); ++i) { - if (int(2.0*qrand()/(RAND_MAX+1.0)) == 1) { - QListWidgetItem *item = piecesList->takeItem(i); - piecesList->insertItem(0, item); - } - } - - puzzleWidget->clear(); -} - -void MainWindow::setupMenus() -{ - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - - QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcuts(QKeySequence::Open); - - QAction *exitAction = fileMenu->addAction(tr("E&xit")); - exitAction->setShortcuts(QKeySequence::Quit); - - QMenu *gameMenu = menuBar()->addMenu(tr("&Game")); - - QAction *restartAction = gameMenu->addAction(tr("&Restart")); - - connect(openAction, SIGNAL(triggered()), this, SLOT(openImage())); - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(restartAction, SIGNAL(triggered()), this, SLOT(setupPuzzle())); -} - -void MainWindow::setupWidgets() -{ - QFrame *frame = new QFrame; - QHBoxLayout *frameLayout = new QHBoxLayout(frame); - puzzleWidget = new PuzzleWidget(400); - - piecesList = new PiecesList(puzzleWidget->pieceSize(), this); - - - connect(puzzleWidget, SIGNAL(puzzleCompleted()), - this, SLOT(setCompleted()), Qt::QueuedConnection); - - frameLayout->addWidget(piecesList); - frameLayout->addWidget(puzzleWidget); - setCentralWidget(frame); -} diff --git a/examples/draganddrop/puzzle/mainwindow.h b/examples/draganddrop/puzzle/mainwindow.h deleted file mode 100644 index c7ce2c8ef3..0000000000 --- a/examples/draganddrop/puzzle/mainwindow.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -class PiecesList; -class PuzzleWidget; -QT_BEGIN_NAMESPACE -class QListWidgetItem; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - -public slots: - void openImage(const QString &path = QString()); - void setupPuzzle(); - -private slots: - void setCompleted(); - -private: - void setupMenus(); - void setupWidgets(); - - QPixmap puzzleImage; - PiecesList *piecesList; - PuzzleWidget *puzzleWidget; -}; - -#endif diff --git a/examples/draganddrop/puzzle/pieceslist.cpp b/examples/draganddrop/puzzle/pieceslist.cpp deleted file mode 100644 index 8e0892aae6..0000000000 --- a/examples/draganddrop/puzzle/pieceslist.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "pieceslist.h" - -PiecesList::PiecesList(int pieceSize, QWidget *parent) - : QListWidget(parent), m_PieceSize(pieceSize) -{ - setDragEnabled(true); - setViewMode(QListView::IconMode); - setIconSize(QSize(m_PieceSize, m_PieceSize)); - setSpacing(10); - setAcceptDrops(true); - setDropIndicatorShown(true); -} - -void PiecesList::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece")) - event->accept(); - else - event->ignore(); -} - -void PiecesList::dragMoveEvent(QDragMoveEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece")) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } else - event->ignore(); -} - -void PiecesList::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece")) { - QByteArray pieceData = event->mimeData()->data("image/x-puzzle-piece"); - QDataStream dataStream(&pieceData, QIODevice::ReadOnly); - QPixmap pixmap; - QPoint location; - dataStream >> pixmap >> location; - - addPiece(pixmap, location); - - event->setDropAction(Qt::MoveAction); - event->accept(); - } else - event->ignore(); -} - -void PiecesList::addPiece(QPixmap pixmap, QPoint location) -{ - QListWidgetItem *pieceItem = new QListWidgetItem(this); - pieceItem->setIcon(QIcon(pixmap)); - pieceItem->setData(Qt::UserRole, QVariant(pixmap)); - pieceItem->setData(Qt::UserRole+1, location); - pieceItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable - | Qt::ItemIsDragEnabled); -} - -void PiecesList::startDrag(Qt::DropActions /*supportedActions*/) -{ - QListWidgetItem *item = currentItem(); - - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - QPixmap pixmap = qvariant_cast(item->data(Qt::UserRole)); - QPoint location = item->data(Qt::UserRole+1).toPoint(); - - dataStream << pixmap << location; - - QMimeData *mimeData = new QMimeData; - mimeData->setData("image/x-puzzle-piece", itemData); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2)); - drag->setPixmap(pixmap); - - if (drag->exec(Qt::MoveAction) == Qt::MoveAction) - delete takeItem(row(item)); -} diff --git a/examples/draganddrop/puzzle/pieceslist.h b/examples/draganddrop/puzzle/pieceslist.h deleted file mode 100644 index 3c6b042b4e..0000000000 --- a/examples/draganddrop/puzzle/pieceslist.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PIECESLIST_H -#define PIECESLIST_H - -#include - -class PiecesList : public QListWidget -{ - Q_OBJECT - -public: - PiecesList(int pieceSize, QWidget *parent = 0); - void addPiece(QPixmap pixmap, QPoint location); - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dropEvent(QDropEvent *event); - void startDrag(Qt::DropActions supportedActions); - - int m_PieceSize; -}; - -#endif diff --git a/examples/draganddrop/puzzle/puzzle.desktop b/examples/draganddrop/puzzle/puzzle.desktop deleted file mode 100644 index f6765e1e01..0000000000 --- a/examples/draganddrop/puzzle/puzzle.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Drag and Drop Puzzle -Exec=/opt/usr/bin/puzzle -Icon=puzzle -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/draganddrop/puzzle/puzzle.pro b/examples/draganddrop/puzzle/puzzle.pro deleted file mode 100644 index 7c69a41a39..0000000000 --- a/examples/draganddrop/puzzle/puzzle.pro +++ /dev/null @@ -1,23 +0,0 @@ -HEADERS = mainwindow.h \ - pieceslist.h \ - puzzlewidget.h -RESOURCES = puzzle.qrc -SOURCES = main.cpp \ - mainwindow.cpp \ - pieceslist.cpp \ - puzzlewidget.cpp - -QMAKE_PROJECT_NAME = dndpuzzle - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/puzzle -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.jpg -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/puzzle -INSTALLS += target sources - -wince*: { - addFile.files = example.jpg - addFile.path = . - DEPLOYMENT += addFile -} -QT += widgets diff --git a/examples/draganddrop/puzzle/puzzle.qrc b/examples/draganddrop/puzzle/puzzle.qrc deleted file mode 100644 index 4076cec026..0000000000 --- a/examples/draganddrop/puzzle/puzzle.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.jpg - - diff --git a/examples/draganddrop/puzzle/puzzlewidget.cpp b/examples/draganddrop/puzzle/puzzlewidget.cpp deleted file mode 100644 index 2e39f84e9e..0000000000 --- a/examples/draganddrop/puzzle/puzzlewidget.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "puzzlewidget.h" - -PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent) - : QWidget(parent), m_ImageSize(imageSize) -{ - setAcceptDrops(true); - setMinimumSize(m_ImageSize, m_ImageSize); - setMaximumSize(m_ImageSize, m_ImageSize); -} - -void PuzzleWidget::clear() -{ - pieceLocations.clear(); - piecePixmaps.clear(); - pieceRects.clear(); - highlightedRect = QRect(); - inPlace = 0; - update(); -} - -void PuzzleWidget::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece")) - event->accept(); - else - event->ignore(); -} - -void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event) -{ - QRect updateRect = highlightedRect; - highlightedRect = QRect(); - update(updateRect); - event->accept(); -} - -void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event) -{ - QRect updateRect = highlightedRect.united(targetSquare(event->pos())); - - if (event->mimeData()->hasFormat("image/x-puzzle-piece") - && findPiece(targetSquare(event->pos())) == -1) { - - highlightedRect = targetSquare(event->pos()); - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - highlightedRect = QRect(); - event->ignore(); - } - - update(updateRect); -} - -void PuzzleWidget::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece") - && findPiece(targetSquare(event->pos())) == -1) { - - QByteArray pieceData = event->mimeData()->data("image/x-puzzle-piece"); - QDataStream dataStream(&pieceData, QIODevice::ReadOnly); - QRect square = targetSquare(event->pos()); - QPixmap pixmap; - QPoint location; - dataStream >> pixmap >> location; - - pieceLocations.append(location); - piecePixmaps.append(pixmap); - pieceRects.append(square); - - highlightedRect = QRect(); - update(square); - - event->setDropAction(Qt::MoveAction); - event->accept(); - - if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) { - inPlace++; - if (inPlace == 25) - emit puzzleCompleted(); - } - } else { - highlightedRect = QRect(); - event->ignore(); - } -} - -int PuzzleWidget::findPiece(const QRect &pieceRect) const -{ - for (int i = 0; i < pieceRects.size(); ++i) { - if (pieceRect == pieceRects[i]) { - return i; - } - } - return -1; -} - -void PuzzleWidget::mousePressEvent(QMouseEvent *event) -{ - QRect square = targetSquare(event->pos()); - int found = findPiece(square); - - if (found == -1) - return; - - QPoint location = pieceLocations[found]; - QPixmap pixmap = piecePixmaps[found]; - pieceLocations.removeAt(found); - piecePixmaps.removeAt(found); - pieceRects.removeAt(found); - - if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) - inPlace--; - - update(square); - - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - - dataStream << pixmap << location; - - QMimeData *mimeData = new QMimeData; - mimeData->setData("image/x-puzzle-piece", itemData); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setHotSpot(event->pos() - square.topLeft()); - drag->setPixmap(pixmap); - - if (!(drag->exec(Qt::MoveAction) == Qt::MoveAction)) { - pieceLocations.insert(found, location); - piecePixmaps.insert(found, pixmap); - pieceRects.insert(found, square); - update(targetSquare(event->pos())); - - if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) - inPlace++; - } -} - -void PuzzleWidget::paintEvent(QPaintEvent *event) -{ - QPainter painter; - painter.begin(this); - painter.fillRect(event->rect(), Qt::white); - - if (highlightedRect.isValid()) { - painter.setBrush(QColor("#ffcccc")); - painter.setPen(Qt::NoPen); - painter.drawRect(highlightedRect.adjusted(0, 0, -1, -1)); - } - - for (int i = 0; i < pieceRects.size(); ++i) { - painter.drawPixmap(pieceRects[i], piecePixmaps[i]); - } - painter.end(); -} - -const QRect PuzzleWidget::targetSquare(const QPoint &position) const -{ - return QRect(position.x()/pieceSize() * pieceSize(), position.y()/pieceSize() * pieceSize(), pieceSize(), pieceSize()); -} - -int PuzzleWidget::pieceSize() const -{ - return m_ImageSize / 5; -} - -int PuzzleWidget::imageSize() const -{ - return m_ImageSize; -} diff --git a/examples/draganddrop/puzzle/puzzlewidget.h b/examples/draganddrop/puzzle/puzzlewidget.h deleted file mode 100644 index 1c0fc77a5f..0000000000 --- a/examples/draganddrop/puzzle/puzzlewidget.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PUZZLEWIDGET_H -#define PUZZLEWIDGET_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDropEvent; -class QMouseEvent; -QT_END_NAMESPACE - -class PuzzleWidget : public QWidget -{ - Q_OBJECT - -public: - PuzzleWidget(int imageSize, QWidget *parent = 0); - void clear(); - - int pieceSize() const; - int imageSize() const; - -signals: - void puzzleCompleted(); - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dropEvent(QDropEvent *event); - void mousePressEvent(QMouseEvent *event); - void paintEvent(QPaintEvent *event); - -private: - int findPiece(const QRect &pieceRect) const; - const QRect targetSquare(const QPoint &position) const; - - QList piecePixmaps; - QList pieceRects; - QList pieceLocations; - QRect highlightedRect; - int inPlace; - int m_ImageSize; -}; - -#endif diff --git a/examples/effects/blurpicker/blureffect.cpp b/examples/effects/blurpicker/blureffect.cpp deleted file mode 100644 index d9a757722b..0000000000 --- a/examples/effects/blurpicker/blureffect.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "blureffect.h" - -#include - -BlurEffect::BlurEffect(QGraphicsItem *item) - : QGraphicsBlurEffect() - , m_baseLine(200), item(item) -{ -} - -void BlurEffect::adjustForItem() -{ - qreal y = m_baseLine - item->pos().y(); - qreal radius = qBound(qreal(0.0), y / 32, qreal(16.0)); - setBlurRadius(radius); -} - -QRectF BlurEffect::boundingRect() const -{ - const_cast(this)->adjustForItem(); - return QGraphicsBlurEffect::boundingRect(); -} - -void BlurEffect::draw(QPainter *painter) -{ - adjustForItem(); - QGraphicsBlurEffect::draw(painter); -} diff --git a/examples/effects/blurpicker/blureffect.h b/examples/effects/blurpicker/blureffect.h deleted file mode 100644 index 6cef9df4b5..0000000000 --- a/examples/effects/blurpicker/blureffect.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 BLUREFFECT_H -#define BLUREFFECT_H - -#include -#include - -class BlurEffect: public QGraphicsBlurEffect -{ -public: - BlurEffect(QGraphicsItem *item); - - void setBaseLine(qreal y) { m_baseLine = y; } - - QRectF boundingRect() const; - - void draw(QPainter *painter); - -private: - void adjustForItem(); - -private: - qreal m_baseLine; - QGraphicsItem *item; -}; - -#endif // BLUREFFECT_H diff --git a/examples/effects/blurpicker/blurpicker.cpp b/examples/effects/blurpicker/blurpicker.cpp deleted file mode 100644 index ab56b241f8..0000000000 --- a/examples/effects/blurpicker/blurpicker.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "blurpicker.h" - -#include - -#include "blureffect.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0), m_animation(this, "index") -{ - setBackgroundBrush(QPixmap(":/images/background.jpg")); - setScene(new QGraphicsScene(this)); - - setupScene(); - setIndex(0); - - m_animation.setDuration(400); - m_animation.setEasingCurve(QEasingCurve::InOutSine); - - setRenderHint(QPainter::Antialiasing, true); - setFrameStyle(QFrame::NoFrame); -} - -qreal BlurPicker::index() const -{ - return m_index; -} - -void BlurPicker::setIndex(qreal index) -{ - m_index = index; - - qreal baseline = 0; - for (int i = 0; i < m_icons.count(); ++i) { - QGraphicsItem *icon = m_icons[i]; - qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count(); - qreal xs = 170 * sin(a); - qreal ys = 100 * cos(a); - QPointF pos(xs, ys); - pos = QTransform().rotate(-20).map(pos); - pos -= QPointF(40, 40); - icon->setPos(pos); - baseline = qMax(baseline, ys); - static_cast(icon->graphicsEffect())->setBaseLine(baseline); - } - - scene()->update(); -} - -void BlurPicker::setupScene() -{ - scene()->setSceneRect(-200, -120, 400, 240); - - QStringList names; - names << ":/images/accessories-calculator.png"; - names << ":/images/accessories-text-editor.png"; - names << ":/images/help-browser.png"; - names << ":/images/internet-group-chat.png"; - names << ":/images/internet-mail.png"; - names << ":/images/internet-web-browser.png"; - names << ":/images/office-calendar.png"; - names << ":/images/system-users.png"; - - for (int i = 0; i < names.count(); i++) { - QPixmap pixmap(names[i]); - QGraphicsPixmapItem *icon = scene()->addPixmap(pixmap); - icon->setZValue(1); - icon->setGraphicsEffect(new BlurEffect(icon)); - m_icons << icon; - } - - QGraphicsPixmapItem *bg = scene()->addPixmap(QPixmap(":/images/background.jpg")); - bg->setZValue(0); - bg->setPos(-200, -150); -} - -void BlurPicker::keyPressEvent(QKeyEvent *event) -{ - int delta = 0; - switch (event->key()) - { - case Qt::Key_Left: - delta = -1; - break; - case Qt::Key_Right: - delta = 1; - break; - default: - break; - } - if (m_animation.state() == QAbstractAnimation::Stopped && delta) { - m_animation.setEndValue(m_index + delta); - m_animation.start(); - event->accept(); - } -} - -void BlurPicker::resizeEvent(QResizeEvent */*event*/) -{ -} - -void BlurPicker::mousePressEvent(QMouseEvent *event) -{ - int delta = 0; - if(event->x() > (width() / 2)) - { - delta = 1; - } - else - { - delta = -1; - } - - if (m_animation.state() == QAbstractAnimation::Stopped && delta) { - m_animation.setEndValue(m_index + delta); - m_animation.start(); - event->accept(); - } -} diff --git a/examples/effects/blurpicker/blurpicker.desktop b/examples/effects/blurpicker/blurpicker.desktop deleted file mode 100644 index 0863ef7ba8..0000000000 --- a/examples/effects/blurpicker/blurpicker.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Blur Picker Effect -Exec=/opt/usr/bin/blurpicker -Icon=blurpicker -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/effects/blurpicker/blurpicker.h b/examples/effects/blurpicker/blurpicker.h deleted file mode 100644 index c0df0814d0..0000000000 --- a/examples/effects/blurpicker/blurpicker.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 BLURPICKER_H -#define BLURPICKER_H - -#include -#include -#include - -#include "blureffect.h" - -class BlurPicker: public QGraphicsView -{ - Q_OBJECT - Q_PROPERTY(qreal index READ index WRITE setIndex) - -public: - BlurPicker(QWidget *parent = 0); - - qreal index() const; - void setIndex(qreal); - -protected: - void keyPressEvent(QKeyEvent *event); - void resizeEvent(QResizeEvent *event); - void mousePressEvent(QMouseEvent *event); - -private: - void setupScene(); - -private: - qreal m_index; - QList m_icons; - QPropertyAnimation m_animation; -}; - -#endif // BLURPICKER_H diff --git a/examples/effects/blurpicker/blurpicker.pro b/examples/effects/blurpicker/blurpicker.pro deleted file mode 100644 index c477ea6e39..0000000000 --- a/examples/effects/blurpicker/blurpicker.pro +++ /dev/null @@ -1,11 +0,0 @@ -SOURCES += main.cpp blurpicker.cpp blureffect.cpp -HEADERS += blurpicker.h blureffect.h -RESOURCES += blurpicker.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/blurpicker -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS blurpicker.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/blurpicker -INSTALLS += target sources -QT += widgets - diff --git a/examples/effects/blurpicker/blurpicker.qrc b/examples/effects/blurpicker/blurpicker.qrc deleted file mode 100644 index e88eaca966..0000000000 --- a/examples/effects/blurpicker/blurpicker.qrc +++ /dev/null @@ -1,14 +0,0 @@ - - - images/background.jpg - images/accessories-calculator.png - images/accessories-text-editor.png - images/help-browser.png - images/internet-group-chat.png - images/internet-mail.png - images/internet-web-browser.png - images/office-calendar.png - images/system-users.png - - - diff --git a/examples/effects/blurpicker/images/README.txt b/examples/effects/blurpicker/images/README.txt deleted file mode 100644 index 0927e177d2..0000000000 --- a/examples/effects/blurpicker/images/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -The background is taken from a public domain photo at: -http://www.photos8.com/view/computer_board2-800x600.html - -All other icons are from the Tango Desktop project: -http://tango.freedesktop.org/Tango_Desktop_Project diff --git a/examples/effects/blurpicker/images/accessories-calculator.png b/examples/effects/blurpicker/images/accessories-calculator.png deleted file mode 100644 index 4e7661f65c..0000000000 Binary files a/examples/effects/blurpicker/images/accessories-calculator.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/accessories-text-editor.png b/examples/effects/blurpicker/images/accessories-text-editor.png deleted file mode 100644 index 33bef0bc17..0000000000 Binary files a/examples/effects/blurpicker/images/accessories-text-editor.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/background.jpg b/examples/effects/blurpicker/images/background.jpg deleted file mode 100644 index e75b38899d..0000000000 Binary files a/examples/effects/blurpicker/images/background.jpg and /dev/null differ diff --git a/examples/effects/blurpicker/images/help-browser.png b/examples/effects/blurpicker/images/help-browser.png deleted file mode 100644 index 8ef4fae91b..0000000000 Binary files a/examples/effects/blurpicker/images/help-browser.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/internet-group-chat.png b/examples/effects/blurpicker/images/internet-group-chat.png deleted file mode 100644 index dd92d93947..0000000000 Binary files a/examples/effects/blurpicker/images/internet-group-chat.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/internet-mail.png b/examples/effects/blurpicker/images/internet-mail.png deleted file mode 100644 index 7e6b93be83..0000000000 Binary files a/examples/effects/blurpicker/images/internet-mail.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/internet-web-browser.png b/examples/effects/blurpicker/images/internet-web-browser.png deleted file mode 100644 index a979a92b4f..0000000000 Binary files a/examples/effects/blurpicker/images/internet-web-browser.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/office-calendar.png b/examples/effects/blurpicker/images/office-calendar.png deleted file mode 100644 index e09590682b..0000000000 Binary files a/examples/effects/blurpicker/images/office-calendar.png and /dev/null differ diff --git a/examples/effects/blurpicker/images/system-users.png b/examples/effects/blurpicker/images/system-users.png deleted file mode 100644 index a7f630a5bd..0000000000 Binary files a/examples/effects/blurpicker/images/system-users.png and /dev/null differ diff --git a/examples/effects/blurpicker/main.cpp b/examples/effects/blurpicker/main.cpp deleted file mode 100644 index 662800596d..0000000000 --- a/examples/effects/blurpicker/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "blurpicker.h" -#include - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - BlurPicker blurPicker; - blurPicker.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Application Picker")); - - blurPicker.setFixedSize(400, 300); - blurPicker.show(); - - return app.exec(); -} diff --git a/examples/effects/effects.pro b/examples/effects/effects.pro deleted file mode 100644 index db7b8a723e..0000000000 --- a/examples/effects/effects.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = \ - subdirs -SUBDIRS = \ - blurpicker \ - lighting \ - fademessage - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS effects.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects -INSTALLS += target sources - -QT += widgets diff --git a/examples/effects/fademessage/README.txt b/examples/effects/fademessage/README.txt deleted file mode 100644 index f639e76508..0000000000 --- a/examples/effects/fademessage/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -The background is taken from a public domain photo at: -http://www.photos8.com/view/windows_problem_blue-800x600.html diff --git a/examples/effects/fademessage/background.jpg b/examples/effects/fademessage/background.jpg deleted file mode 100644 index 9884233a29..0000000000 Binary files a/examples/effects/fademessage/background.jpg and /dev/null differ diff --git a/examples/effects/fademessage/fademessage.cpp b/examples/effects/fademessage/fademessage.cpp deleted file mode 100644 index 0af0a57904..0000000000 --- a/examples/effects/fademessage/fademessage.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "fademessage.h" - -#include - -FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent) -{ - setScene(&m_scene); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - setupScene(); - - m_animation = new QPropertyAnimation(m_effect, "strength", this); - m_animation->setDuration(500); - m_animation->setEasingCurve(QEasingCurve::InOutSine); - m_animation->setStartValue(0); - m_animation->setEndValue(1); - - setRenderHint(QPainter::Antialiasing, true); - setFrameStyle(QFrame::NoFrame); -} - -void FadeMessage::togglePopup() -{ - if (m_message->isVisible()) { - m_message->setVisible(false); - m_animation->setDirection(QAbstractAnimation::Backward); - } else { - m_message->setVisible(true); - m_animation->setDirection(QAbstractAnimation::Forward); - } - m_animation->start(); -} - -void FadeMessage::setupScene() -{ - QGraphicsRectItem *parent = m_scene.addRect(0, 0, 800, 600); - parent->setPen(Qt::NoPen); - parent->setZValue(0); - - QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/background.jpg")); - bg->setParentItem(parent); - bg->setZValue(-1); - - for (int i = 1; i < 5; ++i) - for (int j = 2; j < 5; ++j) { - QGraphicsRectItem *item = m_scene.addRect(i * 50, (j - 1) * 50, 38, 38); - item->setParentItem(parent); - item->setZValue(1); - int hue = 12 * (i * 5 + j); - item->setBrush(QColor::fromHsv(hue, 128, 128)); - } - - QFont font; - font.setPointSize(font.pointSize() * 2); - font.setBold(true); - QFontMetrics fontMetrics(font); - int fh = fontMetrics.height(); - - QString sceneText = "Qt Everywhere!"; - int sceneTextWidth = fontMetrics.width(sceneText); - - QGraphicsRectItem *block = m_scene.addRect(50, 300, sceneTextWidth, fh + 3); - block->setPen(Qt::NoPen); - block->setBrush(QColor(102, 153, 51)); - - QGraphicsTextItem *text = m_scene.addText(sceneText, font); - text->setDefaultTextColor(Qt::white); - text->setPos(50, 300); - block->setZValue(2); - block->hide(); - - text->setParentItem(block); - m_message = block; - - m_effect = new QGraphicsColorizeEffect; - m_effect->setColor(QColor(122, 193, 66)); - m_effect->setStrength(0); - m_effect->setEnabled(true); - parent->setGraphicsEffect(m_effect); - - QPushButton *press = new QPushButton; - press->setText(tr("Press me")); - connect(press, SIGNAL(clicked()), SLOT(togglePopup())); - m_scene.addWidget(press); - - press->move(300, 500); -} diff --git a/examples/effects/fademessage/fademessage.desktop b/examples/effects/fademessage/fademessage.desktop deleted file mode 100644 index aa22ad7912..0000000000 --- a/examples/effects/fademessage/fademessage.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Fade Message Effect -Exec=/opt/usr/bin/fademessage -Icon=fademessage -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/effects/fademessage/fademessage.h b/examples/effects/fademessage/fademessage.h deleted file mode 100644 index 635f57a725..0000000000 --- a/examples/effects/fademessage/fademessage.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 FADEMESSAGE_H -#define FADEMESSAGE_H - -#include -#include -#include - -#include "fademessage.h" - -class FadeMessage: public QGraphicsView -{ - Q_OBJECT - -public: - FadeMessage(QWidget *parent = 0); - -private: - void setupScene(); - -private slots: - void togglePopup(); - -private: - QGraphicsScene m_scene; - QGraphicsColorizeEffect *m_effect; - QGraphicsItem *m_message; - QPropertyAnimation *m_animation; -}; - -#endif // FADEMESSAGE_H diff --git a/examples/effects/fademessage/fademessage.pro b/examples/effects/fademessage/fademessage.pro deleted file mode 100644 index 98161e0be4..0000000000 --- a/examples/effects/fademessage/fademessage.pro +++ /dev/null @@ -1,18 +0,0 @@ -SOURCES += main.cpp fademessage.cpp -HEADERS += fademessage.h -RESOURCES += fademessage.qrc -INSTALLS += target sources - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/fademessage -sources.files = $$SOURCES \ - $$HEADERS \ - $$RESOURCES \ - $$FORMS \ - fademessage.pro \ - background.jpg -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/fademessage - - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/effects/fademessage/fademessage.qrc b/examples/effects/fademessage/fademessage.qrc deleted file mode 100644 index 9efea6a67d..0000000000 --- a/examples/effects/fademessage/fademessage.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - background.jpg - - diff --git a/examples/effects/fademessage/main.cpp b/examples/effects/fademessage/main.cpp deleted file mode 100644 index d755ebeb7b..0000000000 --- a/examples/effects/fademessage/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "fademessage.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - FadeMessage widget; - widget.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Popup Message with Effect")); - widget.setFixedSize(400, 600); - widget.show(); - - return app.exec(); -} diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp deleted file mode 100644 index 713d0e0ec9..0000000000 --- a/examples/effects/lighting/lighting.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "lighting.h" - -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -Lighting::Lighting(QWidget *parent): QGraphicsView(parent), angle(0.0) -{ - setScene(&m_scene); - - setupScene(); - - QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), SLOT(animate())); - timer->setInterval(30); - timer->start(); - - setRenderHint(QPainter::Antialiasing, true); - setFrameStyle(QFrame::NoFrame); -} - -void Lighting::setupScene() -{ - m_scene.setSceneRect(-300, -200, 600, 460); - - QLinearGradient linearGrad(QPointF(-100, -100), QPointF(100, 100)); - linearGrad.setColorAt(0, QColor(255, 255, 255)); - linearGrad.setColorAt(1, QColor(192, 192, 255)); - setBackgroundBrush(linearGrad); - - QRadialGradient radialGrad(30, 30, 30); - radialGrad.setColorAt(0, Qt::yellow); - radialGrad.setColorAt(0.2, Qt::yellow); - radialGrad.setColorAt(1, Qt::transparent); - QPixmap pixmap(60, 60); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setPen(Qt::NoPen); - painter.setBrush(radialGrad); - painter.drawEllipse(0, 0, 60, 60); - painter.end(); - - m_lightSource = m_scene.addPixmap(pixmap); - m_lightSource->setZValue(2); - - for (int i = -2; i < 3; ++i) - for (int j = -2; j < 3; ++j) { - QAbstractGraphicsShapeItem *item; - if ((i + j) & 1) - item = new QGraphicsEllipseItem(0, 0, 50, 50); - else - item = new QGraphicsRectItem(0, 0, 50, 50); - - item->setPen(QPen(Qt::black, 1)); - item->setBrush(QBrush(Qt::white)); - QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; - effect->setBlurRadius(8); - item->setGraphicsEffect(effect); - item->setZValue(1); - item->setPos(i * 80, j * 80); - m_scene.addItem(item); - m_items << item; - } - - -} - -void Lighting::animate() -{ - angle += (M_PI / 30); - qreal xs = 200 * sin(angle) - 40 + 25; - qreal ys = 200 * cos(angle) - 40 + 25; - m_lightSource->setPos(xs, ys); - - for (int i = 0; i < m_items.size(); ++i) { - QGraphicsItem *item = m_items.at(i); - Q_ASSERT(item); - QGraphicsDropShadowEffect *effect = static_cast(item->graphicsEffect()); - Q_ASSERT(effect); - - QPointF delta(item->x() - xs, item->y() - ys); - effect->setOffset(delta.toPoint() / 30); - - qreal dx = delta.x(); - qreal dy = delta.y(); - qreal dd = sqrt(dx * dx + dy * dy); - QColor color = effect->color(); - color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); - effect->setColor(color); - } - - m_scene.update(); -} - -void Lighting::resizeEvent(QResizeEvent */*event*/) -{ -} diff --git a/examples/effects/lighting/lighting.desktop b/examples/effects/lighting/lighting.desktop deleted file mode 100644 index 806b3deca0..0000000000 --- a/examples/effects/lighting/lighting.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Lighting Effect -Exec=/opt/usr/bin/lighting -Icon=lighting -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/effects/lighting/lighting.h b/examples/effects/lighting/lighting.h deleted file mode 100644 index 2ed0d5ac12..0000000000 --- a/examples/effects/lighting/lighting.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 LIGHTING_H -#define LIGHTING_H - -#include -#include - -class Lighting: public QGraphicsView -{ - Q_OBJECT - -public: - Lighting(QWidget *parent = 0); - -private slots: - void animate(); - -private: - void setupScene(); - -protected: - void resizeEvent(QResizeEvent *event); - -private: - qreal angle; - QGraphicsScene m_scene; - QGraphicsItem *m_lightSource; - QList m_items; -}; - -#endif // LIGHTING_H diff --git a/examples/effects/lighting/lighting.pro b/examples/effects/lighting/lighting.pro deleted file mode 100644 index 16be936b26..0000000000 --- a/examples/effects/lighting/lighting.pro +++ /dev/null @@ -1,11 +0,0 @@ -SOURCES += main.cpp lighting.cpp -HEADERS += lighting.h - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/lighting -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS lighting.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/lighting -INSTALLS += target sources -QT += widgets - - diff --git a/examples/effects/lighting/main.cpp b/examples/effects/lighting/main.cpp deleted file mode 100644 index aedd9a24cb..0000000000 --- a/examples/effects/lighting/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "lighting.h" -#include - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - Lighting lighting; - lighting.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Lighting and Shadows")); - - lighting.resize(640, 480); - lighting.show(); - - return app.exec(); -} diff --git a/examples/examples.pro b/examples/examples.pro index 9cf603da47..29eda7dff5 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -3,43 +3,26 @@ CONFIG += no_docs_target SUBDIRS = \ network \ - statemachine \ threads \ xml \ qpa !contains(QT_CONFIG, no-widgets) { - SUBDIRS += \ - animation \ - desktop \ - dialogs \ - draganddrop \ - effects \ - graphicsview \ - ipc \ - layouts \ - linguist \ - mainwindows \ - painting \ - richtext \ - scroller \ - sql \ - tools \ - tutorials \ - touch \ - gestures - - !contains(QT_CONFIG, no-widgets) { - SUBDIRS += widgets \ - itemviews - } + SUBDIRS += widgets \ + ipc \ + linguist \ + sql \ + tools \ + tutorials \ + touch \ + gestures } + wince*|embedded|x11:!contains(QT_CONFIG, no-gui): SUBDIRS += embedded contains(QT_BUILD_PARTS, tools):!contains(QT_CONFIG, no-gui):!contains(QT_CONFIG, no-widgets):SUBDIRS += qtestlib contains(QT_CONFIG, opengl):!contains(QT_CONFIG, no-widgets):SUBDIRS += opengl contains(QT_CONFIG, dbus): SUBDIRS += dbus -contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows contains(QT_CONFIG, concurrent): SUBDIRS += qtconcurrent # install diff --git a/examples/graphicsview/README b/examples/graphicsview/README deleted file mode 100644 index e710fc3c13..0000000000 --- a/examples/graphicsview/README +++ /dev/null @@ -1,9 +0,0 @@ -Qt is provided with a comprehensive canvas through the GraphicsView -classes. - -These examples demonstrate the fundamental aspects of canvas programming -with Qt. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/graphicsview/anchorlayout/anchorlayout.desktop b/examples/graphicsview/anchorlayout/anchorlayout.desktop deleted file mode 100644 index 6cf53c3f9b..0000000000 --- a/examples/graphicsview/anchorlayout/anchorlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Anchor Layout -Exec=/opt/usr/bin/anchorlayout -Icon=anchorlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro deleted file mode 100644 index 7b18a621db..0000000000 --- a/examples/graphicsview/anchorlayout/anchorlayout.pro +++ /dev/null @@ -1,13 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/anchorlayout -sources.files = $$SOURCES $$HEADERS $$RESOURCES anchorlayout.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/anchorlayout -INSTALLS += target sources - -TARGET = anchorlayout -QT += widgets - - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp deleted file mode 100644 index 839aef2e39..0000000000 --- a/examples/graphicsview/anchorlayout/main.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0), - const QSizeF &preferred = QSize(150.0, 100.0), - const QSizeF &maximum = QSizeF(200.0, 100.0), - const QString &name = "0") -{ - QGraphicsProxyWidget *w = new QGraphicsProxyWidget; - w->setWidget(new QPushButton(name)); - w->setData(0, name); - w->setMinimumSize(minimum); - w->setPreferredSize(preferred); - w->setMaximumSize(maximum); - - w->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - return w; -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QGraphicsScene scene; - scene.setSceneRect(0, 0, 800, 480); - - QSizeF minSize(30, 100); - QSizeF prefSize(210, 100); - QSizeF maxSize(300, 100); - - QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, "A"); - QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, "B"); - QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C"); - QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D"); - QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E"); - QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)"); - QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)"); - - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; - l->setSpacing(0); - - QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window); - w->setPos(20, 20); - w->setLayout(l); - - // vertical - l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); - l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); - - l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); - l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); - l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); - l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); - - l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); - l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); - - l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); - l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); - l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); - l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); - - // horizontal - l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); - l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); - l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); - - l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); - l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); - - l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); - l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); - l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); - - l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); - l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); - l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); - - - scene.addItem(w); - scene.setBackgroundBrush(Qt::darkGreen); - QGraphicsView view(&scene); - - view.show(); - - return app.exec(); -} diff --git a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.desktop b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.desktop deleted file mode 100644 index be1c3e4a84..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Basic Graphics Layouts -Exec=/opt/usr/bin/basicgraphicslayouts -Icon=basicgraphicslayouts -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro deleted file mode 100644 index 202c8d87a0..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = layoutitem.h \ - window.h -SOURCES = layoutitem.cpp \ - main.cpp \ - window.cpp -RESOURCES = basicgraphicslayouts.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/basicgraphicslayouts -sources.files = $$SOURCES $$HEADERS $$RESOURCES basicgraphicslayouts.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/basicgraphicslayouts -INSTALLS += target sources - -QT += widgets diff --git a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.qrc b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.qrc deleted file mode 100644 index fbe2efa572..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/block.png - - diff --git a/examples/graphicsview/basicgraphicslayouts/images/block.png b/examples/graphicsview/basicgraphicslayouts/images/block.png deleted file mode 100644 index 4c72a3f508..0000000000 Binary files a/examples/graphicsview/basicgraphicslayouts/images/block.png and /dev/null differ diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp deleted file mode 100644 index 7067cddece..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "layoutitem.h" - -//! [0] -LayoutItem::LayoutItem(QGraphicsItem *parent/* = 0*/) - : QGraphicsLayoutItem(), QGraphicsItem(parent) -{ - m_pix = new QPixmap(QLatin1String(":/images/block.png")); - setGraphicsItem(this); -} -//! [0] - -LayoutItem::~LayoutItem() -{ - delete m_pix; -} - -//! [1] -void LayoutItem::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/) -{ - Q_UNUSED(widget); - Q_UNUSED(option); - - QRectF frame(QPointF(0,0), geometry().size()); - qreal w = m_pix->width(); - qreal h = m_pix->height(); - QGradientStops stops; -//! [1] - -//! [2] - // paint a background rect (with gradient) - QLinearGradient gradient(frame.topLeft(), frame.topLeft() + QPointF(200,200)); - stops << QGradientStop(0.0, QColor(60, 60, 60)); - stops << QGradientStop(frame.height()/2/frame.height(), QColor(102, 176, 54)); - - //stops << QGradientStop(((frame.height() + h)/2 )/frame.height(), QColor(157, 195, 55)); - stops << QGradientStop(1.0, QColor(215, 215, 215)); - gradient.setStops(stops); - painter->setBrush(QBrush(gradient)); - painter->drawRoundedRect(frame, 10.0, 10.0); - - // paint a rect around the pixmap (with gradient) - QPointF pixpos = frame.center() - (QPointF(w, h)/2); - QRectF innerFrame(pixpos, QSizeF(w, h)); - innerFrame.adjust(-4, -4, +4, +4); - gradient.setStart(innerFrame.topLeft()); - gradient.setFinalStop(innerFrame.bottomRight()); - stops.clear(); - stops << QGradientStop(0.0, QColor(215, 255, 200)); - stops << QGradientStop(0.5, QColor(102, 176, 54)); - stops << QGradientStop(1.0, QColor(0, 0, 0)); - gradient.setStops(stops); - painter->setBrush(QBrush(gradient)); - painter->drawRoundedRect(innerFrame, 10.0, 10.0); - painter->drawPixmap(pixpos, *m_pix); -} -//! [2] - -//! [3] -QRectF LayoutItem::boundingRect() const -{ - return QRectF(QPointF(0,0), geometry().size()); -} -//! [3] - -//! [4] -void LayoutItem::setGeometry(const QRectF &geom) -{ - prepareGeometryChange(); - QGraphicsLayoutItem::setGeometry(geom); - setPos(geom.topLeft()); -} -//! [4] - -//! [5] -QSizeF LayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - switch (which) { - case Qt::MinimumSize: - case Qt::PreferredSize: - // Do not allow a size smaller than the pixmap with two frames around it. - return m_pix->size() + QSize(12, 12); - case Qt::MaximumSize: - return QSizeF(1000,1000); - default: - break; - } - return constraint; -} -//! [5] diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.h b/examples/graphicsview/basicgraphicslayouts/layoutitem.h deleted file mode 100644 index 798c4650c6..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/layoutitem.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 LAYOUTITEM_H -#define LAYOUTITEM_H -#include - -//! [0] -class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem -{ -public: - LayoutItem(QGraphicsItem *parent = 0); - ~LayoutItem(); - // Inherited from QGraphicsLayoutItem - void setGeometry(const QRectF &geom); - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - - // Inherited from QGraphicsItem - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = 0); - -private: - QPixmap *m_pix; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/basicgraphicslayouts/main.cpp b/examples/graphicsview/basicgraphicslayouts/main.cpp deleted file mode 100644 index ef482235a9..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QGraphicsScene scene; - - Window *window = new Window; - scene.addItem(window); - QGraphicsView view(&scene); - view.resize(600, 600); - view.show(); - - return app.exec(); -} diff --git a/examples/graphicsview/basicgraphicslayouts/window.cpp b/examples/graphicsview/basicgraphicslayouts/window.cpp deleted file mode 100644 index e3786b61f1..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/window.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "window.h" -#include "layoutitem.h" - -Window::Window(QGraphicsWidget *parent) : QGraphicsWidget(parent, Qt::Window) -{ -//! [0] - QGraphicsLinearLayout *windowLayout = new QGraphicsLinearLayout(Qt::Vertical); - QGraphicsLinearLayout *linear = new QGraphicsLinearLayout(windowLayout); - LayoutItem *item = new LayoutItem; - linear->addItem(item); - linear->setStretchFactor(item, 1); -//! [0] - -//! [1] - item = new LayoutItem; - linear->addItem(item); - linear->setStretchFactor(item, 3); - windowLayout->addItem(linear); -//! [1] - -//! [2] - QGraphicsGridLayout *grid = new QGraphicsGridLayout(windowLayout); - item = new LayoutItem; - grid->addItem(item, 0, 0, 4, 1); - item = new LayoutItem; - item->setMaximumHeight(item->minimumHeight()); - grid->addItem(item, 0, 1, 2, 1, Qt::AlignVCenter); - item = new LayoutItem; - item->setMaximumHeight(item->minimumHeight()); - grid->addItem(item, 2, 1, 2, 1, Qt::AlignVCenter); - item = new LayoutItem; - grid->addItem(item, 0, 2); - item = new LayoutItem; - grid->addItem(item, 1, 2); - item = new LayoutItem; - grid->addItem(item, 2, 2); - item = new LayoutItem; - grid->addItem(item, 3, 2); - windowLayout->addItem(grid); -//! [2] - -//! [3] - setLayout(windowLayout); - setWindowTitle(tr("Basic Graphics Layouts Example")); -//! [3] - -} - - - diff --git a/examples/graphicsview/basicgraphicslayouts/window.h b/examples/graphicsview/basicgraphicslayouts/window.h deleted file mode 100644 index 5c1cc2ed4f..0000000000 --- a/examples/graphicsview/basicgraphicslayouts/window.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -//! [0] -class Window : public QGraphicsWidget { - Q_OBJECT - -public: - Window(QGraphicsWidget *parent = 0); - -}; -//! [0] - -#endif //WINDOW_H - diff --git a/examples/graphicsview/boxes/3rdparty/fbm.c b/examples/graphicsview/boxes/3rdparty/fbm.c deleted file mode 100644 index 98eb87a33b..0000000000 --- a/examples/graphicsview/boxes/3rdparty/fbm.c +++ /dev/null @@ -1,207 +0,0 @@ -/***************************************************************** - - Implementation of the fractional Brownian motion algorithm. These - functions were originally the work of F. Kenton Musgrave. - For documentation of the different functions please refer to the - book: - "Texturing and modeling: a procedural approach" - by David S. Ebert et. al. - -******************************************************************/ - -#if defined (_MSC_VER) -#include -#endif - -#include -#include -#include "fbm.h" - -#if defined(Q_CC_MSVC) -#pragma warning(disable:4244) -#endif - -/* Definitions used by the noise2() functions */ - -//#define B 0x100 -//#define BM 0xff -#define B 0x20 -#define BM 0x1f - -#define N 0x1000 -#define NP 12 /* 2^N */ -#define NM 0xfff - -static int p[B + B + 2]; -static float g3[B + B + 2][3]; -static float g2[B + B + 2][2]; -static float g1[B + B + 2]; -static int start = 1; - -static void init(void); - -#define s_curve(t) ( t * t * (3. - 2. * t) ) - -#define lerp(t, a, b) ( a + t * (b - a) ) - -#define setup(i,b0,b1,r0,r1)\ - t = vec[i] + N;\ - b0 = ((int)t) & BM;\ - b1 = (b0+1) & BM;\ - r0 = t - (int)t;\ - r1 = r0 - 1.; -#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] ) - -/* Fractional Brownian Motion function */ - -double fBm( Vector point, double H, double lacunarity, double octaves, - int init ) -{ - - double value, frequency, remainder; - int i; - static double exponent_array[10]; - float vec[3]; - - /* precompute and store spectral weights */ - if ( init ) { - start = 1; - srand( time(0) ); - /* seize required memory for exponent_array */ - frequency = 1.0; - for (i=0; i<=octaves; i++) { - /* compute weight for each frequency */ - exponent_array[i] = pow( frequency, -H ); - frequency *= lacunarity; - } - } - - value = 0.0; /* initialize vars to proper values */ - frequency = 1.0; - vec[0]=point.x; - vec[1]=point.y; - vec[2]=point.z; - - - /* inner loop of spectral construction */ - for (i=0; i - -#ifdef __cplusplus -extern "C" { -#endif - -//#define TRUE 1 -//#define FALSE 0 - -typedef struct { - double x; - double y; - double z; -} Vector; - -float noise3(float vec[]); -double fBm( Vector point, double H, double lacunarity, double octaves, - int init ); -#endif - -#ifdef __cplusplus -} -#endif - - - - diff --git a/examples/graphicsview/boxes/basic.fsh b/examples/graphicsview/boxes/basic.fsh deleted file mode 100644 index 917dbbaa0b..0000000000 --- a/examples/graphicsview/boxes/basic.fsh +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform vec4 basicColor; - -void main() -{ - vec3 N = normalize(normal); - // assume directional light - - gl_MaterialParameters M = gl_FrontMaterial; - - float NdotL = dot(N, lightDirection.xyz); - float RdotL = dot(reflect(normalize(position), N), lightDirection.xyz); - - vec3 absN = abs(gl_TexCoord[1].xyz); - vec3 texCoord; - if (absN.x > absN.y && absN.x > absN.z) - texCoord = gl_TexCoord[1].yzx; - else if (absN.y > absN.z) - texCoord = gl_TexCoord[1].zxy; - else - texCoord = gl_TexCoord[1].xyz; - texCoord.y *= -sign(texCoord.z); - texCoord += 0.5; - - vec4 texColor = texture2D(tex, texCoord.xy); - vec4 unlitColor = gl_Color * mix(basicColor, vec4(texColor.xyz, 1.0), texColor.w); - gl_FragColor = (ambient + diffuse * max(NdotL, 0.0)) * unlitColor + - M.specular * specular * pow(max(RdotL, 0.0), M.shininess); -} diff --git a/examples/graphicsview/boxes/basic.vsh b/examples/graphicsview/boxes/basic.vsh deleted file mode 100644 index db34a1a0d3..0000000000 --- a/examples/graphicsview/boxes/basic.vsh +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform mat4 view; - -void main() -{ - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_TexCoord[1] = gl_Vertex; - specular = gl_LightSource[0].specular; - ambient = gl_LightSource[0].ambient; - diffuse = gl_LightSource[0].diffuse; - lightDirection = view * gl_LightSource[0].position; - - normal = gl_NormalMatrix * gl_Normal; - position = (gl_ModelViewMatrix * gl_Vertex).xyz; - - gl_FrontColor = gl_Color; - gl_Position = ftransform(); -} diff --git a/examples/graphicsview/boxes/boxes.pro b/examples/graphicsview/boxes/boxes.pro deleted file mode 100644 index 0564ae0ba6..0000000000 --- a/examples/graphicsview/boxes/boxes.pro +++ /dev/null @@ -1,39 +0,0 @@ -QT += opengl widgets - -HEADERS += 3rdparty/fbm.h \ - glbuffers.h \ - glextensions.h \ - gltrianglemesh.h \ - qtbox.h \ - roundedbox.h \ - scene.h \ - trackball.h -SOURCES += 3rdparty/fbm.c \ - glbuffers.cpp \ - glextensions.cpp \ - main.cpp \ - qtbox.cpp \ - roundedbox.cpp \ - scene.cpp \ - trackball.cpp - -RESOURCES += boxes.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/boxes -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.jpg *.png *.fsh *.vsh *.par -sources.files -= 3rdparty/fbm.h 3rdparty/fbm.c -sources.files += 3rdparty -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/boxes -INSTALLS += target sources - -wince*: { - DEPLOYMENT_PLUGIN += qjpeg -} - -win32-msvc* { - QMAKE_CXXFLAGS -= -Zm200 - QMAKE_CFLAGS -= -Zm200 - QMAKE_CXXFLAGS += -Zm500 - QMAKE_CFLAGS += -Zm500 -} diff --git a/examples/graphicsview/boxes/boxes.qrc b/examples/graphicsview/boxes/boxes.qrc deleted file mode 100644 index d27506dc5a..0000000000 --- a/examples/graphicsview/boxes/boxes.qrc +++ /dev/null @@ -1,25 +0,0 @@ - - - cubemap_negx.jpg - cubemap_negy.jpg - cubemap_negz.jpg - cubemap_posx.jpg - cubemap_posy.jpg - cubemap_posz.jpg - square.jpg - basic.vsh - basic.fsh - dotted.fsh - fresnel.fsh - glass.fsh - granite.fsh - marble.fsh - reflection.fsh - refraction.fsh - wood.fsh - parameters.par - qt-logo.png - smiley.png - qt-logo.jpg - - diff --git a/examples/graphicsview/boxes/cubemap_negx.jpg b/examples/graphicsview/boxes/cubemap_negx.jpg deleted file mode 100644 index 07c282eab9..0000000000 Binary files a/examples/graphicsview/boxes/cubemap_negx.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/cubemap_negy.jpg b/examples/graphicsview/boxes/cubemap_negy.jpg deleted file mode 100644 index 46cd2f9cf3..0000000000 Binary files a/examples/graphicsview/boxes/cubemap_negy.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/cubemap_negz.jpg b/examples/graphicsview/boxes/cubemap_negz.jpg deleted file mode 100644 index 40c01ddff3..0000000000 Binary files a/examples/graphicsview/boxes/cubemap_negz.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/cubemap_posx.jpg b/examples/graphicsview/boxes/cubemap_posx.jpg deleted file mode 100644 index 0b42e8a1b1..0000000000 Binary files a/examples/graphicsview/boxes/cubemap_posx.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/cubemap_posy.jpg b/examples/graphicsview/boxes/cubemap_posy.jpg deleted file mode 100644 index 2aca9b1e98..0000000000 Binary files a/examples/graphicsview/boxes/cubemap_posy.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/cubemap_posz.jpg b/examples/graphicsview/boxes/cubemap_posz.jpg deleted file mode 100644 index 2e49173848..0000000000 Binary files a/examples/graphicsview/boxes/cubemap_posz.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/dotted.fsh b/examples/graphicsview/boxes/dotted.fsh deleted file mode 100644 index 2fe32b3b89..0000000000 --- a/examples/graphicsview/boxes/dotted.fsh +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; - -void main() -{ - vec3 N = normalize(normal); - - gl_MaterialParameters M = gl_FrontMaterial; - - // assume directional light - float NdotL = dot(N, lightDirection.xyz); - float RdotL = dot(reflect(normalize(position), N), lightDirection.xyz); - - float r1 = length(fract(7.0 * gl_TexCoord[1].xyz) - 0.5); - float r2 = length(fract(5.0 * gl_TexCoord[1].xyz + 0.2) - 0.5); - float r3 = length(fract(11.0 * gl_TexCoord[1].xyz + 0.7) - 0.5); - vec4 rs = vec4(r1, r2, r3, 0.0); - - vec4 unlitColor = gl_Color * (0.8 - clamp(10.0 * (0.4 - rs), 0.0, 0.2)); - unlitColor.w = 1.0; - gl_FragColor = (ambient + diffuse * max(NdotL, 0.0)) * unlitColor + - M.specular * specular * pow(max(RdotL, 0.0), M.shininess); -} diff --git a/examples/graphicsview/boxes/fresnel.fsh b/examples/graphicsview/boxes/fresnel.fsh deleted file mode 100644 index 8750dd9f20..0000000000 --- a/examples/graphicsview/boxes/fresnel.fsh +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform samplerCube env; -uniform mat4 view; -uniform vec4 basicColor; - -void main() -{ - vec3 N = normalize(normal); - // assume directional light - - gl_MaterialParameters M = gl_FrontMaterial; - - float NdotL = dot(N, lightDirection.xyz); - float RdotL = dot(reflect(normalize(position), N), lightDirection.xyz); - - vec3 absN = abs(gl_TexCoord[1].xyz); - vec3 texCoord; - if (absN.x > absN.y && absN.x > absN.z) - texCoord = gl_TexCoord[1].yzx; - else if (absN.y > absN.z) - texCoord = gl_TexCoord[1].zxy; - else - texCoord = gl_TexCoord[1].xyz; - texCoord.y *= -sign(texCoord.z); - texCoord += 0.5; - - vec4 texColor = texture2D(tex, texCoord.xy); - vec4 unlitColor = gl_Color * mix(basicColor, vec4(texColor.xyz, 1.0), texColor.w); - vec4 litColor = (ambient + diffuse * max(NdotL, 0.0)) * unlitColor + - M.specular * specular * pow(max(RdotL, 0.0), M.shininess); - - vec3 R = 2.0 * dot(-position, N) * N + position; - vec4 reflectedColor = textureCube(env, R * mat3(view[0].xyz, view[1].xyz, view[2].xyz)); - gl_FragColor = mix(litColor, reflectedColor, 0.2 + 0.8 * pow(1.0 + dot(N, normalize(position)), 2.0)); -} diff --git a/examples/graphicsview/boxes/glass.fsh b/examples/graphicsview/boxes/glass.fsh deleted file mode 100644 index d635b2cdc3..0000000000 --- a/examples/graphicsview/boxes/glass.fsh +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform samplerCube env; -uniform mat4 view; - -// Some arbitrary values -// Arrays don't work here on glsl < 120, apparently. -//const float coeffs[6] = float[6](1.0/4.0, 1.0/4.1, 1.0/4.2, 1.0/4.3, 1.0/4.4, 1.0/4.5); -float coeffs(int i) -{ - return 1.0 / (3.0 + 0.1 * float(i)); -} - -void main() -{ - vec3 N = normalize(normal); - vec3 I = -normalize(position); - mat3 V = mat3(view[0].xyz, view[1].xyz, view[2].xyz); - float IdotN = dot(I, N); - float scales[6]; - vec3 C[6]; - for (int i = 0; i < 6; ++i) { - scales[i] = (IdotN - sqrt(1.0 - coeffs(i) + coeffs(i) * (IdotN * IdotN))); - C[i] = textureCube(env, (-I + coeffs(i) * N) * V).xyz; - } - vec4 refractedColor = 0.25 * vec4(C[5].x + 2.0*C[0].x + C[1].x, C[1].y + 2.0*C[2].y + C[3].y, - C[3].z + 2.0*C[4].z + C[5].z, 4.0); - - vec3 R = 2.0 * dot(-position, N) * N + position; - vec4 reflectedColor = textureCube(env, R * V); - - gl_FragColor = mix(refractedColor, reflectedColor, 0.4 + 0.6 * pow(1.0 - IdotN, 2.0)); -} diff --git a/examples/graphicsview/boxes/glbuffers.cpp b/examples/graphicsview/boxes/glbuffers.cpp deleted file mode 100644 index e2aa2a4789..0000000000 --- a/examples/graphicsview/boxes/glbuffers.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "glbuffers.h" -#include - - -void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) -{ - const GLdouble ymax = zNear * tan(fovy * M_PI / 360.0); - const GLdouble ymin = -ymax; - const GLdouble xmin = ymin * aspect; - const GLdouble xmax = ymax * aspect; - glFrustum(xmin, xmax, ymin, ymax, zNear, zFar); -} - -//============================================================================// -// GLTexture // -//============================================================================// - -GLTexture::GLTexture() : m_texture(0), m_failed(false) -{ - glGenTextures(1, &m_texture); -} - -GLTexture::~GLTexture() -{ - glDeleteTextures(1, &m_texture); -} - -//============================================================================// -// GLTexture2D // -//============================================================================// - -GLTexture2D::GLTexture2D(int width, int height) -{ - glBindTexture(GL_TEXTURE_2D, m_texture); - glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, - GL_BGRA, GL_UNSIGNED_BYTE, 0); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - glBindTexture(GL_TEXTURE_2D, 0); -} - - -GLTexture2D::GLTexture2D(const QString& fileName, int width, int height) -{ - // TODO: Add error handling. - QImage image(fileName); - - if (image.isNull()) { - m_failed = true; - return; - } - - image = image.convertToFormat(QImage::Format_ARGB32); - - //qDebug() << "Image size:" << image.width() << "x" << image.height(); - if (width <= 0) - width = image.width(); - if (height <= 0) - height = image.height(); - if (width != image.width() || height != image.height()) - image = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - glBindTexture(GL_TEXTURE_2D, m_texture); - - // Works on x86, so probably works on all little-endian systems. - // Does it work on big-endian systems? - glTexImage2D(GL_TEXTURE_2D, 0, 4, image.width(), image.height(), 0, - GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - glBindTexture(GL_TEXTURE_2D, 0); -} - -void GLTexture2D::load(int width, int height, QRgb *data) -{ - glBindTexture(GL_TEXTURE_2D, m_texture); - glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, - GL_BGRA, GL_UNSIGNED_BYTE, data); - glBindTexture(GL_TEXTURE_2D, 0); -} - -void GLTexture2D::bind() -{ - glBindTexture(GL_TEXTURE_2D, m_texture); - glEnable(GL_TEXTURE_2D); -} - -void GLTexture2D::unbind() -{ - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); -} - - -//============================================================================// -// GLTexture3D // -//============================================================================// - -GLTexture3D::GLTexture3D(int width, int height, int depth) -{ - GLBUFFERS_ASSERT_OPENGL("GLTexture3D::GLTexture3D", glTexImage3D, return) - - glBindTexture(GL_TEXTURE_3D, m_texture); - glTexImage3D(GL_TEXTURE_3D, 0, 4, width, height, depth, 0, - GL_BGRA, GL_UNSIGNED_BYTE, 0); - - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - //glTexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP, GL_TRUE); - glBindTexture(GL_TEXTURE_3D, 0); -} - -void GLTexture3D::load(int width, int height, int depth, QRgb *data) -{ - GLBUFFERS_ASSERT_OPENGL("GLTexture3D::load", glTexImage3D, return) - - glBindTexture(GL_TEXTURE_3D, m_texture); - glTexImage3D(GL_TEXTURE_3D, 0, 4, width, height, depth, 0, - GL_BGRA, GL_UNSIGNED_BYTE, data); - glBindTexture(GL_TEXTURE_3D, 0); -} - -void GLTexture3D::bind() -{ - glBindTexture(GL_TEXTURE_3D, m_texture); - glEnable(GL_TEXTURE_3D); -} - -void GLTexture3D::unbind() -{ - glBindTexture(GL_TEXTURE_3D, 0); - glDisable(GL_TEXTURE_3D); -} - -//============================================================================// -// GLTextureCube // -//============================================================================// - -GLTextureCube::GLTextureCube(int size) -{ - glBindTexture(GL_TEXTURE_CUBE_MAP, m_texture); - - for (int i = 0; i < 6; ++i) - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 4, size, size, 0, - GL_BGRA, GL_UNSIGNED_BYTE, 0); - - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - //glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP, GL_TRUE); - glBindTexture(GL_TEXTURE_CUBE_MAP, 0); -} - -GLTextureCube::GLTextureCube(const QStringList& fileNames, int size) -{ - // TODO: Add error handling. - - glBindTexture(GL_TEXTURE_CUBE_MAP, m_texture); - - int index = 0; - foreach (QString file, fileNames) { - QImage image(file); - if (image.isNull()) { - m_failed = true; - break; - } - - image = image.convertToFormat(QImage::Format_ARGB32); - - //qDebug() << "Image size:" << image.width() << "x" << image.height(); - if (size <= 0) - size = image.width(); - if (size != image.width() || size != image.height()) - image = image.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - // Works on x86, so probably works on all little-endian systems. - // Does it work on big-endian systems? - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + index, 0, 4, image.width(), image.height(), 0, - GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); - - if (++index == 6) - break; - } - - // Clear remaining faces. - while (index < 6) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + index, 0, 4, size, size, 0, - GL_BGRA, GL_UNSIGNED_BYTE, 0); - ++index; - } - - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - //glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP, GL_TRUE); - glBindTexture(GL_TEXTURE_CUBE_MAP, 0); -} - -void GLTextureCube::load(int size, int face, QRgb *data) -{ - glBindTexture(GL_TEXTURE_CUBE_MAP, m_texture); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, 4, size, size, 0, - GL_BGRA, GL_UNSIGNED_BYTE, data); - glBindTexture(GL_TEXTURE_CUBE_MAP, 0); -} - -void GLTextureCube::bind() -{ - glBindTexture(GL_TEXTURE_CUBE_MAP, m_texture); - glEnable(GL_TEXTURE_CUBE_MAP); -} - -void GLTextureCube::unbind() -{ - glBindTexture(GL_TEXTURE_CUBE_MAP, 0); - glDisable(GL_TEXTURE_CUBE_MAP); -} - -//============================================================================// -// GLFrameBufferObject // -//============================================================================// - -GLFrameBufferObject::GLFrameBufferObject(int width, int height) - : m_fbo(0) - , m_depthBuffer(0) - , m_width(width) - , m_height(height) - , m_failed(false) -{ - GLBUFFERS_ASSERT_OPENGL("GLFrameBufferObject::GLFrameBufferObject", - glGenFramebuffersEXT && glGenRenderbuffersEXT && glBindRenderbufferEXT && glRenderbufferStorageEXT, return) - - // TODO: share depth buffers of same size - glGenFramebuffersEXT(1, &m_fbo); - //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); - glGenRenderbuffersEXT(1, &m_depthBuffer); - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, m_width, m_height); - //glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer); - //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -} - -GLFrameBufferObject::~GLFrameBufferObject() -{ - GLBUFFERS_ASSERT_OPENGL("GLFrameBufferObject::~GLFrameBufferObject", - glDeleteFramebuffersEXT && glDeleteRenderbuffersEXT, return) - - glDeleteFramebuffersEXT(1, &m_fbo); - glDeleteRenderbuffersEXT(1, &m_depthBuffer); -} - -void GLFrameBufferObject::setAsRenderTarget(bool state) -{ - GLBUFFERS_ASSERT_OPENGL("GLFrameBufferObject::setAsRenderTarget", glBindFramebufferEXT, return) - - if (state) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); - glPushAttrib(GL_VIEWPORT_BIT); - glViewport(0, 0, m_width, m_height); - } else { - glPopAttrib(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } -} - -bool GLFrameBufferObject::isComplete() -{ - GLBUFFERS_ASSERT_OPENGL("GLFrameBufferObject::isComplete", glCheckFramebufferStatusEXT, return false) - - return GL_FRAMEBUFFER_COMPLETE_EXT == glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); -} - -//============================================================================// -// GLRenderTargetCube // -//============================================================================// - -GLRenderTargetCube::GLRenderTargetCube(int size) - : GLTextureCube(size) - , m_fbo(size, size) -{ -} - -void GLRenderTargetCube::begin(int face) -{ - GLBUFFERS_ASSERT_OPENGL("GLRenderTargetCube::begin", - glFramebufferTexture2DEXT && glFramebufferRenderbufferEXT, return) - - m_fbo.setAsRenderTarget(true); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, m_texture, 0); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_fbo.m_depthBuffer); -} - -void GLRenderTargetCube::end() -{ - m_fbo.setAsRenderTarget(false); -} - -void GLRenderTargetCube::getViewMatrix(QMatrix4x4& mat, int face) -{ - if (face < 0 || face >= 6) { - qWarning("GLRenderTargetCube::getViewMatrix: 'face' must be in the range [0, 6). (face == %d)", face); - return; - } - - static int perm[6][3] = { - {2, 1, 0}, - {2, 1, 0}, - {0, 2, 1}, - {0, 2, 1}, - {0, 1, 2}, - {0, 1, 2}, - }; - - static float signs[6][3] = { - {-1.0f, -1.0f, -1.0f}, - {+1.0f, -1.0f, +1.0f}, - {+1.0f, +1.0f, -1.0f}, - {+1.0f, -1.0f, +1.0f}, - {+1.0f, -1.0f, -1.0f}, - {-1.0f, -1.0f, +1.0f}, - }; - - mat.fill(0.0f); - for (int i = 0; i < 3; ++i) - mat(i, perm[face][i]) = signs[face][i]; - mat(3, 3) = 1.0f; -} - -void GLRenderTargetCube::getProjectionMatrix(QMatrix4x4& mat, float nearZ, float farZ) -{ - static const QMatrix4x4 reference( - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, -1.0f, 0.0f); - - mat = reference; - mat(2, 2) = (nearZ+farZ)/(nearZ-farZ); - mat(2, 3) = 2.0f*nearZ*farZ/(nearZ-farZ); -} diff --git a/examples/graphicsview/boxes/glbuffers.h b/examples/graphicsview/boxes/glbuffers.h deleted file mode 100644 index 2b91915e8e..0000000000 --- a/examples/graphicsview/boxes/glbuffers.h +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GLBUFFERS_H -#define GLBUFFERS_H - -//#include -#include "glextensions.h" - -#include -#include - -#define BUFFER_OFFSET(i) ((char*)0 + (i)) -#define SIZE_OF_MEMBER(cls, member) sizeof(static_cast(0)->member) - -#define GLBUFFERS_ASSERT_OPENGL(prefix, assertion, returnStatement) \ -if (m_failed || !(assertion)) { \ - if (!m_failed) qCritical(prefix ": The necessary OpenGL functions are not available."); \ - m_failed = true; \ - returnStatement; \ -} - -void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); - -QT_BEGIN_NAMESPACE -class QMatrix4x4; -QT_END_NAMESPACE - -class GLTexture -{ -public: - GLTexture(); - virtual ~GLTexture(); - virtual void bind() = 0; - virtual void unbind() = 0; - virtual bool failed() const {return m_failed;} -protected: - GLuint m_texture; - bool m_failed; -}; - -class GLFrameBufferObject -{ -public: - friend class GLRenderTargetCube; - // friend class GLRenderTarget2D; - - GLFrameBufferObject(int width, int height); - virtual ~GLFrameBufferObject(); - bool isComplete(); - virtual bool failed() const {return m_failed;} -protected: - void setAsRenderTarget(bool state = true); - GLuint m_fbo; - GLuint m_depthBuffer; - int m_width, m_height; - bool m_failed; -}; - -class GLTexture2D : public GLTexture -{ -public: - GLTexture2D(int width, int height); - GLTexture2D(const QString& fileName, int width = 0, int height = 0); - void load(int width, int height, QRgb *data); - virtual void bind(); - virtual void unbind(); -}; - -class GLTexture3D : public GLTexture -{ -public: - GLTexture3D(int width, int height, int depth); - // TODO: Implement function below - //GLTexture3D(const QString& fileName, int width = 0, int height = 0); - void load(int width, int height, int depth, QRgb *data); - virtual void bind(); - virtual void unbind(); -}; - -class GLTextureCube : public GLTexture -{ -public: - GLTextureCube(int size); - GLTextureCube(const QStringList& fileNames, int size = 0); - void load(int size, int face, QRgb *data); - virtual void bind(); - virtual void unbind(); -}; - -// TODO: Define and implement class below -//class GLRenderTarget2D : public GLTexture2D - -class GLRenderTargetCube : public GLTextureCube -{ -public: - GLRenderTargetCube(int size); - // begin rendering to one of the cube's faces. 0 <= face < 6 - void begin(int face); - // end rendering - void end(); - virtual bool failed() const {return m_failed || m_fbo.failed();} - - static void getViewMatrix(QMatrix4x4& mat, int face); - static void getProjectionMatrix(QMatrix4x4& mat, float nearZ, float farZ); -private: - GLFrameBufferObject m_fbo; -}; - -struct VertexDescription -{ - enum - { - Null = 0, // Terminates a VertexDescription array - Position, - TexCoord, - Normal, - Color, - }; - int field; // Position, TexCoord, Normal, Color - int type; // GL_FLOAT, GL_UNSIGNED_BYTE - int count; // number of elements - int offset; // field's offset into vertex struct - int index; // 0 (unused at the moment) -}; - -// Implementation of interleaved buffers. -// 'T' is a struct which must include a null-terminated static array -// 'VertexDescription* description'. -// Example: -/* -struct Vertex -{ - GLfloat position[3]; - GLfloat texCoord[2]; - GLfloat normal[3]; - GLbyte color[4]; - static VertexDescription description[]; -}; - -VertexDescription Vertex::description[] = { - {VertexDescription::Position, GL_FLOAT, SIZE_OF_MEMBER(Vertex, position) / sizeof(GLfloat), offsetof(Vertex, position), 0}, - {VertexDescription::TexCoord, GL_FLOAT, SIZE_OF_MEMBER(Vertex, texCoord) / sizeof(GLfloat), offsetof(Vertex, texCoord), 0}, - {VertexDescription::Normal, GL_FLOAT, SIZE_OF_MEMBER(Vertex, normal) / sizeof(GLfloat), offsetof(Vertex, normal), 0}, - {VertexDescription::Color, GL_BYTE, SIZE_OF_MEMBER(Vertex, color) / sizeof(GLbyte), offsetof(Vertex, color), 0}, - {VertexDescription::Null, 0, 0, 0, 0}, -}; -*/ -template -class GLVertexBuffer -{ -public: - GLVertexBuffer(int length, const T *data = 0, int mode = GL_STATIC_DRAW) - : m_length(0) - , m_mode(mode) - , m_buffer(0) - , m_failed(false) - { - GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::GLVertexBuffer", glGenBuffers && glBindBuffer && glBufferData, return) - - glGenBuffers(1, &m_buffer); - glBindBuffer(GL_ARRAY_BUFFER, m_buffer); - glBufferData(GL_ARRAY_BUFFER, (m_length = length) * sizeof(T), data, mode); - } - - ~GLVertexBuffer() - { - GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::~GLVertexBuffer", glDeleteBuffers, return) - - glDeleteBuffers(1, &m_buffer); - } - - void bind() - { - GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::bind", glBindBuffer, return) - - glBindBuffer(GL_ARRAY_BUFFER, m_buffer); - for (VertexDescription *desc = T::description; desc->field != VertexDescription::Null; ++desc) { - switch (desc->field) { - case VertexDescription::Position: - glVertexPointer(desc->count, desc->type, sizeof(T), BUFFER_OFFSET(desc->offset)); - glEnableClientState(GL_VERTEX_ARRAY); - break; - case VertexDescription::TexCoord: - glTexCoordPointer(desc->count, desc->type, sizeof(T), BUFFER_OFFSET(desc->offset)); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - break; - case VertexDescription::Normal: - glNormalPointer(desc->type, sizeof(T), BUFFER_OFFSET(desc->offset)); - glEnableClientState(GL_NORMAL_ARRAY); - break; - case VertexDescription::Color: - glColorPointer(desc->count, desc->type, sizeof(T), BUFFER_OFFSET(desc->offset)); - glEnableClientState(GL_COLOR_ARRAY); - break; - default: - break; - } - } - } - - void unbind() - { - GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::unbind", glBindBuffer, return) - - glBindBuffer(GL_ARRAY_BUFFER, 0); - for (VertexDescription *desc = T::description; desc->field != VertexDescription::Null; ++desc) { - switch (desc->field) { - case VertexDescription::Position: - glDisableClientState(GL_VERTEX_ARRAY); - break; - case VertexDescription::TexCoord: - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - break; - case VertexDescription::Normal: - glDisableClientState(GL_NORMAL_ARRAY); - break; - case VertexDescription::Color: - glDisableClientState(GL_COLOR_ARRAY); - break; - default: - break; - } - } - } - - int length() const {return m_length;} - - T *lock() - { - GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::lock", glBindBuffer && glMapBuffer, return 0) - - glBindBuffer(GL_ARRAY_BUFFER, m_buffer); - //glBufferData(GL_ARRAY_BUFFER, m_length, NULL, m_mode); - GLvoid* buffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - m_failed = (buffer == 0); - return reinterpret_cast(buffer); - } - - void unlock() - { - GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::unlock", glBindBuffer && glUnmapBuffer, return) - - glBindBuffer(GL_ARRAY_BUFFER, m_buffer); - glUnmapBuffer(GL_ARRAY_BUFFER); - } - - bool failed() - { - return m_failed; - } - -private: - int m_length, m_mode; - GLuint m_buffer; - bool m_failed; -}; - -template -class GLIndexBuffer -{ -public: - GLIndexBuffer(int length, const T *data = 0, int mode = GL_STATIC_DRAW) - : m_length(0) - , m_mode(mode) - , m_buffer(0) - , m_failed(false) - { - GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::GLIndexBuffer", glGenBuffers && glBindBuffer && glBufferData, return) - - glGenBuffers(1, &m_buffer); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, (m_length = length) * sizeof(T), data, mode); - } - - ~GLIndexBuffer() - { - GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::~GLIndexBuffer", glDeleteBuffers, return) - - glDeleteBuffers(1, &m_buffer); - } - - void bind() - { - GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::bind", glBindBuffer, return) - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); - } - - void unbind() - { - GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::unbind", glBindBuffer, return) - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - - int length() const {return m_length;} - - T *lock() - { - GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::lock", glBindBuffer && glMapBuffer, return 0) - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); - GLvoid* buffer = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_WRITE); - m_failed = (buffer == 0); - return reinterpret_cast(buffer); - } - - void unlock() - { - GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::unlock", glBindBuffer && glUnmapBuffer, return) - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); - } - - bool failed() - { - return m_failed; - } - -private: - int m_length, m_mode; - GLuint m_buffer; - bool m_failed; -}; - -#endif diff --git a/examples/graphicsview/boxes/glextensions.cpp b/examples/graphicsview/boxes/glextensions.cpp deleted file mode 100644 index ada8f457f6..0000000000 --- a/examples/graphicsview/boxes/glextensions.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "glextensions.h" - -#define RESOLVE_GL_FUNC(f) ok &= bool((f = (_gl##f) context->getProcAddress(QLatin1String("gl" #f)))); - -bool GLExtensionFunctions::resolve(const QGLContext *context) -{ - bool ok = true; - - RESOLVE_GL_FUNC(GenFramebuffersEXT) - RESOLVE_GL_FUNC(GenRenderbuffersEXT) - RESOLVE_GL_FUNC(BindRenderbufferEXT) - RESOLVE_GL_FUNC(RenderbufferStorageEXT) - RESOLVE_GL_FUNC(DeleteFramebuffersEXT) - RESOLVE_GL_FUNC(DeleteRenderbuffersEXT) - RESOLVE_GL_FUNC(BindFramebufferEXT) - RESOLVE_GL_FUNC(FramebufferTexture2DEXT) - RESOLVE_GL_FUNC(FramebufferRenderbufferEXT) - RESOLVE_GL_FUNC(CheckFramebufferStatusEXT) - - RESOLVE_GL_FUNC(ActiveTexture) - RESOLVE_GL_FUNC(TexImage3D) - - RESOLVE_GL_FUNC(GenBuffers) - RESOLVE_GL_FUNC(BindBuffer) - RESOLVE_GL_FUNC(BufferData) - RESOLVE_GL_FUNC(DeleteBuffers) - RESOLVE_GL_FUNC(MapBuffer) - RESOLVE_GL_FUNC(UnmapBuffer) - - return ok; -} - -bool GLExtensionFunctions::fboSupported() { - return GenFramebuffersEXT - && GenRenderbuffersEXT - && BindRenderbufferEXT - && RenderbufferStorageEXT - && DeleteFramebuffersEXT - && DeleteRenderbuffersEXT - && BindFramebufferEXT - && FramebufferTexture2DEXT - && FramebufferRenderbufferEXT - && CheckFramebufferStatusEXT; -} - -bool GLExtensionFunctions::openGL15Supported() { - return ActiveTexture - && TexImage3D - && GenBuffers - && BindBuffer - && BufferData - && DeleteBuffers - && MapBuffer - && UnmapBuffer; -} - -#undef RESOLVE_GL_FUNC diff --git a/examples/graphicsview/boxes/glextensions.h b/examples/graphicsview/boxes/glextensions.h deleted file mode 100644 index 35dd9a047c..0000000000 --- a/examples/graphicsview/boxes/glextensions.h +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GLEXTENSIONS_H -#define GLEXTENSIONS_H - -#include - -/* -Functions resolved: - -glGenFramebuffersEXT -glGenRenderbuffersEXT -glBindRenderbufferEXT -glRenderbufferStorageEXT -glDeleteFramebuffersEXT -glDeleteRenderbuffersEXT -glBindFramebufferEXT -glFramebufferTexture2DEXT -glFramebufferRenderbufferEXT -glCheckFramebufferStatusEXT - -glActiveTexture -glTexImage3D - -glGenBuffers -glBindBuffer -glBufferData -glDeleteBuffers -glMapBuffer -glUnmapBuffer -*/ - -#ifndef Q_OS_MAC -# ifndef APIENTRYP -# ifdef APIENTRY -# define APIENTRYP APIENTRY * -# else -# define APIENTRY -# define APIENTRYP * -# endif -# endif -#else -# define APIENTRY -# define APIENTRYP * -#endif - -#ifndef GL_VERSION_1_2 -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_BGRA 0x80E1 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -//#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -//#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#endif - -#ifndef GL_ARB_vertex_buffer_object -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_VERSION_1_5 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_READ_WRITE 0x88BA -#define GL_STATIC_DRAW 0x88E4 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#endif - -typedef void (APIENTRY *_glGenFramebuffersEXT) (GLsizei, GLuint *); -typedef void (APIENTRY *_glGenRenderbuffersEXT) (GLsizei, GLuint *); -typedef void (APIENTRY *_glBindRenderbufferEXT) (GLenum, GLuint); -typedef void (APIENTRY *_glRenderbufferStorageEXT) (GLenum, GLenum, GLsizei, GLsizei); -typedef void (APIENTRY *_glDeleteFramebuffersEXT) (GLsizei, const GLuint*); -typedef void (APIENTRY *_glDeleteRenderbuffersEXT) (GLsizei, const GLuint*); -typedef void (APIENTRY *_glBindFramebufferEXT) (GLenum, GLuint); -typedef void (APIENTRY *_glFramebufferTexture2DEXT) (GLenum, GLenum, GLenum, GLuint, GLint); -typedef void (APIENTRY *_glFramebufferRenderbufferEXT) (GLenum, GLenum, GLenum, GLuint); -typedef GLenum (APIENTRY *_glCheckFramebufferStatusEXT) (GLenum); - -typedef void (APIENTRY *_glActiveTexture) (GLenum); -typedef void (APIENTRY *_glTexImage3D) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); - -typedef void (APIENTRY *_glGenBuffers) (GLsizei, GLuint *); -typedef void (APIENTRY *_glBindBuffer) (GLenum, GLuint); -typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -typedef void (APIENTRY *_glDeleteBuffers) (GLsizei, const GLuint *); -typedef void *(APIENTRY *_glMapBuffer) (GLenum, GLenum); -typedef GLboolean (APIENTRY *_glUnmapBuffer) (GLenum); - -struct GLExtensionFunctions -{ - bool resolve(const QGLContext *context); - - bool fboSupported(); - bool openGL15Supported(); // the rest: multi-texture, 3D-texture, vertex buffer objects - - _glGenFramebuffersEXT GenFramebuffersEXT; - _glGenRenderbuffersEXT GenRenderbuffersEXT; - _glBindRenderbufferEXT BindRenderbufferEXT; - _glRenderbufferStorageEXT RenderbufferStorageEXT; - _glDeleteFramebuffersEXT DeleteFramebuffersEXT; - _glDeleteRenderbuffersEXT DeleteRenderbuffersEXT; - _glBindFramebufferEXT BindFramebufferEXT; - _glFramebufferTexture2DEXT FramebufferTexture2DEXT; - _glFramebufferRenderbufferEXT FramebufferRenderbufferEXT; - _glCheckFramebufferStatusEXT CheckFramebufferStatusEXT; - - _glActiveTexture ActiveTexture; - _glTexImage3D TexImage3D; - - _glGenBuffers GenBuffers; - _glBindBuffer BindBuffer; - _glBufferData BufferData; - _glDeleteBuffers DeleteBuffers; - _glMapBuffer MapBuffer; - _glUnmapBuffer UnmapBuffer; -}; - -inline GLExtensionFunctions &getGLExtensionFunctions() -{ - static GLExtensionFunctions funcs; - return funcs; -} - -#define glGenFramebuffersEXT getGLExtensionFunctions().GenFramebuffersEXT -#define glGenRenderbuffersEXT getGLExtensionFunctions().GenRenderbuffersEXT -#define glBindRenderbufferEXT getGLExtensionFunctions().BindRenderbufferEXT -#define glRenderbufferStorageEXT getGLExtensionFunctions().RenderbufferStorageEXT -#define glDeleteFramebuffersEXT getGLExtensionFunctions().DeleteFramebuffersEXT -#define glDeleteRenderbuffersEXT getGLExtensionFunctions().DeleteRenderbuffersEXT -#define glBindFramebufferEXT getGLExtensionFunctions().BindFramebufferEXT -#define glFramebufferTexture2DEXT getGLExtensionFunctions().FramebufferTexture2DEXT -#define glFramebufferRenderbufferEXT getGLExtensionFunctions().FramebufferRenderbufferEXT -#define glCheckFramebufferStatusEXT getGLExtensionFunctions().CheckFramebufferStatusEXT - -#define glActiveTexture getGLExtensionFunctions().ActiveTexture -#define glTexImage3D getGLExtensionFunctions().TexImage3D - -#define glGenBuffers getGLExtensionFunctions().GenBuffers -#define glBindBuffer getGLExtensionFunctions().BindBuffer -#define glBufferData getGLExtensionFunctions().BufferData -#define glDeleteBuffers getGLExtensionFunctions().DeleteBuffers -#define glMapBuffer getGLExtensionFunctions().MapBuffer -#define glUnmapBuffer getGLExtensionFunctions().UnmapBuffer - -#endif diff --git a/examples/graphicsview/boxes/gltrianglemesh.h b/examples/graphicsview/boxes/gltrianglemesh.h deleted file mode 100644 index 2c9ab01c3f..0000000000 --- a/examples/graphicsview/boxes/gltrianglemesh.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GLTRIANGLEMESH_H -#define GLTRIANGLEMESH_H - -//#include -#include "glextensions.h" - -#include -#include - -#include "glbuffers.h" - -template -class GLTriangleMesh -{ -public: - GLTriangleMesh(int vertexCount, int indexCount) : m_vb(vertexCount), m_ib(indexCount) - { - } - - virtual ~GLTriangleMesh() - { - } - - virtual void draw() - { - if (failed()) - return; - - int type = GL_UNSIGNED_INT; - if (sizeof(TIndex) == sizeof(char)) type = GL_UNSIGNED_BYTE; - if (sizeof(TIndex) == sizeof(short)) type = GL_UNSIGNED_SHORT; - - m_vb.bind(); - m_ib.bind(); - glDrawElements(GL_TRIANGLES, m_ib.length(), type, BUFFER_OFFSET(0)); - m_vb.unbind(); - m_ib.unbind(); - } - - bool failed() - { - return m_vb.failed() || m_ib.failed(); - } -protected: - GLVertexBuffer m_vb; - GLIndexBuffer m_ib; -}; - - -#endif diff --git a/examples/graphicsview/boxes/granite.fsh b/examples/graphicsview/boxes/granite.fsh deleted file mode 100644 index 175420f351..0000000000 --- a/examples/graphicsview/boxes/granite.fsh +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform sampler3D noise; - -//const vec4 graniteColors[3] = {vec4(0.0, 0.0, 0.0, 1), vec4(0.30, 0.15, 0.10, 1), vec4(0.80, 0.70, 0.75, 1)}; -uniform vec4 graniteColors[3]; - -float steep(float x) -{ - return clamp(5.0 * x - 2.0, 0.0, 1.0); -} - -void main() -{ - vec2 turbulence = vec2(0, 0); - float scale = 1.0; - for (int i = 0; i < 4; ++i) { - turbulence += scale * (texture3D(noise, gl_TexCoord[1].xyz / scale).xy - 0.5); - scale *= 0.5; - } - - vec3 N = normalize(normal); - // assume directional light - - gl_MaterialParameters M = gl_FrontMaterial; - - float NdotL = dot(N, lightDirection.xyz); - float RdotL = dot(reflect(normalize(position), N), lightDirection.xyz); - - vec4 unlitColor = mix(graniteColors[1], mix(graniteColors[0], graniteColors[2], steep(0.5 + turbulence.y)), 4.0 * abs(turbulence.x)); - gl_FragColor = (ambient + diffuse * max(NdotL, 0.0)) * unlitColor + - M.specular * specular * pow(max(RdotL, 0.0), M.shininess); -} diff --git a/examples/graphicsview/boxes/main.cpp b/examples/graphicsview/boxes/main.cpp deleted file mode 100644 index 2baa539d3a..0000000000 --- a/examples/graphicsview/boxes/main.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//#include -#include "glextensions.h" - -#include "scene.h" - -#include -#include - -class GraphicsView : public QGraphicsView -{ -public: - GraphicsView() - { - setWindowTitle(tr("Boxes")); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - //setRenderHints(QPainter::SmoothPixmapTransform); - } - -protected: - void resizeEvent(QResizeEvent *event) { - if (scene()) - scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); - QGraphicsView::resizeEvent(event); - } -}; - -inline bool matchString(const char *extensionString, const char *subString) -{ - int subStringLength = strlen(subString); - return (strncmp(extensionString, subString, subStringLength) == 0) - && ((extensionString[subStringLength] == ' ') || (extensionString[subStringLength] == '\0')); -} - -bool necessaryExtensionsSupported() -{ - const char *extensionString = reinterpret_cast(glGetString(GL_EXTENSIONS)); - const char *p = extensionString; - - const int GL_EXT_FBO = 1; - const int GL_ARB_VS = 2; - const int GL_ARB_FS = 4; - const int GL_ARB_SO = 8; - int extensions = 0; - - while (*p) { - if (matchString(p, "GL_EXT_framebuffer_object")) - extensions |= GL_EXT_FBO; - else if (matchString(p, "GL_ARB_vertex_shader")) - extensions |= GL_ARB_VS; - else if (matchString(p, "GL_ARB_fragment_shader")) - extensions |= GL_ARB_FS; - else if (matchString(p, "GL_ARB_shader_objects")) - extensions |= GL_ARB_SO; - while ((*p != ' ') && (*p != '\0')) - ++p; - if (*p == ' ') - ++p; - } - return (extensions == 15); -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5) == 0) { - QMessageBox::critical(0, "OpenGL features missing", - "OpenGL version 1.5 or higher is required to run this demo.\n" - "The program will now exit."); - return -1; - } - - int maxTextureSize = 1024; - QGLWidget *widget = new QGLWidget(QGLFormat(QGL::SampleBuffers)); - widget->makeCurrent(); - - if (!necessaryExtensionsSupported()) { - QMessageBox::critical(0, "OpenGL features missing", - "The OpenGL extensions required to run this demo are missing.\n" - "The program will now exit."); - delete widget; - return -2; - } - - // Check if all the necessary functions are resolved. - if (!getGLExtensionFunctions().resolve(widget->context())) { - QMessageBox::critical(0, "OpenGL features missing", - "Failed to resolve OpenGL functions required to run this demo.\n" - "The program will now exit."); - delete widget; - return -3; - } - - // TODO: Make conditional for final release - QMessageBox::information(0, "For your information", - "This demo can be GPU and CPU intensive and may\n" - "work poorly or not at all on your system."); - - widget->makeCurrent(); // The current context must be set before calling Scene's constructor - Scene scene(1024, 768, maxTextureSize); - GraphicsView view; - view.setViewport(widget); - view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - view.setScene(&scene); - view.show(); - - return app.exec(); -} - diff --git a/examples/graphicsview/boxes/marble.fsh b/examples/graphicsview/boxes/marble.fsh deleted file mode 100644 index 3985a98e96..0000000000 --- a/examples/graphicsview/boxes/marble.fsh +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform sampler3D noise; - -//const vec4 marbleColors[2] = {vec4(0.9, 0.9, 0.9, 1), vec4(0.6, 0.5, 0.5, 1)}; -uniform vec4 marbleColors[2]; - -void main() -{ - float turbulence = 0.0; - float scale = 1.0; - for (int i = 0; i < 4; ++i) { - turbulence += scale * (texture3D(noise, 0.125 * gl_TexCoord[1].xyz / scale).x - 0.5); - scale *= 0.5; - } - - vec3 N = normalize(normal); - // assume directional light - - gl_MaterialParameters M = gl_FrontMaterial; - - float NdotL = dot(N, lightDirection.xyz); - float RdotL = dot(reflect(normalize(position), N), lightDirection.xyz); - - vec4 unlitColor = mix(marbleColors[0], marbleColors[1], exp(-4.0 * abs(turbulence))); - gl_FragColor = (ambient + diffuse * max(NdotL, 0.0)) * unlitColor + - M.specular * specular * pow(max(RdotL, 0.0), M.shininess); -} diff --git a/examples/graphicsview/boxes/parameters.par b/examples/graphicsview/boxes/parameters.par deleted file mode 100644 index 50e20739b9..0000000000 --- a/examples/graphicsview/boxes/parameters.par +++ /dev/null @@ -1,5 +0,0 @@ -color basicColor ff0e3d0e -color woodColors ff5e3d33 ffcc9966 -float woodTubulence 0.1 -color graniteColors ff000000 ff4d261a ffccb3bf -color marbleColors ffe6e6e6 ff998080 diff --git a/examples/graphicsview/boxes/qt-logo.jpg b/examples/graphicsview/boxes/qt-logo.jpg deleted file mode 100644 index 4014b4659c..0000000000 Binary files a/examples/graphicsview/boxes/qt-logo.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/qt-logo.png b/examples/graphicsview/boxes/qt-logo.png deleted file mode 100644 index 7d3e97eb36..0000000000 Binary files a/examples/graphicsview/boxes/qt-logo.png and /dev/null differ diff --git a/examples/graphicsview/boxes/qtbox.cpp b/examples/graphicsview/boxes/qtbox.cpp deleted file mode 100644 index cff4497253..0000000000 --- a/examples/graphicsview/boxes/qtbox.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtbox.h" - -const qreal ROTATE_SPEED_X = 30.0 / 1000.0; -const qreal ROTATE_SPEED_Y = 20.0 / 1000.0; -const qreal ROTATE_SPEED_Z = 40.0 / 1000.0; -const int MAX_ITEM_SIZE = 512; -const int MIN_ITEM_SIZE = 16; - -//============================================================================// -// ItemBase // -//============================================================================// - -ItemBase::ItemBase(int size, int x, int y) : m_size(size), m_isResizing(false) -{ - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsSelectable, true); - setFlag(QGraphicsItem::ItemIsFocusable, true); - setAcceptHoverEvents(true); - setPos(x, y); - m_startTime = QTime::currentTime(); -} - -ItemBase::~ItemBase() -{ -} - -QRectF ItemBase::boundingRect() const -{ - return QRectF(-m_size / 2, -m_size / 2, m_size, m_size); -} - -void ItemBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) -{ - if (option->state & QStyle::State_Selected) { - painter->setRenderHint(QPainter::Antialiasing, true); - if (option->state & QStyle::State_HasFocus) - painter->setPen(Qt::yellow); - else - painter->setPen(Qt::white); - painter->drawRect(boundingRect()); - - painter->drawLine(m_size / 2 - 9, m_size / 2, m_size / 2, m_size / 2 - 9); - painter->drawLine(m_size / 2 - 6, m_size / 2, m_size / 2, m_size / 2 - 6); - painter->drawLine(m_size / 2 - 3, m_size / 2, m_size / 2, m_size / 2 - 3); - - painter->setRenderHint(QPainter::Antialiasing, false); - } -} - -void ItemBase::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - if (!isSelected() && scene()) { - scene()->clearSelection(); - setSelected(true); - } - - QMenu menu; - QAction *delAction = menu.addAction("Delete"); - QAction *newAction = menu.addAction("New"); - QAction *growAction = menu.addAction("Grow"); - QAction *shrinkAction = menu.addAction("Shrink"); - - QAction *selectedAction = menu.exec(event->screenPos()); - - if (selectedAction == delAction) - deleteSelectedItems(scene()); - else if (selectedAction == newAction) - duplicateSelectedItems(scene()); - else if (selectedAction == growAction) - growSelectedItems(scene()); - else if (selectedAction == shrinkAction) - shrinkSelectedItems(scene()); -} - -void ItemBase::duplicateSelectedItems(QGraphicsScene *scene) -{ - if (!scene) - return; - - QList selected; - selected = scene->selectedItems(); - - foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = qgraphicsitem_cast(item); - if (itemBase) - scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y())); - } -} - -void ItemBase::deleteSelectedItems(QGraphicsScene *scene) -{ - if (!scene) - return; - - QList selected; - selected = scene->selectedItems(); - - foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = qgraphicsitem_cast(item); - if (itemBase) - delete itemBase; - } -} - -void ItemBase::growSelectedItems(QGraphicsScene *scene) -{ - if (!scene) - return; - - QList selected; - selected = scene->selectedItems(); - - foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = qgraphicsitem_cast(item); - if (itemBase) { - itemBase->prepareGeometryChange(); - itemBase->m_size *= 2; - if (itemBase->m_size > MAX_ITEM_SIZE) - itemBase->m_size = MAX_ITEM_SIZE; - } - } -} - -void ItemBase::shrinkSelectedItems(QGraphicsScene *scene) -{ - if (!scene) - return; - - QList selected; - selected = scene->selectedItems(); - - foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = qgraphicsitem_cast(item); - if (itemBase) { - itemBase->prepareGeometryChange(); - itemBase->m_size /= 2; - if (itemBase->m_size < MIN_ITEM_SIZE) - itemBase->m_size = MIN_ITEM_SIZE; - } - } -} - -void ItemBase::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (m_isResizing) { - int dx = int(2.0 * event->pos().x()); - int dy = int(2.0 * event->pos().y()); - prepareGeometryChange(); - m_size = (dx > dy ? dx : dy); - if (m_size < MIN_ITEM_SIZE) - m_size = MIN_ITEM_SIZE; - else if (m_size > MAX_ITEM_SIZE) - m_size = MAX_ITEM_SIZE; - } else { - QGraphicsItem::mouseMoveEvent(event); - } -} - -void ItemBase::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - if (m_isResizing || (isInResizeArea(event->pos()) && isSelected())) - setCursor(Qt::SizeFDiagCursor); - else - setCursor(Qt::ArrowCursor); - QGraphicsItem::hoverMoveEvent(event); -} - -void ItemBase::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - static qreal z = 0.0; - setZValue(z += 1.0); - if (event->button() == Qt::LeftButton && isInResizeArea(event->pos())) { - m_isResizing = true; - } else { - QGraphicsItem::mousePressEvent(event); - } -} - -void ItemBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton && m_isResizing) { - m_isResizing = false; - } else { - QGraphicsItem::mouseReleaseEvent(event); - } -} - -void ItemBase::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Delete: - deleteSelectedItems(scene()); - break; - case Qt::Key_Insert: - duplicateSelectedItems(scene()); - break; - case Qt::Key_Plus: - growSelectedItems(scene()); - break; - case Qt::Key_Minus: - shrinkSelectedItems(scene()); - break; - default: - QGraphicsItem::keyPressEvent(event); - break; - } -} - -void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event) -{ - prepareGeometryChange(); - m_size = int(m_size * exp(-event->delta() / 600.0)); - if (m_size > MAX_ITEM_SIZE) - m_size = MAX_ITEM_SIZE; - else if (m_size < MIN_ITEM_SIZE) - m_size = MIN_ITEM_SIZE; -} - -int ItemBase::type() const -{ - return Type; -} - - -bool ItemBase::isInResizeArea(const QPointF &pos) -{ - return (-pos.y() < pos.x() - m_size + 9); -} - -//============================================================================// -// QtBox // -//============================================================================// - -QtBox::QtBox(int size, int x, int y) : ItemBase(size, x, y), m_texture(0) -{ - for (int i = 0; i < 8; ++i) { - m_vertices[i].setX(i & 1 ? 0.5f : -0.5f); - m_vertices[i].setY(i & 2 ? 0.5f : -0.5f); - m_vertices[i].setZ(i & 4 ? 0.5f : -0.5f); - } - for (int i = 0; i < 4; ++i) { - m_texCoords[i].setX(i & 1 ? 1.0f : 0.0f); - m_texCoords[i].setY(i & 2 ? 1.0f : 0.0f); - } - m_normals[0] = QVector3D(-1.0f, 0.0f, 0.0f); - m_normals[1] = QVector3D(1.0f, 0.0f, 0.0f); - m_normals[2] = QVector3D(0.0f, -1.0f, 0.0f); - m_normals[3] = QVector3D(0.0f, 1.0f, 0.0f); - m_normals[4] = QVector3D(0.0f, 0.0f, -1.0f); - m_normals[5] = QVector3D(0.0f, 0.0f, 1.0f); -} - -QtBox::~QtBox() -{ - if (m_texture) - delete m_texture; -} - -ItemBase *QtBox::createNew(int size, int x, int y) -{ - return new QtBox(size, x, y); -} - -void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - QRectF rect = boundingRect().translated(pos()); - float width = float(painter->device()->width()); - float height = float(painter->device()->height()); - - float left = 2.0f * float(rect.left()) / width - 1.0f; - float right = 2.0f * float(rect.right()) / width - 1.0f; - float top = 1.0f - 2.0f * float(rect.top()) / height; - float bottom = 1.0f - 2.0f * float(rect.bottom()) / height; - float moveToRectMatrix[] = { - 0.5f * (right - left), 0.0f, 0.0f, 0.0f, - 0.0f, 0.5f * (bottom - top), 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.5f * (right + left), 0.5f * (bottom + top), 0.0f, 1.0f - }; - - painter->beginNativePainting(); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadMatrixf(moveToRectMatrix); - qgluPerspective(60.0, 1.0, 0.01, 10.0); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - //glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); - glEnable(GL_NORMALIZE); - - if(m_texture == 0) - m_texture = new GLTexture2D(":/res/boxes/qt-logo.jpg", 64, 64); - m_texture->bind(); - glEnable(GL_TEXTURE_2D); - - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - float lightColour[] = {1.0f, 1.0f, 1.0f, 1.0f}; - float lightDir[] = {0.0f, 0.0f, 1.0f, 0.0f}; - glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColour); - glLightfv(GL_LIGHT0, GL_POSITION, lightDir); - glEnable(GL_LIGHT0); - - glTranslatef(0.0f, 0.0f, -1.5f); - glRotatef(ROTATE_SPEED_X * m_startTime.msecsTo(QTime::currentTime()), 1.0f, 0.0f, 0.0f); - glRotatef(ROTATE_SPEED_Y * m_startTime.msecsTo(QTime::currentTime()), 0.0f, 1.0f, 0.0f); - glRotatef(ROTATE_SPEED_Z * m_startTime.msecsTo(QTime::currentTime()), 0.0f, 0.0f, 1.0f); - int dt = m_startTime.msecsTo(QTime::currentTime()); - if (dt < 500) - glScalef(dt / 500.0f, dt / 500.0f, dt / 500.0f); - - for (int dir = 0; dir < 3; ++dir) { - glColor4f(1.0f, 1.0f, 1.0f, 1.0); - - glBegin(GL_TRIANGLE_STRIP); - glNormal3fv(reinterpret_cast(&m_normals[2 * dir + 0])); - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < 2; ++j) { - glTexCoord2fv(reinterpret_cast(&m_texCoords[(j << 1) | i])); - glVertex3fv(reinterpret_cast(&m_vertices[(i << ((dir + 2) % 3)) | (j << ((dir + 1) % 3))])); - } - } - glEnd(); - - glBegin(GL_TRIANGLE_STRIP); - glNormal3fv(reinterpret_cast(&m_normals[2 * dir + 1])); - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < 2; ++j) { - glTexCoord2fv(reinterpret_cast(&m_texCoords[(j << 1) | i])); - glVertex3fv(reinterpret_cast(&m_vertices[(1 << dir) | (i << ((dir + 1) % 3)) | (j << ((dir + 2) % 3))])); - } - } - glEnd(); - } - m_texture->unbind(); - - //glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_TEXTURE_2D); - glDisable(GL_LIGHT0); - glDisable(GL_NORMALIZE); - - glPopMatrix(); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - - painter->endNativePainting(); - - ItemBase::paint(painter, option, widget); -} - -//============================================================================// -// CircleItem // -//============================================================================// - -CircleItem::CircleItem(int size, int x, int y) : ItemBase(size, x, y) -{ - m_color = QColor::fromHsv(rand() % 360, 255, 255); -} - -void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - int dt = m_startTime.msecsTo(QTime::currentTime()); - - qreal r0 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 3800) % 4000))); - qreal r1 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 0) % 4000))); - qreal r2 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 1800) % 4000))); - qreal r3 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 2000) % 4000))); - - if (r0 > r1) - r0 = 0.0; - if (r2 > r3) - r2 = 0.0; - - QPainterPath path; - path.moveTo(r1, 0.0); - path.arcTo(-r1, -r1, 2 * r1, 2 * r1, 0.0, 360.0); - path.lineTo(r0, 0.0); - path.arcTo(-r0, -r0, 2 * r0, 2 * r0, 0.0, -360.0); - path.closeSubpath(); - path.moveTo(r3, 0.0); - path.arcTo(-r3, -r3, 2 * r3, 2 * r3, 0.0, 360.0); - path.lineTo(r0, 0.0); - path.arcTo(-r2, -r2, 2 * r2, 2 * r2, 0.0, -360.0); - path.closeSubpath(); - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setBrush(QBrush(m_color)); - painter->setPen(Qt::NoPen); - painter->drawPath(path); - painter->setBrush(Qt::NoBrush); - painter->setPen(Qt::SolidLine); - painter->setRenderHint(QPainter::Antialiasing, false); - - ItemBase::paint(painter, option, widget); -} - -ItemBase *CircleItem::createNew(int size, int x, int y) -{ - return new CircleItem(size, x, y); -} - -//============================================================================// -// SquareItem // -//============================================================================// - -SquareItem::SquareItem(int size, int x, int y) : ItemBase(size, x, y) -{ - m_image = QPixmap(":/res/boxes/square.jpg"); -} - -void SquareItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - int dt = m_startTime.msecsTo(QTime::currentTime()); - QTransform oldTransform = painter->worldTransform(); - int dtMod = dt % 2000; - qreal amp = 0.002 * (dtMod < 1000 ? dtMod : 2000 - dtMod) - 1.0; - - qreal scale = 0.6 + 0.2 * amp * amp; - painter->setWorldTransform(QTransform().rotate(15.0 * amp).scale(scale, scale), true); - - painter->drawPixmap(-m_size / 2, -m_size / 2, m_size, m_size, m_image); - - painter->setWorldTransform(oldTransform, false); - ItemBase::paint(painter, option, widget); -} - -ItemBase *SquareItem::createNew(int size, int x, int y) -{ - return new SquareItem(size, x, y); -} diff --git a/examples/graphicsview/boxes/qtbox.h b/examples/graphicsview/boxes/qtbox.h deleted file mode 100644 index 66b9b17b7f..0000000000 --- a/examples/graphicsview/boxes/qtbox.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTBOX_H -#define QTBOX_H - -#include - -#include -#include "glbuffers.h" - -class ItemBase : public QGraphicsItem -{ -public: - enum { Type = UserType + 1 }; - - ItemBase(int size, int x, int y); - virtual ~ItemBase(); - virtual QRectF boundingRect() const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual ItemBase *createNew(int size, int x, int y) = 0; - virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void keyPressEvent(QKeyEvent *event); - virtual void wheelEvent(QGraphicsSceneWheelEvent *event); - virtual int type() const; - bool isInResizeArea(const QPointF &pos); - - static void duplicateSelectedItems(QGraphicsScene *scene); - static void deleteSelectedItems(QGraphicsScene *scene); - static void growSelectedItems(QGraphicsScene *scene); - static void shrinkSelectedItems(QGraphicsScene *scene); - - int m_size; - QTime m_startTime; - bool m_isResizing; -}; - -class QtBox : public ItemBase -{ -public: - QtBox(int size, int x, int y); - virtual ~QtBox(); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual ItemBase *createNew(int size, int x, int y); -private: - QVector3D m_vertices[8]; - QVector3D m_texCoords[4]; - QVector3D m_normals[6]; - GLTexture *m_texture; -}; - -class CircleItem : public ItemBase -{ -public: - CircleItem(int size, int x, int y); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual ItemBase *createNew(int size, int x, int y); - - QColor m_color; -}; - -class SquareItem : public ItemBase -{ -public: - SquareItem(int size, int x, int y); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual ItemBase *createNew(int size, int x, int y); - - QPixmap m_image; -}; - -#endif diff --git a/examples/graphicsview/boxes/reflection.fsh b/examples/graphicsview/boxes/reflection.fsh deleted file mode 100644 index 95a21112ea..0000000000 --- a/examples/graphicsview/boxes/reflection.fsh +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform samplerCube env; -uniform mat4 view; - -void main() -{ - vec3 N = normalize(normal); - vec3 R = 2.0 * dot(-position, N) * N + position; - gl_FragColor = textureCube(env, R * mat3(view[0].xyz, view[1].xyz, view[2].xyz)); -} diff --git a/examples/graphicsview/boxes/refraction.fsh b/examples/graphicsview/boxes/refraction.fsh deleted file mode 100644 index 5411478ea2..0000000000 --- a/examples/graphicsview/boxes/refraction.fsh +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform samplerCube env; -uniform mat4 view; - -// Arrays don't work here on glsl < 120, apparently. -//const float coeffs[6] = float[6](1.0/2.0, 1.0/2.1, 1.0/2.2, 1.0/2.3, 1.0/2.4, 1.0/2.5); -float coeffs(int i) -{ - return 1.0 / (2.0 + 0.1 * float(i)); -} - -void main() -{ - vec3 N = normalize(normal); - vec3 I = -normalize(position); - float IdotN = dot(I, N); - float scales[6]; - vec3 C[6]; - for (int i = 0; i < 6; ++i) { - scales[i] = (IdotN - sqrt(1.0 - coeffs(i) + coeffs(i) * (IdotN * IdotN))); - C[i] = textureCube(env, (-I + coeffs(i) * N) * mat3(view[0].xyz, view[1].xyz, view[2].xyz)).xyz; - } - - gl_FragColor = 0.25 * vec4(C[5].x + 2.0*C[0].x + C[1].x, C[1].y + 2.0*C[2].y + C[3].y, - C[3].z + 2.0*C[4].z + C[5].z, 4.0); -} diff --git a/examples/graphicsview/boxes/roundedbox.cpp b/examples/graphicsview/boxes/roundedbox.cpp deleted file mode 100644 index e205dbdb2b..0000000000 --- a/examples/graphicsview/boxes/roundedbox.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "roundedbox.h" - -//============================================================================// -// P3T2N3Vertex // -//============================================================================// - -VertexDescription P3T2N3Vertex::description[] = { - {VertexDescription::Position, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, position) / sizeof(float), 0, 0}, - {VertexDescription::TexCoord, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, texCoord) / sizeof(float), sizeof(QVector3D), 0}, - {VertexDescription::Normal, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, normal) / sizeof(float), sizeof(QVector3D) + sizeof(QVector2D), 0}, - - {VertexDescription::Null, 0, 0, 0, 0}, -}; - -//============================================================================// -// GLRoundedBox // -//============================================================================// - -float lerp(float a, float b, float t) -{ - return a * (1.0f - t) + b * t; -} - -GLRoundedBox::GLRoundedBox(float r, float scale, int n) - : GLTriangleMesh((n+2)*(n+3)*4, (n+1)*(n+1)*24+36+72*(n+1)) -{ - int vidx = 0, iidx = 0; - int vertexCountPerCorner = (n + 2) * (n + 3) / 2; - - P3T2N3Vertex *vp = m_vb.lock(); - unsigned short *ip = m_ib.lock(); - - if (!vp || !ip) { - qWarning("GLRoundedBox::GLRoundedBox: Failed to lock vertex buffer and/or index buffer."); - m_ib.unlock(); - m_vb.unlock(); - return; - } - - for (int corner = 0; corner < 8; ++corner) { - QVector3D centre(corner & 1 ? 1.0f : -1.0f, - corner & 2 ? 1.0f : -1.0f, - corner & 4 ? 1.0f : -1.0f); - int winding = (corner & 1) ^ ((corner >> 1) & 1) ^ (corner >> 2); - int offsX = ((corner ^ 1) - corner) * vertexCountPerCorner; - int offsY = ((corner ^ 2) - corner) * vertexCountPerCorner; - int offsZ = ((corner ^ 4) - corner) * vertexCountPerCorner; - - // Face polygons - if (winding) { - ip[iidx++] = vidx; - ip[iidx++] = vidx + offsX; - ip[iidx++] = vidx + offsY; - - ip[iidx++] = vidx + vertexCountPerCorner - n - 2; - ip[iidx++] = vidx + vertexCountPerCorner - n - 2 + offsY; - ip[iidx++] = vidx + vertexCountPerCorner - n - 2 + offsZ; - - ip[iidx++] = vidx + vertexCountPerCorner - 1; - ip[iidx++] = vidx + vertexCountPerCorner - 1 + offsZ; - ip[iidx++] = vidx + vertexCountPerCorner - 1 + offsX; - } - - for (int i = 0; i < n + 2; ++i) { - - // Edge polygons - if (winding && i < n + 1) { - ip[iidx++] = vidx + i + 1; - ip[iidx++] = vidx; - ip[iidx++] = vidx + offsY + i + 1; - ip[iidx++] = vidx + offsY; - ip[iidx++] = vidx + offsY + i + 1; - ip[iidx++] = vidx; - - ip[iidx++] = vidx + i; - ip[iidx++] = vidx + 2 * i + 2; - ip[iidx++] = vidx + i + offsX; - ip[iidx++] = vidx + 2 * i + offsX + 2; - ip[iidx++] = vidx + i + offsX; - ip[iidx++] = vidx + 2 * i + 2; - - ip[iidx++] = (corner + 1) * vertexCountPerCorner - 1 - i; - ip[iidx++] = (corner + 1) * vertexCountPerCorner - 2 - i; - ip[iidx++] = (corner + 1) * vertexCountPerCorner - 1 - i + offsZ; - ip[iidx++] = (corner + 1) * vertexCountPerCorner - 2 - i + offsZ; - ip[iidx++] = (corner + 1) * vertexCountPerCorner - 1 - i + offsZ; - ip[iidx++] = (corner + 1) * vertexCountPerCorner - 2 - i; - } - - for (int j = 0; j <= i; ++j) { - QVector3D normal = QVector3D(i - j, j, n + 1 - i).normalized(); - QVector3D offset(0.5f - r, 0.5f - r, 0.5f - r); - QVector3D pos = centre * (offset + r * normal); - - vp[vidx].position = scale * pos; - vp[vidx].normal = centre * normal; - vp[vidx].texCoord = QVector2D(pos.x() + 0.5f, pos.y() + 0.5f); - - // Corner polygons - if (i < n + 1) { - ip[iidx++] = vidx; - ip[iidx++] = vidx + i + 2 - winding; - ip[iidx++] = vidx + i + 1 + winding; - } - if (i < n) { - ip[iidx++] = vidx + i + 1 + winding; - ip[iidx++] = vidx + i + 2 - winding; - ip[iidx++] = vidx + 2 * i + 4; - } - - ++vidx; - } - } - - } - - m_ib.unlock(); - m_vb.unlock(); -} - diff --git a/examples/graphicsview/boxes/roundedbox.h b/examples/graphicsview/boxes/roundedbox.h deleted file mode 100644 index 3edfb69fa8..0000000000 --- a/examples/graphicsview/boxes/roundedbox.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ROUNDEDBOX_H -#define ROUNDEDBOX_H - -//#include -#include "glextensions.h" - -#include -#include - -#include "gltrianglemesh.h" -#include -#include -#include "glbuffers.h" - -struct P3T2N3Vertex -{ - QVector3D position; - QVector2D texCoord; - QVector3D normal; - static VertexDescription description[]; -}; - -class GLRoundedBox : public GLTriangleMesh -{ -public: - // 0 < r < 0.5, 0 <= n <= 125 - GLRoundedBox(float r = 0.25f, float scale = 1.0f, int n = 10); -}; - - -#endif diff --git a/examples/graphicsview/boxes/scene.cpp b/examples/graphicsview/boxes/scene.cpp deleted file mode 100644 index 5fb43d8c99..0000000000 --- a/examples/graphicsview/boxes/scene.cpp +++ /dev/null @@ -1,1085 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "scene.h" -#include -#include - -#include "3rdparty/fbm.h" - -void checkGLErrors(const QString& prefix) -{ - switch (glGetError()) { - case GL_NO_ERROR: - //qDebug() << prefix << tr("No error."); - break; - case GL_INVALID_ENUM: - qDebug() << prefix << QObject::tr("Invalid enum."); - break; - case GL_INVALID_VALUE: - qDebug() << prefix << QObject::tr("Invalid value."); - break; - case GL_INVALID_OPERATION: - qDebug() << prefix << QObject::tr("Invalid operation."); - break; - case GL_STACK_OVERFLOW: - qDebug() << prefix << QObject::tr("Stack overflow."); - break; - case GL_STACK_UNDERFLOW: - qDebug() << prefix << QObject::tr("Stack underflow."); - break; - case GL_OUT_OF_MEMORY: - qDebug() << prefix << QObject::tr("Out of memory."); - break; - default: - qDebug() << prefix << QObject::tr("Unknown error."); - break; - } -} - -//============================================================================// -// ColorEdit // -//============================================================================// - -ColorEdit::ColorEdit(QRgb initialColor, int id) - : m_color(initialColor), m_id(id) -{ - QHBoxLayout *layout = new QHBoxLayout; - setLayout(layout); - layout->setContentsMargins(0, 0, 0, 0); - - m_lineEdit = new QLineEdit(QString::number(m_color, 16)); - layout->addWidget(m_lineEdit); - - m_button = new QFrame; - QPalette palette = m_button->palette(); - palette.setColor(QPalette::Window, QColor(m_color)); - m_button->setPalette(palette); - m_button->setAutoFillBackground(true); - m_button->setMinimumSize(32, 0); - m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - m_button->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - layout->addWidget(m_button); - - connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(editDone())); -} - -void ColorEdit::editDone() -{ - bool ok; - QRgb newColor = m_lineEdit->text().toUInt(&ok, 16); - if (ok) - setColor(newColor); -} - -void ColorEdit::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - QColor color(m_color); - QColorDialog dialog(color, 0); - dialog.setOption(QColorDialog::ShowAlphaChannel, true); -// The ifdef block is a workaround for the beta, TODO: remove when bug 238525 is fixed -#ifdef Q_WS_MAC - dialog.setOption(QColorDialog::DontUseNativeDialog, true); -#endif - dialog.move(280, 120); - if (dialog.exec() == QDialog::Rejected) - return; - QRgb newColor = dialog.selectedColor().rgba(); - if (newColor == m_color) - return; - setColor(newColor); - } -} - -void ColorEdit::setColor(QRgb color) -{ - m_color = color; - m_lineEdit->setText(QString::number(m_color, 16)); // "Clean up" text - QPalette palette = m_button->palette(); - palette.setColor(QPalette::Window, QColor(m_color)); - m_button->setPalette(palette); - emit colorChanged(m_color, m_id); -} - -//============================================================================// -// FloatEdit // -//============================================================================// - -FloatEdit::FloatEdit(float initialValue, int id) - : m_value(initialValue), m_id(id) -{ - QHBoxLayout *layout = new QHBoxLayout; - setLayout(layout); - layout->setContentsMargins(0, 0, 0, 0); - - m_lineEdit = new QLineEdit(QString::number(m_value)); - layout->addWidget(m_lineEdit); - - connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(editDone())); -} - -void FloatEdit::editDone() -{ - bool ok; - float newValue = m_lineEdit->text().toFloat(&ok); - if (ok) { - m_value = newValue; - m_lineEdit->setText(QString::number(m_value)); // "Clean up" text - emit valueChanged(m_value, m_id); - } -} - -//============================================================================// -// TwoSidedGraphicsWidget // -//============================================================================// - -TwoSidedGraphicsWidget::TwoSidedGraphicsWidget(QGraphicsScene *scene) - : QObject(scene) - , m_current(0) - , m_angle(0) - , m_delta(0) -{ - for (int i = 0; i < 2; ++i) - m_proxyWidgets[i] = 0; -} - -void TwoSidedGraphicsWidget::setWidget(int index, QWidget *widget) -{ - if (index < 0 || index >= 2) - { - qWarning("TwoSidedGraphicsWidget::setWidget: Index out of bounds, index == %d", index); - return; - } - - GraphicsWidget *proxy = new GraphicsWidget; - proxy->setWidget(widget); - - if (m_proxyWidgets[index]) - delete m_proxyWidgets[index]; - m_proxyWidgets[index] = proxy; - - proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache); - proxy->setZValue(1e30); // Make sure the dialog is drawn on top of all other (OpenGL) items - - if (index != m_current) - proxy->setVisible(false); - - qobject_cast(parent())->addItem(proxy); -} - -QWidget *TwoSidedGraphicsWidget::widget(int index) -{ - if (index < 0 || index >= 2) - { - qWarning("TwoSidedGraphicsWidget::widget: Index out of bounds, index == %d", index); - return 0; - } - return m_proxyWidgets[index]->widget(); -} - -void TwoSidedGraphicsWidget::flip() -{ - m_delta = (m_current == 0 ? 9 : -9); - animateFlip(); -} - -void TwoSidedGraphicsWidget::animateFlip() -{ - m_angle += m_delta; - if (m_angle == 90) { - int old = m_current; - m_current ^= 1; - m_proxyWidgets[old]->setVisible(false); - m_proxyWidgets[m_current]->setVisible(true); - m_proxyWidgets[m_current]->setGeometry(m_proxyWidgets[old]->geometry()); - } - - QRectF r = m_proxyWidgets[m_current]->boundingRect(); - m_proxyWidgets[m_current]->setTransform(QTransform() - .translate(r.width() / 2, r.height() / 2) - .rotate(m_angle - 180 * m_current, Qt::YAxis) - .translate(-r.width() / 2, -r.height() / 2)); - - if ((m_current == 0 && m_angle > 0) || (m_current == 1 && m_angle < 180)) - QTimer::singleShot(25, this, SLOT(animateFlip())); -} - -QVariant GraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemPositionChange && scene()) { - QRectF rect = boundingRect(); - QPointF pos = value.toPointF(); - QRectF sceneRect = scene()->sceneRect(); - if (pos.x() + rect.left() < sceneRect.left()) - pos.setX(sceneRect.left() - rect.left()); - else if (pos.x() + rect.right() >= sceneRect.right()) - pos.setX(sceneRect.right() - rect.right()); - if (pos.y() + rect.top() < sceneRect.top()) - pos.setY(sceneRect.top() - rect.top()); - else if (pos.y() + rect.bottom() >= sceneRect.bottom()) - pos.setY(sceneRect.bottom() - rect.bottom()); - return pos; - } - return QGraphicsProxyWidget::itemChange(change, value); -} - -void GraphicsWidget::resizeEvent(QGraphicsSceneResizeEvent *event) -{ - setCacheMode(QGraphicsItem::NoCache); - setCacheMode(QGraphicsItem::ItemCoordinateCache); - QGraphicsProxyWidget::resizeEvent(event); -} - -void GraphicsWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - painter->setRenderHint(QPainter::Antialiasing, false); - QGraphicsProxyWidget::paint(painter, option, widget); - //painter->setRenderHint(QPainter::Antialiasing, true); -} - -//============================================================================// -// RenderOptionsDialog // -//============================================================================// - -RenderOptionsDialog::RenderOptionsDialog() - : QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint) -{ - setWindowOpacity(0.75); - setWindowTitle(tr("Options (double click to flip)")); - QGridLayout *layout = new QGridLayout; - setLayout(layout); - layout->setColumnStretch(1, 1); - - int row = 0; - - QCheckBox *check = new QCheckBox(tr("Dynamic cube map")); - check->setCheckState(Qt::Unchecked); - // Dynamic cube maps are only enabled when multi-texturing and render to texture are available. - check->setEnabled(glActiveTexture && glGenFramebuffersEXT); - connect(check, SIGNAL(stateChanged(int)), this, SIGNAL(dynamicCubemapToggled(int))); - layout->addWidget(check, 0, 0, 1, 2); - ++row; - - QPalette palette; - - // Load all .par files - // .par files have a simple syntax for specifying user adjustable uniform variables. - QSet uniforms; - QList filter = QStringList("*.par"); - QList files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable); - - foreach (QFileInfo fileInfo, files) { - QFile file(fileInfo.absoluteFilePath()); - if (file.open(QIODevice::ReadOnly)) { - while (!file.atEnd()) { - QList tokens = file.readLine().simplified().split(' '); - QList::const_iterator it = tokens.begin(); - if (it == tokens.end()) - continue; - QByteArray type = *it; - if (++it == tokens.end()) - continue; - QByteArray name = *it; - bool singleElement = (tokens.size() == 3); // type, name and one value - char counter[10] = "000000000"; - int counterPos = 8; // position of last digit - while (++it != tokens.end()) { - m_parameterNames << name; - if (!singleElement) { - m_parameterNames.back() += "["; - m_parameterNames.back() += counter + counterPos; - m_parameterNames.back() += "]"; - int j = 8; // position of last digit - ++counter[j]; - while (j > 0 && counter[j] > '9') { - counter[j] = '0'; - ++counter[--j]; - } - if (j < counterPos) - counterPos = j; - } - - if (type == "color") { - layout->addWidget(new QLabel(m_parameterNames.back())); - bool ok; - ColorEdit *colorEdit = new ColorEdit(it->toUInt(&ok, 16), m_parameterNames.size() - 1); - m_parameterEdits << colorEdit; - layout->addWidget(colorEdit); - connect(colorEdit, SIGNAL(colorChanged(QRgb,int)), this, SLOT(setColorParameter(QRgb,int))); - ++row; - } else if (type == "float") { - layout->addWidget(new QLabel(m_parameterNames.back())); - bool ok; - FloatEdit *floatEdit = new FloatEdit(it->toFloat(&ok), m_parameterNames.size() - 1); - m_parameterEdits << floatEdit; - layout->addWidget(floatEdit); - connect(floatEdit, SIGNAL(valueChanged(float,int)), this, SLOT(setFloatParameter(float,int))); - ++row; - } - } - } - file.close(); - } - } - - layout->addWidget(new QLabel(tr("Texture:"))); - m_textureCombo = new QComboBox; - connect(m_textureCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(textureChanged(int))); - layout->addWidget(m_textureCombo); - ++row; - - layout->addWidget(new QLabel(tr("Shader:"))); - m_shaderCombo = new QComboBox; - connect(m_shaderCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(shaderChanged(int))); - layout->addWidget(m_shaderCombo); - ++row; - - layout->setRowStretch(row, 1); -} - -int RenderOptionsDialog::addTexture(const QString &name) -{ - m_textureCombo->addItem(name); - return m_textureCombo->count() - 1; -} - -int RenderOptionsDialog::addShader(const QString &name) -{ - m_shaderCombo->addItem(name); - return m_shaderCombo->count() - 1; -} - -void RenderOptionsDialog::emitParameterChanged() -{ - foreach (ParameterEdit *edit, m_parameterEdits) - edit->emitChange(); -} - -void RenderOptionsDialog::setColorParameter(QRgb color, int id) -{ - emit colorParameterChanged(m_parameterNames[id], color); -} - -void RenderOptionsDialog::setFloatParameter(float value, int id) -{ - emit floatParameterChanged(m_parameterNames[id], value); -} - -void RenderOptionsDialog::mouseDoubleClickEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - emit doubleClicked(); -} - -//============================================================================// -// ItemDialog // -//============================================================================// - -ItemDialog::ItemDialog() - : QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint) -{ - setWindowTitle(tr("Items (double click to flip)")); - setWindowOpacity(0.75); - resize(160, 100); - - QVBoxLayout *layout = new QVBoxLayout; - setLayout(layout); - QPushButton *button; - - button = new QPushButton(tr("Add Qt box")); - layout->addWidget(button); - connect(button, SIGNAL(clicked()), this, SLOT(triggerNewQtBox())); - - button = new QPushButton(tr("Add circle")); - layout->addWidget(button); - connect(button, SIGNAL(clicked()), this, SLOT(triggerNewCircleItem())); - - button = new QPushButton(tr("Add square")); - layout->addWidget(button); - connect(button, SIGNAL(clicked()), this, SLOT(triggerNewSquareItem())); - - layout->addStretch(1); -} - -void ItemDialog::triggerNewQtBox() -{ - emit newItemTriggered(QtBoxItem); -} - -void ItemDialog::triggerNewCircleItem() -{ - emit newItemTriggered(CircleItem); -} - -void ItemDialog::triggerNewSquareItem() -{ - emit newItemTriggered(SquareItem); -} - -void ItemDialog::mouseDoubleClickEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - emit doubleClicked(); -} - -//============================================================================// -// Scene // -//============================================================================// - -const static char environmentShaderText[] = - "uniform samplerCube env;" - "void main() {" - "gl_FragColor = textureCube(env, gl_TexCoord[1].xyz);" - "}"; - -Scene::Scene(int width, int height, int maxTextureSize) - : m_distExp(600) - , m_frame(0) - , m_maxTextureSize(maxTextureSize) - , m_currentShader(0) - , m_currentTexture(0) - , m_dynamicCubemap(false) - , m_updateAllCubemaps(true) - , m_box(0) - , m_vertexShader(0) - , m_environmentShader(0) - , m_environmentProgram(0) -{ - setSceneRect(0, 0, width, height); - - m_trackBalls[0] = TrackBall(0.05f, QVector3D(0, 1, 0), TrackBall::Sphere); - m_trackBalls[1] = TrackBall(0.005f, QVector3D(0, 0, 1), TrackBall::Sphere); - m_trackBalls[2] = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Plane); - - m_renderOptions = new RenderOptionsDialog; - m_renderOptions->move(20, 120); - m_renderOptions->resize(m_renderOptions->sizeHint()); - - connect(m_renderOptions, SIGNAL(dynamicCubemapToggled(int)), this, SLOT(toggleDynamicCubemap(int))); - connect(m_renderOptions, SIGNAL(colorParameterChanged(QString,QRgb)), this, SLOT(setColorParameter(QString,QRgb))); - connect(m_renderOptions, SIGNAL(floatParameterChanged(QString,float)), this, SLOT(setFloatParameter(QString,float))); - connect(m_renderOptions, SIGNAL(textureChanged(int)), this, SLOT(setTexture(int))); - connect(m_renderOptions, SIGNAL(shaderChanged(int)), this, SLOT(setShader(int))); - - m_itemDialog = new ItemDialog; - connect(m_itemDialog, SIGNAL(newItemTriggered(ItemDialog::ItemType)), this, SLOT(newItem(ItemDialog::ItemType))); - - TwoSidedGraphicsWidget *twoSided = new TwoSidedGraphicsWidget(this); - twoSided->setWidget(0, m_renderOptions); - twoSided->setWidget(1, m_itemDialog); - - connect(m_renderOptions, SIGNAL(doubleClicked()), twoSided, SLOT(flip())); - connect(m_itemDialog, SIGNAL(doubleClicked()), twoSided, SLOT(flip())); - - addItem(new QtBox(64, width - 64, height - 64)); - addItem(new QtBox(64, width - 64, 64)); - addItem(new QtBox(64, 64, height - 64)); - addItem(new QtBox(64, 64, 64)); - - initGL(); - - m_timer = new QTimer(this); - m_timer->setInterval(20); - connect(m_timer, SIGNAL(timeout()), this, SLOT(update())); - m_timer->start(); - - m_time.start(); -} - -Scene::~Scene() -{ - if (m_box) - delete m_box; - foreach (GLTexture *texture, m_textures) - if (texture) delete texture; - if (m_mainCubemap) - delete m_mainCubemap; - foreach (QGLShaderProgram *program, m_programs) - if (program) delete program; - if (m_vertexShader) - delete m_vertexShader; - foreach (QGLShader *shader, m_fragmentShaders) - if (shader) delete shader; - foreach (GLRenderTargetCube *rt, m_cubemaps) - if (rt) delete rt; - if (m_environmentShader) - delete m_environmentShader; - if (m_environmentProgram) - delete m_environmentProgram; -} - -void Scene::initGL() -{ - m_box = new GLRoundedBox(0.25f, 1.0f, 10); - - m_vertexShader = new QGLShader(QGLShader::Vertex); - m_vertexShader->compileSourceFile(QLatin1String(":/res/boxes/basic.vsh")); - - QStringList list; - list << ":/res/boxes/cubemap_posx.jpg" << ":/res/boxes/cubemap_negx.jpg" << ":/res/boxes/cubemap_posy.jpg" - << ":/res/boxes/cubemap_negy.jpg" << ":/res/boxes/cubemap_posz.jpg" << ":/res/boxes/cubemap_negz.jpg"; - m_environment = new GLTextureCube(list, qMin(1024, m_maxTextureSize)); - m_environmentShader = new QGLShader(QGLShader::Fragment); - m_environmentShader->compileSourceCode(environmentShaderText); - m_environmentProgram = new QGLShaderProgram; - m_environmentProgram->addShader(m_vertexShader); - m_environmentProgram->addShader(m_environmentShader); - m_environmentProgram->link(); - - const int NOISE_SIZE = 128; // for a different size, B and BM in fbm.c must also be changed - m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE); - QRgb *data = new QRgb[NOISE_SIZE * NOISE_SIZE * NOISE_SIZE]; - memset(data, 0, NOISE_SIZE * NOISE_SIZE * NOISE_SIZE * sizeof(QRgb)); - QRgb *p = data; - float pos[3]; - for (int k = 0; k < NOISE_SIZE; ++k) { - pos[2] = k * (0x20 / (float)NOISE_SIZE); - for (int j = 0; j < NOISE_SIZE; ++j) { - for (int i = 0; i < NOISE_SIZE; ++i) { - for (int byte = 0; byte < 4; ++byte) { - pos[0] = (i + (byte & 1) * 16) * (0x20 / (float)NOISE_SIZE); - pos[1] = (j + (byte & 2) * 8) * (0x20 / (float)NOISE_SIZE); - *p |= (int)(128.0f * (noise3(pos) + 1.0f)) << (byte * 8); - } - ++p; - } - } - } - m_noise->load(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE, data); - delete[] data; - - m_mainCubemap = new GLRenderTargetCube(512); - - QStringList filter; - QList files; - - // Load all .png files as textures - m_currentTexture = 0; - filter = QStringList("*.png"); - files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable); - - foreach (QFileInfo file, files) { - GLTexture *texture = new GLTexture2D(file.absoluteFilePath(), qMin(256, m_maxTextureSize), qMin(256, m_maxTextureSize)); - if (texture->failed()) { - delete texture; - continue; - } - m_textures << texture; - m_renderOptions->addTexture(file.baseName()); - } - - if (m_textures.size() == 0) - m_textures << new GLTexture2D(qMin(64, m_maxTextureSize), qMin(64, m_maxTextureSize)); - - // Load all .fsh files as fragment shaders - m_currentShader = 0; - filter = QStringList("*.fsh"); - files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable); - foreach (QFileInfo file, files) { - QGLShaderProgram *program = new QGLShaderProgram; - QGLShader* shader = new QGLShader(QGLShader::Fragment); - shader->compileSourceFile(file.absoluteFilePath()); - // The program does not take ownership over the shaders, so store them in a vector so they can be deleted afterwards. - program->addShader(m_vertexShader); - program->addShader(shader); - if (!program->link()) { - qWarning("Failed to compile and link shader program"); - qWarning("Vertex shader log:"); - qWarning() << m_vertexShader->log(); - qWarning() << "Fragment shader log ( file =" << file.absoluteFilePath() << "):"; - qWarning() << shader->log(); - qWarning("Shader program log:"); - qWarning() << program->log(); - - delete shader; - delete program; - continue; - } - - m_fragmentShaders << shader; - m_programs << program; - m_renderOptions->addShader(file.baseName()); - - program->bind(); - m_cubemaps << ((program->uniformLocation("env") != -1) ? new GLRenderTargetCube(qMin(256, m_maxTextureSize)) : 0); - program->release(); - } - - if (m_programs.size() == 0) - m_programs << new QGLShaderProgram; - - m_renderOptions->emitParameterChanged(); -} - -static void loadMatrix(const QMatrix4x4& m) -{ - // static to prevent glLoadMatrixf to fail on certain drivers - static GLfloat mat[16]; - const qreal *data = m.constData(); - for (int index = 0; index < 16; ++index) - mat[index] = data[index]; - glLoadMatrixf(mat); -} - -static void multMatrix(const QMatrix4x4& m) -{ - // static to prevent glMultMatrixf to fail on certain drivers - static GLfloat mat[16]; - const qreal *data = m.constData(); - for (int index = 0; index < 16; ++index) - mat[index] = data[index]; - glMultMatrixf(mat); -} - -// If one of the boxes should not be rendered, set excludeBox to its index. -// If the main box should not be rendered, set excludeBox to -1. -void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox) -{ - QMatrix4x4 invView = view.inverted(); - - // If multi-texturing is supported, use three saplers. - if (glActiveTexture) { - glActiveTexture(GL_TEXTURE0); - m_textures[m_currentTexture]->bind(); - glActiveTexture(GL_TEXTURE2); - m_noise->bind(); - glActiveTexture(GL_TEXTURE1); - } else { - m_textures[m_currentTexture]->bind(); - } - - glDisable(GL_LIGHTING); - glDisable(GL_CULL_FACE); - - QMatrix4x4 viewRotation(view); - viewRotation(3, 0) = viewRotation(3, 1) = viewRotation(3, 2) = 0.0f; - viewRotation(0, 3) = viewRotation(1, 3) = viewRotation(2, 3) = 0.0f; - viewRotation(3, 3) = 1.0f; - loadMatrix(viewRotation); - glScalef(20.0f, 20.0f, 20.0f); - - // Don't render the environment if the environment texture can't be set for the correct sampler. - if (glActiveTexture) { - m_environment->bind(); - m_environmentProgram->bind(); - m_environmentProgram->setUniformValue("tex", GLint(0)); - m_environmentProgram->setUniformValue("env", GLint(1)); - m_environmentProgram->setUniformValue("noise", GLint(2)); - m_box->draw(); - m_environmentProgram->release(); - m_environment->unbind(); - } - - loadMatrix(view); - - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - - for (int i = 0; i < m_programs.size(); ++i) { - if (i == excludeBox) - continue; - - glPushMatrix(); - QMatrix4x4 m; - m.rotate(m_trackBalls[1].rotation()); - multMatrix(m); - - glRotatef(360.0f * i / m_programs.size(), 0.0f, 0.0f, 1.0f); - glTranslatef(2.0f, 0.0f, 0.0f); - glScalef(0.3f, 0.6f, 0.6f); - - if (glActiveTexture) { - if (m_dynamicCubemap && m_cubemaps[i]) - m_cubemaps[i]->bind(); - else - m_environment->bind(); - } - m_programs[i]->bind(); - m_programs[i]->setUniformValue("tex", GLint(0)); - m_programs[i]->setUniformValue("env", GLint(1)); - m_programs[i]->setUniformValue("noise", GLint(2)); - m_programs[i]->setUniformValue("view", view); - m_programs[i]->setUniformValue("invView", invView); - m_box->draw(); - m_programs[i]->release(); - - if (glActiveTexture) { - if (m_dynamicCubemap && m_cubemaps[i]) - m_cubemaps[i]->unbind(); - else - m_environment->unbind(); - } - glPopMatrix(); - } - - if (-1 != excludeBox) { - QMatrix4x4 m; - m.rotate(m_trackBalls[0].rotation()); - multMatrix(m); - - if (glActiveTexture) { - if (m_dynamicCubemap) - m_mainCubemap->bind(); - else - m_environment->bind(); - } - - m_programs[m_currentShader]->bind(); - m_programs[m_currentShader]->setUniformValue("tex", GLint(0)); - m_programs[m_currentShader]->setUniformValue("env", GLint(1)); - m_programs[m_currentShader]->setUniformValue("noise", GLint(2)); - m_programs[m_currentShader]->setUniformValue("view", view); - m_programs[m_currentShader]->setUniformValue("invView", invView); - m_box->draw(); - m_programs[m_currentShader]->release(); - - if (glActiveTexture) { - if (m_dynamicCubemap) - m_mainCubemap->unbind(); - else - m_environment->unbind(); - } - } - - if (glActiveTexture) { - glActiveTexture(GL_TEXTURE2); - m_noise->unbind(); - glActiveTexture(GL_TEXTURE0); - } - m_textures[m_currentTexture]->unbind(); -} - -void Scene::setStates() -{ - //glClearColor(0.25f, 0.25f, 0.5f, 1.0f); - - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - //glEnable(GL_COLOR_MATERIAL); - glEnable(GL_TEXTURE_2D); - glEnable(GL_NORMALIZE); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - setLights(); - - float materialSpecular[] = {0.5f, 0.5f, 0.5f, 1.0f}; - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, materialSpecular); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 32.0f); -} - -void Scene::setLights() -{ - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - //float lightColour[] = {1.0f, 1.0f, 1.0f, 1.0f}; - float lightDir[] = {0.0f, 0.0f, 1.0f, 0.0f}; - //glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColour); - //glLightfv(GL_LIGHT0, GL_SPECULAR, lightColour); - glLightfv(GL_LIGHT0, GL_POSITION, lightDir); - glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0f); - glEnable(GL_LIGHT0); -} - -void Scene::defaultStates() -{ - //glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - //glDisable(GL_COLOR_MATERIAL); - glDisable(GL_TEXTURE_2D); - glDisable(GL_LIGHT0); - glDisable(GL_NORMALIZE); - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - - glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 0.0f); - float defaultMaterialSpecular[] = {0.0f, 0.0f, 0.0f, 1.0f}; - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defaultMaterialSpecular); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f); -} - -void Scene::renderCubemaps() -{ - // To speed things up, only update the cubemaps for the small cubes every N frames. - const int N = (m_updateAllCubemaps ? 1 : 3); - - QMatrix4x4 mat; - GLRenderTargetCube::getProjectionMatrix(mat, 0.1f, 100.0f); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - loadMatrix(mat); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - QVector3D center; - - for (int i = m_frame % N; i < m_cubemaps.size(); i += N) { - if (0 == m_cubemaps[i]) - continue; - - float angle = 2.0f * PI * i / m_cubemaps.size(); - - center = m_trackBalls[1].rotation().rotatedVector(QVector3D(cos(angle), sin(angle), 0.0f)); - - for (int face = 0; face < 6; ++face) { - m_cubemaps[i]->begin(face); - - GLRenderTargetCube::getViewMatrix(mat, face); - QVector4D v = QVector4D(-center.x(), -center.y(), -center.z(), 1.0); - mat.setColumn(3, mat * v); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - renderBoxes(mat, i); - - m_cubemaps[i]->end(); - } - } - - for (int face = 0; face < 6; ++face) { - m_mainCubemap->begin(face); - GLRenderTargetCube::getViewMatrix(mat, face); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - renderBoxes(mat, -1); - - m_mainCubemap->end(); - } - - glPopMatrix(); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - - m_updateAllCubemaps = false; -} - -void Scene::drawBackground(QPainter *painter, const QRectF &) -{ - float width = float(painter->device()->width()); - float height = float(painter->device()->height()); - - painter->beginNativePainting(); - setStates(); - - if (m_dynamicCubemap) - renderCubemaps(); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - qgluPerspective(60.0, width / height, 0.01, 15.0); - - glMatrixMode(GL_MODELVIEW); - - QMatrix4x4 view; - view.rotate(m_trackBalls[2].rotation()); - view(2, 3) -= 2.0f * exp(m_distExp / 1200.0f); - renderBoxes(view); - - defaultStates(); - ++m_frame; - - painter->endNativePainting(); -} - -QPointF Scene::pixelPosToViewPos(const QPointF& p) -{ - return QPointF(2.0 * float(p.x()) / width() - 1.0, - 1.0 - 2.0 * float(p.y()) / height()); -} - -void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsScene::mouseMoveEvent(event); - if (event->isAccepted()) - return; - - if (event->buttons() & Qt::LeftButton) { - m_trackBalls[0].move(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - event->accept(); - } else { - m_trackBalls[0].release(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - } - - if (event->buttons() & Qt::RightButton) { - m_trackBalls[1].move(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - event->accept(); - } else { - m_trackBalls[1].release(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - } - - if (event->buttons() & Qt::MidButton) { - m_trackBalls[2].move(pixelPosToViewPos(event->scenePos()), QQuaternion()); - event->accept(); - } else { - m_trackBalls[2].release(pixelPosToViewPos(event->scenePos()), QQuaternion()); - } -} - -void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsScene::mousePressEvent(event); - if (event->isAccepted()) - return; - - if (event->buttons() & Qt::LeftButton) { - m_trackBalls[0].push(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - event->accept(); - } - - if (event->buttons() & Qt::RightButton) { - m_trackBalls[1].push(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - event->accept(); - } - - if (event->buttons() & Qt::MidButton) { - m_trackBalls[2].push(pixelPosToViewPos(event->scenePos()), QQuaternion()); - event->accept(); - } -} - -void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsScene::mouseReleaseEvent(event); - if (event->isAccepted()) - return; - - if (event->button() == Qt::LeftButton) { - m_trackBalls[0].release(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - event->accept(); - } - - if (event->button() == Qt::RightButton) { - m_trackBalls[1].release(pixelPosToViewPos(event->scenePos()), m_trackBalls[2].rotation().conjugate()); - event->accept(); - } - - if (event->button() == Qt::MidButton) { - m_trackBalls[2].release(pixelPosToViewPos(event->scenePos()), QQuaternion()); - event->accept(); - } -} - -void Scene::wheelEvent(QGraphicsSceneWheelEvent * event) -{ - QGraphicsScene::wheelEvent(event); - if (!event->isAccepted()) { - m_distExp += event->delta(); - if (m_distExp < -8 * 120) - m_distExp = -8 * 120; - if (m_distExp > 10 * 120) - m_distExp = 10 * 120; - event->accept(); - } -} - -void Scene::setShader(int index) -{ - if (index >= 0 && index < m_fragmentShaders.size()) - m_currentShader = index; -} - -void Scene::setTexture(int index) -{ - if (index >= 0 && index < m_textures.size()) - m_currentTexture = index; -} - -void Scene::toggleDynamicCubemap(int state) -{ - if ((m_dynamicCubemap = (state == Qt::Checked))) - m_updateAllCubemaps = true; -} - -void Scene::setColorParameter(const QString &name, QRgb color) -{ - // set the color in all programs - foreach (QGLShaderProgram *program, m_programs) { - program->bind(); - program->setUniformValue(program->uniformLocation(name), QColor(color)); - program->release(); - } -} - -void Scene::setFloatParameter(const QString &name, float value) -{ - // set the color in all programs - foreach (QGLShaderProgram *program, m_programs) { - program->bind(); - program->setUniformValue(program->uniformLocation(name), value); - program->release(); - } -} - -void Scene::newItem(ItemDialog::ItemType type) -{ - QSize size = sceneRect().size().toSize(); - switch (type) { - case ItemDialog::QtBoxItem: - addItem(new QtBox(64, rand() % (size.width() - 64) + 32, rand() % (size.height() - 64) + 32)); - break; - case ItemDialog::CircleItem: - addItem(new CircleItem(64, rand() % (size.width() - 64) + 32, rand() % (size.height() - 64) + 32)); - break; - case ItemDialog::SquareItem: - addItem(new SquareItem(64, rand() % (size.width() - 64) + 32, rand() % (size.height() - 64) + 32)); - break; - default: - break; - } -} diff --git a/examples/graphicsview/boxes/scene.h b/examples/graphicsview/boxes/scene.h deleted file mode 100644 index 9410f7f994..0000000000 --- a/examples/graphicsview/boxes/scene.h +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SCENE_H -#define SCENE_H - -//#include -#include "glextensions.h" - -#include -#include - -#include "roundedbox.h" -#include "gltrianglemesh.h" -#include "trackball.h" -#include "glbuffers.h" -#include "qtbox.h" - -#define PI 3.14159265358979 - -QT_BEGIN_NAMESPACE -class QMatrix4x4; -QT_END_NAMESPACE - -class ParameterEdit : public QWidget -{ -public: - virtual void emitChange() = 0; -}; - -class ColorEdit : public ParameterEdit -{ - Q_OBJECT -public: - ColorEdit(QRgb initialColor, int id); - QRgb color() const {return m_color;} - virtual void emitChange() {emit colorChanged(m_color, m_id);} -public slots: - void editDone(); -signals: - void colorChanged(QRgb color, int id); -protected: - virtual void mousePressEvent(QMouseEvent *event); - void setColor(QRgb color); // also emits colorChanged() -private: - QGraphicsScene *m_dialogParentScene; - QLineEdit *m_lineEdit; - QFrame *m_button; - QRgb m_color; - int m_id; -}; - -class FloatEdit : public ParameterEdit -{ - Q_OBJECT -public: - FloatEdit(float initialValue, int id); - float value() const {return m_value;} - virtual void emitChange() {emit valueChanged(m_value, m_id);} -public slots: - void editDone(); -signals: - void valueChanged(float value, int id); -private: - QGraphicsScene *m_dialogParentScene; - QLineEdit *m_lineEdit; - float m_value; - int m_id; -}; - -class GraphicsWidget : public QGraphicsProxyWidget -{ -public: - GraphicsWidget() : QGraphicsProxyWidget(0, Qt::Window) {} -protected: - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - virtual void resizeEvent(QGraphicsSceneResizeEvent *event); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -}; - -class TwoSidedGraphicsWidget : public QObject -{ - Q_OBJECT -public: - TwoSidedGraphicsWidget(QGraphicsScene *scene); - void setWidget(int index, QWidget *widget); - QWidget *widget(int index); -public slots: - void flip(); -protected slots: - void animateFlip(); -private: - GraphicsWidget *m_proxyWidgets[2]; - int m_current; - int m_angle; // angle in degrees - int m_delta; -}; - -class RenderOptionsDialog : public QDialog -{ - Q_OBJECT -public: - RenderOptionsDialog(); - int addTexture(const QString &name); - int addShader(const QString &name); - void emitParameterChanged(); -protected slots: - void setColorParameter(QRgb color, int id); - void setFloatParameter(float value, int id); -signals: - void dynamicCubemapToggled(int); - void colorParameterChanged(const QString &, QRgb); - void floatParameterChanged(const QString &, float); - void textureChanged(int); - void shaderChanged(int); - void doubleClicked(); -protected: - virtual void mouseDoubleClickEvent(QMouseEvent *event); - - QVector m_parameterNames; - QComboBox *m_textureCombo; - QComboBox *m_shaderCombo; - QVector m_parameterEdits; -}; - -class ItemDialog : public QDialog -{ - Q_OBJECT -public: - enum ItemType { - QtBoxItem, - CircleItem, - SquareItem, - }; - - ItemDialog(); -public slots: - void triggerNewQtBox(); - void triggerNewCircleItem(); - void triggerNewSquareItem(); -signals: - void doubleClicked(); - void newItemTriggered(ItemDialog::ItemType type); -protected: - virtual void mouseDoubleClickEvent(QMouseEvent *event); -}; - -class Scene : public QGraphicsScene -{ - Q_OBJECT -public: - Scene(int width, int height, int maxTextureSize); - ~Scene(); - virtual void drawBackground(QPainter *painter, const QRectF &rect); - -public slots: - void setShader(int index); - void setTexture(int index); - void toggleDynamicCubemap(int state); - void setColorParameter(const QString &name, QRgb color); - void setFloatParameter(const QString &name, float value); - void newItem(ItemDialog::ItemType type); -protected: - void renderBoxes(const QMatrix4x4 &view, int excludeBox = -2); - void setStates(); - void setLights(); - void defaultStates(); - void renderCubemaps(); - - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - virtual void wheelEvent(QGraphicsSceneWheelEvent * event); -private: - void initGL(); - QPointF pixelPosToViewPos(const QPointF& p); - - QTime m_time; - int m_lastTime; - int m_mouseEventTime; - int m_distExp; - int m_frame; - int m_maxTextureSize; - - int m_currentShader; - int m_currentTexture; - bool m_dynamicCubemap; - bool m_updateAllCubemaps; - - RenderOptionsDialog *m_renderOptions; - ItemDialog *m_itemDialog; - QTimer *m_timer; - GLRoundedBox *m_box; - TrackBall m_trackBalls[3]; - QVector m_textures; - GLTextureCube *m_environment; - GLTexture3D *m_noise; - GLRenderTargetCube *m_mainCubemap; - QVector m_cubemaps; - QVector m_programs; - QGLShader *m_vertexShader; - QVector m_fragmentShaders; - QGLShader *m_environmentShader; - QGLShaderProgram *m_environmentProgram; -}; - -#endif diff --git a/examples/graphicsview/boxes/smiley.png b/examples/graphicsview/boxes/smiley.png deleted file mode 100644 index 41cfda6b23..0000000000 Binary files a/examples/graphicsview/boxes/smiley.png and /dev/null differ diff --git a/examples/graphicsview/boxes/square.jpg b/examples/graphicsview/boxes/square.jpg deleted file mode 100644 index 03f53bd530..0000000000 Binary files a/examples/graphicsview/boxes/square.jpg and /dev/null differ diff --git a/examples/graphicsview/boxes/trackball.cpp b/examples/graphicsview/boxes/trackball.cpp deleted file mode 100644 index b0e9c44628..0000000000 --- a/examples/graphicsview/boxes/trackball.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "trackball.h" -#include "scene.h" - -//============================================================================// -// TrackBall // -//============================================================================// - -TrackBall::TrackBall(TrackMode mode) - : m_angularVelocity(0) - , m_paused(false) - , m_pressed(false) - , m_mode(mode) -{ - m_axis = QVector3D(0, 1, 0); - m_rotation = QQuaternion(); - m_lastTime = QTime::currentTime(); -} - -TrackBall::TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode) - : m_axis(axis) - , m_angularVelocity(angularVelocity) - , m_paused(false) - , m_pressed(false) - , m_mode(mode) -{ - m_rotation = QQuaternion(); - m_lastTime = QTime::currentTime(); -} - -void TrackBall::push(const QPointF& p, const QQuaternion &) -{ - m_rotation = rotation(); - m_pressed = true; - m_lastTime = QTime::currentTime(); - m_lastPos = p; - m_angularVelocity = 0.0f; -} - -void TrackBall::move(const QPointF& p, const QQuaternion &transformation) -{ - if (!m_pressed) - return; - - QTime currentTime = QTime::currentTime(); - int msecs = m_lastTime.msecsTo(currentTime); - if (msecs <= 20) - return; - - switch (m_mode) { - case Plane: - { - QLineF delta(m_lastPos, p); - m_angularVelocity = 180*delta.length() / (PI*msecs); - m_axis = QVector3D(-delta.dy(), delta.dx(), 0.0f).normalized(); - m_axis = transformation.rotatedVector(m_axis); - m_rotation = QQuaternion::fromAxisAndAngle(m_axis, 180 / PI * delta.length()) * m_rotation; - } - break; - case Sphere: - { - QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f); - float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D); - if (sqrZ > 0) - lastPos3D.setZ(sqrt(sqrZ)); - else - lastPos3D.normalize(); - - QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f); - sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D); - if (sqrZ > 0) - currentPos3D.setZ(sqrt(sqrZ)); - else - currentPos3D.normalize(); - - m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D); - float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis))); - - m_angularVelocity = angle / msecs; - m_axis.normalize(); - m_axis = transformation.rotatedVector(m_axis); - m_rotation = QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation; - } - break; - } - - - m_lastPos = p; - m_lastTime = currentTime; -} - -void TrackBall::release(const QPointF& p, const QQuaternion &transformation) -{ - // Calling move() caused the rotation to stop if the framerate was too low. - move(p, transformation); - m_pressed = false; -} - -void TrackBall::start() -{ - m_lastTime = QTime::currentTime(); - m_paused = false; -} - -void TrackBall::stop() -{ - m_rotation = rotation(); - m_paused = true; -} - -QQuaternion TrackBall::rotation() const -{ - if (m_paused || m_pressed) - return m_rotation; - - QTime currentTime = QTime::currentTime(); - float angle = m_angularVelocity * m_lastTime.msecsTo(currentTime); - return QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation; -} - diff --git a/examples/graphicsview/boxes/trackball.h b/examples/graphicsview/boxes/trackball.h deleted file mode 100644 index 42a233c4f8..0000000000 --- a/examples/graphicsview/boxes/trackball.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TRACKBALL_H -#define TRACKBALL_H - -#include - -#include -#include - -class TrackBall -{ -public: - enum TrackMode - { - Plane, - Sphere, - }; - TrackBall(TrackMode mode = Sphere); - TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode = Sphere); - // coordinates in [-1,1]x[-1,1] - void push(const QPointF& p, const QQuaternion &transformation); - void move(const QPointF& p, const QQuaternion &transformation); - void release(const QPointF& p, const QQuaternion &transformation); - void start(); // starts clock - void stop(); // stops clock - QQuaternion rotation() const; -private: - QQuaternion m_rotation; - QVector3D m_axis; - float m_angularVelocity; - - QPointF m_lastPos; - QTime m_lastTime; - bool m_paused; - bool m_pressed; - TrackMode m_mode; -}; - -#endif diff --git a/examples/graphicsview/boxes/wood.fsh b/examples/graphicsview/boxes/wood.fsh deleted file mode 100644 index a722bac869..0000000000 --- a/examples/graphicsview/boxes/wood.fsh +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -varying vec3 position, normal; -varying vec4 specular, ambient, diffuse, lightDirection; - -uniform sampler2D tex; -uniform sampler3D noise; - -//const vec4 woodColors[2] = {vec4(0.37,0.24,0.20,1), vec4(0.8,0.6,0.4,1)}; -uniform vec4 woodColors[2]; -//const float woodTubulence = 0.1; -uniform float woodTubulence; - -void main() -{ - float r = length(gl_TexCoord[1].yz); - r += woodTubulence * texture3D(noise, 0.25 * gl_TexCoord[1].xyz).x; - - vec3 N = normalize(normal); - // assume directional light - - gl_MaterialParameters M = gl_FrontMaterial; - - float NdotL = dot(N, lightDirection.xyz); - float RdotL = dot(reflect(normalize(position), N), lightDirection.xyz); - - float f = fract(16.0 * r); - vec4 unlitColor = mix(woodColors[0], woodColors[1], min(1.25 * f, 5.0 - 5.0 * f)); - gl_FragColor = (ambient + diffuse * max(NdotL, 0.0)) * unlitColor + - M.specular * specular * pow(max(RdotL, 0.0), M.shininess); -} diff --git a/examples/graphicsview/chip/chip.cpp b/examples/graphicsview/chip/chip.cpp deleted file mode 100644 index 665daea1dc..0000000000 --- a/examples/graphicsview/chip/chip.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chip.h" - -#include - -Chip::Chip(const QColor &color, int x, int y) -{ - this->x = x; - this->y = y; - this->color = color; - setZValue((x + y) % 2); - - setFlags(ItemIsSelectable | ItemIsMovable); - setAcceptHoverEvents(true); -} - -QRectF Chip::boundingRect() const -{ - return QRectF(0, 0, 110, 70); -} - -QPainterPath Chip::shape() const -{ - QPainterPath path; - path.addRect(14, 14, 82, 42); - return path; -} - -void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(widget); - - QColor fillColor = (option->state & QStyle::State_Selected) ? color.dark(150) : color; - if (option->state & QStyle::State_MouseOver) - fillColor = fillColor.light(125); - - const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform()); - if (lod < 0.2) { - if (lod < 0.125) { - painter->fillRect(QRectF(0, 0, 110, 70), fillColor); - return; - } - - QBrush b = painter->brush(); - painter->setBrush(fillColor); - painter->drawRect(13, 13, 97, 57); - painter->setBrush(b); - return; - } - - QPen oldPen = painter->pen(); - QPen pen = oldPen; - int width = 0; - if (option->state & QStyle::State_Selected) - width += 2; - - pen.setWidth(width); - QBrush b = painter->brush(); - painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100))); - - painter->drawRect(QRect(14, 14, 79, 39)); - painter->setBrush(b); - - if (lod >= 1) { - painter->setPen(QPen(Qt::gray, 1)); - painter->drawLine(15, 54, 94, 54); - painter->drawLine(94, 53, 94, 15); - painter->setPen(QPen(Qt::black, 0)); - } - - // Draw text - if (lod >= 2) { - QFont font("Times", 10); - font.setStyleStrategy(QFont::ForceOutline); - painter->setFont(font); - painter->save(); - painter->scale(0.1, 0.1); - painter->drawText(170, 180, QString("Model: VSC-2000 (Very Small Chip) at %1x%2").arg(x).arg(y)); - painter->drawText(170, 200, QString("Serial number: DLWR-WEER-123L-ZZ33-SDSJ")); - painter->drawText(170, 220, QString("Manufacturer: Chip Manufacturer")); - painter->restore(); - } - - // Draw lines - QVarLengthArray lines; - if (lod >= 0.5) { - for (int i = 0; i <= 10; i += (lod > 0.5 ? 1 : 2)) { - lines.append(QLineF(18 + 7 * i, 13, 18 + 7 * i, 5)); - lines.append(QLineF(18 + 7 * i, 54, 18 + 7 * i, 62)); - } - for (int i = 0; i <= 6; i += (lod > 0.5 ? 1 : 2)) { - lines.append(QLineF(5, 18 + i * 5, 13, 18 + i * 5)); - lines.append(QLineF(94, 18 + i * 5, 102, 18 + i * 5)); - } - } - if (lod >= 0.4) { - const QLineF lineData[] = { - QLineF(25, 35, 35, 35), - QLineF(35, 30, 35, 40), - QLineF(35, 30, 45, 35), - QLineF(35, 40, 45, 35), - QLineF(45, 30, 45, 40), - QLineF(45, 35, 55, 35) - }; - lines.append(lineData, 6); - } - painter->drawLines(lines.data(), lines.size()); - - // Draw red ink - if (stuff.size() > 1) { - QPen p = painter->pen(); - painter->setPen(QPen(Qt::red, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter->setBrush(Qt::NoBrush); - QPainterPath path; - path.moveTo(stuff.first()); - for (int i = 1; i < stuff.size(); ++i) - path.lineTo(stuff.at(i)); - painter->drawPath(path); - painter->setPen(p); - } -} - -void Chip::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsItem::mousePressEvent(event); - update(); -} - -void Chip::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->modifiers() & Qt::ShiftModifier) { - stuff << event->pos(); - update(); - return; - } - QGraphicsItem::mouseMoveEvent(event); -} - -void Chip::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsItem::mouseReleaseEvent(event); - update(); -} diff --git a/examples/graphicsview/chip/chip.h b/examples/graphicsview/chip/chip.h deleted file mode 100644 index 4c1cfae37d..0000000000 --- a/examples/graphicsview/chip/chip.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHIP_H -#define CHIP_H - -#include -#include - -class Chip : public QGraphicsItem -{ -public: - Chip(const QColor &color, int x, int y); - - QRectF boundingRect() const; - QPainterPath shape() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - -private: - int x, y; - QColor color; - QVector stuff; -}; - -#endif diff --git a/examples/graphicsview/chip/chip.pro b/examples/graphicsview/chip/chip.pro deleted file mode 100644 index afe748946e..0000000000 --- a/examples/graphicsview/chip/chip.pro +++ /dev/null @@ -1,21 +0,0 @@ -RESOURCES += images.qrc - -HEADERS += mainwindow.h view.h chip.h -SOURCES += main.cpp -SOURCES += mainwindow.cpp view.cpp chip.cpp - -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport -contains(QT_CONFIG, opengl):QT += opengl - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/chip -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.png *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/chip -INSTALLS += target sources - diff --git a/examples/graphicsview/chip/fileprint.png b/examples/graphicsview/chip/fileprint.png deleted file mode 100644 index ba7c02dc18..0000000000 Binary files a/examples/graphicsview/chip/fileprint.png and /dev/null differ diff --git a/examples/graphicsview/chip/images.qrc b/examples/graphicsview/chip/images.qrc deleted file mode 100644 index c7cdf0c4c0..0000000000 --- a/examples/graphicsview/chip/images.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - qt4logo.png - zoomin.png - zoomout.png - rotateleft.png - rotateright.png - fileprint.png - - diff --git a/examples/graphicsview/chip/main.cpp b/examples/graphicsview/chip/main.cpp deleted file mode 100644 index 689c806be8..0000000000 --- a/examples/graphicsview/chip/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" - -#include - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(images); - - QApplication app(argc, argv); - app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - - MainWindow window; - window.show(); - - return app.exec(); -} diff --git a/examples/graphicsview/chip/mainwindow.cpp b/examples/graphicsview/chip/mainwindow.cpp deleted file mode 100644 index 3d0d295225..0000000000 --- a/examples/graphicsview/chip/mainwindow.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" -#include "view.h" -#include "chip.h" - -#include - -MainWindow::MainWindow(QWidget *parent) - : QWidget(parent) -{ - populateScene(); - - h1Splitter = new QSplitter; - h2Splitter = new QSplitter; - - QSplitter *vSplitter = new QSplitter; - vSplitter->setOrientation(Qt::Vertical); - vSplitter->addWidget(h1Splitter); - vSplitter->addWidget(h2Splitter); - - View *view = new View("Top left view"); - view->view()->setScene(scene); - h1Splitter->addWidget(view); - - view = new View("Top right view"); - view->view()->setScene(scene); - h1Splitter->addWidget(view); - - view = new View("Bottom left view"); - view->view()->setScene(scene); - h2Splitter->addWidget(view); - - view = new View("Bottom right view"); - view->view()->setScene(scene); - h2Splitter->addWidget(view); - - QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(vSplitter); - setLayout(layout); - - setWindowTitle(tr("Chip Example")); -} - -void MainWindow::populateScene() -{ - scene = new QGraphicsScene; - - QImage image(":/qt4logo.png"); - - // Populate scene - int xx = 0; - int nitems = 0; - for (int i = -11000; i < 11000; i += 110) { - ++xx; - int yy = 0; - for (int j = -7000; j < 7000; j += 70) { - ++yy; - qreal x = (i + 11000) / 22000.0; - qreal y = (j + 7000) / 14000.0; - - QColor color(image.pixel(int(image.width() * x), int(image.height() * y))); - QGraphicsItem *item = new Chip(color, xx, yy); - item->setPos(QPointF(i, j)); - scene->addItem(item); - - ++nitems; - } - } -} diff --git a/examples/graphicsview/chip/mainwindow.h b/examples/graphicsview/chip/mainwindow.h deleted file mode 100644 index 18e27a0019..0000000000 --- a/examples/graphicsview/chip/mainwindow.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsScene) -QT_FORWARD_DECLARE_CLASS(QGraphicsView) -QT_FORWARD_DECLARE_CLASS(QLabel) -QT_FORWARD_DECLARE_CLASS(QSlider) -QT_FORWARD_DECLARE_CLASS(QSplitter) - -class MainWindow : public QWidget -{ - Q_OBJECT -public: - MainWindow(QWidget *parent = 0); - -private: - void setupMatrix(); - void populateScene(); - - QGraphicsScene *scene; - QSplitter *h1Splitter; - QSplitter *h2Splitter; -}; - -#endif diff --git a/examples/graphicsview/chip/qt4logo.png b/examples/graphicsview/chip/qt4logo.png deleted file mode 100644 index 157e86ed64..0000000000 Binary files a/examples/graphicsview/chip/qt4logo.png and /dev/null differ diff --git a/examples/graphicsview/chip/rotateleft.png b/examples/graphicsview/chip/rotateleft.png deleted file mode 100644 index 8cfa931986..0000000000 Binary files a/examples/graphicsview/chip/rotateleft.png and /dev/null differ diff --git a/examples/graphicsview/chip/rotateright.png b/examples/graphicsview/chip/rotateright.png deleted file mode 100644 index ec5e8664a1..0000000000 Binary files a/examples/graphicsview/chip/rotateright.png and /dev/null differ diff --git a/examples/graphicsview/chip/view.cpp b/examples/graphicsview/chip/view.cpp deleted file mode 100644 index b755b8eadd..0000000000 --- a/examples/graphicsview/chip/view.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "view.h" - -#include -#ifndef QT_NO_PRINTER -#include -#include -#endif -#ifndef QT_NO_OPENGL -#include -#endif -#include - -void GraphicsView::wheelEvent(QWheelEvent *e) -{ - if (e->modifiers() & Qt::ControlModifier) { - if (e->delta() > 0) - view->zoomIn(6); - else - view->zoomOut(6); - e->accept(); - } else { - QGraphicsView::wheelEvent(e); - } -} - -View::View(const QString &name, QWidget *parent) - : QFrame(parent) -{ - setFrameStyle(Sunken | StyledPanel); - graphicsView = new GraphicsView(this); - graphicsView->setRenderHint(QPainter::Antialiasing, false); - graphicsView->setDragMode(QGraphicsView::RubberBandDrag); - graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState); - graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); - graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - - int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize); - QSize iconSize(size, size); - - QToolButton *zoomInIcon = new QToolButton; - zoomInIcon->setAutoRepeat(true); - zoomInIcon->setAutoRepeatInterval(33); - zoomInIcon->setAutoRepeatDelay(0); - zoomInIcon->setIcon(QPixmap(":/zoomin.png")); - zoomInIcon->setIconSize(iconSize); - QToolButton *zoomOutIcon = new QToolButton; - zoomOutIcon->setAutoRepeat(true); - zoomOutIcon->setAutoRepeatInterval(33); - zoomOutIcon->setAutoRepeatDelay(0); - zoomOutIcon->setIcon(QPixmap(":/zoomout.png")); - zoomOutIcon->setIconSize(iconSize); - zoomSlider = new QSlider; - zoomSlider->setMinimum(0); - zoomSlider->setMaximum(500); - zoomSlider->setValue(250); - zoomSlider->setTickPosition(QSlider::TicksRight); - - // Zoom slider layout - QVBoxLayout *zoomSliderLayout = new QVBoxLayout; - zoomSliderLayout->addWidget(zoomInIcon); - zoomSliderLayout->addWidget(zoomSlider); - zoomSliderLayout->addWidget(zoomOutIcon); - - QToolButton *rotateLeftIcon = new QToolButton; - rotateLeftIcon->setIcon(QPixmap(":/rotateleft.png")); - rotateLeftIcon->setIconSize(iconSize); - QToolButton *rotateRightIcon = new QToolButton; - rotateRightIcon->setIcon(QPixmap(":/rotateright.png")); - rotateRightIcon->setIconSize(iconSize); - rotateSlider = new QSlider; - rotateSlider->setOrientation(Qt::Horizontal); - rotateSlider->setMinimum(-360); - rotateSlider->setMaximum(360); - rotateSlider->setValue(0); - rotateSlider->setTickPosition(QSlider::TicksBelow); - - // Rotate slider layout - QHBoxLayout *rotateSliderLayout = new QHBoxLayout; - rotateSliderLayout->addWidget(rotateLeftIcon); - rotateSliderLayout->addWidget(rotateSlider); - rotateSliderLayout->addWidget(rotateRightIcon); - - resetButton = new QToolButton; - resetButton->setText(tr("0")); - resetButton->setEnabled(false); - - // Label layout - QHBoxLayout *labelLayout = new QHBoxLayout; - label = new QLabel(name); - label2 = new QLabel(tr("Pointer Mode")); - selectModeButton = new QToolButton; - selectModeButton->setText(tr("Select")); - selectModeButton->setCheckable(true); - selectModeButton->setChecked(true); - dragModeButton = new QToolButton; - dragModeButton->setText(tr("Drag")); - dragModeButton->setCheckable(true); - dragModeButton->setChecked(false); - antialiasButton = new QToolButton; - antialiasButton->setText(tr("Antialiasing")); - antialiasButton->setCheckable(true); - antialiasButton->setChecked(false); - openGlButton = new QToolButton; - openGlButton->setText(tr("OpenGL")); - openGlButton->setCheckable(true); -#ifndef QT_NO_OPENGL - openGlButton->setEnabled(QGLFormat::hasOpenGL()); -#else - openGlButton->setEnabled(false); -#endif - printButton = new QToolButton; - printButton->setIcon(QIcon(QPixmap(":/fileprint.png"))); - - QButtonGroup *pointerModeGroup = new QButtonGroup; - pointerModeGroup->setExclusive(true); - pointerModeGroup->addButton(selectModeButton); - pointerModeGroup->addButton(dragModeButton); - - labelLayout->addWidget(label); - labelLayout->addStretch(); - labelLayout->addWidget(label2); - labelLayout->addWidget(selectModeButton); - labelLayout->addWidget(dragModeButton); - labelLayout->addStretch(); - labelLayout->addWidget(antialiasButton); - labelLayout->addWidget(openGlButton); - labelLayout->addWidget(printButton); - - QGridLayout *topLayout = new QGridLayout; - topLayout->addLayout(labelLayout, 0, 0); - topLayout->addWidget(graphicsView, 1, 0); - topLayout->addLayout(zoomSliderLayout, 1, 1); - topLayout->addLayout(rotateSliderLayout, 2, 0); - topLayout->addWidget(resetButton, 2, 1); - setLayout(topLayout); - - connect(resetButton, SIGNAL(clicked()), this, SLOT(resetView())); - connect(zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setupMatrix())); - connect(rotateSlider, SIGNAL(valueChanged(int)), this, SLOT(setupMatrix())); - connect(graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled())); - connect(graphicsView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled())); - connect(selectModeButton, SIGNAL(toggled(bool)), this, SLOT(togglePointerMode())); - connect(dragModeButton, SIGNAL(toggled(bool)), this, SLOT(togglePointerMode())); - connect(antialiasButton, SIGNAL(toggled(bool)), this, SLOT(toggleAntialiasing())); - connect(openGlButton, SIGNAL(toggled(bool)), this, SLOT(toggleOpenGL())); - connect(rotateLeftIcon, SIGNAL(clicked()), this, SLOT(rotateLeft())); - connect(rotateRightIcon, SIGNAL(clicked()), this, SLOT(rotateRight())); - connect(zoomInIcon, SIGNAL(clicked()), this, SLOT(zoomIn())); - connect(zoomOutIcon, SIGNAL(clicked()), this, SLOT(zoomOut())); - connect(printButton, SIGNAL(clicked()), this, SLOT(print())); - - setupMatrix(); -} - -QGraphicsView *View::view() const -{ - return static_cast(graphicsView); -} - -void View::resetView() -{ - zoomSlider->setValue(250); - rotateSlider->setValue(0); - setupMatrix(); - graphicsView->ensureVisible(QRectF(0, 0, 0, 0)); - - resetButton->setEnabled(false); -} - -void View::setResetButtonEnabled() -{ - resetButton->setEnabled(true); -} - -void View::setupMatrix() -{ - qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); - - QMatrix matrix; - matrix.scale(scale, scale); - matrix.rotate(rotateSlider->value()); - - graphicsView->setMatrix(matrix); - setResetButtonEnabled(); -} - -void View::togglePointerMode() -{ - graphicsView->setDragMode(selectModeButton->isChecked() - ? QGraphicsView::RubberBandDrag - : QGraphicsView::ScrollHandDrag); - graphicsView->setInteractive(selectModeButton->isChecked()); -} - -void View::toggleOpenGL() -{ -#ifndef QT_NO_OPENGL - graphicsView->setViewport(openGlButton->isChecked() ? new QGLWidget(QGLFormat(QGL::SampleBuffers)) : new QWidget); -#endif -} - -void View::toggleAntialiasing() -{ - graphicsView->setRenderHint(QPainter::Antialiasing, antialiasButton->isChecked()); -} - -void View::print() -{ -#ifndef QT_NO_PRINTER - QPrinter printer; - QPrintDialog dialog(&printer, this); - if (dialog.exec() == QDialog::Accepted) { - QPainter painter(&printer); - graphicsView->render(&painter); - } -#endif -} - -void View::zoomIn(int level) -{ - zoomSlider->setValue(zoomSlider->value() + level); -} - -void View::zoomOut(int level) -{ - zoomSlider->setValue(zoomSlider->value() - level); -} - -void View::rotateLeft() -{ - rotateSlider->setValue(rotateSlider->value() - 10); -} - -void View::rotateRight() -{ - rotateSlider->setValue(rotateSlider->value() + 10); -} - diff --git a/examples/graphicsview/chip/view.h b/examples/graphicsview/chip/view.h deleted file mode 100644 index 7753efff55..0000000000 --- a/examples/graphicsview/chip/view.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VIEW_H -#define VIEW_H - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QLabel) -QT_FORWARD_DECLARE_CLASS(QSlider) -QT_FORWARD_DECLARE_CLASS(QToolButton) - -class View; - -class GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(View *v) : QGraphicsView(), view(v) { } - -protected: - void wheelEvent(QWheelEvent *); - -private: - View *view; -}; - -class View : public QFrame -{ - Q_OBJECT -public: - View(const QString &name, QWidget *parent = 0); - - QGraphicsView *view() const; - -public slots: - void zoomIn(int level = 1); - void zoomOut(int level = 1); - -private slots: - void resetView(); - void setResetButtonEnabled(); - void setupMatrix(); - void togglePointerMode(); - void toggleOpenGL(); - void toggleAntialiasing(); - void print(); - void rotateLeft(); - void rotateRight(); - -private: - GraphicsView *graphicsView; - QLabel *label; - QLabel *label2; - QToolButton *selectModeButton; - QToolButton *dragModeButton; - QToolButton *openGlButton; - QToolButton *antialiasButton; - QToolButton *printButton; - QToolButton *resetButton; - QSlider *zoomSlider; - QSlider *rotateSlider; -}; - -#endif diff --git a/examples/graphicsview/chip/zoomin.png b/examples/graphicsview/chip/zoomin.png deleted file mode 100644 index 8b0daeea48..0000000000 Binary files a/examples/graphicsview/chip/zoomin.png and /dev/null differ diff --git a/examples/graphicsview/chip/zoomout.png b/examples/graphicsview/chip/zoomout.png deleted file mode 100644 index 1575dd24f6..0000000000 Binary files a/examples/graphicsview/chip/zoomout.png and /dev/null differ diff --git a/examples/graphicsview/collidingmice/collidingmice.desktop b/examples/graphicsview/collidingmice/collidingmice.desktop deleted file mode 100644 index f0064e7112..0000000000 --- a/examples/graphicsview/collidingmice/collidingmice.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Colliding Mice -Exec=/opt/usr/bin/collidingmice -Icon=collidingmice -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/collidingmice/collidingmice.pro b/examples/graphicsview/collidingmice/collidingmice.pro deleted file mode 100644 index d8346023ba..0000000000 --- a/examples/graphicsview/collidingmice/collidingmice.pro +++ /dev/null @@ -1,17 +0,0 @@ -HEADERS += \ - mouse.h -SOURCES += \ - main.cpp \ - mouse.cpp - -RESOURCES += \ - mice.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/collidingmice -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS collidingmice.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/collidingmice -INSTALLS += target sources - -QT += widgets - diff --git a/examples/graphicsview/collidingmice/images/cheese.jpg b/examples/graphicsview/collidingmice/images/cheese.jpg deleted file mode 100644 index dea5795fd0..0000000000 Binary files a/examples/graphicsview/collidingmice/images/cheese.jpg and /dev/null differ diff --git a/examples/graphicsview/collidingmice/main.cpp b/examples/graphicsview/collidingmice/main.cpp deleted file mode 100644 index 63b14cf075..0000000000 --- a/examples/graphicsview/collidingmice/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "mouse.h" - -#include - -#include - -static const int MouseCount = 7; - -//! [0] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); -//! [0] - -//! [1] - QGraphicsScene scene; - scene.setSceneRect(-300, -300, 600, 600); -//! [1] //! [2] - scene.setItemIndexMethod(QGraphicsScene::NoIndex); -//! [2] - -//! [3] - for (int i = 0; i < MouseCount; ++i) { - Mouse *mouse = new Mouse; - mouse->setPos(::sin((i * 6.28) / MouseCount) * 200, - ::cos((i * 6.28) / MouseCount) * 200); - scene.addItem(mouse); - } -//! [3] - -//! [4] - QGraphicsView view(&scene); - view.setRenderHint(QPainter::Antialiasing); - view.setBackgroundBrush(QPixmap(":/images/cheese.jpg")); -//! [4] //! [5] - view.setCacheMode(QGraphicsView::CacheBackground); - view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - view.setDragMode(QGraphicsView::ScrollHandDrag); -//! [5] //! [6] - view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice")); - view.resize(400, 300); - view.show(); - - QTimer timer; - QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance())); - timer.start(1000 / 33); - - return app.exec(); -} -//! [6] diff --git a/examples/graphicsview/collidingmice/mice.qrc b/examples/graphicsview/collidingmice/mice.qrc deleted file mode 100644 index accdb4d0a6..0000000000 --- a/examples/graphicsview/collidingmice/mice.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/cheese.jpg - - diff --git a/examples/graphicsview/collidingmice/mouse.cpp b/examples/graphicsview/collidingmice/mouse.cpp deleted file mode 100644 index 2ffbeff6d5..0000000000 --- a/examples/graphicsview/collidingmice/mouse.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "mouse.h" - -#include -#include -#include - -#include - -static const double Pi = 3.14159265358979323846264338327950288419717; -static double TwoPi = 2.0 * Pi; - -static qreal normalizeAngle(qreal angle) -{ - while (angle < 0) - angle += TwoPi; - while (angle > TwoPi) - angle -= TwoPi; - return angle; -} - -//! [0] -Mouse::Mouse() - : angle(0), speed(0), mouseEyeDirection(0), - color(qrand() % 256, qrand() % 256, qrand() % 256) -{ - setRotation(qrand() % (360 * 16)); -} -//! [0] - -//! [1] -QRectF Mouse::boundingRect() const -{ - qreal adjust = 0.5; - return QRectF(-18 - adjust, -22 - adjust, - 36 + adjust, 60 + adjust); -} -//! [1] - -//! [2] -QPainterPath Mouse::shape() const -{ - QPainterPath path; - path.addRect(-10, -20, 20, 40); - return path; -} -//! [2] - -//! [3] -void Mouse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - // Body - painter->setBrush(color); - painter->drawEllipse(-10, -20, 20, 40); - - // Eyes - painter->setBrush(Qt::white); - painter->drawEllipse(-10, -17, 8, 8); - painter->drawEllipse(2, -17, 8, 8); - - // Nose - painter->setBrush(Qt::black); - painter->drawEllipse(QRectF(-2, -22, 4, 4)); - - // Pupils - painter->drawEllipse(QRectF(-8.0 + mouseEyeDirection, -17, 4, 4)); - painter->drawEllipse(QRectF(4.0 + mouseEyeDirection, -17, 4, 4)); - - // Ears - painter->setBrush(scene()->collidingItems(this).isEmpty() ? Qt::darkYellow : Qt::red); - painter->drawEllipse(-17, -12, 16, 16); - painter->drawEllipse(1, -12, 16, 16); - - // Tail - QPainterPath path(QPointF(0, 20)); - path.cubicTo(-5, 22, -5, 22, 0, 25); - path.cubicTo(5, 27, 5, 32, 0, 30); - path.cubicTo(-5, 32, -5, 42, 0, 35); - painter->setBrush(Qt::NoBrush); - painter->drawPath(path); -} -//! [3] - -//! [4] -void Mouse::advance(int step) -{ - if (!step) - return; -//! [4] - // Don't move too far away -//! [5] - QLineF lineToCenter(QPointF(0, 0), mapFromScene(0, 0)); - if (lineToCenter.length() > 150) { - qreal angleToCenter = ::acos(lineToCenter.dx() / lineToCenter.length()); - if (lineToCenter.dy() < 0) - angleToCenter = TwoPi - angleToCenter; - angleToCenter = normalizeAngle((Pi - angleToCenter) + Pi / 2); - - if (angleToCenter < Pi && angleToCenter > Pi / 4) { - // Rotate left - angle += (angle < -Pi / 2) ? 0.25 : -0.25; - } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) { - // Rotate right - angle += (angle < Pi / 2) ? 0.25 : -0.25; - } - } else if (::sin(angle) < 0) { - angle += 0.25; - } else if (::sin(angle) > 0) { - angle -= 0.25; -//! [5] //! [6] - } -//! [6] - - // Try not to crash with any other mice -//! [7] - QList dangerMice = scene()->items(QPolygonF() - << mapToScene(0, 0) - << mapToScene(-30, -50) - << mapToScene(30, -50)); - foreach (QGraphicsItem *item, dangerMice) { - if (item == this) - continue; - - QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0)); - qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length()); - if (lineToMouse.dy() < 0) - angleToMouse = TwoPi - angleToMouse; - angleToMouse = normalizeAngle((Pi - angleToMouse) + Pi / 2); - - if (angleToMouse >= 0 && angleToMouse < Pi / 2) { - // Rotate right - angle += 0.5; - } else if (angleToMouse <= TwoPi && angleToMouse > (TwoPi - Pi / 2)) { - // Rotate left - angle -= 0.5; -//! [7] //! [8] - } -//! [8] //! [9] - } -//! [9] - - // Add some random movement -//! [10] - if (dangerMice.size() > 1 && (qrand() % 10) == 0) { - if (qrand() % 1) - angle += (qrand() % 100) / 500.0; - else - angle -= (qrand() % 100) / 500.0; - } -//! [10] - -//! [11] - speed += (-50 + qrand() % 100) / 100.0; - - qreal dx = ::sin(angle) * 10; - mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5; - - setRotation(rotation() + dx); - setPos(mapToParent(0, -(3 + sin(speed) * 3))); -} -//! [11] diff --git a/examples/graphicsview/collidingmice/mouse.h b/examples/graphicsview/collidingmice/mouse.h deleted file mode 100644 index fd036e8b93..0000000000 --- a/examples/graphicsview/collidingmice/mouse.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 MOUSE_H -#define MOUSE_H - -#include - -//! [0] -class Mouse : public QGraphicsItem -{ -public: - Mouse(); - - QRectF boundingRect() const; - QPainterPath shape() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget); - -protected: - void advance(int step); - -private: - qreal angle; - qreal speed; - qreal mouseEyeDirection; - QColor color; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/diagramscene/arrow.cpp b/examples/graphicsview/diagramscene/arrow.cpp deleted file mode 100644 index 236d836e13..0000000000 --- a/examples/graphicsview/diagramscene/arrow.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "arrow.h" -#include - -const qreal Pi = 3.14; - -//! [0] -Arrow::Arrow(DiagramItem *startItem, DiagramItem *endItem, QGraphicsItem *parent) - : QGraphicsLineItem(parent) -{ - myStartItem = startItem; - myEndItem = endItem; - setFlag(QGraphicsItem::ItemIsSelectable, true); - myColor = Qt::black; - setPen(QPen(myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); -} -//! [0] - -//! [1] -QRectF Arrow::boundingRect() const -{ - qreal extra = (pen().width() + 20) / 2.0; - - return QRectF(line().p1(), QSizeF(line().p2().x() - line().p1().x(), - line().p2().y() - line().p1().y())) - .normalized() - .adjusted(-extra, -extra, extra, extra); -} -//! [1] - -//! [2] -QPainterPath Arrow::shape() const -{ - QPainterPath path = QGraphicsLineItem::shape(); - path.addPolygon(arrowHead); - return path; -} -//! [2] - -//! [3] -void Arrow::updatePosition() -{ - QLineF line(mapFromItem(myStartItem, 0, 0), mapFromItem(myEndItem, 0, 0)); - setLine(line); -} -//! [3] - -//! [4] -void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *, - QWidget *) -{ - if (myStartItem->collidesWithItem(myEndItem)) - return; - - QPen myPen = pen(); - myPen.setColor(myColor); - qreal arrowSize = 20; - painter->setPen(myPen); - painter->setBrush(myColor); -//! [4] //! [5] - - QLineF centerLine(myStartItem->pos(), myEndItem->pos()); - QPolygonF endPolygon = myEndItem->polygon(); - QPointF p1 = endPolygon.first() + myEndItem->pos(); - QPointF p2; - QPointF intersectPoint; - QLineF polyLine; - for (int i = 1; i < endPolygon.count(); ++i) { - p2 = endPolygon.at(i) + myEndItem->pos(); - polyLine = QLineF(p1, p2); - QLineF::IntersectType intersectType = - polyLine.intersect(centerLine, &intersectPoint); - if (intersectType == QLineF::BoundedIntersection) - break; - p1 = p2; - } - - setLine(QLineF(intersectPoint, myStartItem->pos())); -//! [5] //! [6] - - double angle = ::acos(line().dx() / line().length()); - if (line().dy() >= 0) - angle = (Pi * 2) - angle; - - QPointF arrowP1 = line().p1() + QPointF(sin(angle + Pi / 3) * arrowSize, - cos(angle + Pi / 3) * arrowSize); - QPointF arrowP2 = line().p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize, - cos(angle + Pi - Pi / 3) * arrowSize); - - arrowHead.clear(); - arrowHead << line().p1() << arrowP1 << arrowP2; -//! [6] //! [7] - painter->drawLine(line()); - painter->drawPolygon(arrowHead); - if (isSelected()) { - painter->setPen(QPen(myColor, 1, Qt::DashLine)); - QLineF myLine = line(); - myLine.translate(0, 4.0); - painter->drawLine(myLine); - myLine.translate(0,-8.0); - painter->drawLine(myLine); - } -} -//! [7] diff --git a/examples/graphicsview/diagramscene/arrow.h b/examples/graphicsview/diagramscene/arrow.h deleted file mode 100644 index ac09d6ad00..0000000000 --- a/examples/graphicsview/diagramscene/arrow.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 ARROW_H -#define ARROW_H - -#include - -#include "diagramitem.h" - -QT_BEGIN_NAMESPACE -class QGraphicsPolygonItem; -class QGraphicsLineItem; -class QGraphicsScene; -class QRectF; -class QGraphicsSceneMouseEvent; -class QPainterPath; -QT_END_NAMESPACE - -//! [0] -class Arrow : public QGraphicsLineItem -{ -public: - enum { Type = UserType + 4 }; - - Arrow(DiagramItem *startItem, DiagramItem *endItem, - QGraphicsItem *parent = 0); - - int type() const - { return Type; } - QRectF boundingRect() const; - QPainterPath shape() const; - void setColor(const QColor &color) - { myColor = color; } - DiagramItem *startItem() const - { return myStartItem; } - DiagramItem *endItem() const - { return myEndItem; } - - void updatePosition(); - -protected: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = 0); - -private: - DiagramItem *myStartItem; - DiagramItem *myEndItem; - QColor myColor; - QPolygonF arrowHead; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/diagramscene/diagramitem.cpp b/examples/graphicsview/diagramscene/diagramitem.cpp deleted file mode 100644 index 9509c30270..0000000000 --- a/examples/graphicsview/diagramscene/diagramitem.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "diagramitem.h" -#include "arrow.h" - -//! [0] -DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu, - QGraphicsItem *parent) - : QGraphicsPolygonItem(parent) -{ - myDiagramType = diagramType; - myContextMenu = contextMenu; - - QPainterPath path; - switch (myDiagramType) { - case StartEnd: - path.moveTo(200, 50); - path.arcTo(150, 0, 50, 50, 0, 90); - path.arcTo(50, 0, 50, 50, 90, 90); - path.arcTo(50, 50, 50, 50, 180, 90); - path.arcTo(150, 50, 50, 50, 270, 90); - path.lineTo(200, 25); - myPolygon = path.toFillPolygon(); - break; - case Conditional: - myPolygon << QPointF(-100, 0) << QPointF(0, 100) - << QPointF(100, 0) << QPointF(0, -100) - << QPointF(-100, 0); - break; - case Step: - myPolygon << QPointF(-100, -100) << QPointF(100, -100) - << QPointF(100, 100) << QPointF(-100, 100) - << QPointF(-100, -100); - break; - default: - myPolygon << QPointF(-120, -80) << QPointF(-70, 80) - << QPointF(120, 80) << QPointF(70, -80) - << QPointF(-120, -80); - break; - } - setPolygon(myPolygon); - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsSelectable, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); -} -//! [0] - -//! [1] -void DiagramItem::removeArrow(Arrow *arrow) -{ - int index = arrows.indexOf(arrow); - - if (index != -1) - arrows.removeAt(index); -} -//! [1] - -//! [2] -void DiagramItem::removeArrows() -{ - foreach (Arrow *arrow, arrows) { - arrow->startItem()->removeArrow(arrow); - arrow->endItem()->removeArrow(arrow); - scene()->removeItem(arrow); - delete arrow; - } -} -//! [2] - -//! [3] -void DiagramItem::addArrow(Arrow *arrow) -{ - arrows.append(arrow); -} -//! [3] - -//! [4] -QPixmap DiagramItem::image() const -{ - QPixmap pixmap(250, 250); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setPen(QPen(Qt::black, 8)); - painter.translate(125, 125); - painter.drawPolyline(myPolygon); - - return pixmap; -} -//! [4] - -//! [5] -void DiagramItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - scene()->clearSelection(); - setSelected(true); - myContextMenu->exec(event->screenPos()); -} -//! [5] - -//! [6] -QVariant DiagramItem::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - if (change == QGraphicsItem::ItemPositionChange) { - foreach (Arrow *arrow, arrows) { - arrow->updatePosition(); - } - } - - return value; -} -//! [6] diff --git a/examples/graphicsview/diagramscene/diagramitem.h b/examples/graphicsview/diagramscene/diagramitem.h deleted file mode 100644 index 07b3b6e830..0000000000 --- a/examples/graphicsview/diagramscene/diagramitem.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIAGRAMITEM_H -#define DIAGRAMITEM_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QPixmap; -class QGraphicsItem; -class QGraphicsScene; -class QTextEdit; -class QGraphicsSceneMouseEvent; -class QMenu; -class QGraphicsSceneContextMenuEvent; -class QPainter; -class QStyleOptionGraphicsItem; -class QWidget; -class QPolygonF; -QT_END_NAMESPACE - -class Arrow; - -//! [0] -class DiagramItem : public QGraphicsPolygonItem -{ -public: - enum { Type = UserType + 15 }; - enum DiagramType { Step, Conditional, StartEnd, Io }; - - DiagramItem(DiagramType diagramType, QMenu *contextMenu, - QGraphicsItem *parent = 0); - - void removeArrow(Arrow *arrow); - void removeArrows(); - DiagramType diagramType() const - { return myDiagramType; } - QPolygonF polygon() const - { return myPolygon; } - void addArrow(Arrow *arrow); - QPixmap image() const; - int type() const - { return Type;} - -protected: - void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - -private: - DiagramType myDiagramType; - QPolygonF myPolygon; - QMenu *myContextMenu; - QList arrows; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/diagramscene/diagramscene.cpp b/examples/graphicsview/diagramscene/diagramscene.cpp deleted file mode 100644 index c4a654aa99..0000000000 --- a/examples/graphicsview/diagramscene/diagramscene.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "diagramscene.h" -#include "arrow.h" - -//! [0] -DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent) - : QGraphicsScene(parent) -{ - myItemMenu = itemMenu; - myMode = MoveItem; - myItemType = DiagramItem::Step; - line = 0; - textItem = 0; - myItemColor = Qt::white; - myTextColor = Qt::black; - myLineColor = Qt::black; -} -//! [0] - -//! [1] -void DiagramScene::setLineColor(const QColor &color) -{ - myLineColor = color; - if (isItemChange(Arrow::Type)) { - Arrow *item = - qgraphicsitem_cast(selectedItems().first()); - item->setColor(myLineColor); - update(); - } -} -//! [1] - -//! [2] -void DiagramScene::setTextColor(const QColor &color) -{ - myTextColor = color; - if (isItemChange(DiagramTextItem::Type)) { - DiagramTextItem *item = - qgraphicsitem_cast(selectedItems().first()); - item->setDefaultTextColor(myTextColor); - } -} -//! [2] - -//! [3] -void DiagramScene::setItemColor(const QColor &color) -{ - myItemColor = color; - if (isItemChange(DiagramItem::Type)) { - DiagramItem *item = - qgraphicsitem_cast(selectedItems().first()); - item->setBrush(myItemColor); - } -} -//! [3] - -//! [4] -void DiagramScene::setFont(const QFont &font) -{ - myFont = font; - - if (isItemChange(DiagramTextItem::Type)) { - QGraphicsTextItem *item = - qgraphicsitem_cast(selectedItems().first()); - //At this point the selection can change so the first selected item might not be a DiagramTextItem - if (item) - item->setFont(myFont); - } -} -//! [4] - -void DiagramScene::setMode(Mode mode) -{ - myMode = mode; -} - -void DiagramScene::setItemType(DiagramItem::DiagramType type) -{ - myItemType = type; -} - -//! [5] -void DiagramScene::editorLostFocus(DiagramTextItem *item) -{ - QTextCursor cursor = item->textCursor(); - cursor.clearSelection(); - item->setTextCursor(cursor); - - if (item->toPlainText().isEmpty()) { - removeItem(item); - item->deleteLater(); - } -} -//! [5] - -//! [6] -void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - if (mouseEvent->button() != Qt::LeftButton) - return; - - DiagramItem *item; - switch (myMode) { - case InsertItem: - item = new DiagramItem(myItemType, myItemMenu); - item->setBrush(myItemColor); - addItem(item); - item->setPos(mouseEvent->scenePos()); - emit itemInserted(item); - break; -//! [6] //! [7] - case InsertLine: - line = new QGraphicsLineItem(QLineF(mouseEvent->scenePos(), - mouseEvent->scenePos())); - line->setPen(QPen(myLineColor, 2)); - addItem(line); - break; -//! [7] //! [8] - case InsertText: - textItem = new DiagramTextItem(); - textItem->setFont(myFont); - textItem->setTextInteractionFlags(Qt::TextEditorInteraction); - textItem->setZValue(1000.0); - connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)), - this, SLOT(editorLostFocus(DiagramTextItem*))); - connect(textItem, SIGNAL(selectedChange(QGraphicsItem*)), - this, SIGNAL(itemSelected(QGraphicsItem*))); - addItem(textItem); - textItem->setDefaultTextColor(myTextColor); - textItem->setPos(mouseEvent->scenePos()); - emit textInserted(textItem); -//! [8] //! [9] - default: - ; - } - QGraphicsScene::mousePressEvent(mouseEvent); -} -//! [9] - -//! [10] -void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - if (myMode == InsertLine && line != 0) { - QLineF newLine(line->line().p1(), mouseEvent->scenePos()); - line->setLine(newLine); - } else if (myMode == MoveItem) { - QGraphicsScene::mouseMoveEvent(mouseEvent); - } -} -//! [10] - -//! [11] -void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - if (line != 0 && myMode == InsertLine) { - QList startItems = items(line->line().p1()); - if (startItems.count() && startItems.first() == line) - startItems.removeFirst(); - QList endItems = items(line->line().p2()); - if (endItems.count() && endItems.first() == line) - endItems.removeFirst(); - - removeItem(line); - delete line; -//! [11] //! [12] - - if (startItems.count() > 0 && endItems.count() > 0 && - startItems.first()->type() == DiagramItem::Type && - endItems.first()->type() == DiagramItem::Type && - startItems.first() != endItems.first()) { - DiagramItem *startItem = - qgraphicsitem_cast(startItems.first()); - DiagramItem *endItem = - qgraphicsitem_cast(endItems.first()); - Arrow *arrow = new Arrow(startItem, endItem); - arrow->setColor(myLineColor); - startItem->addArrow(arrow); - endItem->addArrow(arrow); - arrow->setZValue(-1000.0); - addItem(arrow); - arrow->updatePosition(); - } - } -//! [12] //! [13] - line = 0; - QGraphicsScene::mouseReleaseEvent(mouseEvent); -} -//! [13] - -//! [14] -bool DiagramScene::isItemChange(int type) -{ - foreach (QGraphicsItem *item, selectedItems()) { - if (item->type() == type) - return true; - } - return false; -} -//! [14] diff --git a/examples/graphicsview/diagramscene/diagramscene.desktop b/examples/graphicsview/diagramscene/diagramscene.desktop deleted file mode 100644 index 54506ff979..0000000000 --- a/examples/graphicsview/diagramscene/diagramscene.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Diagram Scene -Exec=/opt/usr/bin/diagramscene -Icon=diagramscene -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/diagramscene/diagramscene.h b/examples/graphicsview/diagramscene/diagramscene.h deleted file mode 100644 index 9f65eba890..0000000000 --- a/examples/graphicsview/diagramscene/diagramscene.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIAGRAMSCENE_H -#define DIAGRAMSCENE_H - -#include -#include "diagramitem.h" -#include "diagramtextitem.h" - -QT_BEGIN_NAMESPACE -class QGraphicsSceneMouseEvent; -class QMenu; -class QPointF; -class QGraphicsLineItem; -class QFont; -class QGraphicsTextItem; -class QColor; -QT_END_NAMESPACE - -//! [0] -class DiagramScene : public QGraphicsScene -{ - Q_OBJECT - -public: - enum Mode { InsertItem, InsertLine, InsertText, MoveItem }; - - DiagramScene(QMenu *itemMenu, QObject *parent = 0); - QFont font() const - { return myFont; } - QColor textColor() const - { return myTextColor; } - QColor itemColor() const - { return myItemColor; } - QColor lineColor() const - { return myLineColor; } - void setLineColor(const QColor &color); - void setTextColor(const QColor &color); - void setItemColor(const QColor &color); - void setFont(const QFont &font); - -public slots: - void setMode(Mode mode); - void setItemType(DiagramItem::DiagramType type); - void editorLostFocus(DiagramTextItem *item); - -signals: - void itemInserted(DiagramItem *item); - void textInserted(QGraphicsTextItem *item); - void itemSelected(QGraphicsItem *item); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); - void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); - -private: - bool isItemChange(int type); - - DiagramItem::DiagramType myItemType; - QMenu *myItemMenu; - Mode myMode; - bool leftButtonDown; - QPointF startPoint; - QGraphicsLineItem *line; - QFont myFont; - DiagramTextItem *textItem; - QColor myTextColor; - QColor myItemColor; - QColor myLineColor; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/diagramscene/diagramscene.pro b/examples/graphicsview/diagramscene/diagramscene.pro deleted file mode 100644 index e45f4a894b..0000000000 --- a/examples/graphicsview/diagramscene/diagramscene.pro +++ /dev/null @@ -1,23 +0,0 @@ -HEADERS = mainwindow.h \ - diagramitem.h \ - diagramscene.h \ - arrow.h \ - diagramtextitem.h -SOURCES = mainwindow.cpp \ - diagramitem.cpp \ - main.cpp \ - arrow.cpp \ - diagramtextitem.cpp \ - diagramscene.cpp -RESOURCES = diagramscene.qrc - - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/diagramscene -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS diagramscene.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/diagramscene -INSTALLS += target sources - - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/diagramscene/diagramscene.qrc b/examples/graphicsview/diagramscene/diagramscene.qrc deleted file mode 100644 index a11158402f..0000000000 --- a/examples/graphicsview/diagramscene/diagramscene.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - - images/pointer.png - images/linepointer.png - images/textpointer.png - images/bold.png - images/italic.png - images/underline.png - images/floodfill.png - images/bringtofront.png - images/delete.png - images/sendtoback.png - images/linecolor.png - images/background1.png - images/background2.png - images/background3.png - images/background4.png - - - diff --git a/examples/graphicsview/diagramscene/diagramtextitem.cpp b/examples/graphicsview/diagramscene/diagramtextitem.cpp deleted file mode 100644 index 1e583045da..0000000000 --- a/examples/graphicsview/diagramscene/diagramtextitem.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "diagramtextitem.h" -#include "diagramscene.h" - -//! [0] -DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) - : QGraphicsTextItem(parent) -{ - setFlag(QGraphicsItem::ItemIsMovable); - setFlag(QGraphicsItem::ItemIsSelectable); -} -//! [0] - -//! [1] -QVariant DiagramTextItem::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - if (change == QGraphicsItem::ItemSelectedHasChanged) - emit selectedChange(this); - return value; -} -//! [1] - -//! [2] -void DiagramTextItem::focusOutEvent(QFocusEvent *event) -{ - setTextInteractionFlags(Qt::NoTextInteraction); - emit lostFocus(this); - QGraphicsTextItem::focusOutEvent(event); -} -//! [2] - -//! [5] -void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - if (textInteractionFlags() == Qt::NoTextInteraction) - setTextInteractionFlags(Qt::TextEditorInteraction); - QGraphicsTextItem::mouseDoubleClickEvent(event); -} -//! [5] diff --git a/examples/graphicsview/diagramscene/diagramtextitem.h b/examples/graphicsview/diagramscene/diagramtextitem.h deleted file mode 100644 index 611e9b6700..0000000000 --- a/examples/graphicsview/diagramscene/diagramtextitem.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIAGRAMTEXTITEM_H -#define DIAGRAMTEXTITEM_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QFocusEvent; -class QGraphicsItem; -class QGraphicsScene; -class QGraphicsSceneMouseEvent; -QT_END_NAMESPACE - -//! [0] -class DiagramTextItem : public QGraphicsTextItem -{ - Q_OBJECT - -public: - enum { Type = UserType + 3 }; - - DiagramTextItem(QGraphicsItem *parent = 0); - - int type() const - { return Type; } - -signals: - void lostFocus(DiagramTextItem *item); - void selectedChange(QGraphicsItem *item); - -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - void focusOutEvent(QFocusEvent *event); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); -}; -//! [0] - -#endif diff --git a/examples/graphicsview/diagramscene/images/background1.png b/examples/graphicsview/diagramscene/images/background1.png deleted file mode 100644 index 0f93c6bf42..0000000000 Binary files a/examples/graphicsview/diagramscene/images/background1.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/background2.png b/examples/graphicsview/diagramscene/images/background2.png deleted file mode 100644 index 1e293db67a..0000000000 Binary files a/examples/graphicsview/diagramscene/images/background2.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/background3.png b/examples/graphicsview/diagramscene/images/background3.png deleted file mode 100644 index 3db4f8ea5f..0000000000 Binary files a/examples/graphicsview/diagramscene/images/background3.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/background4.png b/examples/graphicsview/diagramscene/images/background4.png deleted file mode 100644 index 9c1f3bfd77..0000000000 Binary files a/examples/graphicsview/diagramscene/images/background4.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/bold.png b/examples/graphicsview/diagramscene/images/bold.png deleted file mode 100644 index 986e65e250..0000000000 Binary files a/examples/graphicsview/diagramscene/images/bold.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/bringtofront.png b/examples/graphicsview/diagramscene/images/bringtofront.png deleted file mode 100644 index bda27578a2..0000000000 Binary files a/examples/graphicsview/diagramscene/images/bringtofront.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/delete.png b/examples/graphicsview/diagramscene/images/delete.png deleted file mode 100644 index df2a147d24..0000000000 Binary files a/examples/graphicsview/diagramscene/images/delete.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/floodfill.png b/examples/graphicsview/diagramscene/images/floodfill.png deleted file mode 100644 index 54c0dae237..0000000000 Binary files a/examples/graphicsview/diagramscene/images/floodfill.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/italic.png b/examples/graphicsview/diagramscene/images/italic.png deleted file mode 100644 index 9a438b57ad..0000000000 Binary files a/examples/graphicsview/diagramscene/images/italic.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/linecolor.png b/examples/graphicsview/diagramscene/images/linecolor.png deleted file mode 100644 index 98a821f27e..0000000000 Binary files a/examples/graphicsview/diagramscene/images/linecolor.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/linepointer.png b/examples/graphicsview/diagramscene/images/linepointer.png deleted file mode 100644 index 66933d43b3..0000000000 Binary files a/examples/graphicsview/diagramscene/images/linepointer.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/pointer.png b/examples/graphicsview/diagramscene/images/pointer.png deleted file mode 100644 index 0b0b0aa69d..0000000000 Binary files a/examples/graphicsview/diagramscene/images/pointer.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/sendtoback.png b/examples/graphicsview/diagramscene/images/sendtoback.png deleted file mode 100644 index 5aa3b0a243..0000000000 Binary files a/examples/graphicsview/diagramscene/images/sendtoback.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/textpointer.png b/examples/graphicsview/diagramscene/images/textpointer.png deleted file mode 100644 index b25832cada..0000000000 Binary files a/examples/graphicsview/diagramscene/images/textpointer.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/images/underline.png b/examples/graphicsview/diagramscene/images/underline.png deleted file mode 100644 index 9b8209f525..0000000000 Binary files a/examples/graphicsview/diagramscene/images/underline.png and /dev/null differ diff --git a/examples/graphicsview/diagramscene/main.cpp b/examples/graphicsview/diagramscene/main.cpp deleted file mode 100644 index 33bc97b71f..0000000000 --- a/examples/graphicsview/diagramscene/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argv, char *args[]) -{ - Q_INIT_RESOURCE(diagramscene); - - QApplication app(argv, args); - MainWindow mainWindow; - mainWindow.setGeometry(100, 100, 800, 500); - mainWindow.show(); - - return app.exec(); -} diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp deleted file mode 100644 index 977730a3bb..0000000000 --- a/examples/graphicsview/diagramscene/mainwindow.cpp +++ /dev/null @@ -1,661 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#include "mainwindow.h" -#include "diagramitem.h" -#include "diagramscene.h" -#include "diagramtextitem.h" -#include "arrow.h" - -const int InsertTextButton = 10; - -//! [0] -MainWindow::MainWindow() -{ - createActions(); - createToolBox(); - createMenus(); - - scene = new DiagramScene(itemMenu, this); - scene->setSceneRect(QRectF(0, 0, 5000, 5000)); - connect(scene, SIGNAL(itemInserted(DiagramItem*)), - this, SLOT(itemInserted(DiagramItem*))); - connect(scene, SIGNAL(textInserted(QGraphicsTextItem*)), - this, SLOT(textInserted(QGraphicsTextItem*))); - connect(scene, SIGNAL(itemSelected(QGraphicsItem*)), - this, SLOT(itemSelected(QGraphicsItem*))); - createToolbars(); - - QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(toolBox); - view = new QGraphicsView(scene); - layout->addWidget(view); - - QWidget *widget = new QWidget; - widget->setLayout(layout); - - setCentralWidget(widget); - setWindowTitle(tr("Diagramscene")); - setUnifiedTitleAndToolBarOnMac(true); -} -//! [0] - -//! [1] -void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button) -{ - QList buttons = backgroundButtonGroup->buttons(); - foreach (QAbstractButton *myButton, buttons) { - if (myButton != button) - button->setChecked(false); - } - QString text = button->text(); - if (text == tr("Blue Grid")) - scene->setBackgroundBrush(QPixmap(":/images/background1.png")); - else if (text == tr("White Grid")) - scene->setBackgroundBrush(QPixmap(":/images/background2.png")); - else if (text == tr("Gray Grid")) - scene->setBackgroundBrush(QPixmap(":/images/background3.png")); - else - scene->setBackgroundBrush(QPixmap(":/images/background4.png")); - - scene->update(); - view->update(); -} -//! [1] - -//! [2] -void MainWindow::buttonGroupClicked(int id) -{ - QList buttons = buttonGroup->buttons(); - foreach (QAbstractButton *button, buttons) { - if (buttonGroup->button(id) != button) - button->setChecked(false); - } - if (id == InsertTextButton) { - scene->setMode(DiagramScene::InsertText); - } else { - scene->setItemType(DiagramItem::DiagramType(id)); - scene->setMode(DiagramScene::InsertItem); - } -} -//! [2] - -//! [3] -void MainWindow::deleteItem() -{ - foreach (QGraphicsItem *item, scene->selectedItems()) { - if (item->type() == Arrow::Type) { - scene->removeItem(item); - Arrow *arrow = qgraphicsitem_cast(item); - arrow->startItem()->removeArrow(arrow); - arrow->endItem()->removeArrow(arrow); - delete item; - } - } - - foreach (QGraphicsItem *item, scene->selectedItems()) { - if (item->type() == DiagramItem::Type) { - qgraphicsitem_cast(item)->removeArrows(); - } - scene->removeItem(item); - delete item; - } -} -//! [3] - -//! [4] -void MainWindow::pointerGroupClicked(int) -{ - scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId())); -} -//! [4] - -//! [5] -void MainWindow::bringToFront() -{ - if (scene->selectedItems().isEmpty()) - return; - - QGraphicsItem *selectedItem = scene->selectedItems().first(); - QList overlapItems = selectedItem->collidingItems(); - - qreal zValue = 0; - foreach (QGraphicsItem *item, overlapItems) { - if (item->zValue() >= zValue && - item->type() == DiagramItem::Type) - zValue = item->zValue() + 0.1; - } - selectedItem->setZValue(zValue); -} -//! [5] - -//! [6] -void MainWindow::sendToBack() -{ - if (scene->selectedItems().isEmpty()) - return; - - QGraphicsItem *selectedItem = scene->selectedItems().first(); - QList overlapItems = selectedItem->collidingItems(); - - qreal zValue = 0; - foreach (QGraphicsItem *item, overlapItems) { - if (item->zValue() <= zValue && - item->type() == DiagramItem::Type) - zValue = item->zValue() - 0.1; - } - selectedItem->setZValue(zValue); -} -//! [6] - -//! [7] -void MainWindow::itemInserted(DiagramItem *item) -{ - pointerTypeGroup->button(int(DiagramScene::MoveItem))->setChecked(true); - scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId())); - buttonGroup->button(int(item->diagramType()))->setChecked(false); -} -//! [7] - -//! [8] -void MainWindow::textInserted(QGraphicsTextItem *) -{ - buttonGroup->button(InsertTextButton)->setChecked(false); - scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId())); -} -//! [8] - -//! [9] -void MainWindow::currentFontChanged(const QFont &) -{ - handleFontChange(); -} -//! [9] - -//! [10] -void MainWindow::fontSizeChanged(const QString &) -{ - handleFontChange(); -} -//! [10] - -//! [11] -void MainWindow::sceneScaleChanged(const QString &scale) -{ - double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() / 100.0; - QMatrix oldMatrix = view->matrix(); - view->resetMatrix(); - view->translate(oldMatrix.dx(), oldMatrix.dy()); - view->scale(newScale, newScale); -} -//! [11] - -//! [12] -void MainWindow::textColorChanged() -{ - textAction = qobject_cast(sender()); - fontColorToolButton->setIcon(createColorToolButtonIcon( - ":/images/textpointer.png", - qvariant_cast(textAction->data()))); - textButtonTriggered(); -} -//! [12] - -//! [13] -void MainWindow::itemColorChanged() -{ - fillAction = qobject_cast(sender()); - fillColorToolButton->setIcon(createColorToolButtonIcon( - ":/images/floodfill.png", - qvariant_cast(fillAction->data()))); - fillButtonTriggered(); -} -//! [13] - -//! [14] -void MainWindow::lineColorChanged() -{ - lineAction = qobject_cast(sender()); - lineColorToolButton->setIcon(createColorToolButtonIcon( - ":/images/linecolor.png", - qvariant_cast(lineAction->data()))); - lineButtonTriggered(); -} -//! [14] - -//! [15] -void MainWindow::textButtonTriggered() -{ - scene->setTextColor(qvariant_cast(textAction->data())); -} -//! [15] - -//! [16] -void MainWindow::fillButtonTriggered() -{ - scene->setItemColor(qvariant_cast(fillAction->data())); -} -//! [16] - -//! [17] -void MainWindow::lineButtonTriggered() -{ - scene->setLineColor(qvariant_cast(lineAction->data())); -} -//! [17] - -//! [18] -void MainWindow::handleFontChange() -{ - QFont font = fontCombo->currentFont(); - font.setPointSize(fontSizeCombo->currentText().toInt()); - font.setWeight(boldAction->isChecked() ? QFont::Bold : QFont::Normal); - font.setItalic(italicAction->isChecked()); - font.setUnderline(underlineAction->isChecked()); - - scene->setFont(font); -} -//! [18] - -//! [19] -void MainWindow::itemSelected(QGraphicsItem *item) -{ - DiagramTextItem *textItem = - qgraphicsitem_cast(item); - - QFont font = textItem->font(); - fontCombo->setCurrentFont(font); - fontSizeCombo->setEditText(QString().setNum(font.pointSize())); - boldAction->setChecked(font.weight() == QFont::Bold); - italicAction->setChecked(font.italic()); - underlineAction->setChecked(font.underline()); -} -//! [19] - -//! [20] -void MainWindow::about() -{ - QMessageBox::about(this, tr("About Diagram Scene"), - tr("The Diagram Scene example shows " - "use of the graphics framework.")); -} -//! [20] - -//! [21] -void MainWindow::createToolBox() -{ - buttonGroup = new QButtonGroup(this); - buttonGroup->setExclusive(false); - connect(buttonGroup, SIGNAL(buttonClicked(int)), - this, SLOT(buttonGroupClicked(int))); - QGridLayout *layout = new QGridLayout; - layout->addWidget(createCellWidget(tr("Conditional"), - DiagramItem::Conditional), 0, 0); - layout->addWidget(createCellWidget(tr("Process"), - DiagramItem::Step),0, 1); - layout->addWidget(createCellWidget(tr("Input/Output"), - DiagramItem::Io), 1, 0); -//! [21] - - QToolButton *textButton = new QToolButton; - textButton->setCheckable(true); - buttonGroup->addButton(textButton, InsertTextButton); - textButton->setIcon(QIcon(QPixmap(":/images/textpointer.png") - .scaled(30, 30))); - textButton->setIconSize(QSize(50, 50)); - QGridLayout *textLayout = new QGridLayout; - textLayout->addWidget(textButton, 0, 0, Qt::AlignHCenter); - textLayout->addWidget(new QLabel(tr("Text")), 1, 0, Qt::AlignCenter); - QWidget *textWidget = new QWidget; - textWidget->setLayout(textLayout); - layout->addWidget(textWidget, 1, 1); - - layout->setRowStretch(3, 10); - layout->setColumnStretch(2, 10); - - QWidget *itemWidget = new QWidget; - itemWidget->setLayout(layout); - - backgroundButtonGroup = new QButtonGroup(this); - connect(backgroundButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), - this, SLOT(backgroundButtonGroupClicked(QAbstractButton*))); - - QGridLayout *backgroundLayout = new QGridLayout; - backgroundLayout->addWidget(createBackgroundCellWidget(tr("Blue Grid"), - ":/images/background1.png"), 0, 0); - backgroundLayout->addWidget(createBackgroundCellWidget(tr("White Grid"), - ":/images/background2.png"), 0, 1); - backgroundLayout->addWidget(createBackgroundCellWidget(tr("Gray Grid"), - ":/images/background3.png"), 1, 0); - backgroundLayout->addWidget(createBackgroundCellWidget(tr("No Grid"), - ":/images/background4.png"), 1, 1); - - backgroundLayout->setRowStretch(2, 10); - backgroundLayout->setColumnStretch(2, 10); - - QWidget *backgroundWidget = new QWidget; - backgroundWidget->setLayout(backgroundLayout); - - -//! [22] - toolBox = new QToolBox; - toolBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored)); - toolBox->setMinimumWidth(itemWidget->sizeHint().width()); - toolBox->addItem(itemWidget, tr("Basic Flowchart Shapes")); - toolBox->addItem(backgroundWidget, tr("Backgrounds")); -} -//! [22] - -//! [23] -void MainWindow::createActions() -{ - toFrontAction = new QAction(QIcon(":/images/bringtofront.png"), - tr("Bring to &Front"), this); - toFrontAction->setShortcut(tr("Ctrl+F")); - toFrontAction->setStatusTip(tr("Bring item to front")); - connect(toFrontAction, SIGNAL(triggered()), - this, SLOT(bringToFront())); -//! [23] - - sendBackAction = new QAction(QIcon(":/images/sendtoback.png"), - tr("Send to &Back"), this); - sendBackAction->setShortcut(tr("Ctrl+B")); - sendBackAction->setStatusTip(tr("Send item to back")); - connect(sendBackAction, SIGNAL(triggered()), - this, SLOT(sendToBack())); - - deleteAction = new QAction(QIcon(":/images/delete.png"), - tr("&Delete"), this); - deleteAction->setShortcut(tr("Delete")); - deleteAction->setStatusTip(tr("Delete item from diagram")); - connect(deleteAction, SIGNAL(triggered()), - this, SLOT(deleteItem())); - - exitAction = new QAction(tr("E&xit"), this); - exitAction->setShortcuts(QKeySequence::Quit); - exitAction->setStatusTip(tr("Quit Scenediagram example")); - connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); - - boldAction = new QAction(tr("Bold"), this); - boldAction->setCheckable(true); - QPixmap pixmap(":/images/bold.png"); - boldAction->setIcon(QIcon(pixmap)); - boldAction->setShortcut(tr("Ctrl+B")); - connect(boldAction, SIGNAL(triggered()), - this, SLOT(handleFontChange())); - - italicAction = new QAction(QIcon(":/images/italic.png"), - tr("Italic"), this); - italicAction->setCheckable(true); - italicAction->setShortcut(tr("Ctrl+I")); - connect(italicAction, SIGNAL(triggered()), - this, SLOT(handleFontChange())); - - underlineAction = new QAction(QIcon(":/images/underline.png"), - tr("Underline"), this); - underlineAction->setCheckable(true); - underlineAction->setShortcut(tr("Ctrl+U")); - connect(underlineAction, SIGNAL(triggered()), - this, SLOT(handleFontChange())); - - aboutAction = new QAction(tr("A&bout"), this); - aboutAction->setShortcut(tr("Ctrl+B")); - connect(aboutAction, SIGNAL(triggered()), - this, SLOT(about())); -} - -//! [24] -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(exitAction); - - itemMenu = menuBar()->addMenu(tr("&Item")); - itemMenu->addAction(deleteAction); - itemMenu->addSeparator(); - itemMenu->addAction(toFrontAction); - itemMenu->addAction(sendBackAction); - - aboutMenu = menuBar()->addMenu(tr("&Help")); - aboutMenu->addAction(aboutAction); -} -//! [24] - -//! [25] -void MainWindow::createToolbars() -{ -//! [25] - editToolBar = addToolBar(tr("Edit")); - editToolBar->addAction(deleteAction); - editToolBar->addAction(toFrontAction); - editToolBar->addAction(sendBackAction); - - fontCombo = new QFontComboBox(); - connect(fontCombo, SIGNAL(currentFontChanged(QFont)), - this, SLOT(currentFontChanged(QFont))); - - fontSizeCombo = new QComboBox; - fontSizeCombo->setEditable(true); - for (int i = 8; i < 30; i = i + 2) - fontSizeCombo->addItem(QString().setNum(i)); - QIntValidator *validator = new QIntValidator(2, 64, this); - fontSizeCombo->setValidator(validator); - connect(fontSizeCombo, SIGNAL(currentIndexChanged(QString)), - this, SLOT(fontSizeChanged(QString))); - - fontColorToolButton = new QToolButton; - fontColorToolButton->setPopupMode(QToolButton::MenuButtonPopup); - fontColorToolButton->setMenu(createColorMenu(SLOT(textColorChanged()), - Qt::black)); - textAction = fontColorToolButton->menu()->defaultAction(); - fontColorToolButton->setIcon(createColorToolButtonIcon( - ":/images/textpointer.png", Qt::black)); - fontColorToolButton->setAutoFillBackground(true); - connect(fontColorToolButton, SIGNAL(clicked()), - this, SLOT(textButtonTriggered())); - -//! [26] - fillColorToolButton = new QToolButton; - fillColorToolButton->setPopupMode(QToolButton::MenuButtonPopup); - fillColorToolButton->setMenu(createColorMenu(SLOT(itemColorChanged()), - Qt::white)); - fillAction = fillColorToolButton->menu()->defaultAction(); - fillColorToolButton->setIcon(createColorToolButtonIcon( - ":/images/floodfill.png", Qt::white)); - connect(fillColorToolButton, SIGNAL(clicked()), - this, SLOT(fillButtonTriggered())); -//! [26] - - lineColorToolButton = new QToolButton; - lineColorToolButton->setPopupMode(QToolButton::MenuButtonPopup); - lineColorToolButton->setMenu(createColorMenu(SLOT(lineColorChanged()), - Qt::black)); - lineAction = lineColorToolButton->menu()->defaultAction(); - lineColorToolButton->setIcon(createColorToolButtonIcon( - ":/images/linecolor.png", Qt::black)); - connect(lineColorToolButton, SIGNAL(clicked()), - this, SLOT(lineButtonTriggered())); - - textToolBar = addToolBar(tr("Font")); - textToolBar->addWidget(fontCombo); - textToolBar->addWidget(fontSizeCombo); - textToolBar->addAction(boldAction); - textToolBar->addAction(italicAction); - textToolBar->addAction(underlineAction); - - colorToolBar = addToolBar(tr("Color")); - colorToolBar->addWidget(fontColorToolButton); - colorToolBar->addWidget(fillColorToolButton); - colorToolBar->addWidget(lineColorToolButton); - - QToolButton *pointerButton = new QToolButton; - pointerButton->setCheckable(true); - pointerButton->setChecked(true); - pointerButton->setIcon(QIcon(":/images/pointer.png")); - QToolButton *linePointerButton = new QToolButton; - linePointerButton->setCheckable(true); - linePointerButton->setIcon(QIcon(":/images/linepointer.png")); - - pointerTypeGroup = new QButtonGroup(this); - pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem)); - pointerTypeGroup->addButton(linePointerButton, - int(DiagramScene::InsertLine)); - connect(pointerTypeGroup, SIGNAL(buttonClicked(int)), - this, SLOT(pointerGroupClicked(int))); - - sceneScaleCombo = new QComboBox; - QStringList scales; - scales << tr("50%") << tr("75%") << tr("100%") << tr("125%") << tr("150%"); - sceneScaleCombo->addItems(scales); - sceneScaleCombo->setCurrentIndex(2); - connect(sceneScaleCombo, SIGNAL(currentIndexChanged(QString)), - this, SLOT(sceneScaleChanged(QString))); - - pointerToolbar = addToolBar(tr("Pointer type")); - pointerToolbar->addWidget(pointerButton); - pointerToolbar->addWidget(linePointerButton); - pointerToolbar->addWidget(sceneScaleCombo); -//! [27] -} -//! [27] - -//! [28] -QWidget *MainWindow::createBackgroundCellWidget(const QString &text, - const QString &image) -{ - QToolButton *button = new QToolButton; - button->setText(text); - button->setIcon(QIcon(image)); - button->setIconSize(QSize(50, 50)); - button->setCheckable(true); - backgroundButtonGroup->addButton(button); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(button, 0, 0, Qt::AlignHCenter); - layout->addWidget(new QLabel(text), 1, 0, Qt::AlignCenter); - - QWidget *widget = new QWidget; - widget->setLayout(layout); - - return widget; -} -//! [28] - -//! [29] -QWidget *MainWindow::createCellWidget(const QString &text, - DiagramItem::DiagramType type) -{ - - DiagramItem item(type, itemMenu); - QIcon icon(item.image()); - - QToolButton *button = new QToolButton; - button->setIcon(icon); - button->setIconSize(QSize(50, 50)); - button->setCheckable(true); - buttonGroup->addButton(button, int(type)); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(button, 0, 0, Qt::AlignHCenter); - layout->addWidget(new QLabel(text), 1, 0, Qt::AlignCenter); - - QWidget *widget = new QWidget; - widget->setLayout(layout); - - return widget; -} -//! [29] - -//! [30] -QMenu *MainWindow::createColorMenu(const char *slot, QColor defaultColor) -{ - QList colors; - colors << Qt::black << Qt::white << Qt::red << Qt::blue << Qt::yellow; - QStringList names; - names << tr("black") << tr("white") << tr("red") << tr("blue") - << tr("yellow"); - - QMenu *colorMenu = new QMenu(this); - for (int i = 0; i < colors.count(); ++i) { - QAction *action = new QAction(names.at(i), this); - action->setData(colors.at(i)); - action->setIcon(createColorIcon(colors.at(i))); - connect(action, SIGNAL(triggered()), - this, slot); - colorMenu->addAction(action); - if (colors.at(i) == defaultColor) { - colorMenu->setDefaultAction(action); - } - } - return colorMenu; -} -//! [30] - -//! [31] -QIcon MainWindow::createColorToolButtonIcon(const QString &imageFile, - QColor color) -{ - QPixmap pixmap(50, 80); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - QPixmap image(imageFile); - QRect target(0, 0, 50, 60); - QRect source(0, 0, 42, 42); - painter.fillRect(QRect(0, 60, 50, 80), color); - painter.drawPixmap(target, image, source); - - return QIcon(pixmap); -} -//! [31] - -//! [32] -QIcon MainWindow::createColorIcon(QColor color) -{ - QPixmap pixmap(20, 20); - QPainter painter(&pixmap); - painter.setPen(Qt::NoPen); - painter.fillRect(QRect(0, 0, 20, 20), color); - - return QIcon(pixmap); -} -//! [32] diff --git a/examples/graphicsview/diagramscene/mainwindow.h b/examples/graphicsview/diagramscene/mainwindow.h deleted file mode 100644 index e3c0496c79..0000000000 --- a/examples/graphicsview/diagramscene/mainwindow.h +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "diagramitem.h" - -class DiagramScene; - -QT_BEGIN_NAMESPACE -class QAction; -class QToolBox; -class QSpinBox; -class QComboBox; -class QFontComboBox; -class QButtonGroup; -class QLineEdit; -class QGraphicsTextItem; -class QFont; -class QToolButton; -class QAbstractButton; -class QGraphicsView; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private slots: - void backgroundButtonGroupClicked(QAbstractButton *button); - void buttonGroupClicked(int id); - void deleteItem(); - void pointerGroupClicked(int id); - void bringToFront(); - void sendToBack(); - void itemInserted(DiagramItem *item); - void textInserted(QGraphicsTextItem *item); - void currentFontChanged(const QFont &font); - void fontSizeChanged(const QString &size); - void sceneScaleChanged(const QString &scale); - void textColorChanged(); - void itemColorChanged(); - void lineColorChanged(); - void textButtonTriggered(); - void fillButtonTriggered(); - void lineButtonTriggered(); - void handleFontChange(); - void itemSelected(QGraphicsItem *item); - void about(); - -private: - void createToolBox(); - void createActions(); - void createMenus(); - void createToolbars(); - QWidget *createBackgroundCellWidget(const QString &text, - const QString &image); - QWidget *createCellWidget(const QString &text, - DiagramItem::DiagramType type); - QMenu *createColorMenu(const char *slot, QColor defaultColor); - QIcon createColorToolButtonIcon(const QString &image, QColor color); - QIcon createColorIcon(QColor color); - - DiagramScene *scene; - QGraphicsView *view; - - QAction *exitAction; - QAction *addAction; - QAction *deleteAction; - - QAction *toFrontAction; - QAction *sendBackAction; - QAction *aboutAction; - - QMenu *fileMenu; - QMenu *itemMenu; - QMenu *aboutMenu; - - QToolBar *textToolBar; - QToolBar *editToolBar; - QToolBar *colorToolBar; - QToolBar *pointerToolbar; - - QComboBox *sceneScaleCombo; - QComboBox *itemColorCombo; - QComboBox *textColorCombo; - QComboBox *fontSizeCombo; - QFontComboBox *fontCombo; - - QToolBox *toolBox; - QButtonGroup *buttonGroup; - QButtonGroup *pointerTypeGroup; - QButtonGroup *backgroundButtonGroup; - QToolButton *fontColorToolButton; - QToolButton *fillColorToolButton; - QToolButton *lineColorToolButton; - QAction *boldAction; - QAction *underlineAction; - QAction *italicAction; - QAction *textAction; - QAction *fillAction; - QAction *lineAction; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/dragdroprobot/coloritem.cpp b/examples/graphicsview/dragdroprobot/coloritem.cpp deleted file mode 100644 index 18e7a01af2..0000000000 --- a/examples/graphicsview/dragdroprobot/coloritem.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "coloritem.h" - -//! [0] -ColorItem::ColorItem() - : color(qrand() % 256, qrand() % 256, qrand() % 256) -{ - setToolTip(QString("QColor(%1, %2, %3)\n%4") - .arg(color.red()).arg(color.green()).arg(color.blue()) - .arg("Click and drag this color onto the robot!")); - setCursor(Qt::OpenHandCursor); - setAcceptedMouseButtons(Qt::LeftButton); -} -//! [0] - -//! [1] -QRectF ColorItem::boundingRect() const -{ - return QRectF(-15.5, -15.5, 34, 34); -} -//! [1] - -//! [2] -void ColorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(Qt::NoPen); - painter->setBrush(Qt::darkGray); - painter->drawEllipse(-12, -12, 30, 30); - painter->setPen(QPen(Qt::black, 1)); - painter->setBrush(QBrush(color)); - painter->drawEllipse(-15, -15, 30, 30); -} -//! [2] - -//! [3] -void ColorItem::mousePressEvent(QGraphicsSceneMouseEvent *) -{ - setCursor(Qt::ClosedHandCursor); -} -//! [3] - -//! [5] -void ColorItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)) - .length() < QApplication::startDragDistance()) { - return; - } - - QDrag *drag = new QDrag(event->widget()); - QMimeData *mime = new QMimeData; - drag->setMimeData(mime); -//! [5] - -//! [6] - static int n = 0; - if (n++ > 2 && (qrand() % 3) == 0) { - QImage image(":/images/head.png"); - mime->setImageData(image); - - drag->setPixmap(QPixmap::fromImage(image).scaled(30, 40)); - drag->setHotSpot(QPoint(15, 30)); -//! [6] -//! [7] - } else { - mime->setColorData(color); - mime->setText(QString("#%1%2%3") - .arg(color.red(), 2, 16, QLatin1Char('0')) - .arg(color.green(), 2, 16, QLatin1Char('0')) - .arg(color.blue(), 2, 16, QLatin1Char('0'))); - - QPixmap pixmap(34, 34); - pixmap.fill(Qt::white); - - QPainter painter(&pixmap); - painter.translate(15, 15); - painter.setRenderHint(QPainter::Antialiasing); - paint(&painter, 0, 0); - painter.end(); - - pixmap.setMask(pixmap.createHeuristicMask()); - - drag->setPixmap(pixmap); - drag->setHotSpot(QPoint(15, 20)); - } -//! [7] - -//! [8] - drag->exec(); - setCursor(Qt::OpenHandCursor); -} -//! [8] - -//! [4] -void ColorItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) -{ - setCursor(Qt::OpenHandCursor); -} -//! [4] diff --git a/examples/graphicsview/dragdroprobot/coloritem.h b/examples/graphicsview/dragdroprobot/coloritem.h deleted file mode 100644 index 9d3b4a9693..0000000000 --- a/examples/graphicsview/dragdroprobot/coloritem.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 COLORITEM_H -#define COLORITEM_H - -#include - -//! [0] -class ColorItem : public QGraphicsItem -{ -public: - ColorItem(); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - -private: - QColor color; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.desktop b/examples/graphicsview/dragdroprobot/dragdroprobot.desktop deleted file mode 100644 index c01e3a3425..0000000000 --- a/examples/graphicsview/dragdroprobot/dragdroprobot.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Drag and Drop Robot -Exec=/opt/usr/bin/dragdroprobot -Icon=dragdroprobot -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.pro b/examples/graphicsview/dragdroprobot/dragdroprobot.pro deleted file mode 100644 index 3e33bad2f9..0000000000 --- a/examples/graphicsview/dragdroprobot/dragdroprobot.pro +++ /dev/null @@ -1,22 +0,0 @@ -HEADERS += \ - coloritem.h \ - robot.h - -SOURCES += \ - coloritem.cpp \ - main.cpp \ - robot.cpp - -RESOURCES += \ - robot.qrc - - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dragdroprobot.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/dragdroprobot/images/head.png b/examples/graphicsview/dragdroprobot/images/head.png deleted file mode 100644 index 1e520e09b8..0000000000 Binary files a/examples/graphicsview/dragdroprobot/images/head.png and /dev/null differ diff --git a/examples/graphicsview/dragdroprobot/main.cpp b/examples/graphicsview/dragdroprobot/main.cpp deleted file mode 100644 index 05d3c8f1b3..0000000000 --- a/examples/graphicsview/dragdroprobot/main.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "coloritem.h" -#include "robot.h" - -#include - -class GraphicsView : public QGraphicsView -{ -public: - GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene) - { - } - -protected: - virtual void resizeEvent(QResizeEvent *) - { - } -}; - -//! [0] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); -//! [0] -//! [1] - QGraphicsScene scene(-200, -200, 400, 400); - - for (int i = 0; i < 10; ++i) { - ColorItem *item = new ColorItem; - item->setPos(::sin((i * 6.28) / 10.0) * 150, - ::cos((i * 6.28) / 10.0) * 150); - - scene.addItem(item); - } - - Robot *robot = new Robot; - robot->setTransform(QTransform::fromScale(1.2, 1.2), true); - robot->setPos(0, -20); - scene.addItem(robot); -//! [1] -//! [2] - GraphicsView view(&scene); - view.setRenderHint(QPainter::Antialiasing); - view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - view.setBackgroundBrush(QColor(230, 200, 167)); - view.setWindowTitle("Drag and Drop Robot"); - view.show(); - - return app.exec(); -} -//! [2] diff --git a/examples/graphicsview/dragdroprobot/robot.cpp b/examples/graphicsview/dragdroprobot/robot.cpp deleted file mode 100644 index 20935bf6c5..0000000000 --- a/examples/graphicsview/dragdroprobot/robot.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "robot.h" - -//! [0] -RobotPart::RobotPart(QGraphicsItem *parent) - : QGraphicsObject(parent), color(Qt::lightGray), dragOver(false) -{ - setAcceptDrops(true); -} -//! [0] - -//! [1] -void RobotPart::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -{ - if (event->mimeData()->hasColor()) { - event->setAccepted(true); - dragOver = true; - update(); - } else { - event->setAccepted(false); - } -} -//! [1] - -//! [2] -void RobotPart::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -{ - Q_UNUSED(event); - dragOver = false; - update(); -} -//! [2] - -//! [3] -void RobotPart::dropEvent(QGraphicsSceneDragDropEvent *event) -{ - dragOver = false; - if (event->mimeData()->hasColor()) - color = qvariant_cast(event->mimeData()->colorData()); - update(); -} -//! [3] - -//! [4] -RobotHead::RobotHead(QGraphicsItem *parent) - : RobotPart(parent) -{ -} -//! [4] - -//! [5] -QRectF RobotHead::boundingRect() const -{ - return QRectF(-15, -50, 30, 50); -} -//! [5] - -//! [6] -void RobotHead::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - if (pixmap.isNull()) { - painter->setBrush(dragOver ? color.light(130) : color); - painter->drawRoundedRect(-10, -30, 20, 30, 25, 25, Qt::RelativeSize); - painter->setBrush(Qt::white); - painter->drawEllipse(-7, -3 - 20, 7, 7); - painter->drawEllipse(0, -3 - 20, 7, 7); - painter->setBrush(Qt::black); - painter->drawEllipse(-5, -1 - 20, 2, 2); - painter->drawEllipse(2, -1 - 20, 2, 2); - painter->setPen(QPen(Qt::black, 2)); - painter->setBrush(Qt::NoBrush); - painter->drawArc(-6, -2 - 20, 12, 15, 190 * 16, 160 * 16); - } else { - painter->scale(.2272, .2824); - painter->drawPixmap(QPointF(-15 * 4.4, -50 * 3.54), pixmap); - } -} -//! [6] - -//! [7] -void RobotHead::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -{ - if (event->mimeData()->hasImage()) { - event->setAccepted(true); - dragOver = true; - update(); - } else { - RobotPart::dragEnterEvent(event); - } -} -//! [7] - -//! [8] -void RobotHead::dropEvent(QGraphicsSceneDragDropEvent *event) -{ - if (event->mimeData()->hasImage()) { - dragOver = false; - pixmap = qvariant_cast(event->mimeData()->imageData()); - update(); - } else { - RobotPart::dropEvent(event); - } -} -//! [8] - -RobotTorso::RobotTorso(QGraphicsItem *parent) - : RobotPart(parent) -{ -} - -QRectF RobotTorso::boundingRect() const -{ - return QRectF(-30, -20, 60, 60); -} - -void RobotTorso::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - - painter->setBrush(dragOver ? color.light(130) : color); - painter->drawRoundedRect(-20, -20, 40, 60, 25, 25, Qt::RelativeSize); - painter->drawEllipse(-25, -20, 20, 20); - painter->drawEllipse(5, -20, 20, 20); - painter->drawEllipse(-20, 22, 20, 20); - painter->drawEllipse(0, 22, 20, 20); -} - -RobotLimb::RobotLimb(QGraphicsItem *parent) - : RobotPart(parent) -{ -} - -QRectF RobotLimb::boundingRect() const -{ - return QRectF(-5, -5, 40, 10); -} - -void RobotLimb::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - - painter->setBrush(dragOver ? color.light(130) : color); - painter->drawRoundedRect(boundingRect(), 50, 50, Qt::RelativeSize); - painter->drawEllipse(-5, -5, 10, 10); -} - -//! [10] -Robot::Robot(QGraphicsItem *parent) - : RobotPart(parent) -{ - setFlag(ItemHasNoContents); - - QGraphicsObject *torsoItem = new RobotTorso(this); - QGraphicsObject *headItem = new RobotHead(torsoItem); - QGraphicsObject *upperLeftArmItem = new RobotLimb(torsoItem); - QGraphicsObject *lowerLeftArmItem = new RobotLimb(upperLeftArmItem); - QGraphicsObject *upperRightArmItem = new RobotLimb(torsoItem); - QGraphicsObject *lowerRightArmItem = new RobotLimb(upperRightArmItem); - QGraphicsObject *upperRightLegItem = new RobotLimb(torsoItem); - QGraphicsObject *lowerRightLegItem = new RobotLimb(upperRightLegItem); - QGraphicsObject *upperLeftLegItem = new RobotLimb(torsoItem); - QGraphicsObject *lowerLeftLegItem = new RobotLimb(upperLeftLegItem); -//! [10] - -//! [11] - headItem->setPos(0, -18); - upperLeftArmItem->setPos(-15, -10); - lowerLeftArmItem->setPos(30, 0); - upperRightArmItem->setPos(15, -10); - lowerRightArmItem->setPos(30, 0); - upperRightLegItem->setPos(10, 32); - lowerRightLegItem->setPos(30, 0); - upperLeftLegItem->setPos(-10, 32); - lowerLeftLegItem->setPos(30, 0); -//! [11] - -//! [12] - QParallelAnimationGroup *animation = new QParallelAnimationGroup(this); - - QPropertyAnimation *headAnimation = new QPropertyAnimation(headItem, "rotation"); - headAnimation->setStartValue(20); - headAnimation->setEndValue(-20); - QPropertyAnimation *headScaleAnimation = new QPropertyAnimation(headItem, "scale"); - headScaleAnimation->setEndValue(1.1); - animation->addAnimation(headAnimation); - animation->addAnimation(headScaleAnimation); -//! [12] - - QPropertyAnimation *upperLeftArmAnimation = new QPropertyAnimation(upperLeftArmItem, "rotation"); - upperLeftArmAnimation->setStartValue(190); - upperLeftArmAnimation->setEndValue(180); - animation->addAnimation(upperLeftArmAnimation); - - QPropertyAnimation *lowerLeftArmAnimation = new QPropertyAnimation(lowerLeftArmItem, "rotation"); - lowerLeftArmAnimation->setStartValue(50); - lowerLeftArmAnimation->setEndValue(10); - animation->addAnimation(lowerLeftArmAnimation); - - QPropertyAnimation *upperRightArmAnimation = new QPropertyAnimation(upperRightArmItem, "rotation"); - upperRightArmAnimation->setStartValue(300); - upperRightArmAnimation->setEndValue(310); - animation->addAnimation(upperRightArmAnimation); - - QPropertyAnimation *lowerRightArmAnimation = new QPropertyAnimation(lowerRightArmItem, "rotation"); - lowerRightArmAnimation->setStartValue(0); - lowerRightArmAnimation->setEndValue(-70); - animation->addAnimation(lowerRightArmAnimation); - - QPropertyAnimation *upperLeftLegAnimation = new QPropertyAnimation(upperLeftLegItem, "rotation"); - upperLeftLegAnimation->setStartValue(150); - upperLeftLegAnimation->setEndValue(80); - animation->addAnimation(upperLeftLegAnimation); - - QPropertyAnimation *lowerLeftLegAnimation = new QPropertyAnimation(lowerLeftLegItem, "rotation"); - lowerLeftLegAnimation->setStartValue(70); - lowerLeftLegAnimation->setEndValue(10); - animation->addAnimation(lowerLeftLegAnimation); - - QPropertyAnimation *upperRightLegAnimation = new QPropertyAnimation(upperRightLegItem, "rotation"); - upperRightLegAnimation->setStartValue(40); - upperRightLegAnimation->setEndValue(120); - animation->addAnimation(upperRightLegAnimation); - - QPropertyAnimation *lowerRightLegAnimation = new QPropertyAnimation(lowerRightLegItem, "rotation"); - lowerRightLegAnimation->setStartValue(10); - lowerRightLegAnimation->setEndValue(50); - animation->addAnimation(lowerRightLegAnimation); - - QPropertyAnimation *torsoAnimation = new QPropertyAnimation(torsoItem, "rotation"); - torsoAnimation->setStartValue(5); - torsoAnimation->setEndValue(-20); - animation->addAnimation(torsoAnimation); - -//! [13] - for (int i = 0; i < animation->animationCount(); ++i) { - QPropertyAnimation *anim = qobject_cast(animation->animationAt(i)); - anim->setEasingCurve(QEasingCurve::SineCurve); - anim->setDuration(2000); - } - - animation->setLoopCount(-1); - animation->start(); -//! [13] -} - -//! [9] -QRectF Robot::boundingRect() const -{ - return QRectF(); -} - -void Robot::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(painter); - Q_UNUSED(option); - Q_UNUSED(widget); -} -//! [9] diff --git a/examples/graphicsview/dragdroprobot/robot.h b/examples/graphicsview/dragdroprobot/robot.h deleted file mode 100644 index ff9fb49485..0000000000 --- a/examples/graphicsview/dragdroprobot/robot.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 ROBOT_H -#define ROBOT_H - -#include - -QT_BEGIN_NAMESPACE -class QGraphicsSceneMouseEvent; -class QParallelAnimationGroup; -QT_END_NAMESPACE - -//! [0] -class RobotPart : public QGraphicsObject -{ -public: - RobotPart(QGraphicsItem *parent = 0); - -protected: - void dragEnterEvent(QGraphicsSceneDragDropEvent *event); - void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); - void dropEvent(QGraphicsSceneDragDropEvent *event); - - QColor color; - bool dragOver; -}; -//! [0] - -//! [1] -class RobotHead : public RobotPart -{ -public: - RobotHead(QGraphicsItem *parent = 0); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -protected: - void dragEnterEvent(QGraphicsSceneDragDropEvent *event); - void dropEvent(QGraphicsSceneDragDropEvent *event); - -private: - QPixmap pixmap; -}; -//! [1] - -//! [2] -class RobotTorso : public RobotPart -{ -public: - RobotTorso(QGraphicsItem *parent = 0); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); -}; -//! [2] - -//! [3] -class RobotLimb : public RobotPart -{ -public: - RobotLimb(QGraphicsItem *parent = 0); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); -}; -//! [3] - -//! [4] -class Robot : public RobotPart -{ -public: - Robot(QGraphicsItem *parent = 0); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); -}; -//! [4] - -#endif diff --git a/examples/graphicsview/dragdroprobot/robot.qrc b/examples/graphicsview/dragdroprobot/robot.qrc deleted file mode 100644 index b0969d2a64..0000000000 --- a/examples/graphicsview/dragdroprobot/robot.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/head.png - - diff --git a/examples/graphicsview/elasticnodes/edge.cpp b/examples/graphicsview/elasticnodes/edge.cpp deleted file mode 100644 index ee7334cdcc..0000000000 --- a/examples/graphicsview/elasticnodes/edge.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "edge.h" -#include "node.h" - -#include - -static const double Pi = 3.14159265358979323846264338327950288419717; -static double TwoPi = 2.0 * Pi; - -//! [0] -Edge::Edge(Node *sourceNode, Node *destNode) - : arrowSize(10) -{ - setAcceptedMouseButtons(0); - source = sourceNode; - dest = destNode; - source->addEdge(this); - dest->addEdge(this); - adjust(); -} -//! [0] - -//! [1] -Node *Edge::sourceNode() const -{ - return source; -} - -Node *Edge::destNode() const -{ - return dest; -} -//! [1] - -//! [2] -void Edge::adjust() -{ - if (!source || !dest) - return; - - QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0)); - qreal length = line.length(); - - prepareGeometryChange(); - - if (length > qreal(20.)) { - QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length); - sourcePoint = line.p1() + edgeOffset; - destPoint = line.p2() - edgeOffset; - } else { - sourcePoint = destPoint = line.p1(); - } -} -//! [2] - -//! [3] -QRectF Edge::boundingRect() const -{ - if (!source || !dest) - return QRectF(); - - qreal penWidth = 1; - qreal extra = (penWidth + arrowSize) / 2.0; - - return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(), - destPoint.y() - sourcePoint.y())) - .normalized() - .adjusted(-extra, -extra, extra, extra); -} -//! [3] - -//! [4] -void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - if (!source || !dest) - return; - - QLineF line(sourcePoint, destPoint); - if (qFuzzyCompare(line.length(), qreal(0.))) - return; -//! [4] - -//! [5] - // Draw the line itself - painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter->drawLine(line); -//! [5] - -//! [6] - // Draw the arrows - double angle = ::acos(line.dx() / line.length()); - if (line.dy() >= 0) - angle = TwoPi - angle; - - QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize, - cos(angle + Pi / 3) * arrowSize); - QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize, - cos(angle + Pi - Pi / 3) * arrowSize); - QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize, - cos(angle - Pi / 3) * arrowSize); - QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize, - cos(angle - Pi + Pi / 3) * arrowSize); - - painter->setBrush(Qt::black); - painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2); - painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2); -} -//! [6] diff --git a/examples/graphicsview/elasticnodes/edge.h b/examples/graphicsview/elasticnodes/edge.h deleted file mode 100644 index 9bf4112212..0000000000 --- a/examples/graphicsview/elasticnodes/edge.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 EDGE_H -#define EDGE_H - -#include - -class Node; - -//! [0] -class Edge : public QGraphicsItem -{ -public: - Edge(Node *sourceNode, Node *destNode); - - Node *sourceNode() const; - Node *destNode() const; - - void adjust(); - - enum { Type = UserType + 2 }; - int type() const { return Type; } - -protected: - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -private: - Node *source, *dest; - - QPointF sourcePoint; - QPointF destPoint; - qreal arrowSize; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/elasticnodes/elasticnodes.desktop b/examples/graphicsview/elasticnodes/elasticnodes.desktop deleted file mode 100644 index 64402d080f..0000000000 --- a/examples/graphicsview/elasticnodes/elasticnodes.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Elastic Nodes -Exec=/opt/usr/bin/elasticnodes -Icon=elasticnodes -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/elasticnodes/elasticnodes.pro b/examples/graphicsview/elasticnodes/elasticnodes.pro deleted file mode 100644 index 2a61809457..0000000000 --- a/examples/graphicsview/elasticnodes/elasticnodes.pro +++ /dev/null @@ -1,20 +0,0 @@ -HEADERS += \ - edge.h \ - node.h \ - graphwidget.h - -SOURCES += \ - edge.cpp \ - main.cpp \ - node.cpp \ - graphwidget.cpp - -TARGET.EPOCHEAPSIZE = 0x200000 0xA00000 - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/elasticnodes -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS elasticnodes.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/elasticnodes -INSTALLS += target sources - -QT += widgets diff --git a/examples/graphicsview/elasticnodes/graphwidget.cpp b/examples/graphicsview/elasticnodes/graphwidget.cpp deleted file mode 100644 index 36005b85f4..0000000000 --- a/examples/graphicsview/elasticnodes/graphwidget.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "graphwidget.h" -#include "edge.h" -#include "node.h" - -#include - -#include - -//! [0] -GraphWidget::GraphWidget(QWidget *parent) - : QGraphicsView(parent), timerId(0) -{ - QGraphicsScene *scene = new QGraphicsScene(this); - scene->setItemIndexMethod(QGraphicsScene::NoIndex); - scene->setSceneRect(-200, -200, 400, 400); - setScene(scene); - setCacheMode(CacheBackground); - setViewportUpdateMode(BoundingRectViewportUpdate); - setRenderHint(QPainter::Antialiasing); - setTransformationAnchor(AnchorUnderMouse); - scale(qreal(0.8), qreal(0.8)); - setMinimumSize(400, 400); - setWindowTitle(tr("Elastic Nodes")); -//! [0] - -//! [1] - Node *node1 = new Node(this); - Node *node2 = new Node(this); - Node *node3 = new Node(this); - Node *node4 = new Node(this); - centerNode = new Node(this); - Node *node6 = new Node(this); - Node *node7 = new Node(this); - Node *node8 = new Node(this); - Node *node9 = new Node(this); - scene->addItem(node1); - scene->addItem(node2); - scene->addItem(node3); - scene->addItem(node4); - scene->addItem(centerNode); - scene->addItem(node6); - scene->addItem(node7); - scene->addItem(node8); - scene->addItem(node9); - scene->addItem(new Edge(node1, node2)); - scene->addItem(new Edge(node2, node3)); - scene->addItem(new Edge(node2, centerNode)); - scene->addItem(new Edge(node3, node6)); - scene->addItem(new Edge(node4, node1)); - scene->addItem(new Edge(node4, centerNode)); - scene->addItem(new Edge(centerNode, node6)); - scene->addItem(new Edge(centerNode, node8)); - scene->addItem(new Edge(node6, node9)); - scene->addItem(new Edge(node7, node4)); - scene->addItem(new Edge(node8, node7)); - scene->addItem(new Edge(node9, node8)); - - node1->setPos(-50, -50); - node2->setPos(0, -50); - node3->setPos(50, -50); - node4->setPos(-50, 0); - centerNode->setPos(0, 0); - node6->setPos(50, 0); - node7->setPos(-50, 50); - node8->setPos(0, 50); - node9->setPos(50, 50); -} -//! [1] - -//! [2] -void GraphWidget::itemMoved() -{ - if (!timerId) - timerId = startTimer(1000 / 25); -} -//! [2] - -//! [3] -void GraphWidget::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Up: - centerNode->moveBy(0, -20); - break; - case Qt::Key_Down: - centerNode->moveBy(0, 20); - break; - case Qt::Key_Left: - centerNode->moveBy(-20, 0); - break; - case Qt::Key_Right: - centerNode->moveBy(20, 0); - break; - case Qt::Key_Plus: - zoomIn(); - break; - case Qt::Key_Minus: - zoomOut(); - break; - case Qt::Key_Space: - case Qt::Key_Enter: - shuffle(); - break; - default: - QGraphicsView::keyPressEvent(event); - } -} -//! [3] - -//! [4] -void GraphWidget::timerEvent(QTimerEvent *event) -{ - Q_UNUSED(event); - - QList nodes; - foreach (QGraphicsItem *item, scene()->items()) { - if (Node *node = qgraphicsitem_cast(item)) - nodes << node; - } - - foreach (Node *node, nodes) - node->calculateForces(); - - bool itemsMoved = false; - foreach (Node *node, nodes) { - if (node->advance()) - itemsMoved = true; - } - - if (!itemsMoved) { - killTimer(timerId); - timerId = 0; - } -} -//! [4] - -//! [5] -void GraphWidget::wheelEvent(QWheelEvent *event) -{ - scaleView(pow((double)2, -event->delta() / 240.0)); -} -//! [5] - -//! [6] -void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect) -{ - Q_UNUSED(rect); - - // Shadow - QRectF sceneRect = this->sceneRect(); - QRectF rightShadow(sceneRect.right(), sceneRect.top() + 5, 5, sceneRect.height()); - QRectF bottomShadow(sceneRect.left() + 5, sceneRect.bottom(), sceneRect.width(), 5); - if (rightShadow.intersects(rect) || rightShadow.contains(rect)) - painter->fillRect(rightShadow, Qt::darkGray); - if (bottomShadow.intersects(rect) || bottomShadow.contains(rect)) - painter->fillRect(bottomShadow, Qt::darkGray); - - // Fill - QLinearGradient gradient(sceneRect.topLeft(), sceneRect.bottomRight()); - gradient.setColorAt(0, Qt::white); - gradient.setColorAt(1, Qt::lightGray); - painter->fillRect(rect.intersected(sceneRect), gradient); - painter->setBrush(Qt::NoBrush); - painter->drawRect(sceneRect); - - // Text - QRectF textRect(sceneRect.left() + 4, sceneRect.top() + 4, - sceneRect.width() - 4, sceneRect.height() - 4); - QString message(tr("Click and drag the nodes around, and zoom with the mouse " - "wheel or the '+' and '-' keys")); - - QFont font = painter->font(); - font.setBold(true); - font.setPointSize(14); - painter->setFont(font); - painter->setPen(Qt::lightGray); - painter->drawText(textRect.translated(2, 2), message); - painter->setPen(Qt::black); - painter->drawText(textRect, message); -} -//! [6] - -//! [7] -void GraphWidget::scaleView(qreal scaleFactor) -{ - qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); - if (factor < 0.07 || factor > 100) - return; - - scale(scaleFactor, scaleFactor); -} -//! [7] - -void GraphWidget::shuffle() -{ - foreach (QGraphicsItem *item, scene()->items()) { - if (qgraphicsitem_cast(item)) - item->setPos(-150 + qrand() % 300, -150 + qrand() % 300); - } -} - -void GraphWidget::zoomIn() -{ - scaleView(qreal(1.2)); -} - -void GraphWidget::zoomOut() -{ - scaleView(1 / qreal(1.2)); -} diff --git a/examples/graphicsview/elasticnodes/graphwidget.h b/examples/graphicsview/elasticnodes/graphwidget.h deleted file mode 100644 index 61bcfdb5cb..0000000000 --- a/examples/graphicsview/elasticnodes/graphwidget.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 GRAPHWIDGET_H -#define GRAPHWIDGET_H - -#include - -class Node; - -//! [0] -class GraphWidget : public QGraphicsView -{ - Q_OBJECT - -public: - GraphWidget(QWidget *parent = 0); - - void itemMoved(); - -public slots: - void shuffle(); - void zoomIn(); - void zoomOut(); - -protected: - void keyPressEvent(QKeyEvent *event); - void timerEvent(QTimerEvent *event); - void wheelEvent(QWheelEvent *event); - void drawBackground(QPainter *painter, const QRectF &rect); - - void scaleView(qreal scaleFactor); - -private: - int timerId; - Node *centerNode; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/elasticnodes/main.cpp b/examples/graphicsview/elasticnodes/main.cpp deleted file mode 100644 index 239b8290ea..0000000000 --- a/examples/graphicsview/elasticnodes/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "graphwidget.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); - - GraphWidget *widget = new GraphWidget; - - QMainWindow mainWindow; - mainWindow.setCentralWidget(widget); - - mainWindow.show(); - return app.exec(); -} diff --git a/examples/graphicsview/elasticnodes/node.cpp b/examples/graphicsview/elasticnodes/node.cpp deleted file mode 100644 index dad226a5e6..0000000000 --- a/examples/graphicsview/elasticnodes/node.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -#include "edge.h" -#include "node.h" -#include "graphwidget.h" - -//! [0] -Node::Node(GraphWidget *graphWidget) - : graph(graphWidget) -{ - setFlag(ItemIsMovable); - setFlag(ItemSendsGeometryChanges); - setCacheMode(DeviceCoordinateCache); - setZValue(-1); -} -//! [0] - -//! [1] -void Node::addEdge(Edge *edge) -{ - edgeList << edge; - edge->adjust(); -} - -QList Node::edges() const -{ - return edgeList; -} -//! [1] - -//! [2] -void Node::calculateForces() -{ - if (!scene() || scene()->mouseGrabberItem() == this) { - newPos = pos(); - return; - } -//! [2] - -//! [3] - // Sum up all forces pushing this item away - qreal xvel = 0; - qreal yvel = 0; - foreach (QGraphicsItem *item, scene()->items()) { - Node *node = qgraphicsitem_cast(item); - if (!node) - continue; - - QPointF vec = mapToItem(node, 0, 0); - qreal dx = vec.x(); - qreal dy = vec.y(); - double l = 2.0 * (dx * dx + dy * dy); - if (l > 0) { - xvel += (dx * 150.0) / l; - yvel += (dy * 150.0) / l; - } - } -//! [3] - -//! [4] - // Now subtract all forces pulling items together - double weight = (edgeList.size() + 1) * 10; - foreach (Edge *edge, edgeList) { - QPointF vec; - if (edge->sourceNode() == this) - vec = mapToItem(edge->destNode(), 0, 0); - else - vec = mapToItem(edge->sourceNode(), 0, 0); - xvel -= vec.x() / weight; - yvel -= vec.y() / weight; - } -//! [4] - -//! [5] - if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1) - xvel = yvel = 0; -//! [5] - -//! [6] - 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)); -} -//! [6] - -//! [7] -bool Node::advance() -{ - if (newPos == pos()) - return false; - - setPos(newPos); - return true; -} -//! [7] - -//! [8] -QRectF Node::boundingRect() const -{ - qreal adjust = 2; - return QRectF( -10 - adjust, -10 - adjust, - 23 + adjust, 23 + adjust); -} -//! [8] - -//! [9] -QPainterPath Node::shape() const -{ - QPainterPath path; - path.addEllipse(-10, -10, 20, 20); - return path; -} -//! [9] - -//! [10] -void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) -{ - painter->setPen(Qt::NoPen); - painter->setBrush(Qt::darkGray); - painter->drawEllipse(-7, -7, 20, 20); - - QRadialGradient gradient(-3, -3, 10); - if (option->state & QStyle::State_Sunken) { - gradient.setCenter(3, 3); - gradient.setFocalPoint(3, 3); - gradient.setColorAt(1, QColor(Qt::yellow).light(120)); - gradient.setColorAt(0, QColor(Qt::darkYellow).light(120)); - } else { - gradient.setColorAt(0, Qt::yellow); - gradient.setColorAt(1, Qt::darkYellow); - } - painter->setBrush(gradient); - - painter->setPen(QPen(Qt::black, 0)); - painter->drawEllipse(-10, -10, 20, 20); -} -//! [10] - -//! [11] -QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) -{ - switch (change) { - case ItemPositionHasChanged: - foreach (Edge *edge, edgeList) - edge->adjust(); - graph->itemMoved(); - break; - default: - break; - }; - - return QGraphicsItem::itemChange(change, value); -} -//! [11] - -//! [12] -void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - update(); - QGraphicsItem::mousePressEvent(event); -} - -void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - update(); - QGraphicsItem::mouseReleaseEvent(event); -} -//! [12] diff --git a/examples/graphicsview/elasticnodes/node.h b/examples/graphicsview/elasticnodes/node.h deleted file mode 100644 index 86ca407e08..0000000000 --- a/examples/graphicsview/elasticnodes/node.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 NODE_H -#define NODE_H - -#include -#include - -class Edge; -class GraphWidget; -QT_BEGIN_NAMESPACE -class QGraphicsSceneMouseEvent; -QT_END_NAMESPACE - -//! [0] -class Node : public QGraphicsItem -{ -public: - Node(GraphWidget *graphWidget); - - void addEdge(Edge *edge); - QList edges() const; - - enum { Type = UserType + 1 }; - int type() const { return Type; } - - void calculateForces(); - bool advance(); - - QRectF boundingRect() const; - QPainterPath shape() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - -private: - QList edgeList; - QPointF newPos; - GraphWidget *graph; -}; -//! [0] - -#endif diff --git a/examples/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg b/examples/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg deleted file mode 100644 index 445567fbda..0000000000 Binary files a/examples/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg and /dev/null differ diff --git a/examples/graphicsview/embeddeddialogs/customproxy.cpp b/examples/graphicsview/embeddeddialogs/customproxy.cpp deleted file mode 100644 index 2aa2986014..0000000000 --- a/examples/graphicsview/embeddeddialogs/customproxy.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customproxy.h" - -#include - -CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsProxyWidget(parent, wFlags), popupShown(false), currentPopup(0) -{ - timeLine = new QTimeLine(250, this); - connect(timeLine, SIGNAL(valueChanged(qreal)), - this, SLOT(updateStep(qreal))); - connect(timeLine, SIGNAL(stateChanged(QTimeLine::State)), - this, SLOT(stateChanged(QTimeLine::State))); -} - -QRectF CustomProxy::boundingRect() const -{ - return QGraphicsProxyWidget::boundingRect().adjusted(0, 0, 10, 10); -} - -void CustomProxy::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - const QColor color(0, 0, 0, 64); - - QRectF r = windowFrameRect(); - QRectF right(r.right(), r.top() + 10, 10, r.height() - 10); - QRectF bottom(r.left() + 10, r.bottom(), r.width(), 10); - bool intersectsRight = right.intersects(option->exposedRect); - bool intersectsBottom = bottom.intersects(option->exposedRect); - if (intersectsRight && intersectsBottom) { - QPainterPath path; - path.addRect(right); - path.addRect(bottom); - painter->setPen(Qt::NoPen); - painter->setBrush(color); - painter->drawPath(path); - } else if (intersectsBottom) { - painter->fillRect(bottom, color); - } else if (intersectsRight) { - painter->fillRect(right, color); - } - - QGraphicsProxyWidget::paintWindowFrame(painter, option, widget); -} - -void CustomProxy::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - QGraphicsProxyWidget::hoverEnterEvent(event); - scene()->setActiveWindow(this); - if (timeLine->currentValue() != 1) - zoomIn(); -} - -void CustomProxy::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - QGraphicsProxyWidget::hoverLeaveEvent(event); - if (!popupShown && (timeLine->direction() != QTimeLine::Backward || timeLine->currentValue() != 0)) - zoomOut(); -} - -bool CustomProxy::sceneEventFilter(QGraphicsItem *watched, QEvent *event) -{ - if (watched->isWindow() && (event->type() == QEvent::UngrabMouse || event->type() == QEvent::GrabMouse)) { - popupShown = watched->isVisible(); - if (!popupShown && !isUnderMouse()) - zoomOut(); - } - return QGraphicsProxyWidget::sceneEventFilter(watched, event); -} - -QVariant CustomProxy::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { - if (change == ItemChildAddedChange) { - currentPopup = qvariant_cast(value); - currentPopup->setCacheMode(ItemCoordinateCache); - if (scene()) - currentPopup->installSceneEventFilter(this); - } else if (scene()) { - currentPopup->removeSceneEventFilter(this); - currentPopup = 0; - } - } else if (currentPopup && change == ItemSceneHasChanged) { - currentPopup->installSceneEventFilter(this); - } - return QGraphicsProxyWidget::itemChange(change, value); -} - -void CustomProxy::updateStep(qreal step) -{ - QRectF r = boundingRect(); - setTransform(QTransform() - .translate(r.width() / 2, r.height() / 2) - .rotate(step * 30, Qt::XAxis) - .rotate(step * 10, Qt::YAxis) - .rotate(step * 5, Qt::ZAxis) - .scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, -r.height() / 2)); -} - -void CustomProxy::stateChanged(QTimeLine::State state) -{ - if (state == QTimeLine::Running) { - if (timeLine->direction() == QTimeLine::Forward) - setCacheMode(ItemCoordinateCache); - } else if (state == QTimeLine::NotRunning) { - if (timeLine->direction() == QTimeLine::Backward) - setCacheMode(DeviceCoordinateCache); - } -} - -void CustomProxy::zoomIn() -{ - if (timeLine->direction() != QTimeLine::Forward) - timeLine->setDirection(QTimeLine::Forward); - if (timeLine->state() == QTimeLine::NotRunning) - timeLine->start(); -} - -void CustomProxy::zoomOut() -{ - if (timeLine->direction() != QTimeLine::Backward) - timeLine->setDirection(QTimeLine::Backward); - if (timeLine->state() == QTimeLine::NotRunning) - timeLine->start(); -} diff --git a/examples/graphicsview/embeddeddialogs/customproxy.h b/examples/graphicsview/embeddeddialogs/customproxy.h deleted file mode 100644 index c85bbaccd3..0000000000 --- a/examples/graphicsview/embeddeddialogs/customproxy.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMPROXY_H -#define CUSTOMPROXY_H - -#include -#include - -class CustomProxy : public QGraphicsProxyWidget -{ - Q_OBJECT -public: - CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); - - QRectF boundingRect() const; - void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget); - -protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - -private slots: - void updateStep(qreal step); - void stateChanged(QTimeLine::State); - void zoomIn(); - void zoomOut(); - -private: - QTimeLine *timeLine; - bool popupShown; - QGraphicsItem *currentPopup; -}; - -#endif diff --git a/examples/graphicsview/embeddeddialogs/embeddeddialog.cpp b/examples/graphicsview/embeddeddialogs/embeddeddialog.cpp deleted file mode 100644 index e306f32c71..0000000000 --- a/examples/graphicsview/embeddeddialogs/embeddeddialog.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "embeddeddialog.h" -#include "ui_embeddeddialog.h" - -#include - -EmbeddedDialog::EmbeddedDialog(QWidget *parent) - : QDialog(parent) -{ - ui = new Ui_embeddedDialog; - ui->setupUi(this); - ui->layoutDirection->setCurrentIndex(layoutDirection() != Qt::LeftToRight); - - foreach (QString styleName, QStyleFactory::keys()) { - ui->style->addItem(styleName); - if (style()->objectName().toLower() == styleName.toLower()) - ui->style->setCurrentIndex(ui->style->count() - 1); - } - - connect(ui->layoutDirection, SIGNAL(activated(int)), - this, SLOT(layoutDirectionChanged(int))); - connect(ui->spacing, SIGNAL(valueChanged(int)), - this, SLOT(spacingChanged(int))); - connect(ui->fontComboBox, SIGNAL(currentFontChanged(QFont)), - this, SLOT(fontChanged(QFont))); - connect(ui->style, SIGNAL(activated(QString)), - this, SLOT(styleChanged(QString))); -} - -EmbeddedDialog::~EmbeddedDialog() -{ - delete ui; -} - -void EmbeddedDialog::layoutDirectionChanged(int index) -{ - setLayoutDirection(index == 0 ? Qt::LeftToRight : Qt::RightToLeft); -} - -void EmbeddedDialog::spacingChanged(int spacing) -{ - layout()->setSpacing(spacing); - adjustSize(); -} - -void EmbeddedDialog::fontChanged(const QFont &font) -{ - setFont(font); -} - -static void setStyleHelper(QWidget *widget, QStyle *style) -{ - widget->setStyle(style); - widget->setPalette(style->standardPalette()); - foreach (QObject *child, widget->children()) { - if (QWidget *childWidget = qobject_cast(child)) - setStyleHelper(childWidget, style); - } -} - -void EmbeddedDialog::styleChanged(const QString &styleName) -{ - QStyle *style = QStyleFactory::create(styleName); - if (style) - setStyleHelper(this, style); -} diff --git a/examples/graphicsview/embeddeddialogs/embeddeddialog.h b/examples/graphicsview/embeddeddialogs/embeddeddialog.h deleted file mode 100644 index 59aa4c244a..0000000000 --- a/examples/graphicsview/embeddeddialogs/embeddeddialog.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef EMBEDDEDDIALOG_H -#define EMBEDDEDDIALOG_H - -#include - -QT_FORWARD_DECLARE_CLASS(Ui_embeddedDialog); - -class EmbeddedDialog : public QDialog -{ - Q_OBJECT -public: - EmbeddedDialog(QWidget *parent = 0); - ~EmbeddedDialog(); - -private slots: - void layoutDirectionChanged(int index); - void spacingChanged(int spacing); - void fontChanged(const QFont &font); - void styleChanged(const QString &styleName); - -private: - Ui_embeddedDialog *ui; -}; - -#endif diff --git a/examples/graphicsview/embeddeddialogs/embeddeddialog.ui b/examples/graphicsview/embeddeddialogs/embeddeddialog.ui deleted file mode 100644 index f967b10085..0000000000 --- a/examples/graphicsview/embeddeddialogs/embeddeddialog.ui +++ /dev/null @@ -1,87 +0,0 @@ - - embeddedDialog - - - - 0 - 0 - 407 - 134 - - - - Embedded Dialog - - - - - - Layout Direction: - - - layoutDirection - - - - - - - - Left to Right - - - - - Right to Left - - - - - - - - Select Font: - - - fontComboBox - - - - - - - - - - Style: - - - style - - - - - - - - - - Layout spacing: - - - spacing - - - - - - - Qt::Horizontal - - - - - - - - diff --git a/examples/graphicsview/embeddeddialogs/embeddeddialogs.pro b/examples/graphicsview/embeddeddialogs/embeddeddialogs.pro deleted file mode 100644 index 6244df4b68..0000000000 --- a/examples/graphicsview/embeddeddialogs/embeddeddialogs.pro +++ /dev/null @@ -1,19 +0,0 @@ -SOURCES += main.cpp -SOURCES += customproxy.cpp embeddeddialog.cpp -HEADERS += customproxy.h embeddeddialog.h - -FORMS += embeddeddialog.ui -RESOURCES += embeddeddialogs.qrc - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/embeddeddialogs -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.png *.jpg *.plist *.icns *.ico *.rc *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/embeddeddialogs -INSTALLS += target sources - -QT += widgets diff --git a/examples/graphicsview/embeddeddialogs/embeddeddialogs.qrc b/examples/graphicsview/embeddeddialogs/embeddeddialogs.qrc deleted file mode 100644 index 33be5038da..0000000000 --- a/examples/graphicsview/embeddeddialogs/embeddeddialogs.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - No-Ones-Laughing-3.jpg - - diff --git a/examples/graphicsview/embeddeddialogs/main.cpp b/examples/graphicsview/embeddeddialogs/main.cpp deleted file mode 100644 index 88b249e481..0000000000 --- a/examples/graphicsview/embeddeddialogs/main.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customproxy.h" -#include "embeddeddialog.h" - -#include - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(embeddeddialogs); - QApplication app(argc, argv); - - QGraphicsScene scene; - scene.setStickyFocus(true); -#ifndef Q_OS_WINCE - const int gridSize = 10; -#else - const int gridSize = 5; -#endif - - for (int y = 0; y < gridSize; ++y) { - for (int x = 0; x < gridSize; ++x) { - CustomProxy *proxy = new CustomProxy(0, Qt::Window); - proxy->setWidget(new EmbeddedDialog); - - QRectF rect = proxy->boundingRect(); - - proxy->setPos(x * rect.width() * 1.05, y * rect.height() * 1.05); - proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - - scene.addItem(proxy); - } - } - scene.setSceneRect(scene.itemsBoundingRect()); - - QGraphicsView view(&scene); - view.scale(0.5, 0.5); - view.setRenderHints(view.renderHints() | QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - view.setBackgroundBrush(QPixmap(":/No-Ones-Laughing-3.jpg")); - view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - view.show(); - view.setWindowTitle("Embedded Dialogs Example"); - return app.exec(); -} diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp deleted file mode 100644 index 3f787109eb..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "flowlayout.h" -#include -#include - -FlowLayout::FlowLayout() -{ - m_spacing[0] = 6; - m_spacing[1] = 6; - QSizePolicy sp = sizePolicy(); - sp.setHeightForWidth(true); - setSizePolicy(sp); -} - -void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item) -{ - item->setParentLayoutItem(this); - if (uint(index) > uint(m_items.count())) - index = m_items.count(); - m_items.insert(index, item); - invalidate(); -} - -int FlowLayout::count() const -{ - return m_items.count(); -} - -QGraphicsLayoutItem *FlowLayout::itemAt(int index) const -{ - return m_items.value(index); -} - -void FlowLayout::removeAt(int index) -{ - m_items.removeAt(index); - invalidate(); -} - -qreal FlowLayout::spacing(Qt::Orientation o) const -{ - return m_spacing[int(o) - 1]; -} - -void FlowLayout::setSpacing(Qt::Orientations o, qreal spacing) -{ - if (o & Qt::Horizontal) - m_spacing[0] = spacing; - if (o & Qt::Vertical) - m_spacing[1] = spacing; -} - -void FlowLayout::setGeometry(const QRectF &geom) -{ - QGraphicsLayout::setGeometry(geom); - doLayout(geom, true); -} - -qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const -{ - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - const qreal maxw = geom.width() - left - right; - - qreal x = 0; - qreal y = 0; - qreal maxRowHeight = 0; - QSizeF pref; - for (int i = 0; i < m_items.count(); ++i) { - QGraphicsLayoutItem *item = m_items.at(i); - pref = item->effectiveSizeHint(Qt::PreferredSize); - maxRowHeight = qMax(maxRowHeight, pref.height()); - - qreal next_x; - next_x = x + pref.width(); - if (next_x > maxw) { - if (x == 0) { - pref.setWidth(maxw); - } else { - x = 0; - next_x = pref.width(); - } - y += maxRowHeight + spacing(Qt::Vertical); - maxRowHeight = 0; - } - - if (applyNewGeometry) - item->setGeometry(QRectF(QPointF(left + x, top + y), pref)); - x = next_x + spacing(Qt::Horizontal); - } - maxRowHeight = qMax(maxRowHeight, pref.height()); - return top + y + maxRowHeight + bottom; -} - -QSizeF FlowLayout::minSize(const QSizeF &constraint) const -{ - QSizeF size(0, 0); - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - if (constraint.width() >= 0) { // height for width - const qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); - size = QSizeF(constraint.width(), height); - } else if (constraint.height() >= 0) { // width for height? - // not supported - } else { - QGraphicsLayoutItem *item; - foreach (item, m_items) - size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize)); - size += QSize(left + right, top + bottom); - } - return size; -} - -QSizeF FlowLayout::prefSize() const -{ - qreal left, right; - getContentsMargins(&left, 0, &right, 0); - - QGraphicsLayoutItem *item; - qreal maxh = 0; - qreal totalWidth = 0; - foreach (item, m_items) { - if (totalWidth > 0) - totalWidth += spacing(Qt::Horizontal); - QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); - totalWidth += pref.width(); - maxh = qMax(maxh, pref.height()); - } - maxh += spacing(Qt::Vertical); - - const qreal goldenAspectRatio = 1.61803399; - qreal w = qSqrt(totalWidth * maxh * goldenAspectRatio) + left + right; - - return minSize(QSizeF(w, -1)); -} - -QSizeF FlowLayout::maxSize() const -{ - QGraphicsLayoutItem *item; - qreal totalWidth = 0; - qreal totalHeight = 0; - foreach (item, m_items) { - if (totalWidth > 0) - totalWidth += spacing(Qt::Horizontal); - if (totalHeight > 0) - totalHeight += spacing(Qt::Vertical); - QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); - totalWidth += pref.width(); - totalHeight += pref.height(); - } - - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - return QSizeF(left + totalWidth + right, top + totalHeight + bottom); -} - -QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - QSizeF sh = constraint; - switch (which) { - case Qt::PreferredSize: - sh = prefSize(); - break; - case Qt::MinimumSize: - sh = minSize(constraint); - break; - case Qt::MaximumSize: - sh = maxSize(); - break; - default: - break; - } - return sh; -} diff --git a/examples/graphicsview/flowlayout/flowlayout.desktop b/examples/graphicsview/flowlayout/flowlayout.desktop deleted file mode 100644 index 54ea3b0290..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Flow Layout -Exec=/opt/usr/bin/flowlayout -Icon=flowlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h deleted file mode 100644 index 751e435ec0..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -class FlowLayout : public QGraphicsLayout -{ -public: - FlowLayout(); - inline void addItem(QGraphicsLayoutItem *item); - void insertItem(int index, QGraphicsLayoutItem *item); - void setSpacing(Qt::Orientations o, qreal spacing); - qreal spacing(Qt::Orientation o) const; - - // inherited functions - void setGeometry(const QRectF &geom); - - int count() const; - QGraphicsLayoutItem *itemAt(int index) const; - void removeAt(int index); - -protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - -private: - qreal doLayout(const QRectF &geom, bool applyNewGeometry) const; - QSizeF minSize(const QSizeF &constraint) const; - QSizeF prefSize() const; - QSizeF maxSize() const; - - QList m_items; - qreal m_spacing[2]; -}; - - -inline void FlowLayout::addItem(QGraphicsLayoutItem *item) -{ - insertItem(-1, item); -} diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro deleted file mode 100644 index 5f69a74d60..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.pro +++ /dev/null @@ -1,14 +0,0 @@ -QT += widgets - -QMAKE_PROJECT_NAME = flowlayout_graphicsview - -HEADERS += flowlayout.h window.h -SOURCES += flowlayout.cpp main.cpp window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/flowlayout -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/flowlayout -INSTALLS += target sources - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp deleted file mode 100644 index a7a1155224..0000000000 --- a/examples/graphicsview/flowlayout/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "window.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QGraphicsScene scene; - QGraphicsView *view = new QGraphicsView(&scene); - Window *w = new Window; - scene.addItem(w); - - view->resize(400, 300); - view->show(); - - return app.exec(); -} diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp deleted file mode 100644 index 193a2bbc6e..0000000000 --- a/examples/graphicsview/flowlayout/window.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include "flowlayout.h" -#include "window.h" - -Window::Window() -: QGraphicsWidget(0, Qt::Window) -{ - FlowLayout *lay = new FlowLayout; - QLatin1String wiseWords("I am not bothered by the fact that I am unknown." - " I am bothered when I do not know others. (Confucius)"); - QString sentence(wiseWords); - QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); - for (int i = 0; i < words.count(); ++i) { - QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); - QLabel *label = new QLabel(words.at(i)); - label->setFrameStyle(QFrame::Box | QFrame::Plain); - proxy->setWidget(label); - lay->addItem(proxy); - } - setLayout(lay); -} diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h deleted file mode 100644 index b1eb874c21..0000000000 --- a/examples/graphicsview/flowlayout/window.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -class Window : public QGraphicsWidget { - Q_OBJECT -public: - Window(); -}; diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro deleted file mode 100644 index 6b7de527c6..0000000000 --- a/examples/graphicsview/graphicsview.pro +++ /dev/null @@ -1,28 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = \ - chip \ - elasticnodes \ - embeddeddialogs \ - collidingmice \ - padnavigator \ - basicgraphicslayouts \ - diagramscene \ - dragdroprobot \ - flowlayout \ - anchorlayout \ - simpleanchorlayout \ - weatheranchorlayout - -contains(DEFINES, QT_NO_CURSOR)|contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= dragdroprobot - -contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles2):{ - SUBDIRS += boxes -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS graphicsview.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview -INSTALLS += target sources - -QT += widgets diff --git a/examples/graphicsview/padnavigator/flippablepad.cpp b/examples/graphicsview/padnavigator/flippablepad.cpp deleted file mode 100644 index a6c44af70c..0000000000 --- a/examples/graphicsview/padnavigator/flippablepad.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "flippablepad.h" - -#include - -//! [0] -static QRectF boundsFromSize(const QSize &size) -{ - return QRectF((-size.width() / 2.0) * 150, (-size.height() / 2.0) * 150, - size.width() * 150, size.height() * 150); -} -//! [0] - -//! [1] -static QPointF posForLocation(int column, int row, const QSize &size) -{ - return QPointF(column * 150, row * 150) - - QPointF((size.width() - 1) * 75, (size.height() - 1) * 75); -} -//! [1] - -//! [2] -FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent) - : RoundRectItem(boundsFromSize(size), QColor(226, 255, 92, 64), parent) -{ -//! [2] -//! [3] - int numIcons = size.width() * size.height(); - QList pixmaps; - QDirIterator it(":/images", QStringList() << "*.png"); - while (it.hasNext() && pixmaps.size() < numIcons) - pixmaps << it.next(); -//! [3] - -//! [4] - const QRectF iconRect(-54, -54, 108, 108); - const QColor iconColor(214, 240, 110, 128); - iconGrid.resize(size.height()); - int n = 0; - - for (int y = 0; y < size.height(); ++y) { - iconGrid[y].resize(size.width()); - for (int x = 0; x < size.width(); ++x) { - RoundRectItem *rect = new RoundRectItem(iconRect, iconColor, this); - rect->setZValue(1); - rect->setPos(posForLocation(x, y, size)); - rect->setPixmap(pixmaps.at(n++ % pixmaps.size())); - iconGrid[y][x] = rect; - } - } -} -//! [4] - -//! [5] -RoundRectItem *FlippablePad::iconAt(int column, int row) const -{ - return iconGrid[row][column]; -} -//! [5] diff --git a/examples/graphicsview/padnavigator/flippablepad.h b/examples/graphicsview/padnavigator/flippablepad.h deleted file mode 100644 index e0d1fe24e5..0000000000 --- a/examples/graphicsview/padnavigator/flippablepad.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 FLIPPABLEPAD_H -#define FLIPPABLEPAD_H - -#include "roundrectitem.h" - -#include -#include -#include - -//! [0] -class FlippablePad : public RoundRectItem -{ -public: - FlippablePad(const QSize &size, QGraphicsItem *parent = 0); - - RoundRectItem *iconAt(int column, int row) const; - -private: - QVector > iconGrid; -}; -//! [0] - -#endif // FLIPPABLEPAD_H diff --git a/examples/graphicsview/padnavigator/form.ui b/examples/graphicsview/padnavigator/form.ui deleted file mode 100644 index fc7d12321e..0000000000 --- a/examples/graphicsview/padnavigator/form.ui +++ /dev/null @@ -1,208 +0,0 @@ - - Form - - - - 0 - 0 - 378 - 385 - - - - BackSide - - - - - - Settings - - - true - - - true - - - - - - Title: - - - - - - - Pad Navigator Example - - - - - - - Modified: - - - - - - - Extent - - - - - - - - - 42 - - - Qt::Horizontal - - - - - - - 42 - - - - - - - - - - - - - - - Other input - - - true - - - true - - - - - - - Widgets On Graphics View - - - - - QGraphicsProxyWidget - - - - QGraphicsWidget - - - - QObject - - - - - QGraphicsItem - - - - - QGraphicsLayoutItem - - - - - - - QGraphicsGridLayout - - - - QGraphicsLayout - - - - QGraphicsLayoutItem - - - - - - - QGraphicsLinearLayout - - - - QGraphicsLayout - - - - QGraphicsLayoutItem - - - - - - - - - - - - - groupBox - hostName - dateTimeEdit - horizontalSlider - spinBox - groupBox_2 - treeWidget - - - - - horizontalSlider - valueChanged(int) - spinBox - setValue(int) - - - 184 - 125 - - - 275 - 127 - - - - - spinBox - valueChanged(int) - horizontalSlider - setValue(int) - - - 272 - 114 - - - 190 - 126 - - - - - diff --git a/examples/graphicsview/padnavigator/images/artsfftscope.png b/examples/graphicsview/padnavigator/images/artsfftscope.png deleted file mode 100644 index 4db003f8d2..0000000000 Binary files a/examples/graphicsview/padnavigator/images/artsfftscope.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/blue_angle_swirl.jpg b/examples/graphicsview/padnavigator/images/blue_angle_swirl.jpg deleted file mode 100644 index 5bf0debdbd..0000000000 Binary files a/examples/graphicsview/padnavigator/images/blue_angle_swirl.jpg and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/kontact_contacts.png b/examples/graphicsview/padnavigator/images/kontact_contacts.png deleted file mode 100644 index 6fb4cc8f38..0000000000 Binary files a/examples/graphicsview/padnavigator/images/kontact_contacts.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/kontact_journal.png b/examples/graphicsview/padnavigator/images/kontact_journal.png deleted file mode 100644 index b1fedb6982..0000000000 Binary files a/examples/graphicsview/padnavigator/images/kontact_journal.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/kontact_mail.png b/examples/graphicsview/padnavigator/images/kontact_mail.png deleted file mode 100644 index 672f8fa3ab..0000000000 Binary files a/examples/graphicsview/padnavigator/images/kontact_mail.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/kontact_notes.png b/examples/graphicsview/padnavigator/images/kontact_notes.png deleted file mode 100644 index 229bf73ac6..0000000000 Binary files a/examples/graphicsview/padnavigator/images/kontact_notes.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/kopeteavailable.png b/examples/graphicsview/padnavigator/images/kopeteavailable.png deleted file mode 100644 index 2eaf41afec..0000000000 Binary files a/examples/graphicsview/padnavigator/images/kopeteavailable.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/metacontact_online.png b/examples/graphicsview/padnavigator/images/metacontact_online.png deleted file mode 100644 index 6a398dd10f..0000000000 Binary files a/examples/graphicsview/padnavigator/images/metacontact_online.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/images/minitools.png b/examples/graphicsview/padnavigator/images/minitools.png deleted file mode 100644 index 0248c9d50a..0000000000 Binary files a/examples/graphicsview/padnavigator/images/minitools.png and /dev/null differ diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp deleted file mode 100644 index 380fde8cd9..0000000000 --- a/examples/graphicsview/padnavigator/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "padnavigator.h" - -#include - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(padnavigator); - - PadNavigator navigator(QSize(3, 3)); - navigator.show(); - return app.exec(); -} -//! [0] diff --git a/examples/graphicsview/padnavigator/padnavigator.cpp b/examples/graphicsview/padnavigator/padnavigator.cpp deleted file mode 100644 index fcfe84bb72..0000000000 --- a/examples/graphicsview/padnavigator/padnavigator.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "flippablepad.h" -#include "padnavigator.h" -#include "splashitem.h" - -#include -#ifndef QT_NO_OPENGL -#include -#endif - -//! [0] -PadNavigator::PadNavigator(const QSize &size, QWidget *parent) - : QGraphicsView(parent) -{ -//! [0] -//! [1] - // Splash item - SplashItem *splash = new SplashItem; - splash->setZValue(1); -//! [1] - -//! [2] - // Pad item - FlippablePad *pad = new FlippablePad(size); - QGraphicsRotation *flipRotation = new QGraphicsRotation(pad); - QGraphicsRotation *xRotation = new QGraphicsRotation(pad); - QGraphicsRotation *yRotation = new QGraphicsRotation(pad); - flipRotation->setAxis(Qt::YAxis); - xRotation->setAxis(Qt::YAxis); - yRotation->setAxis(Qt::XAxis); - pad->setTransformations(QList() - << flipRotation - << xRotation << yRotation); -//! [2] - -//! [3] - // Back (proxy widget) item - QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad); - QWidget *widget = new QWidget; - form.setupUi(widget); - form.hostName->setFocus(); - backItem->setWidget(widget); - backItem->setVisible(false); - backItem->setFocus(); - backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); - const QRectF r = backItem->rect(); - backItem->setTransform(QTransform() - .rotate(180, Qt::YAxis) - .translate(-r.width()/2, -r.height()/2)); -//! [3] - -//! [4] - // Selection item - RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), - Qt::gray, pad); - selectionItem->setZValue(0.5); -//! [4] - -//! [5] - // Splash animations - QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y"); - QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity"); - smoothSplashMove->setEasingCurve(QEasingCurve::InQuad); - smoothSplashMove->setDuration(250); - smoothSplashOpacity->setDuration(250); -//! [5] - -//! [6] - // Selection animation - QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x"); - QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y"); - QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle"); - QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle"); - smoothXSelection->setDuration(125); - smoothYSelection->setDuration(125); - smoothXRotation->setDuration(125); - smoothYRotation->setDuration(125); - smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad); - smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad); - smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); -//! [6] - -//! [7] - // Flip animation setup - QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle"); - QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale"); - QPropertyAnimation *smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle"); - QPropertyAnimation *smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle"); - QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this); - smoothFlipScale->setDuration(500); - smoothFlipRotation->setDuration(500); - smoothFlipXRotation->setDuration(500); - smoothFlipYRotation->setDuration(500); - smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipScale->setKeyValueAt(0, qvariant_cast(1.0)); - smoothFlipScale->setKeyValueAt(0.5, qvariant_cast(0.7)); - smoothFlipScale->setKeyValueAt(1, qvariant_cast(1.0)); - flipAnimation->addAnimation(smoothFlipRotation); - flipAnimation->addAnimation(smoothFlipScale); - flipAnimation->addAnimation(smoothFlipXRotation); - flipAnimation->addAnimation(smoothFlipYRotation); -//! [7] - -//! [8] - // Flip animation delayed property assignment - QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup; - QPropertyAnimation *setFillAnimation = new QPropertyAnimation(pad, "fill"); - QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(backItem, "visible"); - QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(selectionItem, "visible"); - setFillAnimation->setDuration(0); - setBackItemVisibleAnimation->setDuration(0); - setSelectionItemVisibleAnimation->setDuration(0); - setVariablesSequence->addPause(250); - setVariablesSequence->addAnimation(setBackItemVisibleAnimation); - setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation); - setVariablesSequence->addAnimation(setFillAnimation); - flipAnimation->addAnimation(setVariablesSequence); -//! [8] - -//! [9] - // Build the state machine - QStateMachine *stateMachine = new QStateMachine(this); - QState *splashState = new QState(stateMachine); - QState *frontState = new QState(stateMachine); - QHistoryState *historyState = new QHistoryState(frontState); - QState *backState = new QState(stateMachine); -//! [9] -//! [10] - frontState->assignProperty(pad, "fill", false); - frontState->assignProperty(splash, "opacity", 0.0); - frontState->assignProperty(backItem, "visible", false); - frontState->assignProperty(flipRotation, "angle", qvariant_cast(0.0)); - frontState->assignProperty(selectionItem, "visible", true); - backState->assignProperty(pad, "fill", true); - backState->assignProperty(backItem, "visible", true); - backState->assignProperty(xRotation, "angle", qvariant_cast(0.0)); - backState->assignProperty(yRotation, "angle", qvariant_cast(0.0)); - backState->assignProperty(flipRotation, "angle", qvariant_cast(180.0)); - backState->assignProperty(selectionItem, "visible", false); - stateMachine->addDefaultAnimation(smoothXRotation); - stateMachine->addDefaultAnimation(smoothYRotation); - stateMachine->addDefaultAnimation(smoothXSelection); - stateMachine->addDefaultAnimation(smoothYSelection); - stateMachine->setInitialState(splashState); -//! [10] - -//! [11] - // Transitions - QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState); - anyKeyTransition->setTargetState(frontState); - anyKeyTransition->addAnimation(smoothSplashMove); - anyKeyTransition->addAnimation(smoothSplashOpacity); -//! [11] - -//! [12] - QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Enter, backState); - QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Return, backState); - QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Enter, frontState); - QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Return, frontState); - enterTransition->setTargetState(historyState); - returnTransition->setTargetState(historyState); - backEnterTransition->setTargetState(backState); - backReturnTransition->setTargetState(backState); - enterTransition->addAnimation(flipAnimation); - returnTransition->addAnimation(flipAnimation); - backEnterTransition->addAnimation(flipAnimation); - backReturnTransition->addAnimation(flipAnimation); -//! [12] - -//! [13] - // Create substates for each icon; store in temporary grid. - int columns = size.width(); - int rows = size.height(); - QVector< QVector< QState * > > stateGrid; - stateGrid.resize(rows); - for (int y = 0; y < rows; ++y) { - stateGrid[y].resize(columns); - for (int x = 0; x < columns; ++x) - stateGrid[y][x] = new QState(frontState); - } - frontState->setInitialState(stateGrid[0][0]); - selectionItem->setPos(pad->iconAt(0, 0)->pos()); -//! [13] - -//! [14] - // Enable key navigation using state transitions - for (int y = 0; y < rows; ++y) { - for (int x = 0; x < columns; ++x) { - QState *state = stateGrid[y][x]; - QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Right, state); - QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Left, state); - QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Down, state); - QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Up, state); - rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]); - leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]); - downTransition->setTargetState(stateGrid[(y + 1) % rows][x]); - upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]); -//! [14] -//! [15] - RoundRectItem *icon = pad->iconAt(x, y); - state->assignProperty(xRotation, "angle", -icon->x() / 6.0); - state->assignProperty(yRotation, "angle", icon->y() / 6.0); - state->assignProperty(selectionItem, "x", icon->x()); - state->assignProperty(selectionItem, "y", icon->y()); - frontState->assignProperty(icon, "visible", true); - backState->assignProperty(icon, "visible", false); - - QPropertyAnimation *setIconVisibleAnimation = new QPropertyAnimation(icon, "visible"); - setIconVisibleAnimation->setDuration(0); - setVariablesSequence->addAnimation(setIconVisibleAnimation); - } - } -//! [15] - -//! [16] - // Scene - QGraphicsScene *scene = new QGraphicsScene(this); - scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); - scene->setItemIndexMethod(QGraphicsScene::NoIndex); - scene->addItem(pad); - scene->setSceneRect(scene->itemsBoundingRect()); - setScene(scene); -//! [16] - -//! [17] - // Adjust splash item to scene contents - const QRectF sbr = splash->boundingRect(); - splash->setPos(-sbr.width() / 2, scene->sceneRect().top() - 2); - frontState->assignProperty(splash, "y", splash->y() - 100.0); - scene->addItem(splash); -//! [17] - -//! [18] - // View - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setMinimumSize(50, 50); - setViewportUpdateMode(FullViewportUpdate); - setCacheMode(CacheBackground); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); -#ifndef QT_NO_OPENGL - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); -#endif - - stateMachine->start(); -//! [18] -} - -//! [19] -void PadNavigator::resizeEvent(QResizeEvent *event) -{ - QGraphicsView::resizeEvent(event); - fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); -} -//! [19] diff --git a/examples/graphicsview/padnavigator/padnavigator.desktop b/examples/graphicsview/padnavigator/padnavigator.desktop deleted file mode 100644 index f0490730c6..0000000000 --- a/examples/graphicsview/padnavigator/padnavigator.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Pad Navigator -Exec=/opt/usr/bin/padnavigator -Icon=padnavigator -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/padnavigator/padnavigator.h b/examples/graphicsview/padnavigator/padnavigator.h deleted file mode 100644 index 659b901f5c..0000000000 --- a/examples/graphicsview/padnavigator/padnavigator.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PADNAVIGATOR_H -#define PADNAVIGATOR_H - -#include -#include "ui_form.h" - -QT_BEGIN_NAMESPACE - -class QState; -class QStateMachine; -class Ui_Form; - -QT_END_NAMESPACE - -//! [0] -class PadNavigator : public QGraphicsView -{ - Q_OBJECT -public: - explicit PadNavigator(const QSize &size, QWidget *parent = 0); - -protected: - void resizeEvent(QResizeEvent *event); - -private: - Ui_Form form; -}; -//! [0] - -#endif // PADNAVIGATOR_H diff --git a/examples/graphicsview/padnavigator/padnavigator.pro b/examples/graphicsview/padnavigator/padnavigator.pro deleted file mode 100644 index 4b9733bb9b..0000000000 --- a/examples/graphicsview/padnavigator/padnavigator.pro +++ /dev/null @@ -1,28 +0,0 @@ -SOURCES += main.cpp \ - roundrectitem.cpp \ - flippablepad.cpp \ - padnavigator.cpp \ - splashitem.cpp - -HEADERS += \ - roundrectitem.h \ - flippablepad.h \ - padnavigator.h \ - splashitem.h - -RESOURCES += \ - padnavigator.qrc - -FORMS += \ - form.ui - -QT += widgets -contains(QT_CONFIG, opengl):QT += opengl - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/padnavigator -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS padnavigator.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/padnavigator -INSTALLS += target sources - -CONFIG += console diff --git a/examples/graphicsview/padnavigator/padnavigator.qrc b/examples/graphicsview/padnavigator/padnavigator.qrc deleted file mode 100644 index b26ab92ae1..0000000000 --- a/examples/graphicsview/padnavigator/padnavigator.qrc +++ /dev/null @@ -1,13 +0,0 @@ - - - images/blue_angle_swirl.jpg - images/artsfftscope.png - images/kontact_contacts.png - images/kontact_journal.png - images/kontact_mail.png - images/kontact_notes.png - images/kopeteavailable.png - images/metacontact_online.png - images/minitools.png - - diff --git a/examples/graphicsview/padnavigator/roundrectitem.cpp b/examples/graphicsview/padnavigator/roundrectitem.cpp deleted file mode 100644 index 1438db3a9c..0000000000 --- a/examples/graphicsview/padnavigator/roundrectitem.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "roundrectitem.h" - -#include - -//! [0] -RoundRectItem::RoundRectItem(const QRectF &bounds, const QColor &color, - QGraphicsItem *parent) - : QGraphicsObject(parent), fillRect(false), bounds(bounds) -{ - gradient.setStart(bounds.topLeft()); - gradient.setFinalStop(bounds.bottomRight()); - gradient.setColorAt(0, color); - gradient.setColorAt(1, color.dark(200)); - setCacheMode(ItemCoordinateCache); -} -//! [0] - -//! [1] -QPixmap RoundRectItem::pixmap() const -{ - return pix; -} -void RoundRectItem::setPixmap(const QPixmap &pixmap) -{ - pix = pixmap; - update(); -} -//! [1] - -//! [2] -QRectF RoundRectItem::boundingRect() const -{ - return bounds.adjusted(0, 0, 2, 2); -} -//! [2] - -//! [3] -void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor(0, 0, 0, 64)); - painter->drawRoundRect(bounds.translated(2, 2)); -//! [3] -//! [4] - if (fillRect) - painter->setBrush(QApplication::palette().brush(QPalette::Window)); - else - painter->setBrush(gradient); - painter->setPen(QPen(Qt::black, 1)); - painter->drawRoundRect(bounds); -//! [4] -//! [5] - if (!pix.isNull()) { - painter->scale(1.95, 1.95); - painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix); - } -} -//! [5] - -//! [6] -bool RoundRectItem::fill() const -{ - return fillRect; -} -void RoundRectItem::setFill(bool fill) -{ - fillRect = fill; - update(); -} -//! [6] diff --git a/examples/graphicsview/padnavigator/roundrectitem.h b/examples/graphicsview/padnavigator/roundrectitem.h deleted file mode 100644 index af84984d49..0000000000 --- a/examples/graphicsview/padnavigator/roundrectitem.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 ROUNDRECTITEM_H -#define ROUNDRECTITEM_H - -#include -#include - -//! [0] -class RoundRectItem : public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY(bool fill READ fill WRITE setFill) -public: - RoundRectItem(const QRectF &bounds, const QColor &color, - QGraphicsItem *parent = 0); - - QPixmap pixmap() const; - void setPixmap(const QPixmap &pixmap); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - - bool fill() const; - void setFill(bool fill); -//! [0] - -//! [1] -private: - QPixmap pix; - bool fillRect; - QRectF bounds; - QLinearGradient gradient; -}; -//! [1] - -#endif // ROUNDRECTITEM_H diff --git a/examples/graphicsview/padnavigator/splashitem.cpp b/examples/graphicsview/padnavigator/splashitem.cpp deleted file mode 100644 index d87e8333bd..0000000000 --- a/examples/graphicsview/padnavigator/splashitem.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "splashitem.h" - -#include - -//! [0] -SplashItem::SplashItem(QGraphicsItem *parent) - : QGraphicsObject(parent) -{ - text = tr("Welcome to the Pad Navigator Example. You can use the" - " keyboard arrows to navigate the icons, and press enter" - " to activate an item. Press any key to begin."); - setCacheMode(DeviceCoordinateCache); -} -//! [0] - -//! [1] -QRectF SplashItem::boundingRect() const -{ - return QRectF(0, 0, 400, 175); -} -//! [1] - -//! [2] -void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(QPen(Qt::black, 2)); - painter->setBrush(QColor(245, 245, 255, 220)); - painter->setClipRect(boundingRect()); - painter->drawRoundRect(3, -100 + 3, 400 - 6, 250 - 6); - - QRectF textRect = boundingRect().adjusted(10, 10, -10, -10); - int flags = Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap; - - QFont font; - font.setPixelSize(18); - painter->setPen(Qt::black); - painter->setFont(font); - painter->drawText(textRect, flags, text); -} -//! [2] diff --git a/examples/graphicsview/padnavigator/splashitem.h b/examples/graphicsview/padnavigator/splashitem.h deleted file mode 100644 index bc0917e3de..0000000000 --- a/examples/graphicsview/padnavigator/splashitem.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 SPLASHITEM_H -#define SPLASHITEM_H - -#include - -//! [0] -class SplashItem : public QGraphicsObject -{ - Q_OBJECT -public: - explicit SplashItem(QGraphicsItem *parent = 0); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -private: - QString text; -}; -//! [0] - -#endif // SPLASHITEM_H diff --git a/examples/graphicsview/portedasteroids/portedasteroids.desktop b/examples/graphicsview/portedasteroids/portedasteroids.desktop deleted file mode 100644 index abd061699b..0000000000 --- a/examples/graphicsview/portedasteroids/portedasteroids.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Ported Asteroids -Exec=/opt/usr/bin/portedasteroids -Icon=portedasteroids -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/portedcanvas/portedcanvas.desktop b/examples/graphicsview/portedcanvas/portedcanvas.desktop deleted file mode 100644 index 1217dc43de..0000000000 --- a/examples/graphicsview/portedcanvas/portedcanvas.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Ported Canvas -Exec=/opt/usr/bin/portedcanvas -Icon=portedcanvas -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/simpleanchorlayout/main.cpp b/examples/graphicsview/simpleanchorlayout/main.cpp deleted file mode 100644 index 50d8513c84..0000000000 --- a/examples/graphicsview/simpleanchorlayout/main.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -class Widget : public QGraphicsWidget -{ -public: - Widget(const QColor &color, const QColor &textColor, const QString &caption, - QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), caption(caption), color(color), textColor(textColor) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * = 0) - { - QFont font; - font.setPixelSize(0.75 * qMin(boundingRect().width(), boundingRect().height())); - - painter->fillRect(boundingRect(), color); - painter->save(); - painter->setFont(font); - painter->setPen(textColor); - painter->drawText(boundingRect(), Qt::AlignCenter, caption); - painter->restore(); - } - -private: - QString caption; - QColor color; - QColor textColor; -}; - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QGraphicsScene *scene = new QGraphicsScene(); - - Widget *a = new Widget(Qt::blue, Qt::white, "a"); - a->setPreferredSize(100, 100); - Widget *b = new Widget(Qt::green, Qt::black, "b"); - b->setPreferredSize(100, 100); - Widget *c = new Widget(Qt::red, Qt::black, "c"); - c->setPreferredSize(100, 100); - - QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout(); -/* - //! [adding a corner anchor in two steps] - layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop); - layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft); - //! [adding a corner anchor in two steps] -*/ - //! [adding a corner anchor] - layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner); - //! [adding a corner anchor] - - //! [adding anchors] - layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); - layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom); - //! [adding anchors] - - // Place a third widget below the second. - layout->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); - -/* - //! [adding anchors to match sizes in two steps] - layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); - layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight); - //! [adding anchors to match sizes in two steps] -*/ - - //! [adding anchors to match sizes] - layout->addAnchors(b, c, Qt::Horizontal); - //! [adding anchors to match sizes] - - // Anchor the bottom-right corner of the third widget to the bottom-right - // corner of the layout. - layout->addCornerAnchors(c, Qt::BottomRightCorner, layout, Qt::BottomRightCorner); - - QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint); - w->setPos(20, 20); - w->setMinimumSize(100, 100); - w->setPreferredSize(320, 240); - w->setLayout(layout); - w->setWindowTitle(QApplication::translate("simpleanchorlayout", "QGraphicsAnchorLayout in use")); - scene->addItem(w); - - QGraphicsView *view = new QGraphicsView(); - view->setScene(scene); - view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout")); - - view->resize(360, 320); - view->show(); - - return app.exec(); -} diff --git a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.desktop b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.desktop deleted file mode 100644 index 0e8d73a859..0000000000 --- a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Simple Anchor Layout -Exec=/opt/usr/bin/simpleanchorlayout -Icon=simpleanchorlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro deleted file mode 100644 index b044d4e91c..0000000000 --- a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro +++ /dev/null @@ -1,12 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/simpleanchorlayout -sources.files = $$SOURCES $$HEADERS $$RESOURCES simpleanchorlayout.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/simpleanchorlayout -INSTALLS += target sources - -TARGET = simpleanchorlayout -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/weatheranchorlayout/images/5days.jpg b/examples/graphicsview/weatheranchorlayout/images/5days.jpg deleted file mode 100644 index fd92ba8ba7..0000000000 Binary files a/examples/graphicsview/weatheranchorlayout/images/5days.jpg and /dev/null differ diff --git a/examples/graphicsview/weatheranchorlayout/images/details.jpg b/examples/graphicsview/weatheranchorlayout/images/details.jpg deleted file mode 100644 index fde0448c69..0000000000 Binary files a/examples/graphicsview/weatheranchorlayout/images/details.jpg and /dev/null differ diff --git a/examples/graphicsview/weatheranchorlayout/images/place.jpg b/examples/graphicsview/weatheranchorlayout/images/place.jpg deleted file mode 100644 index 03e5344330..0000000000 Binary files a/examples/graphicsview/weatheranchorlayout/images/place.jpg and /dev/null differ diff --git a/examples/graphicsview/weatheranchorlayout/images/tabbar.jpg b/examples/graphicsview/weatheranchorlayout/images/tabbar.jpg deleted file mode 100644 index 7777662901..0000000000 Binary files a/examples/graphicsview/weatheranchorlayout/images/tabbar.jpg and /dev/null differ diff --git a/examples/graphicsview/weatheranchorlayout/images/title.jpg b/examples/graphicsview/weatheranchorlayout/images/title.jpg deleted file mode 100644 index fa84c8156c..0000000000 Binary files a/examples/graphicsview/weatheranchorlayout/images/title.jpg and /dev/null differ diff --git a/examples/graphicsview/weatheranchorlayout/images/weather-few-clouds.png b/examples/graphicsview/weatheranchorlayout/images/weather-few-clouds.png deleted file mode 100644 index eea6ce6529..0000000000 Binary files a/examples/graphicsview/weatheranchorlayout/images/weather-few-clouds.png and /dev/null differ diff --git a/examples/graphicsview/weatheranchorlayout/main.cpp b/examples/graphicsview/weatheranchorlayout/main.cpp deleted file mode 100644 index 64605bebc0..0000000000 --- a/examples/graphicsview/weatheranchorlayout/main.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -class GraphicsView : public QGraphicsView -{ -public: - GraphicsView(QGraphicsScene *scene, QGraphicsWidget *widget) : QGraphicsView(scene), w(widget) - { - } - - virtual void resizeEvent(QResizeEvent *event) - { - w->setGeometry(0, 0, event->size().width(), event->size().height()); - } - - QGraphicsWidget *w; -}; - -class PixmapWidget : public QGraphicsLayoutItem -{ - -public: - PixmapWidget(const QPixmap &pix) : QGraphicsLayoutItem() - { - original = new QGraphicsPixmapItem(pix); - setGraphicsItem(original); - original->show(); - r = QRectF(QPointF(0, 0), pix.size()); - } - - ~PixmapWidget() - { - setGraphicsItem(0); - delete original; - } - - void setZValue(qreal z) - { - original->setZValue(z); - } - - void setGeometry (const QRectF &rect) - { - original->setTransform(QTransform::fromScale(rect.width() / r.width(), rect.height() / r.height()), true); - original->setPos(rect.x(), rect.y()); - r = rect; - } - -protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const - { - Q_UNUSED(constraint); - QSizeF sh; - switch (which) { - case Qt::MinimumSize: - sh = QSizeF(0, 0); - break; - case Qt::PreferredSize: - sh = QSizeF(50, 50); - break; - case Qt::MaximumSize: - sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); - break; - default: - break; - } - return sh; - } - -private: - QGraphicsPixmapItem *original; - QRectF r; -}; - - -class PlaceWidget : public QGraphicsWidget -{ - Q_OBJECT - -public: - PlaceWidget(const QPixmap &pix) : QGraphicsWidget(), original(pix), scaled(pix) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*) - { - QPointF reflection = QPointF(); - reflection.setY(scaled.height() + 2); - - painter->drawPixmap(QPointF(), scaled); - - QPixmap tmp(scaled.size()); - tmp.fill(Qt::transparent); - QPainter p(&tmp); - - // create gradient - QPoint p1(scaled.width() / 2, 0); - QPoint p2(scaled.width() / 2, scaled.height()); - QLinearGradient linearGrad(p1, p2); - linearGrad.setColorAt(0, QColor(0, 0, 0, 0)); - linearGrad.setColorAt(0.65, QColor(0, 0, 0, 127)); - linearGrad.setColorAt(1, QColor(0, 0, 0, 255)); - - // apply 'mask' - p.setBrush(linearGrad); - p.fillRect(0, 0, tmp.width(), tmp.height(), QBrush(linearGrad)); - p.fillRect(0, 0, tmp.width(), tmp.height(), QBrush(linearGrad)); - - // paint the image flipped - p.setCompositionMode(QPainter::CompositionMode_DestinationOver); - p.drawPixmap(0, 0, QPixmap::fromImage(scaled.toImage().mirrored(false, true))); - p.end(); - - painter->drawPixmap(reflection, tmp); - } - - void resizeEvent(QGraphicsSceneResizeEvent *event) - { - QSize newSize = event->newSize().toSize(); - newSize.setHeight(newSize.height() / 2); - scaled = original.scaled(newSize); - } - - QRectF boundingRect() const - { - QSize size(scaled.width(), scaled.height() * 2 + 2); - return QRectF(QPointF(0, 0), size); - } - -private: - QPixmap original; - QPixmap scaled; -}; - - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(weatheranchorlayout); - - QApplication app(argc, argv); - - QGraphicsScene scene; - scene.setSceneRect(0, 0, 800, 480); - - // pixmaps widgets - PixmapWidget *title = new PixmapWidget(QPixmap(":/images/title.jpg")); - PlaceWidget *place = new PlaceWidget(QPixmap(":/images/place.jpg")); - PixmapWidget *details = new PixmapWidget(QPixmap(":/images/5days.jpg")); - PixmapWidget *sunnyWeather = new PixmapWidget(QPixmap(":/images/weather-few-clouds.png")); - PixmapWidget *tabbar = new PixmapWidget(QPixmap(":/images/tabbar.jpg")); - - - // setup sizes - title->setPreferredSize(QSizeF(348, 45)); - title->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - - place->setPreferredSize(QSizeF(96, 72)); - place->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - - details->setMinimumSize(QSizeF(200, 112)); - details->setPreferredSize(QSizeF(200, 112)); - details->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - - tabbar->setPreferredSize(QSizeF(70, 24)); - tabbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - - sunnyWeather->setPreferredSize(QSizeF(128, 97)); - sunnyWeather->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - sunnyWeather->setZValue(9999); - - // start anchor layout - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; - l->setSpacing(0); - - // setup the main widget - QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window); - QPalette p; - p.setColor(QPalette::Window, Qt::black); - w->setPalette(p); - w->setPos(20, 20); - w->setLayout(l); - - // vertical anchors - QGraphicsAnchor *anchor = l->addAnchor(title, Qt::AnchorTop, l, Qt::AnchorTop); - anchor = l->addAnchor(place, Qt::AnchorTop, title, Qt::AnchorBottom); - anchor->setSpacing(12); - anchor = l->addAnchor(place, Qt::AnchorBottom, l, Qt::AnchorBottom); - anchor->setSpacing(12); - - anchor = l->addAnchor(sunnyWeather, Qt::AnchorTop, title, Qt::AnchorTop); - anchor = l->addAnchor(sunnyWeather, Qt::AnchorBottom, l, Qt::AnchorVerticalCenter); - - anchor = l->addAnchor(tabbar, Qt::AnchorTop, title, Qt::AnchorBottom); - anchor->setSpacing(5); - anchor = l->addAnchor(details, Qt::AnchorTop, tabbar, Qt::AnchorBottom); - anchor->setSpacing(2); - anchor = l->addAnchor(details, Qt::AnchorBottom, l, Qt::AnchorBottom); - anchor->setSpacing(12); - - // horizontal anchors - anchor = l->addAnchor(l, Qt::AnchorLeft, title, Qt::AnchorLeft); - anchor = l->addAnchor(title, Qt::AnchorRight, l, Qt::AnchorRight); - - anchor = l->addAnchor(place, Qt::AnchorLeft, l, Qt::AnchorLeft); - anchor->setSpacing(15); - anchor = l->addAnchor(place, Qt::AnchorRight, details, Qt::AnchorLeft); - anchor->setSpacing(35); - - anchor = l->addAnchor(sunnyWeather, Qt::AnchorLeft, place, Qt::AnchorHorizontalCenter); - anchor = l->addAnchor(sunnyWeather, Qt::AnchorRight, l, Qt::AnchorHorizontalCenter); - - anchor = l->addAnchor(tabbar, Qt::AnchorHorizontalCenter, details, Qt::AnchorHorizontalCenter); - anchor = l->addAnchor(details, Qt::AnchorRight, l, Qt::AnchorRight); - - // QGV setup - scene.addItem(w); - scene.setBackgroundBrush(Qt::white); - QGraphicsView *view = new QGraphicsView(&scene); - view->show(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.desktop b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.desktop deleted file mode 100644 index 0c6ab89a68..0000000000 --- a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Weather Anchor Layout -Exec=/opt/usr/bin/weatheranchorlayout -Icon=weatheranchorlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro deleted file mode 100644 index b6eb292a12..0000000000 --- a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets - -SOURCES += main.cpp -RESOURCES += weatheranchorlayout.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/weatheranchorlayout -sources.files = $$SOURCES $$HEADERS $$RESOURCES weatheranchorlayout.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/weatheranchorlayout -INSTALLS += target sources - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc deleted file mode 100644 index e39f8c0423..0000000000 --- a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - images/5days.jpg - images/title.jpg - images/place.jpg - images/tabbar.jpg - images/details.jpg - images/weather-few-clouds.png - - diff --git a/examples/itemviews/README b/examples/itemviews/README deleted file mode 100644 index bded96a849..0000000000 --- a/examples/itemviews/README +++ /dev/null @@ -1,8 +0,0 @@ -Item views are widgets that typically display data sets. Qt 4's model/view -framework lets you handle large data sets by separating the underlying data -from the way it is represented to the user, and provides support for -customized rendering through the use of delegates. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/itemviews/addressbook/adddialog.cpp b/examples/itemviews/addressbook/adddialog.cpp deleted file mode 100644 index f34bd0d46e..0000000000 --- a/examples/itemviews/addressbook/adddialog.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "adddialog.h" - -//! [0] -AddDialog::AddDialog(QWidget *parent) - : QDialog(parent) -{ - nameLabel = new QLabel("Name"); - addressLabel = new QLabel("Address"); - okButton = new QPushButton("OK"); - cancelButton = new QPushButton("Cancel"); - - nameText = new QLineEdit; - addressText = new QTextEdit; - - QGridLayout *gLayout = new QGridLayout; - gLayout->setColumnStretch(1, 2); - gLayout->addWidget(nameLabel, 0, 0); - gLayout->addWidget(nameText, 0, 1); - - gLayout->addWidget(addressLabel, 1, 0, Qt::AlignLeft|Qt::AlignTop); - gLayout->addWidget(addressText, 1, 1, Qt::AlignLeft); - - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addWidget(okButton); - buttonLayout->addWidget(cancelButton); - - gLayout->addLayout(buttonLayout, 2, 1, Qt::AlignRight); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout(gLayout); - setLayout(mainLayout); - - connect(okButton, SIGNAL(clicked()), - this, SLOT(accept())); - - connect(cancelButton, SIGNAL(clicked()), - this, SLOT(reject())); - - setWindowTitle(tr("Add a Contact")); -} -//! [0] diff --git a/examples/itemviews/addressbook/adddialog.h b/examples/itemviews/addressbook/adddialog.h deleted file mode 100644 index 6d9093b638..0000000000 --- a/examples/itemviews/addressbook/adddialog.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 ADDDIALOG_H -#define ADDDIALOG_H - -#include - -QT_BEGIN_NAMESPACE -class QLabel; -class QPushButton; -class QTextEdit; -class QLineEdit; -QT_END_NAMESPACE - -//! [0] -class AddDialog : public QDialog -{ - Q_OBJECT - -public: - AddDialog(QWidget *parent=0); - QLineEdit *nameText; - QTextEdit *addressText; - -private: - QLabel *nameLabel; - QLabel *addressLabel; - QPushButton *okButton; - QPushButton *cancelButton; -}; -//! [0] - -#endif diff --git a/examples/itemviews/addressbook/addressbook.desktop b/examples/itemviews/addressbook/addressbook.desktop deleted file mode 100644 index 11767f59d8..0000000000 --- a/examples/itemviews/addressbook/addressbook.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Address Book -Exec=/opt/usr/bin/addressbook -Icon=addressbook -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/addressbook/addressbook.pro b/examples/itemviews/addressbook/addressbook.pro deleted file mode 100644 index 32cbc4ca36..0000000000 --- a/examples/itemviews/addressbook/addressbook.pro +++ /dev/null @@ -1,19 +0,0 @@ -SOURCES = adddialog.cpp \ - addresswidget.cpp \ - main.cpp \ - mainwindow.cpp \ - newaddresstab.cpp \ - tablemodel.cpp -HEADERS = adddialog.h \ - addresswidget.h \ - mainwindow.h \ - newaddresstab.h \ - tablemodel.h - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/addressbook -sources.files = $$SOURCES $$HEADERS $$RESOURCES addressbook.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/addressbook -INSTALLS += target sources -QT += widgets - diff --git a/examples/itemviews/addressbook/addresswidget.cpp b/examples/itemviews/addressbook/addresswidget.cpp deleted file mode 100644 index 066d5588c7..0000000000 --- a/examples/itemviews/addressbook/addresswidget.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "addresswidget.h" -#include "adddialog.h" - -//! [0] -AddressWidget::AddressWidget(QWidget *parent) - : QTabWidget(parent) -{ - table = new TableModel(this); - newAddressTab = new NewAddressTab(this); - connect(newAddressTab, SIGNAL(sendDetails(QString,QString)), - this, SLOT(addEntry(QString,QString))); - - addTab(newAddressTab, "Address Book"); - - setupTabs(); -} -//! [0] - -//! [2] -void AddressWidget::addEntry() -{ - AddDialog aDialog; - - if (aDialog.exec()) { - QString name = aDialog.nameText->text(); - QString address = aDialog.addressText->toPlainText(); - - addEntry(name, address); - } -} -//! [2] - -//! [3] -void AddressWidget::addEntry(QString name, QString address) -{ - QList< QPair >list = table->getList(); - QPair pair(name, address); - - if (!list.contains(pair)) { - table->insertRows(0, 1, QModelIndex()); - - QModelIndex index = table->index(0, 0, QModelIndex()); - table->setData(index, name, Qt::EditRole); - index = table->index(0, 1, QModelIndex()); - table->setData(index, address, Qt::EditRole); - removeTab(indexOf(newAddressTab)); - } else { - QMessageBox::information(this, tr("Duplicate Name"), - tr("The name \"%1\" already exists.").arg(name)); - } -} -//! [3] - -//! [4a] -void AddressWidget::editEntry() -{ - QTableView *temp = static_cast(currentWidget()); - QSortFilterProxyModel *proxy = static_cast(temp->model()); - QItemSelectionModel *selectionModel = temp->selectionModel(); - - QModelIndexList indexes = selectionModel->selectedRows(); - QModelIndex index, i; - QString name; - QString address; - int row = -1; - - foreach (index, indexes) { - row = proxy->mapToSource(index).row(); - i = table->index(row, 0, QModelIndex()); - QVariant varName = table->data(i, Qt::DisplayRole); - name = varName.toString(); - - i = table->index(row, 1, QModelIndex()); - QVariant varAddr = table->data(i, Qt::DisplayRole); - address = varAddr.toString(); - } -//! [4a] - -//! [4b] - AddDialog aDialog; - aDialog.setWindowTitle(tr("Edit a Contact")); - - aDialog.nameText->setReadOnly(true); - aDialog.nameText->setText(name); - aDialog.addressText->setText(address); - - if (aDialog.exec()) { - QString newAddress = aDialog.addressText->toPlainText(); - if (newAddress != address) { - i = table->index(row, 1, QModelIndex()); - table->setData(i, newAddress, Qt::EditRole); - } - } -} -//! [4b] - -//! [5] -void AddressWidget::removeEntry() -{ - QTableView *temp = static_cast(currentWidget()); - QSortFilterProxyModel *proxy = static_cast(temp->model()); - QItemSelectionModel *selectionModel = temp->selectionModel(); - - QModelIndexList indexes = selectionModel->selectedRows(); - QModelIndex index; - - foreach (index, indexes) { - int row = proxy->mapToSource(index).row(); - table->removeRows(row, 1, QModelIndex()); - } - - if (table->rowCount(QModelIndex()) == 0) { - insertTab(0, newAddressTab, "Address Book"); - } -} -//! [5] - -//! [1] -void AddressWidget::setupTabs() -{ - QStringList groups; - groups << "ABC" << "DEF" << "GHI" << "JKL" << "MNO" << "PQR" << "STU" << "VW" << "XYZ"; - - for (int i = 0; i < groups.size(); ++i) { - QString str = groups.at(i); - - proxyModel = new QSortFilterProxyModel(this); - proxyModel->setSourceModel(table); - - QTableView *tableView = new QTableView; - tableView->setModel(proxyModel); - tableView->setSortingEnabled(true); - tableView->setSelectionBehavior(QAbstractItemView::SelectRows); - tableView->horizontalHeader()->setStretchLastSection(true); - tableView->verticalHeader()->hide(); - tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); - tableView->setSelectionMode(QAbstractItemView::SingleSelection); - - QString newStr = QString("^[%1].*").arg(str); - - proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive)); - proxyModel->setFilterKeyColumn(0); - proxyModel->sort(0, Qt::AscendingOrder); - - connect(tableView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SIGNAL(selectionChanged(QItemSelection))); - - addTab(tableView, str); - } -} -//! [1] - -//! [7] -void AddressWidget::readFromFile(QString fileName) -{ - QFile file(fileName); - - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::information(this, tr("Unable to open file"), - file.errorString()); - return; - } - - QList< QPair > pairs = table->getList(); - QDataStream in(&file); - in >> pairs; - - if (pairs.isEmpty()) { - QMessageBox::information(this, tr("No contacts in file"), - tr("The file you are attempting to open contains no contacts.")); - } else { - for (int i=0; i p = pairs.at(i); - addEntry(p.first, p.second); - } - } -} -//! [7] - -//! [6] -void AddressWidget::writeToFile(QString fileName) -{ - QFile file(fileName); - - if (!file.open(QIODevice::WriteOnly)) { - QMessageBox::information(this, tr("Unable to open file"), file.errorString()); - return; - } - - QList< QPair > pairs = table->getList(); - QDataStream out(&file); - out << pairs; -} -//! [6] diff --git a/examples/itemviews/addressbook/addresswidget.h b/examples/itemviews/addressbook/addresswidget.h deleted file mode 100644 index 3a46818463..0000000000 --- a/examples/itemviews/addressbook/addresswidget.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 ADDRESSWIDGET_H -#define ADDRESSWIDGET_H - -#include -#include -#include "tablemodel.h" -#include "newaddresstab.h" - -QT_BEGIN_NAMESPACE -class QSortFilterProxyModel; -class QItemSelectionModel; -QT_END_NAMESPACE - -//! [0] -class AddressWidget : public QTabWidget -{ - Q_OBJECT - -public: - AddressWidget(QWidget *parent=0); - void readFromFile(QString fileName); - void writeToFile(QString fileName); - -public slots: - void addEntry(); - void addEntry(QString name, QString address); - void editEntry(); - void removeEntry(); - -signals: - void selectionChanged (const QItemSelection &selected); - -private: - void setupTabs(); - - TableModel *table; - NewAddressTab *newAddressTab; - QSortFilterProxyModel *proxyModel; -}; -//! [0] - -#endif diff --git a/examples/itemviews/addressbook/main.cpp b/examples/itemviews/addressbook/main.cpp deleted file mode 100644 index 9f388dc123..0000000000 --- a/examples/itemviews/addressbook/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "mainwindow.h" - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow mw; - mw.show(); - return app.exec(); -} -//! [0] diff --git a/examples/itemviews/addressbook/mainwindow.cpp b/examples/itemviews/addressbook/mainwindow.cpp deleted file mode 100644 index e16aec94b0..0000000000 --- a/examples/itemviews/addressbook/mainwindow.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "mainwindow.h" - -//! [0] -MainWindow::MainWindow() -{ - addressWidget = new AddressWidget; - setCentralWidget(addressWidget); - createMenus(); - setWindowTitle(tr("Address Book")); -} -//! [0] - -//! [1a] -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); - - openAct = new QAction(tr("&Open..."), this); - fileMenu->addAction(openAct); - connect(openAct, SIGNAL(triggered()), - this, SLOT(openFile())); -//! [1a] - - saveAct = new QAction(tr("&Save As..."), this); - fileMenu->addAction(saveAct); - connect(saveAct, SIGNAL(triggered()), - this, SLOT(saveFile())); - - fileMenu->addSeparator(); - - exitAct = new QAction(tr("E&xit"), this); - fileMenu->addAction(exitAct); - connect(exitAct, SIGNAL(triggered()), - this, SLOT(close())); - - toolMenu = menuBar()->addMenu(tr("&Tools")); - - addAct = new QAction(tr("&Add Entry..."), this); - toolMenu->addAction(addAct); - connect(addAct, SIGNAL(triggered()), - addressWidget, SLOT(addEntry())); - -//! [1b] - editAct = new QAction(tr("&Edit Entry..."), this); - editAct->setEnabled(false); - toolMenu->addAction(editAct); - connect(editAct, SIGNAL(triggered()), - addressWidget, SLOT(editEntry())); - - toolMenu->addSeparator(); - - removeAct = new QAction(tr("&Remove Entry"), this); - removeAct->setEnabled(false); - toolMenu->addAction(removeAct); - connect(removeAct, SIGNAL(triggered()), - addressWidget, SLOT(removeEntry())); - - connect(addressWidget, SIGNAL(selectionChanged(QItemSelection)), - this, SLOT(updateActions(QItemSelection))); -} -//! [1b] - -//! [2] -void MainWindow::openFile() -{ - QString fileName = QFileDialog::getOpenFileName(this); - if (!fileName.isEmpty()) { - addressWidget->readFromFile(fileName); - } -} -//! [2] - -//! [3] -void MainWindow::saveFile() -{ - QString fileName = QFileDialog::getSaveFileName(this); - if (!fileName.isEmpty()) { - addressWidget->writeToFile(fileName); - } -} -//! [3] - -//! [4] -void MainWindow::updateActions(const QItemSelection &selection) -{ - QModelIndexList indexes = selection.indexes(); - - if (!indexes.isEmpty()) { - removeAct->setEnabled(true); - editAct->setEnabled(true); - } else { - removeAct->setEnabled(false); - editAct->setEnabled(false); - } -} -//! [4] diff --git a/examples/itemviews/addressbook/mainwindow.h b/examples/itemviews/addressbook/mainwindow.h deleted file mode 100644 index 284e492c4a..0000000000 --- a/examples/itemviews/addressbook/mainwindow.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "addresswidget.h" - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private slots: - void updateActions(const QItemSelection &selection); - void openFile(); - void saveFile(); - -private: - void createMenus(); - - AddressWidget *addressWidget; - QMenu *fileMenu; - QMenu *toolMenu; - QAction *openAct; - QAction *saveAct; - QAction *exitAct; - QAction *addAct; - QAction *editAct; - QAction *removeAct; -}; -//! [0] - -#endif diff --git a/examples/itemviews/addressbook/newaddresstab.cpp b/examples/itemviews/addressbook/newaddresstab.cpp deleted file mode 100644 index f27789a511..0000000000 --- a/examples/itemviews/addressbook/newaddresstab.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "newaddresstab.h" -#include "adddialog.h" - -//! [0] -NewAddressTab::NewAddressTab(QWidget *parent) -{ - Q_UNUSED(parent); - - descriptionLabel = new QLabel(tr("There are currently no contacts in your address book. " - "\nClick Add to add new contacts.")); - - addButton = new QPushButton(tr("Add")); - - connect(addButton, SIGNAL(clicked()), this, SLOT(addEntry())); - - mainLayout = new QVBoxLayout; - mainLayout->addWidget(descriptionLabel); - mainLayout->addWidget(addButton, 0, Qt::AlignCenter); - - setLayout(mainLayout); -} -//! [0] - -//! [1] -void NewAddressTab::addEntry() -{ - AddDialog aDialog; - - if (aDialog.exec()) { - QString name = aDialog.nameText->text(); - QString address = aDialog.addressText->toPlainText(); - - emit sendDetails(name, address); - } -} -//! [1] diff --git a/examples/itemviews/addressbook/newaddresstab.h b/examples/itemviews/addressbook/newaddresstab.h deleted file mode 100644 index 4562050f75..0000000000 --- a/examples/itemviews/addressbook/newaddresstab.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 NEWADDRESSTAB_H -#define NEWADDRESSTAB_H - -#include - -QT_BEGIN_NAMESPACE -class QLabel; -class QPushButton; -class QVBoxLayout; -QT_END_NAMESPACE - -//! [0] -class NewAddressTab : public QWidget -{ - Q_OBJECT - -public: - NewAddressTab(QWidget *parent=0); - -public slots: - void addEntry(); - -signals: - void sendDetails(QString name, QString address); - -private: - QLabel *descriptionLabel; - QPushButton *addButton; - QVBoxLayout *mainLayout; - -}; -//! [0] - -#endif diff --git a/examples/itemviews/addressbook/tablemodel.cpp b/examples/itemviews/addressbook/tablemodel.cpp deleted file mode 100644 index 6d99a02b55..0000000000 --- a/examples/itemviews/addressbook/tablemodel.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "tablemodel.h" - -//! [0] -TableModel::TableModel(QObject *parent) - : QAbstractTableModel(parent) -{ -} - -TableModel::TableModel(QList< QPair > pairs, QObject *parent) - : QAbstractTableModel(parent) -{ - listOfPairs=pairs; -} -//! [0] - -//! [1] -int TableModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return listOfPairs.size(); -} - -int TableModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return 2; -} -//! [1] - -//! [2] -QVariant TableModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() >= listOfPairs.size() || index.row() < 0) - return QVariant(); - - if (role == Qt::DisplayRole) { - QPair pair = listOfPairs.at(index.row()); - - if (index.column() == 0) - return pair.first; - else if (index.column() == 1) - return pair.second; - } - return QVariant(); -} -//! [2] - -//! [3] -QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Horizontal) { - switch (section) { - case 0: - return tr("Name"); - - case 1: - return tr("Address"); - - default: - return QVariant(); - } - } - return QVariant(); -} -//! [3] - -//! [4] -bool TableModel::insertRows(int position, int rows, const QModelIndex &index) -{ - Q_UNUSED(index); - beginInsertRows(QModelIndex(), position, position+rows-1); - - for (int row=0; row < rows; row++) { - QPair pair(" ", " "); - listOfPairs.insert(position, pair); - } - - endInsertRows(); - return true; -} -//! [4] - -//! [5] -bool TableModel::removeRows(int position, int rows, const QModelIndex &index) -{ - Q_UNUSED(index); - beginRemoveRows(QModelIndex(), position, position+rows-1); - - for (int row=0; row < rows; ++row) { - listOfPairs.removeAt(position); - } - - endRemoveRows(); - return true; -} -//! [5] - -//! [6] -bool TableModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (index.isValid() && role == Qt::EditRole) { - int row = index.row(); - - QPair p = listOfPairs.value(row); - - if (index.column() == 0) - p.first = value.toString(); - else if (index.column() == 1) - p.second = value.toString(); - else - return false; - - listOfPairs.replace(row, p); - emit(dataChanged(index, index)); - - return true; - } - - return false; -} -//! [6] - -//! [7] -Qt::ItemFlags TableModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return Qt::ItemIsEnabled; - - return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; -} -//! [7] - -//! [8] -QList< QPair > TableModel::getList() -{ - return listOfPairs; -} -//! [8] diff --git a/examples/itemviews/addressbook/tablemodel.h b/examples/itemviews/addressbook/tablemodel.h deleted file mode 100644 index bb21af587f..0000000000 --- a/examples/itemviews/addressbook/tablemodel.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 TABLEMODEL_H -#define TABLEMODEL_H - -#include -#include -#include - -//! [0] -class TableModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - TableModel(QObject *parent=0); - TableModel(QList< QPair > listofPairs, QObject *parent=0); - - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole); - bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex()); - bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex()); - QList< QPair > getList(); - -private: - QList< QPair > listOfPairs; -}; -//! [0] - -#endif diff --git a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.desktop b/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.desktop deleted file mode 100644 index 22621f3ba5..0000000000 --- a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Basic Sort Filter Model -Exec=/opt/usr/bin/basicsortfiltermodel -Icon=basicsortfiltermodel -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro b/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro deleted file mode 100644 index 75f96e4d48..0000000000 --- a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro +++ /dev/null @@ -1,12 +0,0 @@ -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp -CONFIG += qt - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/basicsortfiltermodel -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/basicsortfiltermodel -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/basicsortfiltermodel/main.cpp b/examples/itemviews/basicsortfiltermodel/main.cpp deleted file mode 100644 index 00b733090a..0000000000 --- a/examples/itemviews/basicsortfiltermodel/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -void addMail(QAbstractItemModel *model, const QString &subject, - const QString &sender, const QDateTime &date) -{ - model->insertRow(0); - model->setData(model->index(0, 0), subject); - model->setData(model->index(0, 1), sender); - model->setData(model->index(0, 2), date); -} - -QAbstractItemModel *createMailModel(QObject *parent) -{ - QStandardItemModel *model = new QStandardItemModel(0, 3, parent); - - model->setHeaderData(0, Qt::Horizontal, QObject::tr("Subject")); - model->setHeaderData(1, Qt::Horizontal, QObject::tr("Sender")); - model->setHeaderData(2, Qt::Horizontal, QObject::tr("Date")); - - addMail(model, "Happy New Year!", "Grace K. ", - QDateTime(QDate(2006, 12, 31), QTime(17, 03))); - addMail(model, "Radically new concept", "Grace K. ", - QDateTime(QDate(2006, 12, 22), QTime(9, 44))); - addMail(model, "Accounts", "pascale@nospam.com", - QDateTime(QDate(2006, 12, 31), QTime(12, 50))); - addMail(model, "Expenses", "Joe Bloggs ", - QDateTime(QDate(2006, 12, 25), QTime(11, 39))); - addMail(model, "Re: Expenses", "Andy ", - QDateTime(QDate(2007, 01, 02), QTime(16, 05))); - addMail(model, "Re: Accounts", "Joe Bloggs ", - QDateTime(QDate(2007, 01, 03), QTime(14, 18))); - addMail(model, "Re: Accounts", "Andy ", - QDateTime(QDate(2007, 01, 03), QTime(14, 26))); - addMail(model, "Sports", "Linda Smith ", - QDateTime(QDate(2007, 01, 05), QTime(11, 33))); - addMail(model, "AW: Sports", "Rolf Newschweinstein ", - QDateTime(QDate(2007, 01, 05), QTime(12, 00))); - addMail(model, "RE: Sports", "Petra Schmidt ", - QDateTime(QDate(2007, 01, 05), QTime(12, 01))); - - return model; -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.setSourceModel(createMailModel(&window)); - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/basicsortfiltermodel/window.cpp b/examples/itemviews/basicsortfiltermodel/window.cpp deleted file mode 100644 index f7f43c1753..0000000000 --- a/examples/itemviews/basicsortfiltermodel/window.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -Window::Window() -{ - proxyModel = new QSortFilterProxyModel; - - sourceView = new QTreeView; - sourceView->setRootIsDecorated(false); - sourceView->setAlternatingRowColors(true); - - proxyView = new QTreeView; - proxyView->setRootIsDecorated(false); - proxyView->setAlternatingRowColors(true); - proxyView->setModel(proxyModel); - proxyView->setSortingEnabled(true); - - sortCaseSensitivityCheckBox = new QCheckBox(tr("Case sensitive sorting")); - filterCaseSensitivityCheckBox = new QCheckBox(tr("Case sensitive filter")); - - filterPatternLineEdit = new QLineEdit; - filterPatternLabel = new QLabel(tr("&Filter pattern:")); - filterPatternLabel->setBuddy(filterPatternLineEdit); - - filterSyntaxComboBox = new QComboBox; - filterSyntaxComboBox->addItem(tr("Regular expression"), QRegExp::RegExp); - filterSyntaxComboBox->addItem(tr("Wildcard"), QRegExp::Wildcard); - filterSyntaxComboBox->addItem(tr("Fixed string"), QRegExp::FixedString); - filterSyntaxLabel = new QLabel(tr("Filter &syntax:")); - filterSyntaxLabel->setBuddy(filterSyntaxComboBox); - - filterColumnComboBox = new QComboBox; - filterColumnComboBox->addItem(tr("Subject")); - filterColumnComboBox->addItem(tr("Sender")); - filterColumnComboBox->addItem(tr("Date")); - filterColumnLabel = new QLabel(tr("Filter &column:")); - filterColumnLabel->setBuddy(filterColumnComboBox); - - connect(filterPatternLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(filterRegExpChanged())); - connect(filterSyntaxComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(filterRegExpChanged())); - connect(filterColumnComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(filterColumnChanged())); - connect(filterCaseSensitivityCheckBox, SIGNAL(toggled(bool)), - this, SLOT(filterRegExpChanged())); - connect(sortCaseSensitivityCheckBox, SIGNAL(toggled(bool)), - this, SLOT(sortChanged())); - - sourceGroupBox = new QGroupBox(tr("Original Model")); - proxyGroupBox = new QGroupBox(tr("Sorted/Filtered Model")); - - QHBoxLayout *sourceLayout = new QHBoxLayout; - sourceLayout->addWidget(sourceView); - sourceGroupBox->setLayout(sourceLayout); - - QGridLayout *proxyLayout = new QGridLayout; - proxyLayout->addWidget(proxyView, 0, 0, 1, 3); - proxyLayout->addWidget(filterPatternLabel, 1, 0); - proxyLayout->addWidget(filterPatternLineEdit, 1, 1, 1, 2); - proxyLayout->addWidget(filterSyntaxLabel, 2, 0); - proxyLayout->addWidget(filterSyntaxComboBox, 2, 1, 1, 2); - proxyLayout->addWidget(filterColumnLabel, 3, 0); - proxyLayout->addWidget(filterColumnComboBox, 3, 1, 1, 2); - proxyLayout->addWidget(filterCaseSensitivityCheckBox, 4, 0, 1, 2); - proxyLayout->addWidget(sortCaseSensitivityCheckBox, 4, 2); - proxyGroupBox->setLayout(proxyLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout; - - mainLayout->addWidget(sourceGroupBox); - mainLayout->addWidget(proxyGroupBox); - - setLayout(mainLayout); - - setWindowTitle(tr("Basic Sort/Filter Model")); - resize(500, 450); - - proxyView->sortByColumn(1, Qt::AscendingOrder); - filterColumnComboBox->setCurrentIndex(1); - - filterPatternLineEdit->setText("Andy|Grace"); - filterCaseSensitivityCheckBox->setChecked(true); - sortCaseSensitivityCheckBox->setChecked(true); -} - -void Window::setSourceModel(QAbstractItemModel *model) -{ - proxyModel->setSourceModel(model); - sourceView->setModel(model); -} - -void Window::filterRegExpChanged() -{ - QRegExp::PatternSyntax syntax = - QRegExp::PatternSyntax(filterSyntaxComboBox->itemData( - filterSyntaxComboBox->currentIndex()).toInt()); - Qt::CaseSensitivity caseSensitivity = - filterCaseSensitivityCheckBox->isChecked() ? Qt::CaseSensitive - : Qt::CaseInsensitive; - - QRegExp regExp(filterPatternLineEdit->text(), caseSensitivity, syntax); - proxyModel->setFilterRegExp(regExp); -} - -void Window::filterColumnChanged() -{ - proxyModel->setFilterKeyColumn(filterColumnComboBox->currentIndex()); -} - -void Window::sortChanged() -{ - proxyModel->setSortCaseSensitivity( - sortCaseSensitivityCheckBox->isChecked() ? Qt::CaseSensitive - : Qt::CaseInsensitive); -} diff --git a/examples/itemviews/basicsortfiltermodel/window.h b/examples/itemviews/basicsortfiltermodel/window.h deleted file mode 100644 index f672a3eb66..0000000000 --- a/examples/itemviews/basicsortfiltermodel/window.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAbstractItemModel; -class QCheckBox; -class QComboBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QSortFilterProxyModel; -class QTreeView; -QT_END_NAMESPACE - -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - - void setSourceModel(QAbstractItemModel *model); - -private slots: - void filterRegExpChanged(); - void filterColumnChanged(); - void sortChanged(); - -private: - QSortFilterProxyModel *proxyModel; - - QGroupBox *sourceGroupBox; - QGroupBox *proxyGroupBox; - QTreeView *sourceView; - QTreeView *proxyView; - QCheckBox *filterCaseSensitivityCheckBox; - QCheckBox *sortCaseSensitivityCheckBox; - QLabel *filterPatternLabel; - QLabel *filterSyntaxLabel; - QLabel *filterColumnLabel; - QLineEdit *filterPatternLineEdit; - QComboBox *filterSyntaxComboBox; - QComboBox *filterColumnComboBox; -}; - -#endif diff --git a/examples/itemviews/chart/chart.desktop b/examples/itemviews/chart/chart.desktop deleted file mode 100644 index 73e017baeb..0000000000 --- a/examples/itemviews/chart/chart.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Chart -Exec=/opt/usr/bin/chart -Icon=chart -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/chart/chart.pro b/examples/itemviews/chart/chart.pro deleted file mode 100644 index 310bb85ad7..0000000000 --- a/examples/itemviews/chart/chart.pro +++ /dev/null @@ -1,18 +0,0 @@ -HEADERS = mainwindow.h \ - pieview.h -RESOURCES = chart.qrc -SOURCES = main.cpp \ - mainwindow.cpp \ - pieview.cpp -unix:!mac:!vxworks:!integrity:LIBS+= -lm - -TARGET.EPOCHEAPSIZE = 0x200000 0x800000 - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/chart -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.cht -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/chart -INSTALLS += target sources - -QT += widgets - diff --git a/examples/itemviews/chart/chart.qrc b/examples/itemviews/chart/chart.qrc deleted file mode 100644 index 7401d4d2f8..0000000000 --- a/examples/itemviews/chart/chart.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qtdata.cht - - diff --git a/examples/itemviews/chart/main.cpp b/examples/itemviews/chart/main.cpp deleted file mode 100644 index b1c13116c9..0000000000 --- a/examples/itemviews/chart/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(chart); - - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/chart/mainwindow.cpp b/examples/itemviews/chart/mainwindow.cpp deleted file mode 100644 index 584390252b..0000000000 --- a/examples/itemviews/chart/mainwindow.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "pieview.h" -#include "mainwindow.h" - -MainWindow::MainWindow() -{ - QMenu *fileMenu = new QMenu(tr("&File"), this); - QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcuts(QKeySequence::Open); - QAction *saveAction = fileMenu->addAction(tr("&Save As...")); - saveAction->setShortcuts(QKeySequence::SaveAs); - QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcuts(QKeySequence::Quit); - - setupModel(); - setupViews(); - - connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); - connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile())); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - menuBar()->addMenu(fileMenu); - statusBar(); - - openFile(":/Charts/qtdata.cht"); - - setWindowTitle(tr("Chart")); - resize(870, 550); -} - -void MainWindow::setupModel() -{ - model = new QStandardItemModel(8, 2, this); - model->setHeaderData(0, Qt::Horizontal, tr("Label")); - model->setHeaderData(1, Qt::Horizontal, tr("Quantity")); -} - -void MainWindow::setupViews() -{ - QSplitter *splitter = new QSplitter; - QTableView *table = new QTableView; - pieChart = new PieView; - splitter->addWidget(table); - splitter->addWidget(pieChart); - splitter->setStretchFactor(0, 0); - splitter->setStretchFactor(1, 1); - - table->setModel(model); - pieChart->setModel(model); - - QItemSelectionModel *selectionModel = new QItemSelectionModel(model); - table->setSelectionModel(selectionModel); - pieChart->setSelectionModel(selectionModel); - - QHeaderView *headerView = table->horizontalHeader(); - headerView->setStretchLastSection(true); - - setCentralWidget(splitter); -} - -void MainWindow::openFile(const QString &path) -{ - QString fileName; - if (path.isNull()) - fileName = QFileDialog::getOpenFileName(this, tr("Choose a data file"), - "", "*.cht"); - else - fileName = path; - - if (!fileName.isEmpty()) { - QFile file(fileName); - - if (file.open(QFile::ReadOnly | QFile::Text)) { - QTextStream stream(&file); - QString line; - - model->removeRows(0, model->rowCount(QModelIndex()), QModelIndex()); - - int row = 0; - do { - line = stream.readLine(); - if (!line.isEmpty()) { - - model->insertRows(row, 1, QModelIndex()); - - QStringList pieces = line.split(",", QString::SkipEmptyParts); - model->setData(model->index(row, 0, QModelIndex()), - pieces.value(0)); - model->setData(model->index(row, 1, QModelIndex()), - pieces.value(1)); - model->setData(model->index(row, 0, QModelIndex()), - QColor(pieces.value(2)), Qt::DecorationRole); - row++; - } - } while (!line.isEmpty()); - - file.close(); - statusBar()->showMessage(tr("Loaded %1").arg(fileName), 2000); - } - } -} - -void MainWindow::saveFile() -{ - QString fileName = QFileDialog::getSaveFileName(this, - tr("Save file as"), "", "*.cht"); - - if (!fileName.isEmpty()) { - QFile file(fileName); - QTextStream stream(&file); - - if (file.open(QFile::WriteOnly | QFile::Text)) { - for (int row = 0; row < model->rowCount(QModelIndex()); ++row) { - - QStringList pieces; - - pieces.append(model->data(model->index(row, 0, QModelIndex()), - Qt::DisplayRole).toString()); - pieces.append(model->data(model->index(row, 1, QModelIndex()), - Qt::DisplayRole).toString()); - pieces.append(model->data(model->index(row, 0, QModelIndex()), - Qt::DecorationRole).toString()); - - stream << pieces.join(",") << "\n"; - } - } - - file.close(); - statusBar()->showMessage(tr("Saved %1").arg(fileName), 2000); - } -} diff --git a/examples/itemviews/chart/mainwindow.h b/examples/itemviews/chart/mainwindow.h deleted file mode 100644 index 5ce4f30e32..0000000000 --- a/examples/itemviews/chart/mainwindow.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAbstractItemModel; -class QAbstractItemView; -class QItemSelectionModel; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private slots: - void openFile(const QString &path = QString()); - void saveFile(); - -private: - void setupModel(); - void setupViews(); - - QAbstractItemModel *model; - QAbstractItemView *pieChart; - QItemSelectionModel *selectionModel; -}; - -#endif diff --git a/examples/itemviews/chart/mydata.cht b/examples/itemviews/chart/mydata.cht deleted file mode 100644 index 029fd81458..0000000000 --- a/examples/itemviews/chart/mydata.cht +++ /dev/null @@ -1,8 +0,0 @@ -London,4,red -Stockholm,5,pink -Paris,2,lightgreen -Rome,11,green -Lisbon,9,blue -Madrid,8,lightblue -Berlin,6,magenta -Vienna,7,purple diff --git a/examples/itemviews/chart/pieview.cpp b/examples/itemviews/chart/pieview.cpp deleted file mode 100644 index 30f3255689..0000000000 --- a/examples/itemviews/chart/pieview.cpp +++ /dev/null @@ -1,557 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#ifndef M_PI -#define M_PI 3.1415927 -#endif - -#include "pieview.h" - -PieView::PieView(QWidget *parent) - : QAbstractItemView(parent) -{ - horizontalScrollBar()->setRange(0, 0); - verticalScrollBar()->setRange(0, 0); - - margin = 8; - totalSize = 300; - pieSize = totalSize - 2*margin; - validItems = 0; - totalValue = 0.0; - rubberBand = 0; -} - -void PieView::dataChanged(const QModelIndex &topLeft, - const QModelIndex &bottomRight, - const QVector &) -{ - QAbstractItemView::dataChanged(topLeft, bottomRight); - - validItems = 0; - totalValue = 0.0; - - for (int row = 0; row < model()->rowCount(rootIndex()); ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - double value = model()->data(index).toDouble(); - - if (value > 0.0) { - totalValue += value; - validItems++; - } - } - viewport()->update(); -} - -bool PieView::edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) -{ - if (index.column() == 0) - return QAbstractItemView::edit(index, trigger, event); - else - return false; -} - -/* - Returns the item that covers the coordinate given in the view. -*/ - -QModelIndex PieView::indexAt(const QPoint &point) const -{ - if (validItems == 0) - return QModelIndex(); - - // Transform the view coordinates into contents widget coordinates. - int wx = point.x() + horizontalScrollBar()->value(); - int wy = point.y() + verticalScrollBar()->value(); - - if (wx < totalSize) { - double cx = wx - totalSize/2; - double cy = totalSize/2 - wy; // positive cy for items above the center - - // Determine the distance from the center point of the pie chart. - double d = pow(pow(cx, 2) + pow(cy, 2), 0.5); - - if (d == 0 || d > pieSize/2) - return QModelIndex(); - - // Determine the angle of the point. - double angle = (180 / M_PI) * acos(cx/d); - if (cy < 0) - angle = 360 - angle; - - // Find the relevant slice of the pie. - double startAngle = 0.0; - - for (int row = 0; row < model()->rowCount(rootIndex()); ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - double value = model()->data(index).toDouble(); - - if (value > 0.0) { - double sliceAngle = 360*value/totalValue; - - if (angle >= startAngle && angle < (startAngle + sliceAngle)) - return model()->index(row, 1, rootIndex()); - - startAngle += sliceAngle; - } - } - } else { - double itemHeight = QFontMetrics(viewOptions().font).height(); - int listItem = int((wy - margin) / itemHeight); - int validRow = 0; - - for (int row = 0; row < model()->rowCount(rootIndex()); ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - if (model()->data(index).toDouble() > 0.0) { - - if (listItem == validRow) - return model()->index(row, 0, rootIndex()); - - // Update the list index that corresponds to the next valid row. - validRow++; - } - } - } - - return QModelIndex(); -} - -bool PieView::isIndexHidden(const QModelIndex & /*index*/) const -{ - return false; -} - -/* - Returns the rectangle of the item at position \a index in the - model. The rectangle is in contents coordinates. -*/ - -QRect PieView::itemRect(const QModelIndex &index) const -{ - if (!index.isValid()) - return QRect(); - - // Check whether the index's row is in the list of rows represented - // by slices. - QModelIndex valueIndex; - - if (index.column() != 1) - valueIndex = model()->index(index.row(), 1, rootIndex()); - else - valueIndex = index; - - if (model()->data(valueIndex).toDouble() > 0.0) { - - int listItem = 0; - for (int row = index.row()-1; row >= 0; --row) { - if (model()->data(model()->index(row, 1, rootIndex())).toDouble() > 0.0) - listItem++; - } - - double itemHeight; - - switch (index.column()) { - case 0: - itemHeight = QFontMetrics(viewOptions().font).height(); - - return QRect(totalSize, - int(margin + listItem*itemHeight), - totalSize - margin, int(itemHeight)); - case 1: - return viewport()->rect(); - } - - } - return QRect(); -} - -QRegion PieView::itemRegion(const QModelIndex &index) const -{ - if (!index.isValid()) - return QRegion(); - - if (index.column() != 1) - return itemRect(index); - - if (model()->data(index).toDouble() <= 0.0) - return QRegion(); - - double startAngle = 0.0; - for (int row = 0; row < model()->rowCount(rootIndex()); ++row) { - - QModelIndex sliceIndex = model()->index(row, 1, rootIndex()); - double value = model()->data(sliceIndex).toDouble(); - - if (value > 0.0) { - double angle = 360*value/totalValue; - - if (sliceIndex == index) { - QPainterPath slicePath; - slicePath.moveTo(totalSize/2, totalSize/2); - slicePath.arcTo(margin, margin, margin+pieSize, margin+pieSize, - startAngle, angle); - slicePath.closeSubpath(); - - return QRegion(slicePath.toFillPolygon().toPolygon()); - } - - startAngle += angle; - } - } - - return QRegion(); -} - -int PieView::horizontalOffset() const -{ - return horizontalScrollBar()->value(); -} - -void PieView::mousePressEvent(QMouseEvent *event) -{ - QAbstractItemView::mousePressEvent(event); - origin = event->pos(); - if (!rubberBand) - rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport()); - rubberBand->setGeometry(QRect(origin, QSize())); - rubberBand->show(); -} - -void PieView::mouseMoveEvent(QMouseEvent *event) -{ - if (rubberBand) - rubberBand->setGeometry(QRect(origin, event->pos()).normalized()); - QAbstractItemView::mouseMoveEvent(event); -} - -void PieView::mouseReleaseEvent(QMouseEvent *event) -{ - QAbstractItemView::mouseReleaseEvent(event); - if (rubberBand) - rubberBand->hide(); - viewport()->update(); -} - -QModelIndex PieView::moveCursor(QAbstractItemView::CursorAction cursorAction, - Qt::KeyboardModifiers /*modifiers*/) -{ - QModelIndex current = currentIndex(); - - switch (cursorAction) { - case MoveLeft: - case MoveUp: - if (current.row() > 0) - current = model()->index(current.row() - 1, current.column(), - rootIndex()); - else - current = model()->index(0, current.column(), rootIndex()); - break; - case MoveRight: - case MoveDown: - if (current.row() < rows(current) - 1) - current = model()->index(current.row() + 1, current.column(), - rootIndex()); - else - current = model()->index(rows(current) - 1, current.column(), - rootIndex()); - break; - default: - break; - } - - viewport()->update(); - return current; -} - -void PieView::paintEvent(QPaintEvent *event) -{ - QItemSelectionModel *selections = selectionModel(); - QStyleOptionViewItem option = viewOptions(); - - QBrush background = option.palette.base(); - QPen foreground(option.palette.color(QPalette::WindowText)); - - QPainter painter(viewport()); - painter.setRenderHint(QPainter::Antialiasing); - - painter.fillRect(event->rect(), background); - painter.setPen(foreground); - - // Viewport rectangles - QRect pieRect = QRect(margin, margin, pieSize, pieSize); - - if (validItems > 0) { - - painter.save(); - painter.translate(pieRect.x() - horizontalScrollBar()->value(), - pieRect.y() - verticalScrollBar()->value()); - painter.drawEllipse(0, 0, pieSize, pieSize); - double startAngle = 0.0; - int row; - - for (row = 0; row < model()->rowCount(rootIndex()); ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - double value = model()->data(index).toDouble(); - - if (value > 0.0) { - double angle = 360*value/totalValue; - - QModelIndex colorIndex = model()->index(row, 0, rootIndex()); - QColor color = QColor(model()->data(colorIndex, - Qt::DecorationRole).toString()); - - if (currentIndex() == index) - painter.setBrush(QBrush(color, Qt::Dense4Pattern)); - else if (selections->isSelected(index)) - painter.setBrush(QBrush(color, Qt::Dense3Pattern)); - else - painter.setBrush(QBrush(color)); - - painter.drawPie(0, 0, pieSize, pieSize, int(startAngle*16), - int(angle*16)); - - startAngle += angle; - } - } - painter.restore(); - - int keyNumber = 0; - - for (row = 0; row < model()->rowCount(rootIndex()); ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - double value = model()->data(index).toDouble(); - - if (value > 0.0) { - QModelIndex labelIndex = model()->index(row, 0, rootIndex()); - - QStyleOptionViewItem option = viewOptions(); - option.rect = visualRect(labelIndex); - if (selections->isSelected(labelIndex)) - option.state |= QStyle::State_Selected; - if (currentIndex() == labelIndex) - option.state |= QStyle::State_HasFocus; - itemDelegate()->paint(&painter, option, labelIndex); - - keyNumber++; - } - } - } -} - -void PieView::resizeEvent(QResizeEvent * /* event */) -{ - updateGeometries(); -} - -int PieView::rows(const QModelIndex &index) const -{ - return model()->rowCount(model()->parent(index)); -} - -void PieView::rowsInserted(const QModelIndex &parent, int start, int end) -{ - for (int row = start; row <= end; ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - double value = model()->data(index).toDouble(); - - if (value > 0.0) { - totalValue += value; - validItems++; - } - } - - QAbstractItemView::rowsInserted(parent, start, end); -} - -void PieView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -{ - for (int row = start; row <= end; ++row) { - - QModelIndex index = model()->index(row, 1, rootIndex()); - double value = model()->data(index).toDouble(); - if (value > 0.0) { - totalValue -= value; - validItems--; - } - } - - QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); -} - -void PieView::scrollContentsBy(int dx, int dy) -{ - viewport()->scroll(dx, dy); -} - -void PieView::scrollTo(const QModelIndex &index, ScrollHint) -{ - QRect area = viewport()->rect(); - QRect rect = visualRect(index); - - if (rect.left() < area.left()) - horizontalScrollBar()->setValue( - horizontalScrollBar()->value() + rect.left() - area.left()); - else if (rect.right() > area.right()) - horizontalScrollBar()->setValue( - horizontalScrollBar()->value() + qMin( - rect.right() - area.right(), rect.left() - area.left())); - - if (rect.top() < area.top()) - verticalScrollBar()->setValue( - verticalScrollBar()->value() + rect.top() - area.top()); - else if (rect.bottom() > area.bottom()) - verticalScrollBar()->setValue( - verticalScrollBar()->value() + qMin( - rect.bottom() - area.bottom(), rect.top() - area.top())); - - update(); -} - -/* - Find the indices corresponding to the extent of the selection. -*/ - -void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) -{ - // Use content widget coordinates because we will use the itemRegion() - // function to check for intersections. - - QRect contentsRect = rect.translated( - horizontalScrollBar()->value(), - verticalScrollBar()->value()).normalized(); - - int rows = model()->rowCount(rootIndex()); - int columns = model()->columnCount(rootIndex()); - QModelIndexList indexes; - - for (int row = 0; row < rows; ++row) { - for (int column = 0; column < columns; ++column) { - QModelIndex index = model()->index(row, column, rootIndex()); - QRegion region = itemRegion(index); - if (region.intersects(contentsRect)) - indexes.append(index); - } - } - - if (indexes.size() > 0) { - int firstRow = indexes[0].row(); - int lastRow = indexes[0].row(); - int firstColumn = indexes[0].column(); - int lastColumn = indexes[0].column(); - - for (int i = 1; i < indexes.size(); ++i) { - firstRow = qMin(firstRow, indexes[i].row()); - lastRow = qMax(lastRow, indexes[i].row()); - firstColumn = qMin(firstColumn, indexes[i].column()); - lastColumn = qMax(lastColumn, indexes[i].column()); - } - - QItemSelection selection( - model()->index(firstRow, firstColumn, rootIndex()), - model()->index(lastRow, lastColumn, rootIndex())); - selectionModel()->select(selection, command); - } else { - QModelIndex noIndex; - QItemSelection selection(noIndex, noIndex); - selectionModel()->select(selection, command); - } - - update(); -} - -void PieView::updateGeometries() -{ - horizontalScrollBar()->setPageStep(viewport()->width()); - horizontalScrollBar()->setRange(0, qMax(0, 2*totalSize - viewport()->width())); - verticalScrollBar()->setPageStep(viewport()->height()); - verticalScrollBar()->setRange(0, qMax(0, totalSize - viewport()->height())); -} - -int PieView::verticalOffset() const -{ - return verticalScrollBar()->value(); -} - -/* - Returns the position of the item in viewport coordinates. -*/ - -QRect PieView::visualRect(const QModelIndex &index) const -{ - QRect rect = itemRect(index); - if (rect.isValid()) - return QRect(rect.left() - horizontalScrollBar()->value(), - rect.top() - verticalScrollBar()->value(), - rect.width(), rect.height()); - else - return rect; -} - -/* - Returns a region corresponding to the selection in viewport coordinates. -*/ - -QRegion PieView::visualRegionForSelection(const QItemSelection &selection) const -{ - int ranges = selection.count(); - - if (ranges == 0) - return QRect(); - - QRegion region; - for (int i = 0; i < ranges; ++i) { - QItemSelectionRange range = selection.at(i); - for (int row = range.top(); row <= range.bottom(); ++row) { - for (int col = range.left(); col <= range.right(); ++col) { - QModelIndex index = model()->index(row, col, rootIndex()); - region += visualRect(index); - } - } - } - return region; -} diff --git a/examples/itemviews/chart/pieview.h b/examples/itemviews/chart/pieview.h deleted file mode 100644 index 208159bf73..0000000000 --- a/examples/itemviews/chart/pieview.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PIEVIEW_H -#define PIEVIEW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QRubberBand; -QT_END_NAMESPACE - -//! [0] -class PieView : public QAbstractItemView -{ - Q_OBJECT - -public: - PieView(QWidget *parent = 0); - - QRect visualRect(const QModelIndex &index) const; - void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible); - QModelIndex indexAt(const QPoint &point) const; - -protected slots: - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector & = QVector()); - void rowsInserted(const QModelIndex &parent, int start, int end); - void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - -protected: - bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event); - QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, - Qt::KeyboardModifiers modifiers); - - int horizontalOffset() const; - int verticalOffset() const; - - bool isIndexHidden(const QModelIndex &index) const; - - void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command); - - void mousePressEvent(QMouseEvent *event); - - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - - void paintEvent(QPaintEvent *event); - void resizeEvent(QResizeEvent *event); - void scrollContentsBy(int dx, int dy); - - QRegion visualRegionForSelection(const QItemSelection &selection) const; - -private: - QRect itemRect(const QModelIndex &item) const; - QRegion itemRegion(const QModelIndex &index) const; - int rows(const QModelIndex &index = QModelIndex()) const; - void updateGeometries(); - - int margin; - int totalSize; - int pieSize; - int validItems; - double totalValue; - QPoint origin; - QRubberBand *rubberBand; -}; -//! [0] - -#endif diff --git a/examples/itemviews/chart/qtdata.cht b/examples/itemviews/chart/qtdata.cht deleted file mode 100644 index 6386246c4b..0000000000 --- a/examples/itemviews/chart/qtdata.cht +++ /dev/null @@ -1,14 +0,0 @@ -Scientific Research,21,#99e600 -Engineering & Design,18,#99cc00 -Automotive,14,#99b300 -Aerospace,13,#9f991a -Automation & Machine Tools,13,#a48033 -Medical & Bioinformatics,13,#a9664d -Imaging & Special Effects,12,#ae4d66 -Defense,11,#b33380 -Test & Measurement Systems,9,#a64086 -Oil & Gas,9,#994d8d -Entertainment & Broadcasting,7,#8d5a93 -Financial,6,#806699 -Consumer Electronics,4,#8073a6 -Other,38,#8080b3 diff --git a/examples/itemviews/coloreditorfactory/coloreditorfactory.desktop b/examples/itemviews/coloreditorfactory/coloreditorfactory.desktop deleted file mode 100644 index 70b966445c..0000000000 --- a/examples/itemviews/coloreditorfactory/coloreditorfactory.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Color Editor Factory -Exec=/opt/usr/bin/coloreditorfactory -Icon=coloreditorfactory -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/coloreditorfactory/coloreditorfactory.pro b/examples/itemviews/coloreditorfactory/coloreditorfactory.pro deleted file mode 100644 index 07e1296e06..0000000000 --- a/examples/itemviews/coloreditorfactory/coloreditorfactory.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = colorlisteditor.h \ - window.h -SOURCES = colorlisteditor.cpp \ - window.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/coloreditorfactory -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/coloreditorfactory -INSTALLS += target sources - -QT += widgets - diff --git a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp deleted file mode 100644 index e8f1f2d719..0000000000 --- a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "colorlisteditor.h" - -ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget) -{ - populateList(); -} - -//! [0] -QColor ColorListEditor::color() const -{ - return qvariant_cast(itemData(currentIndex(), Qt::DecorationRole)); -} -//! [0] - -//! [1] -void ColorListEditor::setColor(QColor color) -{ - setCurrentIndex(findData(color, int(Qt::DecorationRole))); -} -//! [1] - -//! [2] -void ColorListEditor::populateList() -{ - QStringList colorNames = QColor::colorNames(); - - for (int i = 0; i < colorNames.size(); ++i) { - QColor color(colorNames[i]); - - insertItem(i, colorNames[i]); - setItemData(i, color, Qt::DecorationRole); - } -} -//! [2] diff --git a/examples/itemviews/coloreditorfactory/colorlisteditor.h b/examples/itemviews/coloreditorfactory/colorlisteditor.h deleted file mode 100644 index 13ece8ef6d..0000000000 --- a/examples/itemviews/coloreditorfactory/colorlisteditor.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 COLORLISTEDITOR_H -#define COLORLISTEDITOR_H - -#include - -QT_BEGIN_NAMESPACE -class QColor; -class QWidget; -QT_END_NAMESPACE - -//! [0] -class ColorListEditor : public QComboBox -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor USER true) - -public: - ColorListEditor(QWidget *widget = 0); - -public: - QColor color() const; - void setColor(QColor c); - -private: - void populateList(); -}; -//! [0] - -#endif diff --git a/examples/itemviews/coloreditorfactory/main.cpp b/examples/itemviews/coloreditorfactory/main.cpp deleted file mode 100644 index 5bbe817214..0000000000 --- a/examples/itemviews/coloreditorfactory/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - Window window; - window.show(); - - return app.exec(); -} diff --git a/examples/itemviews/coloreditorfactory/window.cpp b/examples/itemviews/coloreditorfactory/window.cpp deleted file mode 100644 index 5c1b03ebbe..0000000000 --- a/examples/itemviews/coloreditorfactory/window.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" -#include "colorlisteditor.h" - -//! [0] -Window::Window() -{ - QItemEditorFactory *factory = new QItemEditorFactory; - - QItemEditorCreatorBase *colorListCreator = - new QStandardItemEditorCreator(); - - factory->registerEditor(QVariant::Color, colorListCreator); - - QItemEditorFactory::setDefaultFactory(factory); - - createGUI(); -} -//! [0] - -void Window::createGUI() -{ - QList > list; - list << QPair(tr("Alice"), QColor("aliceblue")) << - QPair(tr("Neptun"), QColor("aquamarine")) << - QPair(tr("Ferdinand"), QColor("springgreen")); - - QTableWidget *table = new QTableWidget(3, 2); - table->setHorizontalHeaderLabels(QStringList() << tr("Name") - << tr("Hair Color")); - table->verticalHeader()->setVisible(false); - table->resize(150, 50); - - for (int i = 0; i < 3; ++i) { - QPair pair = list.at(i); - - QTableWidgetItem *nameItem = new QTableWidgetItem(pair.first); - QTableWidgetItem *colorItem = new QTableWidgetItem; - colorItem->setData(Qt::DisplayRole, pair.second); - - table->setItem(i, 0, nameItem); - table->setItem(i, 1, colorItem); - } - table->resizeColumnToContents(0); - table->horizontalHeader()->setStretchLastSection(true); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(table, 0, 0); - - setLayout(layout); - - setWindowTitle(tr("Color Editor Factory")); -} diff --git a/examples/itemviews/coloreditorfactory/window.h b/examples/itemviews/coloreditorfactory/window.h deleted file mode 100644 index 65a9c8e854..0000000000 --- a/examples/itemviews/coloreditorfactory/window.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -private: - void createGUI(); -}; - -#endif diff --git a/examples/itemviews/combowidgetmapper/combowidgetmapper.desktop b/examples/itemviews/combowidgetmapper/combowidgetmapper.desktop deleted file mode 100644 index 3bbf6ad5f3..0000000000 --- a/examples/itemviews/combowidgetmapper/combowidgetmapper.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Combo Widget Mapper -Exec=/opt/usr/bin/combowidgetmapper -Icon=combowidgetmapper -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/combowidgetmapper/combowidgetmapper.pro b/examples/itemviews/combowidgetmapper/combowidgetmapper.pro deleted file mode 100644 index 9ea1fa0e25..0000000000 --- a/examples/itemviews/combowidgetmapper/combowidgetmapper.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/combowidgetmapper -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/combowidgetmapper -INSTALLS += target sources -QT += widgets - diff --git a/examples/itemviews/combowidgetmapper/main.cpp b/examples/itemviews/combowidgetmapper/main.cpp deleted file mode 100644 index 0fc4966ccf..0000000000 --- a/examples/itemviews/combowidgetmapper/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/combowidgetmapper/window.cpp b/examples/itemviews/combowidgetmapper/window.cpp deleted file mode 100644 index 8c735c04c5..0000000000 --- a/examples/itemviews/combowidgetmapper/window.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "window.h" - -//! [Set up widgets] -Window::Window(QWidget *parent) - : QWidget(parent) -{ - setupModel(); - - nameLabel = new QLabel(tr("Na&me:")); - nameEdit = new QLineEdit(); - addressLabel = new QLabel(tr("&Address:")); - addressEdit = new QTextEdit(); - typeLabel = new QLabel(tr("&Type:")); - typeComboBox = new QComboBox(); - nextButton = new QPushButton(tr("&Next")); - previousButton = new QPushButton(tr("&Previous")); - - nameLabel->setBuddy(nameEdit); - addressLabel->setBuddy(addressEdit); - typeLabel->setBuddy(typeComboBox); - - typeComboBox->setModel(typeModel); -//! [Set up widgets] - -//! [Set up the mapper] - mapper = new QDataWidgetMapper(this); - mapper->setModel(model); - mapper->addMapping(nameEdit, 0); - mapper->addMapping(addressEdit, 1); - mapper->addMapping(typeComboBox, 2, "currentIndex"); -//! [Set up the mapper] - -//! [Set up connections and layouts] - connect(previousButton, SIGNAL(clicked()), - mapper, SLOT(toPrevious())); - connect(nextButton, SIGNAL(clicked()), - mapper, SLOT(toNext())); - connect(mapper, SIGNAL(currentIndexChanged(int)), - this, SLOT(updateButtons(int))); - - QGridLayout *layout = new QGridLayout(); - layout->addWidget(nameLabel, 0, 0, 1, 1); - layout->addWidget(nameEdit, 0, 1, 1, 1); - layout->addWidget(previousButton, 0, 2, 1, 1); - layout->addWidget(addressLabel, 1, 0, 1, 1); - layout->addWidget(addressEdit, 1, 1, 2, 1); - layout->addWidget(nextButton, 1, 2, 1, 1); - layout->addWidget(typeLabel, 3, 0, 1, 1); - layout->addWidget(typeComboBox, 3, 1, 1, 1); - setLayout(layout); - - setWindowTitle(tr("Delegate Widget Mapper")); - mapper->toFirst(); -} -//! [Set up connections and layouts] - -//! [Set up the model] -void Window::setupModel() -{ - QStringList items; - items << tr("Home") << tr("Work") << tr("Other"); - typeModel = new QStringListModel(items, this); - - model = new QStandardItemModel(5, 3, this); - QStringList names; - names << "Alice" << "Bob" << "Carol" << "Donald" << "Emma"; - QStringList addresses; - addresses << "123 Main Street
    Market Town
    " - << "PO Box 32
    Mail Handling Service" - "
    Service City
    " - << "The Lighthouse
    Remote Island
    " - << "47338 Park Avenue
    Big City
    " - << "Research Station
    Base Camp
    Big Mountain
    "; - - QStringList types; - types << "0" << "1" << "2" << "0" << "2"; - - for (int row = 0; row < 5; ++row) { - QStandardItem *item = new QStandardItem(names[row]); - model->setItem(row, 0, item); - item = new QStandardItem(addresses[row]); - model->setItem(row, 1, item); - item = new QStandardItem(types[row]); - model->setItem(row, 2, item); - } -} -//! [Set up the model] - -//! [Slot for updating the buttons] -void Window::updateButtons(int row) -{ - previousButton->setEnabled(row > 0); - nextButton->setEnabled(row < model->rowCount() - 1); -} -//! [Slot for updating the buttons] diff --git a/examples/itemviews/combowidgetmapper/window.h b/examples/itemviews/combowidgetmapper/window.h deleted file mode 100644 index 8ec5523cf1..0000000000 --- a/examples/itemviews/combowidgetmapper/window.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QComboBox; -class QDataWidgetMapper; -class QLabel; -class QLineEdit; -class QPushButton; -class QStandardItemModel; -class QStringListModel; -class QTextEdit; -QT_END_NAMESPACE - -//! [Window definition] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(QWidget *parent = 0); - -private slots: - void updateButtons(int row); - -private: - void setupModel(); - - QLabel *nameLabel; - QLabel *addressLabel; - QLabel *typeLabel; - QLineEdit *nameEdit; - QTextEdit *addressEdit; - QComboBox *typeComboBox; - QPushButton *nextButton; - QPushButton *previousButton; - - QStandardItemModel *model; - QStringListModel *typeModel; - QDataWidgetMapper *mapper; -}; -//! [Window definition] - -#endif diff --git a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.desktop b/examples/itemviews/customsortfiltermodel/customsortfiltermodel.desktop deleted file mode 100644 index 3c961f7e65..0000000000 --- a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Custom Sort Filter Model -Exec=/opt/usr/bin/customsortfiltermodel -Icon=customsortfiltermodel -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro b/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro deleted file mode 100644 index a2288b953c..0000000000 --- a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = mysortfilterproxymodel.h \ - window.h -SOURCES = main.cpp \ - mysortfilterproxymodel.cpp \ - window.cpp -CONFIG += qt - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/customsortfiltermodel -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/customsortfiltermodel -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/customsortfiltermodel/main.cpp b/examples/itemviews/customsortfiltermodel/main.cpp deleted file mode 100644 index 6df986324e..0000000000 --- a/examples/itemviews/customsortfiltermodel/main.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -void addMail(QAbstractItemModel *model, const QString &subject, - const QString &sender, const QDateTime &date) -{ - model->insertRow(0); - model->setData(model->index(0, 0), subject); - model->setData(model->index(0, 1), sender); - model->setData(model->index(0, 2), date); -} - -QAbstractItemModel *createMailModel(QObject *parent) -{ - QStandardItemModel *model = new QStandardItemModel(0, 3, parent); - - model->setHeaderData(0, Qt::Horizontal, QObject::tr("Subject")); - model->setHeaderData(1, Qt::Horizontal, QObject::tr("Sender")); - model->setHeaderData(2, Qt::Horizontal, QObject::tr("Date")); - - addMail(model, "Happy New Year!", "Grace K. ", - QDateTime(QDate(2006, 12, 31), QTime(17, 03))); - addMail(model, "Radically new concept", "Grace K. ", - QDateTime(QDate(2006, 12, 22), QTime(9, 44))); - addMail(model, "Accounts", "pascale@nospam.com", - QDateTime(QDate(2006, 12, 31), QTime(12, 50))); - addMail(model, "Expenses", "Joe Bloggs ", - QDateTime(QDate(2006, 12, 25), QTime(11, 39))); - addMail(model, "Re: Expenses", "Andy ", - QDateTime(QDate(2007, 01, 02), QTime(16, 05))); - addMail(model, "Re: Accounts", "Joe Bloggs ", - QDateTime(QDate(2007, 01, 03), QTime(14, 18))); - addMail(model, "Re: Accounts", "Andy ", - QDateTime(QDate(2007, 01, 03), QTime(14, 26))); - addMail(model, "Sports", "Linda Smith ", - QDateTime(QDate(2007, 01, 05), QTime(11, 33))); - addMail(model, "AW: Sports", "Rolf Newschweinstein ", - QDateTime(QDate(2007, 01, 05), QTime(12, 00))); - addMail(model, "RE: Sports", "Petra Schmidt ", - QDateTime(QDate(2007, 01, 05), QTime(12, 01))); - - return model; -} - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.setSourceModel(createMailModel(&window)); - window.show(); - return app.exec(); -} -//! [0] diff --git a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp deleted file mode 100644 index 3100efa4ac..0000000000 --- a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mysortfilterproxymodel.h" - -//! [0] -MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent) - : QSortFilterProxyModel(parent) -{ -} -//! [0] - -//! [1] -void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date) -{ - minDate = date; - invalidateFilter(); -} -//! [1] - -//! [2] -void MySortFilterProxyModel::setFilterMaximumDate(const QDate &date) -{ - maxDate = date; - invalidateFilter(); -} -//! [2] - -//! [3] -bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, - const QModelIndex &sourceParent) const -{ - QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); - QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); - QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); - - return (sourceModel()->data(index0).toString().contains(filterRegExp()) - || sourceModel()->data(index1).toString().contains(filterRegExp())) - && dateInRange(sourceModel()->data(index2).toDate()); -} -//! [3] - -//! [4] //! [5] -bool MySortFilterProxyModel::lessThan(const QModelIndex &left, - const QModelIndex &right) const -{ - QVariant leftData = sourceModel()->data(left); - QVariant rightData = sourceModel()->data(right); -//! [4] - -//! [6] - if (leftData.type() == QVariant::DateTime) { - return leftData.toDateTime() < rightData.toDateTime(); - } else { - QRegExp *emailPattern = new QRegExp("([\\w\\.]*@[\\w\\.]*)"); - - QString leftString = leftData.toString(); - if(left.column() == 1 && emailPattern->indexIn(leftString) != -1) - leftString = emailPattern->cap(1); - - QString rightString = rightData.toString(); - if(right.column() == 1 && emailPattern->indexIn(rightString) != -1) - rightString = emailPattern->cap(1); - - return QString::localeAwareCompare(leftString, rightString) < 0; - } -} -//! [5] //! [6] - -//! [7] -bool MySortFilterProxyModel::dateInRange(const QDate &date) const -{ - return (!minDate.isValid() || date > minDate) - && (!maxDate.isValid() || date < maxDate); -} -//! [7] diff --git a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.h b/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.h deleted file mode 100644 index 8ca3e10fd5..0000000000 --- a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 MYSORTFILTERPROXYMODEL_H -#define MYSORTFILTERPROXYMODEL_H - -#include -#include - -//! [0] -class MySortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - MySortFilterProxyModel(QObject *parent = 0); - - QDate filterMinimumDate() const { return minDate; } - void setFilterMinimumDate(const QDate &date); - - QDate filterMaximumDate() const { return maxDate; } - void setFilterMaximumDate(const QDate &date); - -protected: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; - -private: - bool dateInRange(const QDate &date) const; - - QDate minDate; - QDate maxDate; -}; -//! [0] - -#endif diff --git a/examples/itemviews/customsortfiltermodel/window.cpp b/examples/itemviews/customsortfiltermodel/window.cpp deleted file mode 100644 index 0a8799dccb..0000000000 --- a/examples/itemviews/customsortfiltermodel/window.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mysortfilterproxymodel.h" -#include "window.h" - -//! [0] -Window::Window() -{ - proxyModel = new MySortFilterProxyModel(this); - //! [0] - - //! [1] - sourceView = new QTreeView; - sourceView->setRootIsDecorated(false); - sourceView->setAlternatingRowColors(true); - //! [1] - - QHBoxLayout *sourceLayout = new QHBoxLayout; - //! [2] - sourceLayout->addWidget(sourceView); - sourceGroupBox = new QGroupBox(tr("Original Model")); - sourceGroupBox->setLayout(sourceLayout); - //! [2] - - //! [3] - filterCaseSensitivityCheckBox = new QCheckBox(tr("Case sensitive filter")); - filterCaseSensitivityCheckBox->setChecked(true); - - filterPatternLineEdit = new QLineEdit; - filterPatternLineEdit->setText("Grace|Sports"); - - filterPatternLabel = new QLabel(tr("&Filter pattern:")); - filterPatternLabel->setBuddy(filterPatternLineEdit); - - filterSyntaxComboBox = new QComboBox; - filterSyntaxComboBox->addItem(tr("Regular expression"), QRegExp::RegExp); - filterSyntaxComboBox->addItem(tr("Wildcard"), QRegExp::Wildcard); - filterSyntaxComboBox->addItem(tr("Fixed string"), QRegExp::FixedString); - - fromDateEdit = new QDateEdit; - fromDateEdit->setDate(QDate(1970, 01, 01)); - fromLabel = new QLabel(tr("F&rom:")); - fromLabel->setBuddy(fromDateEdit); - - toDateEdit = new QDateEdit; - toDateEdit->setDate(QDate(2099, 12, 31)); - toLabel = new QLabel(tr("&To:")); - toLabel->setBuddy(toDateEdit); - - connect(filterPatternLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(textFilterChanged())); - connect(filterSyntaxComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(textFilterChanged())); - connect(filterCaseSensitivityCheckBox, SIGNAL(toggled(bool)), - this, SLOT(textFilterChanged())); - connect(fromDateEdit, SIGNAL(dateChanged(QDate)), - this, SLOT(dateFilterChanged())); - connect(toDateEdit, SIGNAL(dateChanged(QDate)), - //! [3] //! [4] - this, SLOT(dateFilterChanged())); - //! [4] - - //! [5] - proxyView = new QTreeView; - proxyView->setRootIsDecorated(false); - proxyView->setAlternatingRowColors(true); - proxyView->setModel(proxyModel); - proxyView->setSortingEnabled(true); - proxyView->sortByColumn(1, Qt::AscendingOrder); - - QGridLayout *proxyLayout = new QGridLayout; - proxyLayout->addWidget(proxyView, 0, 0, 1, 3); - proxyLayout->addWidget(filterPatternLabel, 1, 0); - proxyLayout->addWidget(filterPatternLineEdit, 1, 1); - proxyLayout->addWidget(filterSyntaxComboBox, 1, 2); - proxyLayout->addWidget(filterCaseSensitivityCheckBox, 2, 0, 1, 3); - proxyLayout->addWidget(fromLabel, 3, 0); - proxyLayout->addWidget(fromDateEdit, 3, 1, 1, 2); - proxyLayout->addWidget(toLabel, 4, 0); - proxyLayout->addWidget(toDateEdit, 4, 1, 1, 2); - - proxyGroupBox = new QGroupBox(tr("Sorted/Filtered Model")); - proxyGroupBox->setLayout(proxyLayout); - //! [5] - - //! [6] - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(sourceGroupBox); - mainLayout->addWidget(proxyGroupBox); - setLayout(mainLayout); - - setWindowTitle(tr("Custom Sort/Filter Model")); - resize(500, 450); -} -//! [6] - -//! [7] -void Window::setSourceModel(QAbstractItemModel *model) -{ - proxyModel->setSourceModel(model); - sourceView->setModel(model); -} -//! [7] - -//! [8] -void Window::textFilterChanged() -{ - QRegExp::PatternSyntax syntax = - QRegExp::PatternSyntax(filterSyntaxComboBox->itemData( - filterSyntaxComboBox->currentIndex()).toInt()); - Qt::CaseSensitivity caseSensitivity = - filterCaseSensitivityCheckBox->isChecked() ? Qt::CaseSensitive - : Qt::CaseInsensitive; - - QRegExp regExp(filterPatternLineEdit->text(), caseSensitivity, syntax); - proxyModel->setFilterRegExp(regExp); -} -//! [8] - -//! [9] -void Window::dateFilterChanged() -{ - proxyModel->setFilterMinimumDate(fromDateEdit->date()); - proxyModel->setFilterMaximumDate(toDateEdit->date()); -} -//! [9] diff --git a/examples/itemviews/customsortfiltermodel/window.h b/examples/itemviews/customsortfiltermodel/window.h deleted file mode 100644 index 36650aedad..0000000000 --- a/examples/itemviews/customsortfiltermodel/window.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAbstractItemModel; -class QCheckBox; -class QComboBox; -class QDateEdit; -class QGroupBox; -class QLabel; -class QLineEdit; -class QTreeView; -QT_END_NAMESPACE -class MySortFilterProxyModel; - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - - void setSourceModel(QAbstractItemModel *model); - -private slots: - void textFilterChanged(); - void dateFilterChanged(); - -private: - MySortFilterProxyModel *proxyModel; - - QGroupBox *sourceGroupBox; - QGroupBox *proxyGroupBox; - QTreeView *sourceView; - QTreeView *proxyView; - QCheckBox *filterCaseSensitivityCheckBox; - QLabel *filterPatternLabel; - QLabel *fromLabel; - QLabel *toLabel; - QLineEdit *filterPatternLineEdit; - QComboBox *filterSyntaxComboBox; - QDateEdit *fromDateEdit; - QDateEdit *toDateEdit; -}; -//! [0] - -#endif diff --git a/examples/itemviews/dirview/dirview.desktop b/examples/itemviews/dirview/dirview.desktop deleted file mode 100644 index 51ec4df26c..0000000000 --- a/examples/itemviews/dirview/dirview.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Dir View -Exec=/opt/usr/bin/dirview -Icon=dirview -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/dirview/dirview.pro b/examples/itemviews/dirview/dirview.pro deleted file mode 100644 index 825f20c630..0000000000 --- a/examples/itemviews/dirview/dirview.pro +++ /dev/null @@ -1,9 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/dirview -sources.files = $$SOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/dirview -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/dirview/main.cpp b/examples/itemviews/dirview/main.cpp deleted file mode 100644 index 55083afa8f..0000000000 --- a/examples/itemviews/dirview/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QFileSystemModel model; - model.setRootPath(""); - QTreeView tree; - tree.setModel(&model); - - // Demonstrating look and feel features - tree.setAnimated(false); - tree.setIndentation(20); - tree.setSortingEnabled(true); - - tree.setWindowTitle(QObject::tr("Dir View")); - tree.resize(640, 480); - tree.show(); - - return app.exec(); -} diff --git a/examples/itemviews/editabletreemodel/default.txt b/examples/itemviews/editabletreemodel/default.txt deleted file mode 100644 index 2b2fb579ae..0000000000 --- a/examples/itemviews/editabletreemodel/default.txt +++ /dev/null @@ -1,40 +0,0 @@ -Getting Started How to familiarize yourself with Qt Designer - Launching Designer Running the Qt Designer application - The User Interface How to interact with Qt Designer - -Designing a Component Creating a GUI for your application - Creating a Dialog How to create a dialog - Composing the Dialog Putting widgets into the dialog example - Creating a Layout Arranging widgets on a form - Signal and Slot Connections Making widget communicate with each other - -Using a Component in Your Application Generating code from forms - The Direct Approach Using a form without any adjustments - The Single Inheritance Approach Subclassing a form's base class - The Multiple Inheritance Approach Subclassing the form itself - Automatic Connections Connecting widgets using a naming scheme - A Dialog Without Auto-Connect How to connect widgets without a naming scheme - A Dialog With Auto-Connect Using automatic connections - -Form Editing Mode How to edit a form in Qt Designer - Managing Forms Loading and saving forms - Editing a Form Basic editing techniques - The Property Editor Changing widget properties - The Object Inspector Examining the hierarchy of objects on a form - Layouts Objects that arrange widgets on a form - Applying and Breaking Layouts Managing widgets in layouts - Horizontal and Vertical Layouts Standard row and column layouts - The Grid Layout Arranging widgets in a matrix - Previewing Forms Checking that the design works - -Using Containers How to group widgets together - General Features Common container features - Frames QFrame - Group Boxes QGroupBox - Stacked Widgets QStackedWidget - Tab Widgets QTabWidget - Toolbox Widgets QToolBox - -Connection Editing Mode Connecting widgets together with signals and slots - Connecting Objects Making connections in Qt Designer - Editing Connections Changing existing connections diff --git a/examples/itemviews/editabletreemodel/editabletreemodel.desktop b/examples/itemviews/editabletreemodel/editabletreemodel.desktop deleted file mode 100644 index 17d17330df..0000000000 --- a/examples/itemviews/editabletreemodel/editabletreemodel.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Editable Tree Model -Exec=/opt/usr/bin/editabletreemodel -Icon=editabletreemodel -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/editabletreemodel/editabletreemodel.pro b/examples/itemviews/editabletreemodel/editabletreemodel.pro deleted file mode 100644 index f86298542d..0000000000 --- a/examples/itemviews/editabletreemodel/editabletreemodel.pro +++ /dev/null @@ -1,18 +0,0 @@ -FORMS = mainwindow.ui -HEADERS = mainwindow.h \ - treeitem.h \ - treemodel.h -RESOURCES = editabletreemodel.qrc -SOURCES = mainwindow.cpp \ - treeitem.cpp \ - treemodel.cpp \ - main.cpp -CONFIG += qt - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/editabletreemodel -sources.files = $$FORMS $$HEADERS $$RESOURCES $$SOURCES *.pro *.txt -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/editabletreemodel -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/editabletreemodel/editabletreemodel.qrc b/examples/itemviews/editabletreemodel/editabletreemodel.qrc deleted file mode 100644 index 2fb48f2e62..0000000000 --- a/examples/itemviews/editabletreemodel/editabletreemodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - default.txt - - diff --git a/examples/itemviews/editabletreemodel/main.cpp b/examples/itemviews/editabletreemodel/main.cpp deleted file mode 100644 index 516adf1543..0000000000 --- a/examples/itemviews/editabletreemodel/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(editabletreemodel); - - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/editabletreemodel/mainwindow.cpp b/examples/itemviews/editabletreemodel/mainwindow.cpp deleted file mode 100644 index 115b02e28e..0000000000 --- a/examples/itemviews/editabletreemodel/mainwindow.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" -#include "treemodel.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - setupUi(this); - - - QStringList headers; - headers << tr("Title") << tr("Description"); - - QFile file(":/default.txt"); - file.open(QIODevice::ReadOnly); - TreeModel *model = new TreeModel(headers, file.readAll()); - file.close(); - - view->setModel(model); - for (int column = 0; column < model->columnCount(); ++column) - view->resizeColumnToContents(column); - - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - connect(view->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection &, - const QItemSelection &)), - this, SLOT(updateActions())); - - connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions())); - connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow())); - connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn())); - connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow())); - connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn())); - connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild())); - - updateActions(); -} - -void MainWindow::insertChild() -{ - QModelIndex index = view->selectionModel()->currentIndex(); - QAbstractItemModel *model = view->model(); - - if (model->columnCount(index) == 0) { - if (!model->insertColumn(0, index)) - return; - } - - if (!model->insertRow(0, index)) - return; - - for (int column = 0; column < model->columnCount(index); ++column) { - QModelIndex child = model->index(0, column, index); - model->setData(child, QVariant("[No data]"), Qt::EditRole); - if (!model->headerData(column, Qt::Horizontal).isValid()) - model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"), - Qt::EditRole); - } - - view->selectionModel()->setCurrentIndex(model->index(0, 0, index), - QItemSelectionModel::ClearAndSelect); - updateActions(); -} - -bool MainWindow::insertColumn(const QModelIndex &parent) -{ - QAbstractItemModel *model = view->model(); - int column = view->selectionModel()->currentIndex().column(); - - // Insert a column in the parent item. - bool changed = model->insertColumn(column + 1, parent); - if (changed) - model->setHeaderData(column + 1, Qt::Horizontal, QVariant("[No header]"), - Qt::EditRole); - - updateActions(); - - return changed; -} - -void MainWindow::insertRow() -{ - QModelIndex index = view->selectionModel()->currentIndex(); - QAbstractItemModel *model = view->model(); - - if (!model->insertRow(index.row()+1, index.parent())) - return; - - updateActions(); - - for (int column = 0; column < model->columnCount(index.parent()); ++column) { - QModelIndex child = model->index(index.row()+1, column, index.parent()); - model->setData(child, QVariant("[No data]"), Qt::EditRole); - } -} - -bool MainWindow::removeColumn(const QModelIndex &parent) -{ - QAbstractItemModel *model = view->model(); - int column = view->selectionModel()->currentIndex().column(); - - // Insert columns in each child of the parent item. - bool changed = model->removeColumn(column, parent); - - if (!parent.isValid() && changed) - updateActions(); - - return changed; -} - -void MainWindow::removeRow() -{ - QModelIndex index = view->selectionModel()->currentIndex(); - QAbstractItemModel *model = view->model(); - if (model->removeRow(index.row(), index.parent())) - updateActions(); -} - -void MainWindow::updateActions() -{ - bool hasSelection = !view->selectionModel()->selection().isEmpty(); - removeRowAction->setEnabled(hasSelection); - removeColumnAction->setEnabled(hasSelection); - - bool hasCurrent = view->selectionModel()->currentIndex().isValid(); - insertRowAction->setEnabled(hasCurrent); - insertColumnAction->setEnabled(hasCurrent); - - if (hasCurrent) { - view->closePersistentEditor(view->selectionModel()->currentIndex()); - - int row = view->selectionModel()->currentIndex().row(); - int column = view->selectionModel()->currentIndex().column(); - if (view->selectionModel()->currentIndex().parent().isValid()) - statusBar()->showMessage(tr("Position: (%1,%2)").arg(row).arg(column)); - else - statusBar()->showMessage(tr("Position: (%1,%2) in top level").arg(row).arg(column)); - } -} diff --git a/examples/itemviews/editabletreemodel/mainwindow.h b/examples/itemviews/editabletreemodel/mainwindow.h deleted file mode 100644 index e45037c2e0..0000000000 --- a/examples/itemviews/editabletreemodel/mainwindow.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#include "ui_mainwindow.h" - -class QAction; -class QTreeView; -class QWidget; - -class MainWindow : public QMainWindow, private Ui::MainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - -public slots: - void updateActions(); - -private slots: - void insertChild(); - bool insertColumn(const QModelIndex &parent = QModelIndex()); - void insertRow(); - bool removeColumn(const QModelIndex &parent = QModelIndex()); - void removeRow(); -}; - -#endif diff --git a/examples/itemviews/editabletreemodel/mainwindow.ui b/examples/itemviews/editabletreemodel/mainwindow.ui deleted file mode 100644 index 2ad084ae24..0000000000 --- a/examples/itemviews/editabletreemodel/mainwindow.ui +++ /dev/null @@ -1,128 +0,0 @@ - - MainWindow - - - - 0 - 0 - 573 - 468 - - - - Editable Tree Model - - - - - 0 - - - 0 - - - - - true - - - QAbstractItemView::SelectItems - - - QAbstractItemView::ScrollPerPixel - - - false - - - true - - - - - - - - - 0 - 0 - 573 - 31 - - - - - &File - - - - - - &Actions - - - - - - - - - - - - - - - - E&xit - - - Ctrl+Q - - - - - Insert Row - - - Ctrl+I, R - - - - - Remove Row - - - Ctrl+R, R - - - - - Insert Column - - - Ctrl+I, C - - - - - Remove Column - - - Ctrl+R, C - - - - - Insert Child - - - Ctrl+N - - - - - - - - diff --git a/examples/itemviews/editabletreemodel/treeitem.cpp b/examples/itemviews/editabletreemodel/treeitem.cpp deleted file mode 100644 index c728f21a92..0000000000 --- a/examples/itemviews/editabletreemodel/treeitem.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -/* - treeitem.cpp - - A container for items of data supplied by the simple tree model. -*/ - -#include - -#include "treeitem.h" - -//! [0] -TreeItem::TreeItem(const QVector &data, TreeItem *parent) -{ - parentItem = parent; - itemData = data; -} -//! [0] - -//! [1] -TreeItem::~TreeItem() -{ - qDeleteAll(childItems); -} -//! [1] - -//! [2] -TreeItem *TreeItem::child(int number) -{ - return childItems.value(number); -} -//! [2] - -//! [3] -int TreeItem::childCount() const -{ - return childItems.count(); -} -//! [3] - -//! [4] -int TreeItem::childNumber() const -{ - if (parentItem) - return parentItem->childItems.indexOf(const_cast(this)); - - return 0; -} -//! [4] - -//! [5] -int TreeItem::columnCount() const -{ - return itemData.count(); -} -//! [5] - -//! [6] -QVariant TreeItem::data(int column) const -{ - return itemData.value(column); -} -//! [6] - -//! [7] -bool TreeItem::insertChildren(int position, int count, int columns) -{ - if (position < 0 || position > childItems.size()) - return false; - - for (int row = 0; row < count; ++row) { - QVector data(columns); - TreeItem *item = new TreeItem(data, this); - childItems.insert(position, item); - } - - return true; -} -//! [7] - -//! [8] -bool TreeItem::insertColumns(int position, int columns) -{ - if (position < 0 || position > itemData.size()) - return false; - - for (int column = 0; column < columns; ++column) - itemData.insert(position, QVariant()); - - foreach (TreeItem *child, childItems) - child->insertColumns(position, columns); - - return true; -} -//! [8] - -//! [9] -TreeItem *TreeItem::parent() -{ - return parentItem; -} -//! [9] - -//! [10] -bool TreeItem::removeChildren(int position, int count) -{ - if (position < 0 || position + count > childItems.size()) - return false; - - for (int row = 0; row < count; ++row) - delete childItems.takeAt(position); - - return true; -} -//! [10] - -bool TreeItem::removeColumns(int position, int columns) -{ - if (position < 0 || position + columns > itemData.size()) - return false; - - for (int column = 0; column < columns; ++column) - itemData.remove(position); - - foreach (TreeItem *child, childItems) - child->removeColumns(position, columns); - - return true; -} - -//! [11] -bool TreeItem::setData(int column, const QVariant &value) -{ - if (column < 0 || column >= itemData.size()) - return false; - - itemData[column] = value; - return true; -} -//! [11] diff --git a/examples/itemviews/editabletreemodel/treeitem.h b/examples/itemviews/editabletreemodel/treeitem.h deleted file mode 100644 index 8426514759..0000000000 --- a/examples/itemviews/editabletreemodel/treeitem.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 TREEITEM_H -#define TREEITEM_H - -#include -#include -#include - -//! [0] -class TreeItem -{ -public: - TreeItem(const QVector &data, TreeItem *parent = 0); - ~TreeItem(); - - TreeItem *child(int number); - int childCount() const; - int columnCount() const; - QVariant data(int column) const; - bool insertChildren(int position, int count, int columns); - bool insertColumns(int position, int columns); - TreeItem *parent(); - bool removeChildren(int position, int count); - bool removeColumns(int position, int columns); - int childNumber() const; - bool setData(int column, const QVariant &value); - -private: - QList childItems; - QVector itemData; - TreeItem *parentItem; -}; -//! [0] - -#endif diff --git a/examples/itemviews/editabletreemodel/treemodel.cpp b/examples/itemviews/editabletreemodel/treemodel.cpp deleted file mode 100644 index 8192c14e9f..0000000000 --- a/examples/itemviews/editabletreemodel/treemodel.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "treeitem.h" -#include "treemodel.h" - -//! [0] -TreeModel::TreeModel(const QStringList &headers, const QString &data, - QObject *parent) - : QAbstractItemModel(parent) -{ - QVector rootData; - foreach (QString header, headers) - rootData << header; - - rootItem = new TreeItem(rootData); - setupModelData(data.split(QString("\n")), rootItem); -} -//! [0] - -//! [1] -TreeModel::~TreeModel() -{ - delete rootItem; -} -//! [1] - -//! [2] -int TreeModel::columnCount(const QModelIndex & /* parent */) const -{ - return rootItem->columnCount(); -} -//! [2] - -QVariant TreeModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role != Qt::DisplayRole && role != Qt::EditRole) - return QVariant(); - - TreeItem *item = getItem(index); - - return item->data(index.column()); -} - -//! [3] -Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return 0; - - return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} -//! [3] - -//! [4] -TreeItem *TreeModel::getItem(const QModelIndex &index) const -{ - if (index.isValid()) { - TreeItem *item = static_cast(index.internalPointer()); - if (item) return item; - } - return rootItem; -} -//! [4] - -QVariant TreeModel::headerData(int section, Qt::Orientation orientation, - int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - return rootItem->data(section); - - return QVariant(); -} - -//! [5] -QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const -{ - if (parent.isValid() && parent.column() != 0) - return QModelIndex(); -//! [5] - -//! [6] - TreeItem *parentItem = getItem(parent); - - TreeItem *childItem = parentItem->child(row); - if (childItem) - return createIndex(row, column, childItem); - else - return QModelIndex(); -} -//! [6] - -bool TreeModel::insertColumns(int position, int columns, const QModelIndex &parent) -{ - bool success; - - beginInsertColumns(parent, position, position + columns - 1); - success = rootItem->insertColumns(position, columns); - endInsertColumns(); - - return success; -} - -bool TreeModel::insertRows(int position, int rows, const QModelIndex &parent) -{ - TreeItem *parentItem = getItem(parent); - bool success; - - beginInsertRows(parent, position, position + rows - 1); - success = parentItem->insertChildren(position, rows, rootItem->columnCount()); - endInsertRows(); - - return success; -} - -//! [7] -QModelIndex TreeModel::parent(const QModelIndex &index) const -{ - if (!index.isValid()) - return QModelIndex(); - - TreeItem *childItem = getItem(index); - TreeItem *parentItem = childItem->parent(); - - if (parentItem == rootItem) - return QModelIndex(); - - return createIndex(parentItem->childNumber(), 0, parentItem); -} -//! [7] - -bool TreeModel::removeColumns(int position, int columns, const QModelIndex &parent) -{ - bool success; - - beginRemoveColumns(parent, position, position + columns - 1); - success = rootItem->removeColumns(position, columns); - endRemoveColumns(); - - if (rootItem->columnCount() == 0) - removeRows(0, rowCount()); - - return success; -} - -bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent) -{ - TreeItem *parentItem = getItem(parent); - bool success = true; - - beginRemoveRows(parent, position, position + rows - 1); - success = parentItem->removeChildren(position, rows); - endRemoveRows(); - - return success; -} - -//! [8] -int TreeModel::rowCount(const QModelIndex &parent) const -{ - TreeItem *parentItem = getItem(parent); - - return parentItem->childCount(); -} -//! [8] - -bool TreeModel::setData(const QModelIndex &index, const QVariant &value, - int role) -{ - if (role != Qt::EditRole) - return false; - - TreeItem *item = getItem(index); - bool result = item->setData(index.column(), value); - - if (result) - emit dataChanged(index, index); - - return result; -} - -bool TreeModel::setHeaderData(int section, Qt::Orientation orientation, - const QVariant &value, int role) -{ - if (role != Qt::EditRole || orientation != Qt::Horizontal) - return false; - - bool result = rootItem->setData(section, value); - - if (result) - emit headerDataChanged(orientation, section, section); - - return result; -} - -void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent) -{ - QList parents; - QList indentations; - parents << parent; - indentations << 0; - - int number = 0; - - while (number < lines.count()) { - int position = 0; - while (position < lines[number].length()) { - if (lines[number].mid(position, 1) != " ") - break; - position++; - } - - QString lineData = lines[number].mid(position).trimmed(); - - if (!lineData.isEmpty()) { - // Read the column data from the rest of the line. - QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); - QVector columnData; - for (int column = 0; column < columnStrings.count(); ++column) - columnData << columnStrings[column]; - - if (position > indentations.last()) { - // The last child of the current parent is now the new parent - // unless the current parent has no children. - - if (parents.last()->childCount() > 0) { - parents << parents.last()->child(parents.last()->childCount()-1); - indentations << position; - } - } else { - while (position < indentations.last() && parents.count() > 0) { - parents.pop_back(); - indentations.pop_back(); - } - } - - // Append a new item to the current parent's list of children. - TreeItem *parent = parents.last(); - parent->insertChildren(parent->childCount(), 1, rootItem->columnCount()); - for (int column = 0; column < columnData.size(); ++column) - parent->child(parent->childCount() - 1)->setData(column, columnData[column]); - } - - number++; - } -} diff --git a/examples/itemviews/editabletreemodel/treemodel.h b/examples/itemviews/editabletreemodel/treemodel.h deleted file mode 100644 index f124df2e1d..0000000000 --- a/examples/itemviews/editabletreemodel/treemodel.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 TREEMODEL_H -#define TREEMODEL_H - -#include -#include -#include - -class TreeItem; - -//! [0] -class TreeModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - TreeModel(const QStringList &headers, const QString &data, - QObject *parent = 0); - ~TreeModel(); -//! [0] //! [1] - - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; -//! [1] - -//! [2] - Qt::ItemFlags flags(const QModelIndex &index) const; - bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole); - bool setHeaderData(int section, Qt::Orientation orientation, - const QVariant &value, int role = Qt::EditRole); - - bool insertColumns(int position, int columns, - const QModelIndex &parent = QModelIndex()); - bool removeColumns(int position, int columns, - const QModelIndex &parent = QModelIndex()); - bool insertRows(int position, int rows, - const QModelIndex &parent = QModelIndex()); - bool removeRows(int position, int rows, - const QModelIndex &parent = QModelIndex()); - -private: - void setupModelData(const QStringList &lines, TreeItem *parent); - TreeItem *getItem(const QModelIndex &index) const; - - TreeItem *rootItem; -}; -//! [2] - -#endif diff --git a/examples/itemviews/fetchmore/fetchmore.desktop b/examples/itemviews/fetchmore/fetchmore.desktop deleted file mode 100644 index b8c9ff32cb..0000000000 --- a/examples/itemviews/fetchmore/fetchmore.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Fetch More -Exec=/opt/usr/bin/fetchmore -Icon=fetchmore -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/fetchmore/fetchmore.pro b/examples/itemviews/fetchmore/fetchmore.pro deleted file mode 100644 index 28af7e9ac0..0000000000 --- a/examples/itemviews/fetchmore/fetchmore.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = filelistmodel.h \ - window.h -SOURCES = filelistmodel.cpp \ - main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/fetchmore -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/fetchmore -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/fetchmore/filelistmodel.cpp b/examples/itemviews/fetchmore/filelistmodel.cpp deleted file mode 100644 index d9678191d9..0000000000 --- a/examples/itemviews/fetchmore/filelistmodel.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "filelistmodel.h" -#include -#include -#include -#include - -FileListModel::FileListModel(QObject *parent) - : QAbstractListModel(parent) -{ -} - -//![4] -int FileListModel::rowCount(const QModelIndex & /* parent */) const -{ - return fileCount; -} - -QVariant FileListModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() >= fileList.size() || index.row() < 0) - return QVariant(); - - if (role == Qt::DisplayRole) - return fileList.at(index.row()); - else if (role == Qt::BackgroundRole) { - int batch = (index.row() / 100) % 2; - if (batch == 0) - return qApp->palette().base(); - else - return qApp->palette().alternateBase(); - } - return QVariant(); -} -//![4] - -//![1] -bool FileListModel::canFetchMore(const QModelIndex & /* index */) const -{ - if (fileCount < fileList.size()) - return true; - else - return false; -} -//![1] - -//![2] -void FileListModel::fetchMore(const QModelIndex & /* index */) -{ - int remainder = fileList.size() - fileCount; - int itemsToFetch = qMin(100, remainder); - - beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch-1); - - fileCount += itemsToFetch; - - endInsertRows(); - - emit numberPopulated(itemsToFetch); -} -//![2] - -//![0] -void FileListModel::setDirPath(const QString &path) -{ - QDir dir(path); - - beginResetModel(); - fileList = dir.entryList(); - fileCount = 0; - endResetModel(); -} -//![0] - diff --git a/examples/itemviews/fetchmore/filelistmodel.h b/examples/itemviews/fetchmore/filelistmodel.h deleted file mode 100644 index f3e9f758c7..0000000000 --- a/examples/itemviews/fetchmore/filelistmodel.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 FILELISTMODEL_H -#define FILELISTMODEL_H - -#include -#include -#include - -//![0] -class FileListModel : public QAbstractListModel -{ - Q_OBJECT - -public: - FileListModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -signals: - void numberPopulated(int number); - -public slots: - void setDirPath(const QString &path); - -protected: - bool canFetchMore(const QModelIndex &parent) const; - void fetchMore(const QModelIndex &parent); - -private: - QStringList fileList; - int fileCount; -}; -//![0] - -#endif diff --git a/examples/itemviews/fetchmore/main.cpp b/examples/itemviews/fetchmore/main.cpp deleted file mode 100644 index 97b94d1d3c..0000000000 --- a/examples/itemviews/fetchmore/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "window.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/fetchmore/window.cpp b/examples/itemviews/fetchmore/window.cpp deleted file mode 100644 index f138fb4bd4..0000000000 --- a/examples/itemviews/fetchmore/window.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include "filelistmodel.h" -#include "window.h" - -Window::Window(QWidget *parent) - : QWidget(parent) -{ - FileListModel *model = new FileListModel(this); - model->setDirPath(QLibraryInfo::location(QLibraryInfo::PrefixPath)); - - QLabel *label = new QLabel(tr("&Directory:")); - QLineEdit *lineEdit = new QLineEdit; - label->setBuddy(lineEdit); - - QListView *view = new QListView; - view->setModel(model); - - logViewer = new QTextBrowser; - logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); - - connect(lineEdit, SIGNAL(textChanged(QString)), - model, SLOT(setDirPath(QString))); - connect(lineEdit, SIGNAL(textChanged(QString)), - logViewer, SLOT(clear())); - connect(model, SIGNAL(numberPopulated(int)), - this, SLOT(updateLog(int))); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(label, 0, 0); - layout->addWidget(lineEdit, 0, 1); - layout->addWidget(view, 1, 0, 1, 2); - layout->addWidget(logViewer, 2, 0, 1, 2); - - setLayout(layout); - setWindowTitle(tr("Fetch More Example")); -} - -void Window::updateLog(int number) -{ - logViewer->append(tr("%1 items added.").arg(number)); -} diff --git a/examples/itemviews/fetchmore/window.h b/examples/itemviews/fetchmore/window.h deleted file mode 100644 index cf6208b643..0000000000 --- a/examples/itemviews/fetchmore/window.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QTextBrowser; -QT_END_NAMESPACE - -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(QWidget *parent = 0); - -public slots: - void updateLog(int number); - -private: - QTextBrowser *logViewer; -}; - -#endif diff --git a/examples/itemviews/frozencolumn/freezetablewidget.cpp b/examples/itemviews/frozencolumn/freezetablewidget.cpp deleted file mode 100644 index ae83c341c4..0000000000 --- a/examples/itemviews/frozencolumn/freezetablewidget.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "freezetablewidget.h" - -//! [constructor] -FreezeTableWidget::FreezeTableWidget(QAbstractItemModel * model) -{ - setModel(model); - frozenTableView = new QTableView(this); - - init(); - - //connect the headers and scrollbars of both tableviews together - connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)), this, - SLOT(updateSectionWidth(int,int,int))); - connect(verticalHeader(),SIGNAL(sectionResized(int,int,int)), this, - SLOT(updateSectionHeight(int,int,int))); - - connect(frozenTableView->verticalScrollBar(), SIGNAL(valueChanged(int)), - verticalScrollBar(), SLOT(setValue(int))); - connect(verticalScrollBar(), SIGNAL(valueChanged(int)), - frozenTableView->verticalScrollBar(), SLOT(setValue(int))); - - -} -//! [constructor] - -FreezeTableWidget::~FreezeTableWidget() -{ - delete frozenTableView; -} - -//! [init part1] -void FreezeTableWidget::init() -{ - frozenTableView->setModel(model()); - frozenTableView->setFocusPolicy(Qt::NoFocus); - frozenTableView->verticalHeader()->hide(); - frozenTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); - - viewport()->stackUnder(frozenTableView); -//! [init part1] - -//! [init part2] - frozenTableView->setStyleSheet("QTableView { border: none;" - "background-color: #8EDE21;" - "selection-background-color: #999}"); //for demo purposes - frozenTableView->setSelectionModel(selectionModel()); - for(int col=1; colcolumnCount(); col++) - frozenTableView->setColumnHidden(col, true); - - frozenTableView->setColumnWidth(0, columnWidth(0) ); - - frozenTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - frozenTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - frozenTableView->show(); - - updateFrozenTableGeometry(); - - setHorizontalScrollMode(ScrollPerPixel); - setVerticalScrollMode(ScrollPerPixel); - frozenTableView->setVerticalScrollMode(ScrollPerPixel); -} -//! [init part2] - - -//! [sections] -void FreezeTableWidget::updateSectionWidth(int logicalIndex, int, int newSize) -{ - if(logicalIndex==0){ - frozenTableView->setColumnWidth(0,newSize); - updateFrozenTableGeometry(); - } -} - -void FreezeTableWidget::updateSectionHeight(int logicalIndex, int, int newSize) -{ - frozenTableView->setRowHeight(logicalIndex, newSize); -} -//! [sections] - - -//! [resize] -void FreezeTableWidget::resizeEvent(QResizeEvent * event) -{ - QTableView::resizeEvent(event); - updateFrozenTableGeometry(); - } -//! [resize] - - -//! [navigate] -QModelIndex FreezeTableWidget::moveCursor(CursorAction cursorAction, - Qt::KeyboardModifiers modifiers) -{ - QModelIndex current = QTableView::moveCursor(cursorAction, modifiers); - - if(cursorAction == MoveLeft && current.column()>0 - && visualRect(current).topLeft().x() < frozenTableView->columnWidth(0) ){ - - const int newValue = horizontalScrollBar()->value() + visualRect(current).topLeft().x() - - frozenTableView->columnWidth(0); - horizontalScrollBar()->setValue(newValue); - } - return current; -} -//! [navigate] - -void FreezeTableWidget::scrollTo (const QModelIndex & index, ScrollHint hint){ - if(index.column()>0) - QTableView::scrollTo(index, hint); -} - - - -//! [geometry] -void FreezeTableWidget::updateFrozenTableGeometry() -{ - frozenTableView->setGeometry( verticalHeader()->width()+frameWidth(), - frameWidth(), columnWidth(0), - viewport()->height()+horizontalHeader()->height()); -} -//! [geometry] - - diff --git a/examples/itemviews/frozencolumn/freezetablewidget.h b/examples/itemviews/frozencolumn/freezetablewidget.h deleted file mode 100644 index 1432c012f5..0000000000 --- a/examples/itemviews/frozencolumn/freezetablewidget.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 FREEZETABLEWIDGET_H -#define FREEZETABLEWIDGET_H - -#include - -//! [Widget definition] -class FreezeTableWidget : public QTableView { - Q_OBJECT - -public: - FreezeTableWidget(QAbstractItemModel * model); - ~FreezeTableWidget(); - - -protected: - virtual void resizeEvent(QResizeEvent *event); - virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); - void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible); - -private: - QTableView *frozenTableView; - void init(); - void updateFrozenTableGeometry(); - - -private slots: - void updateSectionWidth(int logicalIndex,int, int newSize); - void updateSectionHeight(int logicalIndex, int, int newSize); - -}; -//! [Widget definition] -#endif diff --git a/examples/itemviews/frozencolumn/frozencolumn.desktop b/examples/itemviews/frozencolumn/frozencolumn.desktop deleted file mode 100644 index 3d1e3b430d..0000000000 --- a/examples/itemviews/frozencolumn/frozencolumn.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Frozen Column -Exec=/opt/usr/bin/frozencolumn -Icon=frozencolumn -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/frozencolumn/frozencolumn.pro b/examples/itemviews/frozencolumn/frozencolumn.pro deleted file mode 100644 index 34a4a4de8c..0000000000 --- a/examples/itemviews/frozencolumn/frozencolumn.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += freezetablewidget.h -SOURCES += main.cpp freezetablewidget.cpp -RESOURCES += grades.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/frozencolumn -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/frozencolumn -INSTALLS += target sources -QT += widgets - diff --git a/examples/itemviews/frozencolumn/grades.qrc b/examples/itemviews/frozencolumn/grades.qrc deleted file mode 100644 index 5f16d56931..0000000000 --- a/examples/itemviews/frozencolumn/grades.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - grades.txt - - diff --git a/examples/itemviews/frozencolumn/grades.txt b/examples/itemviews/frozencolumn/grades.txt deleted file mode 100644 index e1c6fcc49e..0000000000 --- a/examples/itemviews/frozencolumn/grades.txt +++ /dev/null @@ -1,36 +0,0 @@ - France , Norway , YDS , UK(tech.), UK(adj.) , UIAA , Ger , Australia , Finland , Brazil - -1, , 5.2, , , I , I , , , Isup -2, , 5.3, , , II , II , 11, , II -3, 3, 5.4, , , III , III , 12, , IIsup -4, 4, 5.5, 4a , VD , IV , IV , 12, , III -5a , 5-, 5.6, , S , V- , V , 13, 5-, IIIsup -5b , 5, 5.7, 4b , HS , V , VI , 14, 5, IV - , , , 4c , , V+ , , 15, , -5c , 5+, 5.8, , VS , VI- , VIIa , 16, 5, IVsup -6a , 6-, 5.9, 5a , HVS , VI , VIIb , 17, , V -6a+ , 6-/6 , 5.10a , , E1 , VI+ , VIIc , 18, 6-, VI -6b , , 5.10b , 5b , , , , 19, , VI/VI+ -6b+ , 6, 5.10c , , E2 , VII- , VIIIa , 20, 6, VIsup/VI+ -6c , 6+, 5.10d , 5c , , VII , VIIIb , 21, , VIsup -6c+ , 7-, 5.11a , , E3 , VII+ , VIIIc , 22, 6, 7a -6c+ , 7, 5.11b , , , , , 23, , 7b -7a , 7+, 5.11c , 6a , E4 , VIII- , IXa , 24, 7-, 7c -7a , 7+/8- , 5.11d , , , VIII , IXb , , , 7c -7a+ , 8-, 5.12a , , E5 , VIII+ , IXc , 25, 7, 8a -7b , 8, 5.12b , 6b , , , , 26, 8-, 8b -7b+ , 8/8+ , 5.12c , , E6 , IX- , Xa , 27, 8, 8c -7c , 8+, 5.12d , 6c , , IX , Xb , 28, 8, 9a -7c+ , 9-, 5.13a , , E7 , IX+ , Xc , 29, 9-, 9b -8a , , 5.13b , , , , , , 9, 9c -8a+ , 9-/9 , 5.13c , 7a , , X- , , 30, 9, 10a -8b , 9, 5.13d , , E8 , X , , 31, 10-, 10b -8b+ , 9/9+ , 5.14a , , , X+ , , 32, 10, 10c -8c , 9+, 5.14b , 7b , , , , 33, 10, 11a -8c+ , 10-, 5.14c , , E9 , XI- , , 34, 11-, 11b -9a , 10, 5.14d , 7c , , XI , , 35, 11, 11c -9a+ , , 5.15a , , , XI+ , , , , 12a -9b , , 5.15b , , , , , , , 12b - -# Wikipedia contributors. Grade (climbing). Wikipedia, The Free Encyclopedia. May 15, 2009, 20:42 UTC. -# Available at: http://en.wikipedia.org/w/index.php?title=Grade_(climbing)&oldid=290165724. Accessed May 28, 2009. diff --git a/examples/itemviews/frozencolumn/main.cpp b/examples/itemviews/frozencolumn/main.cpp deleted file mode 100644 index ff50e97db9..0000000000 --- a/examples/itemviews/frozencolumn/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include - -#include "freezetablewidget.h" - -int main( int argc, char** argv ) -{ - - Q_INIT_RESOURCE(grades); - - - QApplication app( argc, argv ); - QStandardItemModel *model=new QStandardItemModel(); - - - QFile file(":/grades.txt"); - QString line; - QStringList list; - if (file.open(QFile::ReadOnly)) { - line = file.readLine(200); - list= line.simplified().split(","); - model->setHorizontalHeaderLabels(list); - - int row=0; - QStandardItem *newItem=0; - while(file.canReadLine()){ - line = file.readLine(200); - if(!line.startsWith("#") && line.contains(",")){ - list= line.simplified().split(","); - for(int col=0; colsetItem(row ,col, newItem); - } - row++; - } - } - } - file.close(); - - FreezeTableWidget *tableView = new FreezeTableWidget(model); - - tableView->setWindowTitle(QObject::tr("Frozen Column Example")); - tableView->resize(560,680); - tableView->show(); - return app.exec(); -} - diff --git a/examples/itemviews/interview/README b/examples/itemviews/interview/README deleted file mode 100644 index 50894428f6..0000000000 --- a/examples/itemviews/interview/README +++ /dev/null @@ -1,2 +0,0 @@ -The interview example shows the same model and selection being shared -between three different views. diff --git a/examples/itemviews/interview/images/folder.png b/examples/itemviews/interview/images/folder.png deleted file mode 100644 index 589fd2df59..0000000000 Binary files a/examples/itemviews/interview/images/folder.png and /dev/null differ diff --git a/examples/itemviews/interview/images/interview.png b/examples/itemviews/interview/images/interview.png deleted file mode 100644 index 0c3d690258..0000000000 Binary files a/examples/itemviews/interview/images/interview.png and /dev/null differ diff --git a/examples/itemviews/interview/images/services.png b/examples/itemviews/interview/images/services.png deleted file mode 100644 index 6b2ad969d4..0000000000 Binary files a/examples/itemviews/interview/images/services.png and /dev/null differ diff --git a/examples/itemviews/interview/interview.pro b/examples/itemviews/interview/interview.pro deleted file mode 100644 index 5cd0d1f9fc..0000000000 --- a/examples/itemviews/interview/interview.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app - -CONFIG += qt warn_on -HEADERS += model.h -SOURCES += model.cpp main.cpp -RESOURCES += interview.qrc - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/interview -sources.files = $$SOURCES $$HEADERS $$RESOURCES README *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/interview -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/interview/interview.qrc b/examples/itemviews/interview/interview.qrc deleted file mode 100644 index b28ea34d8a..0000000000 --- a/examples/itemviews/interview/interview.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/folder.png - images/services.png - images/interview.png - - diff --git a/examples/itemviews/interview/main.cpp b/examples/itemviews/interview/main.cpp deleted file mode 100644 index fa059cdb53..0000000000 --- a/examples/itemviews/interview/main.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "model.h" - -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(interview); - - QApplication app(argc, argv); - QSplitter page; - - QAbstractItemModel *data = new Model(1000, 10, &page); - QItemSelectionModel *selections = new QItemSelectionModel(data); - - QTableView *table = new QTableView; - table->setModel(data); - table->setSelectionModel(selections); - table->horizontalHeader()->setSectionsMovable(true); - table->verticalHeader()->setSectionsMovable(true); - // Set StaticContents to enable minimal repaints on resizes. - table->viewport()->setAttribute(Qt::WA_StaticContents); - page.addWidget(table); - - QTreeView *tree = new QTreeView; - tree->setModel(data); - tree->setSelectionModel(selections); - tree->setUniformRowHeights(true); - tree->header()->setStretchLastSection(false); - tree->viewport()->setAttribute(Qt::WA_StaticContents); - // Disable the focus rect to get minimal repaints when scrolling on Mac. - tree->setAttribute(Qt::WA_MacShowFocusRect, false); - page.addWidget(tree); - - QListView *list = new QListView; - list->setModel(data); - list->setSelectionModel(selections); - list->setViewMode(QListView::IconMode); - list->setSelectionMode(QAbstractItemView::ExtendedSelection); - list->setAlternatingRowColors(false); - list->viewport()->setAttribute(Qt::WA_StaticContents); - list->setAttribute(Qt::WA_MacShowFocusRect, false); - page.addWidget(list); - - page.setWindowIcon(QPixmap(":/images/interview.png")); - page.setWindowTitle("Interview"); - page.show(); - - return app.exec(); -} diff --git a/examples/itemviews/interview/model.cpp b/examples/itemviews/interview/model.cpp deleted file mode 100644 index 3b20f91ed6..0000000000 --- a/examples/itemviews/interview/model.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "model.h" -#include -#include - -Model::Model(int rows, int columns, QObject *parent) - : QAbstractItemModel(parent), - services(QPixmap(":/images/services.png")), - rc(rows), cc(columns), - tree(new QVector(rows, Node(0))) -{ - -} - -Model::~Model() -{ - delete tree; -} - -QModelIndex Model::index(int row, int column, const QModelIndex &parent) const -{ - if (row < rc && row >= 0 && column < cc && column >= 0) { - Node *p = static_cast(parent.internalPointer()); - Node *n = node(row, p); - if (n) - return createIndex(row, column, n); - } - return QModelIndex(); -} - -QModelIndex Model::parent(const QModelIndex &child) const -{ - if (child.isValid()) { - Node *n = static_cast(child.internalPointer()); - Node *p = parent(n); - if (p) - return createIndex(row(p), 0, p); - } - return QModelIndex(); -} - -int Model::rowCount(const QModelIndex &parent) const -{ - return (parent.isValid() && parent.column() != 0) ? 0 : rc; -} - -int Model::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return cc; -} - -QVariant Model::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - if (role == Qt::DisplayRole) - return QVariant("Item " + QString::number(index.row()) + ":" + QString::number(index.column())); - if (role == Qt::DecorationRole) { - if (index.column() == 0) - return iconProvider.icon(QFileIconProvider::Folder); - return iconProvider.icon(QFileIconProvider::File); - } - return QVariant(); -} - -QVariant Model::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role == Qt::DisplayRole) - return QString::number(section); - if (role == Qt::DecorationRole) - return QVariant::fromValue(services); - return QAbstractItemModel::headerData(section, orientation, role); -} - -bool Model::hasChildren(const QModelIndex &parent) const -{ - if (parent.isValid() && parent.column() != 0) - return false; - return rc > 0 && cc > 0; -} - -Qt::ItemFlags Model::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return 0; - return (Qt::ItemIsDragEnabled|Qt::ItemIsSelectable|Qt::ItemIsEnabled); -} - -Model::Node *Model::node(int row, Node *parent) const -{ - if (parent && !parent->children) - parent->children = new QVector(rc, Node(parent)); - QVector *v = parent ? parent->children : tree; - return const_cast(&(v->at(row))); -} - -Model::Node *Model::parent(Node *child) const -{ - return child ? child->parent : 0; -} - -int Model::row(Node *node) const -{ - const Node *first = node->parent ? &(node->parent->children->at(0)) : &(tree->at(0)); - return (node - first); -} diff --git a/examples/itemviews/interview/model.h b/examples/itemviews/interview/model.h deleted file mode 100644 index 0480ce1763..0000000000 --- a/examples/itemviews/interview/model.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MODEL_H -#define MODEL_H - -#include -#include -#include -#include - -class Model : public QAbstractItemModel -{ - Q_OBJECT - -public: - Model(int rows, int columns, QObject *parent = 0); - ~Model(); - - QModelIndex index(int row, int column, const QModelIndex &parent) const; - QModelIndex parent(const QModelIndex &child) const; - - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - - bool hasChildren(const QModelIndex &parent) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - -private: - - struct Node - { - Node(Node *parent = 0) : parent(parent), children(0) {} - ~Node() { delete children; } - Node *parent; - QVector *children; - }; - - Node *node(int row, Node *parent) const; - Node *parent(Node *child) const; - int row(Node *node) const; - - QIcon services; - int rc, cc; - QVector *tree; - QFileIconProvider iconProvider; -}; - -#endif diff --git a/examples/itemviews/itemviews.pro b/examples/itemviews/itemviews.pro deleted file mode 100644 index 347c259bc2..0000000000 --- a/examples/itemviews/itemviews.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = addressbook \ - basicsortfiltermodel \ - chart \ - combowidgetmapper \ - customsortfiltermodel \ - dirview \ - editabletreemodel \ - fetchmore \ - frozencolumn \ - interview \ - pixelator \ - puzzle \ - simpledommodel \ - simpletreemodel \ - simplewidgetmapper \ - spinboxdelegate \ - spreadsheet - -# install -sources.files = README *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews -INSTALLS += sources - -QT += widgets diff --git a/examples/itemviews/pixelator/imagemodel.cpp b/examples/itemviews/pixelator/imagemodel.cpp deleted file mode 100644 index efbf2d35bc..0000000000 --- a/examples/itemviews/pixelator/imagemodel.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "imagemodel.h" - -//! [0] -ImageModel::ImageModel(QObject *parent) - : QAbstractTableModel(parent) -{ -} -//! [0] - -//! [1] -void ImageModel::setImage(const QImage &image) -{ - beginResetModel(); - modelImage = image; - endResetModel(); -} -//! [1] - -//! [2] -int ImageModel::rowCount(const QModelIndex & /* parent */) const -{ - return modelImage.height(); -} - -int ImageModel::columnCount(const QModelIndex & /* parent */) const -//! [2] //! [3] -{ - return modelImage.width(); -} -//! [3] - -//! [4] -QVariant ImageModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || role != Qt::DisplayRole) - return QVariant(); - return qGray(modelImage.pixel(index.column(), index.row())); -} -//! [4] - -//! [5] -QVariant ImageModel::headerData(int /* section */, - Qt::Orientation /* orientation */, - int role) const -{ - if (role == Qt::SizeHintRole) - return QSize(1, 1); - return QVariant(); -} -//! [5] diff --git a/examples/itemviews/pixelator/imagemodel.h b/examples/itemviews/pixelator/imagemodel.h deleted file mode 100644 index 2f778ca927..0000000000 --- a/examples/itemviews/pixelator/imagemodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 IMAGEMODEL_H -#define IMAGEMODEL_H - -#include -#include - -//! [0] -class ImageModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - ImageModel(QObject *parent = 0); - - void setImage(const QImage &image); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - -private: - QImage modelImage; -}; -//! [0] - -#endif diff --git a/examples/itemviews/pixelator/images.qrc b/examples/itemviews/pixelator/images.qrc deleted file mode 100644 index c105e13895..0000000000 --- a/examples/itemviews/pixelator/images.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/qt.png - - diff --git a/examples/itemviews/pixelator/images/qt.png b/examples/itemviews/pixelator/images/qt.png deleted file mode 100644 index a2c9c77c16..0000000000 Binary files a/examples/itemviews/pixelator/images/qt.png and /dev/null differ diff --git a/examples/itemviews/pixelator/main.cpp b/examples/itemviews/pixelator/main.cpp deleted file mode 100644 index e877051775..0000000000 --- a/examples/itemviews/pixelator/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(images); - - QApplication app(argc, argv); - MainWindow window; - window.show(); - window.openImage(":/images/qt.png"); - return app.exec(); -} diff --git a/examples/itemviews/pixelator/mainwindow.cpp b/examples/itemviews/pixelator/mainwindow.cpp deleted file mode 100644 index 20dfba18f4..0000000000 --- a/examples/itemviews/pixelator/mainwindow.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#ifndef QT_NO_PRINTER -#include -#include -#endif - -#include "imagemodel.h" -#include "mainwindow.h" -#include "pixeldelegate.h" - -//! [0] -MainWindow::MainWindow() -{ -//! [0] - currentPath = QDir::homePath(); - model = new ImageModel(this); - - QWidget *centralWidget = new QWidget; - -//! [1] - view = new QTableView; - view->setShowGrid(false); - view->horizontalHeader()->hide(); - view->verticalHeader()->hide(); - view->horizontalHeader()->setMinimumSectionSize(1); - view->verticalHeader()->setMinimumSectionSize(1); - view->setModel(model); -//! [1] - -//! [2] - PixelDelegate *delegate = new PixelDelegate(this); - view->setItemDelegate(delegate); -//! [2] - -//! [3] - QLabel *pixelSizeLabel = new QLabel(tr("Pixel size:")); - QSpinBox *pixelSizeSpinBox = new QSpinBox; - pixelSizeSpinBox->setMinimum(4); - pixelSizeSpinBox->setMaximum(32); - pixelSizeSpinBox->setValue(12); -//! [3] - - QMenu *fileMenu = new QMenu(tr("&File"), this); - QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcuts(QKeySequence::Open); - - printAction = fileMenu->addAction(tr("&Print...")); - printAction->setEnabled(false); - printAction->setShortcut(QKeySequence::Print); - - QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcuts(QKeySequence::Quit); - - QMenu *helpMenu = new QMenu(tr("&Help"), this); - QAction *aboutAction = helpMenu->addAction(tr("&About")); - - menuBar()->addMenu(fileMenu); - menuBar()->addSeparator(); - menuBar()->addMenu(helpMenu); - - connect(openAction, SIGNAL(triggered()), this, SLOT(chooseImage())); - connect(printAction, SIGNAL(triggered()), this, SLOT(printImage())); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAboutBox())); -//! [4] - connect(pixelSizeSpinBox, SIGNAL(valueChanged(int)), - delegate, SLOT(setPixelSize(int))); - connect(pixelSizeSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(updateView())); -//! [4] - - QHBoxLayout *controlsLayout = new QHBoxLayout; - controlsLayout->addWidget(pixelSizeLabel); - controlsLayout->addWidget(pixelSizeSpinBox); - controlsLayout->addStretch(1); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(view); - mainLayout->addLayout(controlsLayout); - centralWidget->setLayout(mainLayout); - - setCentralWidget(centralWidget); - - setWindowTitle(tr("Pixelator")); - resize(640, 480); -//! [5] -} -//! [5] - -void MainWindow::chooseImage() -{ - QString fileName = QFileDialog::getOpenFileName(this, - tr("Choose an image"), currentPath, "*"); - - if (!fileName.isEmpty()) - openImage(fileName); -} - -void MainWindow::openImage(const QString &fileName) -{ - QImage image; - - if (image.load(fileName)) { - model->setImage(image); - if (!fileName.startsWith(":/")) { - currentPath = fileName; - setWindowTitle(tr("%1 - Pixelator").arg(currentPath)); - } - - printAction->setEnabled(true); - updateView(); - } -} - -void MainWindow::printImage() -{ -#ifndef QT_NO_PRINTER - if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) - > 90000) { - QMessageBox::StandardButton answer; - answer = QMessageBox::question(this, tr("Large Image Size"), - tr("The printed image may be very large. Are you sure that " - "you want to print it?"), - QMessageBox::Yes | QMessageBox::No); - if (answer == QMessageBox::No) - return; - } - - QPrinter printer(QPrinter::HighResolution); - - QPrintDialog *dlg = new QPrintDialog(&printer, this); - dlg->setWindowTitle(tr("Print Image")); - - if (dlg->exec() != QDialog::Accepted) - return; - - QPainter painter; - painter.begin(&printer); - - int rows = model->rowCount(QModelIndex()); - int columns = model->columnCount(QModelIndex()); - int sourceWidth = (columns+1) * ItemSize; - int sourceHeight = (rows+1) * ItemSize; - - painter.save(); - - double xscale = printer.pageRect().width()/double(sourceWidth); - double yscale = printer.pageRect().height()/double(sourceHeight); - double scale = qMin(xscale, yscale); - - painter.translate(printer.paperRect().x() + printer.pageRect().width()/2, - printer.paperRect().y() + printer.pageRect().height()/2); - painter.scale(scale, scale); - painter.translate(-sourceWidth/2, -sourceHeight/2); - - QStyleOptionViewItem option; - QModelIndex parent = QModelIndex(); - - QProgressDialog progress(tr("Printing..."), tr("Cancel"), 0, rows, this); - progress.setWindowModality(Qt::ApplicationModal); - float y = ItemSize/2; - - for (int row = 0; row < rows; ++row) { - progress.setValue(row); - qApp->processEvents(); - if (progress.wasCanceled()) - break; - - float x = ItemSize/2; - - for (int column = 0; column < columns; ++column) { - option.rect = QRect(int(x), int(y), ItemSize, ItemSize); - view->itemDelegate()->paint(&painter, option, - model->index(row, column, parent)); - x = x + ItemSize; - } - y = y + ItemSize; - } - progress.setValue(rows); - - painter.restore(); - painter.end(); - - if (progress.wasCanceled()) { - QMessageBox::information(this, tr("Printing canceled"), - tr("The printing process was canceled."), QMessageBox::Cancel); - } -#else - QMessageBox::information(this, tr("Printing canceled"), - tr("Printing is not supported on this Qt build"), QMessageBox::Cancel); -#endif -} - -void MainWindow::showAboutBox() -{ - QMessageBox::about(this, tr("About the Pixelator example"), - tr("This example demonstrates how a standard view and a custom\n" - "delegate can be used to produce a specialized representation\n" - "of data in a simple custom model.")); -} - -//! [6] -void MainWindow::updateView() -{ - view->resizeColumnsToContents(); - view->resizeRowsToContents(); -} -//! [6] diff --git a/examples/itemviews/pixelator/mainwindow.h b/examples/itemviews/pixelator/mainwindow.h deleted file mode 100644 index 1aea1f9807..0000000000 --- a/examples/itemviews/pixelator/mainwindow.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -class ImageModel; -QT_BEGIN_NAMESPACE -class QAction; -class QTableView; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - - void openImage(const QString &fileName); - -public slots: - void chooseImage(); - void printImage(); - void showAboutBox(); - void updateView(); - -private: - ImageModel *model; - QAction *printAction; - QString currentPath; - QTableView *view; -}; - -#endif diff --git a/examples/itemviews/pixelator/pixelator.desktop b/examples/itemviews/pixelator/pixelator.desktop deleted file mode 100644 index 751deb13b3..0000000000 --- a/examples/itemviews/pixelator/pixelator.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Pixelator -Exec=/opt/usr/bin/pixelator -Icon=pixelator -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/pixelator/pixelator.pro b/examples/itemviews/pixelator/pixelator.pro deleted file mode 100644 index 48f8a58a58..0000000000 --- a/examples/itemviews/pixelator/pixelator.pro +++ /dev/null @@ -1,17 +0,0 @@ -HEADERS = imagemodel.h \ - mainwindow.h \ - pixeldelegate.h -SOURCES = imagemodel.cpp \ - main.cpp \ - mainwindow.cpp \ - pixeldelegate.cpp -RESOURCES += images.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/pixelator -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/pixelator -INSTALLS += target sources - -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport diff --git a/examples/itemviews/pixelator/pixeldelegate.cpp b/examples/itemviews/pixelator/pixeldelegate.cpp deleted file mode 100644 index 5904c2e680..0000000000 --- a/examples/itemviews/pixelator/pixeldelegate.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "pixeldelegate.h" - -//! [0] -PixelDelegate::PixelDelegate(QObject *parent) - : QAbstractItemDelegate(parent) -{ - pixelSize = 12; -} -//! [0] - -//! [1] -void PixelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ -//! [2] - if (option.state & QStyle::State_Selected) - painter->fillRect(option.rect, option.palette.highlight()); -//! [1] - -//! [3] - int size = qMin(option.rect.width(), option.rect.height()); -//! [3] //! [4] - int brightness = index.model()->data(index, Qt::DisplayRole).toInt(); - double radius = (size/2.0) - (brightness/255.0 * size/2.0); - if (radius == 0.0) - return; -//! [4] - -//! [5] - painter->save(); -//! [5] //! [6] - painter->setRenderHint(QPainter::Antialiasing, true); -//! [6] //! [7] - painter->setPen(Qt::NoPen); -//! [7] //! [8] - if (option.state & QStyle::State_Selected) -//! [8] //! [9] - painter->setBrush(option.palette.highlightedText()); - else -//! [2] - painter->setBrush(option.palette.text()); -//! [9] - -//! [10] - painter->drawEllipse(QRectF(option.rect.x() + option.rect.width()/2 - radius, - option.rect.y() + option.rect.height()/2 - radius, - 2*radius, 2*radius)); - painter->restore(); -} -//! [10] - -//! [11] -QSize PixelDelegate::sizeHint(const QStyleOptionViewItem & /* option */, - const QModelIndex & /* index */) const -{ - return QSize(pixelSize, pixelSize); -} -//! [11] - -//! [12] -void PixelDelegate::setPixelSize(int size) -{ - pixelSize = size; -} -//! [12] diff --git a/examples/itemviews/pixelator/pixeldelegate.h b/examples/itemviews/pixelator/pixeldelegate.h deleted file mode 100644 index 4035bc4571..0000000000 --- a/examples/itemviews/pixelator/pixeldelegate.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PIXELDELEGATE_H -#define PIXELDELEGATE_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QAbstractItemModel; -class QObject; -class QPainter; -QT_END_NAMESPACE - -static const int ItemSize = 256; - -//! [0] -class PixelDelegate : public QAbstractItemDelegate -{ - Q_OBJECT - -public: - PixelDelegate(QObject *parent = 0); - - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - - QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index ) const; - -public slots: - void setPixelSize(int size); - -private: - int pixelSize; -}; -//! [0] - -#endif diff --git a/examples/itemviews/puzzle/example.jpg b/examples/itemviews/puzzle/example.jpg deleted file mode 100644 index e09fb70757..0000000000 Binary files a/examples/itemviews/puzzle/example.jpg and /dev/null differ diff --git a/examples/itemviews/puzzle/main.cpp b/examples/itemviews/puzzle/main.cpp deleted file mode 100644 index 31b7142819..0000000000 --- a/examples/itemviews/puzzle/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(puzzle); - - QApplication app(argc, argv); - MainWindow window; - window.openImage(":/images/example.jpg"); - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/puzzle/mainwindow.cpp b/examples/itemviews/puzzle/mainwindow.cpp deleted file mode 100644 index 4b9b10946a..0000000000 --- a/examples/itemviews/puzzle/mainwindow.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#include "mainwindow.h" -#include "piecesmodel.h" -#include "puzzlewidget.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - setupMenus(); - setupWidgets(); - model = new PiecesModel(puzzleWidget->pieceSize(), this); - piecesList->setModel(model); - - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - setWindowTitle(tr("Puzzle")); -} - -void MainWindow::openImage(const QString &path) -{ - QString fileName = path; - - if (fileName.isNull()) - fileName = QFileDialog::getOpenFileName(this, - tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)")); - - if (!fileName.isEmpty()) { - QPixmap newImage; - if (!newImage.load(fileName)) { - QMessageBox::warning(this, tr("Open Image"), - tr("The image file could not be loaded."), - QMessageBox::Cancel); - return; - } - puzzleImage = newImage; - setupPuzzle(); - } -} - -void MainWindow::setCompleted() -{ - QMessageBox::information(this, tr("Puzzle Completed"), - tr("Congratulations! You have completed the puzzle!\n" - "Click OK to start again."), - QMessageBox::Ok); - - setupPuzzle(); -} - -void MainWindow::setupPuzzle() -{ - int size = qMin(puzzleImage.width(), puzzleImage.height()); - puzzleImage = puzzleImage.copy((puzzleImage.width() - size)/2, - (puzzleImage.height() - size)/2, size, size).scaled(puzzleWidget->imageSize(), - puzzleWidget->imageSize(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - qsrand(QCursor::pos().x() ^ QCursor::pos().y()); - - model->addPieces(puzzleImage); - puzzleWidget->clear(); -} - -void MainWindow::setupMenus() -{ - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - - QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcuts(QKeySequence::Open); - - QAction *exitAction = fileMenu->addAction(tr("E&xit")); - exitAction->setShortcuts(QKeySequence::Quit); - - QMenu *gameMenu = menuBar()->addMenu(tr("&Game")); - - QAction *restartAction = gameMenu->addAction(tr("&Restart")); - - connect(openAction, SIGNAL(triggered()), this, SLOT(openImage())); - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(restartAction, SIGNAL(triggered()), this, SLOT(setupPuzzle())); -} - -void MainWindow::setupWidgets() -{ - QFrame *frame = new QFrame; - QHBoxLayout *frameLayout = new QHBoxLayout(frame); - - puzzleWidget = new PuzzleWidget(400); - - piecesList = new QListView; - piecesList->setDragEnabled(true); - piecesList->setViewMode(QListView::IconMode); - piecesList->setIconSize(QSize(puzzleWidget->pieceSize() - 20, puzzleWidget->pieceSize() - 20)); - piecesList->setGridSize(QSize(puzzleWidget->pieceSize(), puzzleWidget->pieceSize())); - piecesList->setSpacing(10); - piecesList->setMovement(QListView::Snap); - piecesList->setAcceptDrops(true); - piecesList->setDropIndicatorShown(true); - - PiecesModel *model = new PiecesModel(puzzleWidget->pieceSize(), this); - piecesList->setModel(model); - - connect(puzzleWidget, SIGNAL(puzzleCompleted()), - this, SLOT(setCompleted()), Qt::QueuedConnection); - - frameLayout->addWidget(piecesList); - frameLayout->addWidget(puzzleWidget); - setCentralWidget(frame); -} diff --git a/examples/itemviews/puzzle/mainwindow.h b/examples/itemviews/puzzle/mainwindow.h deleted file mode 100644 index 83704d9932..0000000000 --- a/examples/itemviews/puzzle/mainwindow.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -class PuzzleWidget; -class PiecesModel; -QT_BEGIN_NAMESPACE -class QListView; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - -public slots: - void openImage(const QString &path = QString()); - void setupPuzzle(); - -private slots: - void setCompleted(); - -private: - void setupMenus(); - void setupWidgets(); - - QPixmap puzzleImage; - QListView *piecesList; - PuzzleWidget *puzzleWidget; - PiecesModel *model; -}; - -#endif diff --git a/examples/itemviews/puzzle/piecesmodel.cpp b/examples/itemviews/puzzle/piecesmodel.cpp deleted file mode 100644 index 68574606e2..0000000000 --- a/examples/itemviews/puzzle/piecesmodel.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "piecesmodel.h" - -PiecesModel::PiecesModel(int pieceSize, QObject *parent) - : QAbstractListModel(parent), m_PieceSize(pieceSize) -{ -} - -QVariant PiecesModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role == Qt::DecorationRole) - return QIcon(pixmaps.value(index.row()).scaled(m_PieceSize, m_PieceSize, - Qt::KeepAspectRatio, Qt::SmoothTransformation)); - else if (role == Qt::UserRole) - return pixmaps.value(index.row()); - else if (role == Qt::UserRole + 1) - return locations.value(index.row()); - - return QVariant(); -} - -void PiecesModel::addPiece(const QPixmap &pixmap, const QPoint &location) -{ - int row; - if (int(2.0*qrand()/(RAND_MAX+1.0)) == 1) - row = 0; - else - row = pixmaps.size(); - - beginInsertRows(QModelIndex(), row, row); - pixmaps.insert(row, pixmap); - locations.insert(row, location); - endInsertRows(); -} - -Qt::ItemFlags PiecesModel::flags(const QModelIndex &index) const -{ - if (index.isValid()) - return (Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled); - - return Qt::ItemIsDropEnabled; -} - -bool PiecesModel::removeRows(int row, int count, const QModelIndex &parent) -{ - if (parent.isValid()) - return false; - - if (row >= pixmaps.size() || row + count <= 0) - return false; - - int beginRow = qMax(0, row); - int endRow = qMin(row + count - 1, pixmaps.size() - 1); - - beginRemoveRows(parent, beginRow, endRow); - - while (beginRow <= endRow) { - pixmaps.removeAt(beginRow); - locations.removeAt(beginRow); - ++beginRow; - } - - endRemoveRows(); - return true; -} - -QStringList PiecesModel::mimeTypes() const -{ - QStringList types; - types << "image/x-puzzle-piece"; - return types; -} - -QMimeData *PiecesModel::mimeData(const QModelIndexList &indexes) const -{ - QMimeData *mimeData = new QMimeData(); - QByteArray encodedData; - - QDataStream stream(&encodedData, QIODevice::WriteOnly); - - foreach (QModelIndex index, indexes) { - if (index.isValid()) { - QPixmap pixmap = qvariant_cast(data(index, Qt::UserRole)); - QPoint location = data(index, Qt::UserRole+1).toPoint(); - stream << pixmap << location; - } - } - - mimeData->setData("image/x-puzzle-piece", encodedData); - return mimeData; -} - -bool PiecesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) -{ - if (!data->hasFormat("image/x-puzzle-piece")) - return false; - - if (action == Qt::IgnoreAction) - return true; - - if (column > 0) - return false; - - int endRow; - - if (!parent.isValid()) { - if (row < 0) - endRow = pixmaps.size(); - else - endRow = qMin(row, pixmaps.size()); - } else - endRow = parent.row(); - - QByteArray encodedData = data->data("image/x-puzzle-piece"); - QDataStream stream(&encodedData, QIODevice::ReadOnly); - - while (!stream.atEnd()) { - QPixmap pixmap; - QPoint location; - stream >> pixmap >> location; - - beginInsertRows(QModelIndex(), endRow, endRow); - pixmaps.insert(endRow, pixmap); - locations.insert(endRow, location); - endInsertRows(); - - ++endRow; - } - - return true; -} - -int PiecesModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - else - return pixmaps.size(); -} - -Qt::DropActions PiecesModel::supportedDropActions() const -{ - return Qt::CopyAction | Qt::MoveAction; -} - -void PiecesModel::addPieces(const QPixmap& pixmap) -{ - beginRemoveRows(QModelIndex(), 0, 24); - pixmaps.clear(); - locations.clear(); - endRemoveRows(); - for (int y = 0; y < 5; ++y) { - for (int x = 0; x < 5; ++x) { - QPixmap pieceImage = pixmap.copy(x*m_PieceSize, y*m_PieceSize, m_PieceSize, m_PieceSize); - addPiece(pieceImage, QPoint(x, y)); - } - } -} diff --git a/examples/itemviews/puzzle/piecesmodel.h b/examples/itemviews/puzzle/piecesmodel.h deleted file mode 100644 index e8fa45a9a0..0000000000 --- a/examples/itemviews/puzzle/piecesmodel.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PIECESLIST_H -#define PIECESLIST_H - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QMimeData; -QT_END_NAMESPACE - -class PiecesModel : public QAbstractListModel -{ - Q_OBJECT - -public: - PiecesModel(int pieceSize, QObject *parent = 0); - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - bool removeRows(int row, int count, const QModelIndex &parent); - - bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); - QMimeData *mimeData(const QModelIndexList &indexes) const; - QStringList mimeTypes() const; - int rowCount(const QModelIndex &parent) const; - Qt::DropActions supportedDropActions() const; - - void addPiece(const QPixmap &pixmap, const QPoint &location); - void addPieces(const QPixmap& pixmap); - -private: - QList locations; - QList pixmaps; - - int m_PieceSize; -}; - -#endif diff --git a/examples/itemviews/puzzle/puzzle.desktop b/examples/itemviews/puzzle/puzzle.desktop deleted file mode 100644 index d493e7dd41..0000000000 --- a/examples/itemviews/puzzle/puzzle.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Item Views Puzzle -Exec=/opt/usr/bin/puzzle -Icon=puzzle -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/puzzle/puzzle.pro b/examples/itemviews/puzzle/puzzle.pro deleted file mode 100644 index 3f76bd8fd5..0000000000 --- a/examples/itemviews/puzzle/puzzle.pro +++ /dev/null @@ -1,22 +0,0 @@ -HEADERS = mainwindow.h \ - piecesmodel.h \ - puzzlewidget.h -RESOURCES = puzzle.qrc -SOURCES = main.cpp \ - mainwindow.cpp \ - piecesmodel.cpp \ - puzzlewidget.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/puzzle -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.jpg -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/puzzle -INSTALLS += target sources - - -wince* { - DEPLOYMENT_PLUGIN += qjpeg qgif -} - -QT += widgets - diff --git a/examples/itemviews/puzzle/puzzle.qrc b/examples/itemviews/puzzle/puzzle.qrc deleted file mode 100644 index 4076cec026..0000000000 --- a/examples/itemviews/puzzle/puzzle.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.jpg - - diff --git a/examples/itemviews/puzzle/puzzlewidget.cpp b/examples/itemviews/puzzle/puzzlewidget.cpp deleted file mode 100644 index 96d8c6068f..0000000000 --- a/examples/itemviews/puzzle/puzzlewidget.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "puzzlewidget.h" - -PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent) - : QWidget(parent), m_ImageSize(imageSize) -{ - setAcceptDrops(true); - setMinimumSize(m_ImageSize, m_ImageSize); - setMaximumSize(m_ImageSize, m_ImageSize); -} - -void PuzzleWidget::clear() -{ - pieceLocations.clear(); - piecePixmaps.clear(); - pieceRects.clear(); - highlightedRect = QRect(); - inPlace = 0; - update(); -} - -void PuzzleWidget::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece")) - event->accept(); - else - event->ignore(); -} - -void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event) -{ - QRect updateRect = highlightedRect; - highlightedRect = QRect(); - update(updateRect); - event->accept(); -} - -void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event) -{ - QRect updateRect = highlightedRect.united(targetSquare(event->pos())); - - if (event->mimeData()->hasFormat("image/x-puzzle-piece") - && findPiece(targetSquare(event->pos())) == -1) { - - highlightedRect = targetSquare(event->pos()); - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - highlightedRect = QRect(); - event->ignore(); - } - - update(updateRect); -} - -void PuzzleWidget::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasFormat("image/x-puzzle-piece") - && findPiece(targetSquare(event->pos())) == -1) { - - QByteArray pieceData = event->mimeData()->data("image/x-puzzle-piece"); - QDataStream stream(&pieceData, QIODevice::ReadOnly); - QRect square = targetSquare(event->pos()); - QPixmap pixmap; - QPoint location; - stream >> pixmap >> location; - - pieceLocations.append(location); - piecePixmaps.append(pixmap); - pieceRects.append(square); - - highlightedRect = QRect(); - update(square); - - event->setDropAction(Qt::MoveAction); - event->accept(); - - if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) { - inPlace++; - if (inPlace == 25) - emit puzzleCompleted(); - } - } else { - highlightedRect = QRect(); - event->ignore(); - } -} - -int PuzzleWidget::findPiece(const QRect &pieceRect) const -{ - for (int i = 0; i < pieceRects.size(); ++i) { - if (pieceRect == pieceRects[i]) { - return i; - } - } - return -1; -} - -void PuzzleWidget::mousePressEvent(QMouseEvent *event) -{ - QRect square = targetSquare(event->pos()); - int found = findPiece(square); - - if (found == -1) - return; - - QPoint location = pieceLocations[found]; - QPixmap pixmap = piecePixmaps[found]; - pieceLocations.removeAt(found); - piecePixmaps.removeAt(found); - pieceRects.removeAt(found); - - if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) - inPlace--; - - update(square); - - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - - dataStream << pixmap << location; - - QMimeData *mimeData = new QMimeData; - mimeData->setData("image/x-puzzle-piece", itemData); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setHotSpot(event->pos() - square.topLeft()); - drag->setPixmap(pixmap); - - if (drag->start(Qt::MoveAction) == 0) { - pieceLocations.insert(found, location); - piecePixmaps.insert(found, pixmap); - pieceRects.insert(found, square); - update(targetSquare(event->pos())); - - if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) - inPlace++; - } -} - -void PuzzleWidget::paintEvent(QPaintEvent *event) -{ - QPainter painter; - painter.begin(this); - painter.fillRect(event->rect(), Qt::white); - - if (highlightedRect.isValid()) { - painter.setBrush(QColor("#ffcccc")); - painter.setPen(Qt::NoPen); - painter.drawRect(highlightedRect.adjusted(0, 0, -1, -1)); - } - - for (int i = 0; i < pieceRects.size(); ++i) { - painter.drawPixmap(pieceRects[i], piecePixmaps[i]); - } - painter.end(); -} - -const QRect PuzzleWidget::targetSquare(const QPoint &position) const -{ - return QRect(position.x()/pieceSize() * pieceSize(), position.y()/pieceSize() * pieceSize(), pieceSize(), pieceSize()); -} - -int PuzzleWidget::pieceSize() const -{ - return m_ImageSize / 5; -} - -int PuzzleWidget::imageSize() const -{ - return m_ImageSize; -} diff --git a/examples/itemviews/puzzle/puzzlewidget.h b/examples/itemviews/puzzle/puzzlewidget.h deleted file mode 100644 index 1c0fc77a5f..0000000000 --- a/examples/itemviews/puzzle/puzzlewidget.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 PUZZLEWIDGET_H -#define PUZZLEWIDGET_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDropEvent; -class QMouseEvent; -QT_END_NAMESPACE - -class PuzzleWidget : public QWidget -{ - Q_OBJECT - -public: - PuzzleWidget(int imageSize, QWidget *parent = 0); - void clear(); - - int pieceSize() const; - int imageSize() const; - -signals: - void puzzleCompleted(); - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dropEvent(QDropEvent *event); - void mousePressEvent(QMouseEvent *event); - void paintEvent(QPaintEvent *event); - -private: - int findPiece(const QRect &pieceRect) const; - const QRect targetSquare(const QPoint &position) const; - - QList piecePixmaps; - QList pieceRects; - QList pieceLocations; - QRect highlightedRect; - int inPlace; - int m_ImageSize; -}; - -#endif diff --git a/examples/itemviews/simpledommodel/domitem.cpp b/examples/itemviews/simpledommodel/domitem.cpp deleted file mode 100644 index 2d7ce5a31e..0000000000 --- a/examples/itemviews/simpledommodel/domitem.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "domitem.h" - -//! [0] -DomItem::DomItem(QDomNode &node, int row, DomItem *parent) -{ - domNode = node; -//! [0] - // Record the item's location within its parent. -//! [1] - rowNumber = row; - parentItem = parent; -} -//! [1] - -//! [2] -DomItem::~DomItem() -{ - QHash::iterator it; - for (it = childItems.begin(); it != childItems.end(); ++it) - delete it.value(); -} -//! [2] - -//! [3] -QDomNode DomItem::node() const -{ - return domNode; -} -//! [3] - -//! [4] -DomItem *DomItem::parent() -{ - return parentItem; -} -//! [4] - -//! [5] -DomItem *DomItem::child(int i) -{ - if (childItems.contains(i)) - return childItems[i]; - - if (i >= 0 && i < domNode.childNodes().count()) { - QDomNode childNode = domNode.childNodes().item(i); - DomItem *childItem = new DomItem(childNode, i, this); - childItems[i] = childItem; - return childItem; - } - return 0; -} -//! [5] - -//! [6] -int DomItem::row() -{ - return rowNumber; -} -//! [6] diff --git a/examples/itemviews/simpledommodel/domitem.h b/examples/itemviews/simpledommodel/domitem.h deleted file mode 100644 index 8e9da9dd27..0000000000 --- a/examples/itemviews/simpledommodel/domitem.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DOMITEM_H -#define DOMITEM_H - -#include -#include - -//! [0] -class DomItem -{ -public: - DomItem(QDomNode &node, int row, DomItem *parent = 0); - ~DomItem(); - DomItem *child(int i); - DomItem *parent(); - QDomNode node() const; - int row(); - -private: - QDomNode domNode; - QHash childItems; - DomItem *parentItem; - int rowNumber; -}; -//! [0] - -#endif diff --git a/examples/itemviews/simpledommodel/dommodel.cpp b/examples/itemviews/simpledommodel/dommodel.cpp deleted file mode 100644 index 75d4c3e723..0000000000 --- a/examples/itemviews/simpledommodel/dommodel.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#include "domitem.h" -#include "dommodel.h" - -//! [0] -DomModel::DomModel(QDomDocument document, QObject *parent) - : QAbstractItemModel(parent), domDocument(document) -{ - rootItem = new DomItem(domDocument, 0); -} -//! [0] - -//! [1] -DomModel::~DomModel() -{ - delete rootItem; -} -//! [1] - -//! [2] -int DomModel::columnCount(const QModelIndex &/*parent*/) const -{ - return 3; -} -//! [2] - -//! [3] -QVariant DomModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role != Qt::DisplayRole) - return QVariant(); - - DomItem *item = static_cast(index.internalPointer()); - - QDomNode node = item->node(); -//! [3] //! [4] - QStringList attributes; - QDomNamedNodeMap attributeMap = node.attributes(); - - switch (index.column()) { - case 0: - return node.nodeName(); - case 1: - for (int i = 0; i < attributeMap.count(); ++i) { - QDomNode attribute = attributeMap.item(i); - attributes << attribute.nodeName() + "=\"" - +attribute.nodeValue() + "\""; - } - return attributes.join(" "); - case 2: - return node.nodeValue().split("\n").join(" "); - default: - return QVariant(); - } -} -//! [4] - -//! [5] -Qt::ItemFlags DomModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return 0; - - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} -//! [5] - -//! [6] -QVariant DomModel::headerData(int section, Qt::Orientation orientation, - int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch (section) { - case 0: - return tr("Name"); - case 1: - return tr("Attributes"); - case 2: - return tr("Value"); - default: - return QVariant(); - } - } - - return QVariant(); -} -//! [6] - -//! [7] -QModelIndex DomModel::index(int row, int column, const QModelIndex &parent) - const -{ - if (!hasIndex(row, column, parent)) - return QModelIndex(); - - DomItem *parentItem; - - if (!parent.isValid()) - parentItem = rootItem; - else - parentItem = static_cast(parent.internalPointer()); -//! [7] - -//! [8] - DomItem *childItem = parentItem->child(row); - if (childItem) - return createIndex(row, column, childItem); - else - return QModelIndex(); -} -//! [8] - -//! [9] -QModelIndex DomModel::parent(const QModelIndex &child) const -{ - if (!child.isValid()) - return QModelIndex(); - - DomItem *childItem = static_cast(child.internalPointer()); - DomItem *parentItem = childItem->parent(); - - if (!parentItem || parentItem == rootItem) - return QModelIndex(); - - return createIndex(parentItem->row(), 0, parentItem); -} -//! [9] - -//! [10] -int DomModel::rowCount(const QModelIndex &parent) const -{ - if (parent.column() > 0) - return 0; - - DomItem *parentItem; - - if (!parent.isValid()) - parentItem = rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - return parentItem->node().childNodes().count(); -} -//! [10] diff --git a/examples/itemviews/simpledommodel/dommodel.h b/examples/itemviews/simpledommodel/dommodel.h deleted file mode 100644 index 386f976f79..0000000000 --- a/examples/itemviews/simpledommodel/dommodel.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DOMMODEL_H -#define DOMMODEL_H - -#include -#include -#include -#include - -class DomItem; - -//! [0] -class DomModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - DomModel(QDomDocument document, QObject *parent = 0); - ~DomModel(); - - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - -private: - QDomDocument domDocument; - DomItem *rootItem; -}; -//! [0] - -#endif diff --git a/examples/itemviews/simpledommodel/main.cpp b/examples/itemviews/simpledommodel/main.cpp deleted file mode 100644 index e65d428bc6..0000000000 --- a/examples/itemviews/simpledommodel/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.resize(640, 480); - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/simpledommodel/mainwindow.cpp b/examples/itemviews/simpledommodel/mainwindow.cpp deleted file mode 100644 index f84d8841e7..0000000000 --- a/examples/itemviews/simpledommodel/mainwindow.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include - -#include "dommodel.h" -#include "mainwindow.h" - -MainWindow::MainWindow() : QMainWindow(), model(0) -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), - QKeySequence::Open); - fileMenu->addAction(tr("E&xit"), this, SLOT(close()), - QKeySequence::Quit); - - model = new DomModel(QDomDocument(), this); - view = new QTreeView(this); - view->setModel(model); - - setCentralWidget(view); - setWindowTitle(tr("Simple DOM Model")); -} - -void MainWindow::openFile() -{ - QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"), - xmlPath, tr("XML files (*.xml);;HTML files (*.html);;" - "SVG files (*.svg);;User Interface files (*.ui)")); - - if (!filePath.isEmpty()) { - QFile file(filePath); - if (file.open(QIODevice::ReadOnly)) { - QDomDocument document; - if (document.setContent(&file)) { - DomModel *newModel = new DomModel(document, this); - view->setModel(newModel); - delete model; - model = newModel; - xmlPath = filePath; - } - file.close(); - } - } -} diff --git a/examples/itemviews/simpledommodel/mainwindow.h b/examples/itemviews/simpledommodel/mainwindow.h deleted file mode 100644 index 16e0b800f9..0000000000 --- a/examples/itemviews/simpledommodel/mainwindow.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -class DomModel; -QT_BEGIN_NAMESPACE -class QMenu; -class QTreeView; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -public slots: - void openFile(); - -private: - DomModel *model; - QMenu *fileMenu; - QString xmlPath; - QTreeView *view; -}; - -#endif diff --git a/examples/itemviews/simpledommodel/simpledommodel.desktop b/examples/itemviews/simpledommodel/simpledommodel.desktop deleted file mode 100644 index a53b896848..0000000000 --- a/examples/itemviews/simpledommodel/simpledommodel.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Simple DOM Model -Exec=/opt/usr/bin/simpledommodel -Icon=simpledommodel -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/simpledommodel/simpledommodel.pro b/examples/itemviews/simpledommodel/simpledommodel.pro deleted file mode 100644 index 2d30e71c1a..0000000000 --- a/examples/itemviews/simpledommodel/simpledommodel.pro +++ /dev/null @@ -1,16 +0,0 @@ -HEADERS = domitem.h \ - dommodel.h \ - mainwindow.h -SOURCES = domitem.cpp \ - dommodel.cpp \ - main.cpp \ - mainwindow.cpp -CONFIG += qt -QT += xml widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simpledommodel -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simpledommodel -INSTALLS += target sources - diff --git a/examples/itemviews/simpletreemodel/default.txt b/examples/itemviews/simpletreemodel/default.txt deleted file mode 100644 index 2b2fb579ae..0000000000 --- a/examples/itemviews/simpletreemodel/default.txt +++ /dev/null @@ -1,40 +0,0 @@ -Getting Started How to familiarize yourself with Qt Designer - Launching Designer Running the Qt Designer application - The User Interface How to interact with Qt Designer - -Designing a Component Creating a GUI for your application - Creating a Dialog How to create a dialog - Composing the Dialog Putting widgets into the dialog example - Creating a Layout Arranging widgets on a form - Signal and Slot Connections Making widget communicate with each other - -Using a Component in Your Application Generating code from forms - The Direct Approach Using a form without any adjustments - The Single Inheritance Approach Subclassing a form's base class - The Multiple Inheritance Approach Subclassing the form itself - Automatic Connections Connecting widgets using a naming scheme - A Dialog Without Auto-Connect How to connect widgets without a naming scheme - A Dialog With Auto-Connect Using automatic connections - -Form Editing Mode How to edit a form in Qt Designer - Managing Forms Loading and saving forms - Editing a Form Basic editing techniques - The Property Editor Changing widget properties - The Object Inspector Examining the hierarchy of objects on a form - Layouts Objects that arrange widgets on a form - Applying and Breaking Layouts Managing widgets in layouts - Horizontal and Vertical Layouts Standard row and column layouts - The Grid Layout Arranging widgets in a matrix - Previewing Forms Checking that the design works - -Using Containers How to group widgets together - General Features Common container features - Frames QFrame - Group Boxes QGroupBox - Stacked Widgets QStackedWidget - Tab Widgets QTabWidget - Toolbox Widgets QToolBox - -Connection Editing Mode Connecting widgets together with signals and slots - Connecting Objects Making connections in Qt Designer - Editing Connections Changing existing connections diff --git a/examples/itemviews/simpletreemodel/main.cpp b/examples/itemviews/simpletreemodel/main.cpp deleted file mode 100644 index a7dd720a2f..0000000000 --- a/examples/itemviews/simpletreemodel/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "treemodel.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(simpletreemodel); - - QApplication app(argc, argv); - - QFile file(":/default.txt"); - file.open(QIODevice::ReadOnly); - TreeModel model(file.readAll()); - file.close(); - - QTreeView view; - view.setModel(&model); - view.setWindowTitle(QObject::tr("Simple Tree Model")); - view.show(); - return app.exec(); -} diff --git a/examples/itemviews/simpletreemodel/simpletreemodel.desktop b/examples/itemviews/simpletreemodel/simpletreemodel.desktop deleted file mode 100644 index 361202f5c0..0000000000 --- a/examples/itemviews/simpletreemodel/simpletreemodel.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Simple Tree Model -Exec=/opt/usr/bin/simpletreemodel -Icon=simpletreemodel -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/simpletreemodel/simpletreemodel.pro b/examples/itemviews/simpletreemodel/simpletreemodel.pro deleted file mode 100644 index cd4f8af604..0000000000 --- a/examples/itemviews/simpletreemodel/simpletreemodel.pro +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS = treeitem.h \ - treemodel.h -RESOURCES = simpletreemodel.qrc -SOURCES = treeitem.cpp \ - treemodel.cpp \ - main.cpp -CONFIG += qt - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simpletreemodel -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.txt -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simpletreemodel -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/simpletreemodel/simpletreemodel.qrc b/examples/itemviews/simpletreemodel/simpletreemodel.qrc deleted file mode 100644 index a8ecc98d28..0000000000 --- a/examples/itemviews/simpletreemodel/simpletreemodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - default.txt - - diff --git a/examples/itemviews/simpletreemodel/treeitem.cpp b/examples/itemviews/simpletreemodel/treeitem.cpp deleted file mode 100644 index a296f6ccd5..0000000000 --- a/examples/itemviews/simpletreemodel/treeitem.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -/* - treeitem.cpp - - A container for items of data supplied by the simple tree model. -*/ - -#include - -#include "treeitem.h" - -//! [0] -TreeItem::TreeItem(const QList &data, TreeItem *parent) -{ - parentItem = parent; - itemData = data; -} -//! [0] - -//! [1] -TreeItem::~TreeItem() -{ - qDeleteAll(childItems); -} -//! [1] - -//! [2] -void TreeItem::appendChild(TreeItem *item) -{ - childItems.append(item); -} -//! [2] - -//! [3] -TreeItem *TreeItem::child(int row) -{ - return childItems.value(row); -} -//! [3] - -//! [4] -int TreeItem::childCount() const -{ - return childItems.count(); -} -//! [4] - -//! [5] -int TreeItem::columnCount() const -{ - return itemData.count(); -} -//! [5] - -//! [6] -QVariant TreeItem::data(int column) const -{ - return itemData.value(column); -} -//! [6] - -//! [7] -TreeItem *TreeItem::parent() -{ - return parentItem; -} -//! [7] - -//! [8] -int TreeItem::row() const -{ - if (parentItem) - return parentItem->childItems.indexOf(const_cast(this)); - - return 0; -} -//! [8] diff --git a/examples/itemviews/simpletreemodel/treeitem.h b/examples/itemviews/simpletreemodel/treeitem.h deleted file mode 100644 index b2a7a83066..0000000000 --- a/examples/itemviews/simpletreemodel/treeitem.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 TREEITEM_H -#define TREEITEM_H - -#include -#include - -//! [0] -class TreeItem -{ -public: - TreeItem(const QList &data, TreeItem *parent = 0); - ~TreeItem(); - - void appendChild(TreeItem *child); - - TreeItem *child(int row); - int childCount() const; - int columnCount() const; - QVariant data(int column) const; - int row() const; - TreeItem *parent(); - -private: - QList childItems; - QList itemData; - TreeItem *parentItem; -}; -//! [0] - -#endif diff --git a/examples/itemviews/simpletreemodel/treemodel.cpp b/examples/itemviews/simpletreemodel/treemodel.cpp deleted file mode 100644 index 1fad9ba347..0000000000 --- a/examples/itemviews/simpletreemodel/treemodel.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -/* - treemodel.cpp - - Provides a simple tree model to show how to create and use hierarchical - models. -*/ - -#include - -#include "treeitem.h" -#include "treemodel.h" - -//! [0] -TreeModel::TreeModel(const QString &data, QObject *parent) - : QAbstractItemModel(parent) -{ - QList rootData; - rootData << "Title" << "Summary"; - rootItem = new TreeItem(rootData); - setupModelData(data.split(QString("\n")), rootItem); -} -//! [0] - -//! [1] -TreeModel::~TreeModel() -{ - delete rootItem; -} -//! [1] - -//! [2] -int TreeModel::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return static_cast(parent.internalPointer())->columnCount(); - else - return rootItem->columnCount(); -} -//! [2] - -//! [3] -QVariant TreeModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role != Qt::DisplayRole) - return QVariant(); - - TreeItem *item = static_cast(index.internalPointer()); - - return item->data(index.column()); -} -//! [3] - -//! [4] -Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return 0; - - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} -//! [4] - -//! [5] -QVariant TreeModel::headerData(int section, Qt::Orientation orientation, - int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - return rootItem->data(section); - - return QVariant(); -} -//! [5] - -//! [6] -QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) - const -{ - if (!hasIndex(row, column, parent)) - return QModelIndex(); - - TreeItem *parentItem; - - if (!parent.isValid()) - parentItem = rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - TreeItem *childItem = parentItem->child(row); - if (childItem) - return createIndex(row, column, childItem); - else - return QModelIndex(); -} -//! [6] - -//! [7] -QModelIndex TreeModel::parent(const QModelIndex &index) const -{ - if (!index.isValid()) - return QModelIndex(); - - TreeItem *childItem = static_cast(index.internalPointer()); - TreeItem *parentItem = childItem->parent(); - - if (parentItem == rootItem) - return QModelIndex(); - - return createIndex(parentItem->row(), 0, parentItem); -} -//! [7] - -//! [8] -int TreeModel::rowCount(const QModelIndex &parent) const -{ - TreeItem *parentItem; - if (parent.column() > 0) - return 0; - - if (!parent.isValid()) - parentItem = rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - return parentItem->childCount(); -} -//! [8] - -void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent) -{ - QList parents; - QList indentations; - parents << parent; - indentations << 0; - - int number = 0; - - while (number < lines.count()) { - int position = 0; - while (position < lines[number].length()) { - if (lines[number].mid(position, 1) != " ") - break; - position++; - } - - QString lineData = lines[number].mid(position).trimmed(); - - if (!lineData.isEmpty()) { - // Read the column data from the rest of the line. - QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); - QList columnData; - for (int column = 0; column < columnStrings.count(); ++column) - columnData << columnStrings[column]; - - if (position > indentations.last()) { - // The last child of the current parent is now the new parent - // unless the current parent has no children. - - if (parents.last()->childCount() > 0) { - parents << parents.last()->child(parents.last()->childCount()-1); - indentations << position; - } - } else { - while (position < indentations.last() && parents.count() > 0) { - parents.pop_back(); - indentations.pop_back(); - } - } - - // Append a new item to the current parent's list of children. - parents.last()->appendChild(new TreeItem(columnData, parents.last())); - } - - number++; - } -} diff --git a/examples/itemviews/simpletreemodel/treemodel.h b/examples/itemviews/simpletreemodel/treemodel.h deleted file mode 100644 index 9cf870c0fc..0000000000 --- a/examples/itemviews/simpletreemodel/treemodel.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 TREEMODEL_H -#define TREEMODEL_H - -#include -#include -#include - -class TreeItem; - -//! [0] -class TreeModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - TreeModel(const QString &data, QObject *parent = 0); - ~TreeModel(); - - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - -private: - void setupModelData(const QStringList &lines, TreeItem *parent); - - TreeItem *rootItem; -}; -//! [0] - -#endif diff --git a/examples/itemviews/simplewidgetmapper/main.cpp b/examples/itemviews/simplewidgetmapper/main.cpp deleted file mode 100644 index 0fc4966ccf..0000000000 --- a/examples/itemviews/simplewidgetmapper/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.desktop b/examples/itemviews/simplewidgetmapper/simplewidgetmapper.desktop deleted file mode 100644 index 6b09a236da..0000000000 --- a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Simple Widget Mapper -Exec=/opt/usr/bin/simplewidgetmapper -Icon=simplewidgetmapper -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro b/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro deleted file mode 100644 index 3b2fd8b257..0000000000 --- a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simplewidgetmapper -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simplewidgetmapper -INSTALLS += target sources - -QT += widgets diff --git a/examples/itemviews/simplewidgetmapper/window.cpp b/examples/itemviews/simplewidgetmapper/window.cpp deleted file mode 100644 index 5b5ed8f231..0000000000 --- a/examples/itemviews/simplewidgetmapper/window.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -//! [Set up widgets] -Window::Window(QWidget *parent) - : QWidget(parent) -{ - setupModel(); - - nameLabel = new QLabel(tr("Na&me:")); - nameEdit = new QLineEdit(); - addressLabel = new QLabel(tr("&Address:")); - addressEdit = new QTextEdit(); - ageLabel = new QLabel(tr("A&ge (in years):")); - ageSpinBox = new QSpinBox(); - nextButton = new QPushButton(tr("&Next")); - previousButton = new QPushButton(tr("&Previous")); - - nameLabel->setBuddy(nameEdit); - addressLabel->setBuddy(addressEdit); - ageLabel->setBuddy(ageSpinBox); -//! [Set up widgets] - -//! [Set up the mapper] - mapper = new QDataWidgetMapper(this); - mapper->setModel(model); - mapper->addMapping(nameEdit, 0); - mapper->addMapping(addressEdit, 1); - mapper->addMapping(ageSpinBox, 2); - - connect(previousButton, SIGNAL(clicked()), - mapper, SLOT(toPrevious())); - connect(nextButton, SIGNAL(clicked()), - mapper, SLOT(toNext())); - connect(mapper, SIGNAL(currentIndexChanged(int)), - this, SLOT(updateButtons(int))); -//! [Set up the mapper] - -//! [Set up the layout] - QGridLayout *layout = new QGridLayout(); - layout->addWidget(nameLabel, 0, 0, 1, 1); - layout->addWidget(nameEdit, 0, 1, 1, 1); - layout->addWidget(previousButton, 0, 2, 1, 1); - layout->addWidget(addressLabel, 1, 0, 1, 1); - layout->addWidget(addressEdit, 1, 1, 2, 1); - layout->addWidget(nextButton, 1, 2, 1, 1); - layout->addWidget(ageLabel, 3, 0, 1, 1); - layout->addWidget(ageSpinBox, 3, 1, 1, 1); - setLayout(layout); - - setWindowTitle(tr("Simple Widget Mapper")); - mapper->toFirst(); -} -//! [Set up the layout] - -//! [Set up the model] -void Window::setupModel() -{ - model = new QStandardItemModel(5, 3, this); - - QStringList names; - names << "Alice" << "Bob" << "Carol" << "Donald" << "Emma"; - - QStringList addresses; - addresses << "123 Main Street
    Market Town
    " - << "PO Box 32
    Mail Handling Service" - "
    Service City
    " - << "The Lighthouse
    Remote Island
    " - << "47338 Park Avenue
    Big City
    " - << "Research Station
    Base Camp
    Big Mountain
    "; - - QStringList ages; - ages << "20" << "31" << "32" << "19" << "26"; - - for (int row = 0; row < 5; ++row) { - QStandardItem *item = new QStandardItem(names[row]); - model->setItem(row, 0, item); - item = new QStandardItem(addresses[row]); - model->setItem(row, 1, item); - item = new QStandardItem(ages[row]); - model->setItem(row, 2, item); - } -} -//! [Set up the model] - -//! [Slot for updating the buttons] -void Window::updateButtons(int row) -{ - previousButton->setEnabled(row > 0); - nextButton->setEnabled(row < model->rowCount() - 1); -} -//! [Slot for updating the buttons] diff --git a/examples/itemviews/simplewidgetmapper/window.h b/examples/itemviews/simplewidgetmapper/window.h deleted file mode 100644 index 77772e522f..0000000000 --- a/examples/itemviews/simplewidgetmapper/window.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QDataWidgetMapper; -class QLabel; -class QLineEdit; -class QPushButton; -class QSpinBox; -class QStandardItemModel; -class QTextEdit; -QT_END_NAMESPACE - -//! [Window definition] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(QWidget *parent = 0); - -private slots: - void updateButtons(int row); - -private: - void setupModel(); - - QLabel *nameLabel; - QLabel *addressLabel; - QLabel *ageLabel; - QLineEdit *nameEdit; - QTextEdit *addressEdit; - QSpinBox *ageSpinBox; - QPushButton *nextButton; - QPushButton *previousButton; - - QStandardItemModel *model; - QDataWidgetMapper *mapper; -}; -//! [Window definition] - -#endif diff --git a/examples/itemviews/spinboxdelegate/delegate.cpp b/examples/itemviews/spinboxdelegate/delegate.cpp deleted file mode 100644 index 2967b6ae38..0000000000 --- a/examples/itemviews/spinboxdelegate/delegate.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -/* - delegate.cpp - - A delegate that allows the user to change integer values from the model - using a spin box widget. -*/ - -#include - -#include "delegate.h" - - -//! [0] -SpinBoxDelegate::SpinBoxDelegate(QObject *parent) - : QItemDelegate(parent) -{ -} -//! [0] - -//! [1] -QWidget *SpinBoxDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem &/* option */, - const QModelIndex &/* index */) const -{ - QSpinBox *editor = new QSpinBox(parent); - editor->setMinimum(0); - editor->setMaximum(100); - - return editor; -} -//! [1] - -//! [2] -void SpinBoxDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - int value = index.model()->data(index, Qt::EditRole).toInt(); - - QSpinBox *spinBox = static_cast(editor); - spinBox->setValue(value); -} -//! [2] - -//! [3] -void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - QSpinBox *spinBox = static_cast(editor); - spinBox->interpretText(); - int value = spinBox->value(); - - model->setData(index, value, Qt::EditRole); -} -//! [3] - -//! [4] -void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &/* index */) const -{ - editor->setGeometry(option.rect); -} -//! [4] diff --git a/examples/itemviews/spinboxdelegate/delegate.h b/examples/itemviews/spinboxdelegate/delegate.h deleted file mode 100644 index 19d647043d..0000000000 --- a/examples/itemviews/spinboxdelegate/delegate.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DELEGATE_H -#define DELEGATE_H - -#include -#include -#include -#include -#include - -//! [0] -class SpinBoxDelegate : public QItemDelegate -{ - Q_OBJECT - -public: - SpinBoxDelegate(QObject *parent = 0); - - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; - - void updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &index) const; -}; -//! [0] - -#endif diff --git a/examples/itemviews/spinboxdelegate/main.cpp b/examples/itemviews/spinboxdelegate/main.cpp deleted file mode 100644 index 6fdffad3ac..0000000000 --- a/examples/itemviews/spinboxdelegate/main.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -/* - main.cpp - - A simple example that shows how a view can use a custom delegate to edit - data obtained from a model. -*/ - -#include -#include -#include -#include -#include - -#include "delegate.h" - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QStandardItemModel model(4, 2); - QTableView tableView; - tableView.setModel(&model); - - SpinBoxDelegate delegate; - tableView.setItemDelegate(&delegate); -//! [0] - - tableView.horizontalHeader()->setStretchLastSection(true); - -//! [1] - for (int row = 0; row < 4; ++row) { - for (int column = 0; column < 2; ++column) { - QModelIndex index = model.index(row, column, QModelIndex()); - model.setData(index, QVariant((row+1) * (column+1))); - } -//! [1] //! [2] - } -//! [2] - -//! [3] - tableView.setWindowTitle(QObject::tr("Spin Box Delegate")); - tableView.show(); - return app.exec(); -} -//! [3] diff --git a/examples/itemviews/spinboxdelegate/spinboxdelegate.desktop b/examples/itemviews/spinboxdelegate/spinboxdelegate.desktop deleted file mode 100644 index 347e408e96..0000000000 --- a/examples/itemviews/spinboxdelegate/spinboxdelegate.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Spin Box Delegate -Exec=/opt/usr/bin/spinboxdelegate -Icon=spinboxdelegate -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/spinboxdelegate/spinboxdelegate.pro b/examples/itemviews/spinboxdelegate/spinboxdelegate.pro deleted file mode 100644 index f6416ff936..0000000000 --- a/examples/itemviews/spinboxdelegate/spinboxdelegate.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = delegate.h -SOURCES = delegate.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/spinboxdelegate -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/spinboxdelegate -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/itemviews/spreadsheet/images/interview.png b/examples/itemviews/spreadsheet/images/interview.png deleted file mode 100644 index 0c3d690258..0000000000 Binary files a/examples/itemviews/spreadsheet/images/interview.png and /dev/null differ diff --git a/examples/itemviews/spreadsheet/main.cpp b/examples/itemviews/spreadsheet/main.cpp deleted file mode 100644 index 92b890f735..0000000000 --- a/examples/itemviews/spreadsheet/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "spreadsheet.h" - -int main(int argc, char** argv) { - Q_INIT_RESOURCE(spreadsheet); - QApplication app(argc, argv); - SpreadSheet sheet(10, 6); - sheet.setWindowIcon(QPixmap(":/images/interview.png")); - sheet.resize(640, 420); - sheet.show(); - return app.exec(); -} - - diff --git a/examples/itemviews/spreadsheet/printview.cpp b/examples/itemviews/spreadsheet/printview.cpp deleted file mode 100644 index fe94fde63c..0000000000 --- a/examples/itemviews/spreadsheet/printview.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "printview.h" - -#ifndef QT_NO_PRINTER -#include -#endif -#include - -PrintView::PrintView() -{ - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -} - -void PrintView::print(QPrinter *printer) -{ -#ifndef QT_NO_PRINTER - resize(printer->width(), printer->height()); - render(printer); -#endif -} - diff --git a/examples/itemviews/spreadsheet/printview.h b/examples/itemviews/spreadsheet/printview.h deleted file mode 100644 index c7674f88ce..0000000000 --- a/examples/itemviews/spreadsheet/printview.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PRINTVIEW_H -#define PRINTVIEW_H - -#include -QT_BEGIN_NAMESPACE -class QPrinter; -QT_END_NAMESPACE - -class PrintView : public QTableView -{ - Q_OBJECT - -public: - PrintView(); - -public Q_SLOTS: - void print(QPrinter *printer); -}; - -#endif // PRINTVIEW_H - - diff --git a/examples/itemviews/spreadsheet/spreadsheet.cpp b/examples/itemviews/spreadsheet/spreadsheet.cpp deleted file mode 100644 index 5dff7dc059..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheet.cpp +++ /dev/null @@ -1,639 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#ifndef QT_NO_PRINTER -#include -#include -#include -#endif - -#include "spreadsheet.h" -#include "spreadsheetdelegate.h" -#include "spreadsheetitem.h" -#include "printview.h" - -SpreadSheet::SpreadSheet(int rows, int cols, QWidget *parent) - : QMainWindow(parent) -{ - addToolBar(toolBar = new QToolBar()); - formulaInput = new QLineEdit(); - - cellLabel = new QLabel(toolBar); - cellLabel->setMinimumSize(80, 0); - - toolBar->addWidget(cellLabel); - toolBar->addWidget(formulaInput); - - table = new QTableWidget(rows, cols, this); - for (int c = 0; c < cols; ++c) { - QString character(QChar('A' + c)); - table->setHorizontalHeaderItem(c, new QTableWidgetItem(character)); - } - - table->setItemPrototype(table->item(rows -1, cols - 1)); - table->setItemDelegate(new SpreadSheetDelegate()); - - createActions(); - updateColor(0); - setupMenuBar(); - setupContents(); - setupContextMenu(); - setCentralWidget(table); - - statusBar(); - connect(table, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), - this, SLOT(updateStatus(QTableWidgetItem*))); - connect(table, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), - this, SLOT(updateColor(QTableWidgetItem*))); - connect(table, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), - this, SLOT(updateLineEdit(QTableWidgetItem*))); - connect(table, SIGNAL(itemChanged(QTableWidgetItem*)), - this, SLOT(updateStatus(QTableWidgetItem*))); - connect(formulaInput, SIGNAL(returnPressed()), this, SLOT(returnPressed())); - connect(table, SIGNAL(itemChanged(QTableWidgetItem*)), - this, SLOT(updateLineEdit(QTableWidgetItem*))); - - setWindowTitle(tr("Spreadsheet")); -} - -void SpreadSheet::createActions() -{ - cell_sumAction = new QAction(tr("Sum"), this); - connect(cell_sumAction, SIGNAL(triggered()), this, SLOT(actionSum())); - - cell_addAction = new QAction(tr("&Add"), this); - cell_addAction->setShortcut(Qt::CTRL | Qt::Key_Plus); - connect(cell_addAction, SIGNAL(triggered()), this, SLOT(actionAdd())); - - cell_subAction = new QAction(tr("&Subtract"), this); - cell_subAction->setShortcut(Qt::CTRL | Qt::Key_Minus); - connect(cell_subAction, SIGNAL(triggered()), this, SLOT(actionSubtract())); - - cell_mulAction = new QAction(tr("&Multiply"), this); - cell_mulAction->setShortcut(Qt::CTRL | Qt::Key_multiply); - connect(cell_mulAction, SIGNAL(triggered()), this, SLOT(actionMultiply())); - - cell_divAction = new QAction(tr("&Divide"), this); - cell_divAction->setShortcut(Qt::CTRL | Qt::Key_division); - connect(cell_divAction, SIGNAL(triggered()), this, SLOT(actionDivide())); - - fontAction = new QAction(tr("Font..."), this); - fontAction->setShortcut(Qt::CTRL | Qt::Key_F); - connect(fontAction, SIGNAL(triggered()), this, SLOT(selectFont())); - - colorAction = new QAction(QPixmap(16, 16), tr("Background &Color..."), this); - connect(colorAction, SIGNAL(triggered()), this, SLOT(selectColor())); - - clearAction = new QAction(tr("Clear"), this); - clearAction->setShortcut(Qt::Key_Delete); - connect(clearAction, SIGNAL(triggered()), this, SLOT(clear())); - - aboutSpreadSheet = new QAction(tr("About Spreadsheet"), this); - connect(aboutSpreadSheet, SIGNAL(triggered()), this, SLOT(showAbout())); - - exitAction = new QAction(tr("E&xit"), this); - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - printAction = new QAction(tr("&Print"), this); - connect(printAction, SIGNAL(triggered()), this, SLOT(print())); - - firstSeparator = new QAction(this); - firstSeparator->setSeparator(true); - - secondSeparator = new QAction(this); - secondSeparator->setSeparator(true); -} - -void SpreadSheet::setupMenuBar() -{ - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(printAction); - fileMenu->addAction(exitAction); - - QMenu *cellMenu = menuBar()->addMenu(tr("&Cell")); - cellMenu->addAction(cell_addAction); - cellMenu->addAction(cell_subAction); - cellMenu->addAction(cell_mulAction); - cellMenu->addAction(cell_divAction); - cellMenu->addAction(cell_sumAction); - cellMenu->addSeparator(); - cellMenu->addAction(colorAction); - cellMenu->addAction(fontAction); - - menuBar()->addSeparator(); - - QMenu *aboutMenu = menuBar()->addMenu(tr("&Help")); - aboutMenu->addAction(aboutSpreadSheet); -} - -void SpreadSheet::updateStatus(QTableWidgetItem *item) -{ - if (item && item == table->currentItem()) { - statusBar()->showMessage(item->data(Qt::StatusTipRole).toString(), - 1000); - cellLabel->setText(tr("Cell: (%1)").arg(encode_pos(table->row(item), - table->column(item)))); - } -} - -void SpreadSheet::updateColor(QTableWidgetItem *item) -{ - QPixmap pix(16, 16); - QColor col; - if (item) - col = item->backgroundColor(); - if (!col.isValid()) - col = palette().base().color(); - - QPainter pt(&pix); - pt.fillRect(0, 0, 16, 16, col); - - QColor lighter = col.light(); - pt.setPen(lighter); - QPoint lightFrame[] = { QPoint(0, 15), QPoint(0, 0), QPoint(15, 0) }; - pt.drawPolyline(lightFrame, 3); - - pt.setPen(col.dark()); - QPoint darkFrame[] = { QPoint(1, 15), QPoint(15, 15), QPoint(15, 1) }; - pt.drawPolyline(darkFrame, 3); - - pt.end(); - - colorAction->setIcon(pix); -} - -void SpreadSheet::updateLineEdit(QTableWidgetItem *item) -{ - if (item != table->currentItem()) - return; - if (item) - formulaInput->setText(item->data(Qt::EditRole).toString()); - else - formulaInput->clear(); -} - -void SpreadSheet::returnPressed() -{ - QString text = formulaInput->text(); - int row = table->currentRow(); - int col = table->currentColumn(); - QTableWidgetItem *item = table->item(row, col); - if (!item) - table->setItem(row, col, new SpreadSheetItem(text)); - else - item->setData(Qt::EditRole, text); - table->viewport()->update(); -} - -void SpreadSheet::selectColor() -{ - QTableWidgetItem *item = table->currentItem(); - QColor col = item ? item->backgroundColor() : table->palette().base().color(); - col = QColorDialog::getColor(col, this); - if (!col.isValid()) - return; - - QList selected = table->selectedItems(); - if (selected.count() == 0) - return; - - foreach(QTableWidgetItem *i, selected) - if (i) - i->setBackgroundColor(col); - - updateColor(table->currentItem()); -} - -void SpreadSheet::selectFont() -{ - QList selected = table->selectedItems(); - if (selected.count() == 0) - return; - - bool ok = false; - QFont fnt = QFontDialog::getFont(&ok, font(), this); - - if (!ok) - return; - foreach(QTableWidgetItem *i, selected) - if (i) - i->setFont(fnt); -} - -bool SpreadSheet::runInputDialog(const QString &title, - const QString &c1Text, - const QString &c2Text, - const QString &opText, - const QString &outText, - QString *cell1, QString *cell2, QString *outCell) -{ - QStringList rows, cols; - for (int c = 0; c < table->columnCount(); ++c) - cols << QChar('A' + c); - for (int r = 0; r < table->rowCount(); ++r) - rows << QString::number(1 + r); - - QDialog addDialog(this); - addDialog.setWindowTitle(title); - - QGroupBox group(title, &addDialog); - group.setMinimumSize(250, 100); - - QLabel cell1Label(c1Text, &group); - QComboBox cell1RowInput(&group); - int c1Row, c1Col; - decode_pos(*cell1, &c1Row, &c1Col); - cell1RowInput.addItems(rows); - cell1RowInput.setCurrentIndex(c1Row); - - QComboBox cell1ColInput(&group); - cell1ColInput.addItems(cols); - cell1ColInput.setCurrentIndex(c1Col); - - QLabel operatorLabel(opText, &group); - operatorLabel.setAlignment(Qt::AlignHCenter); - - QLabel cell2Label(c2Text, &group); - QComboBox cell2RowInput(&group); - int c2Row, c2Col; - decode_pos(*cell2, &c2Row, &c2Col); - cell2RowInput.addItems(rows); - cell2RowInput.setCurrentIndex(c2Row); - QComboBox cell2ColInput(&group); - cell2ColInput.addItems(cols); - cell2ColInput.setCurrentIndex(c2Col); - - QLabel equalsLabel("=", &group); - equalsLabel.setAlignment(Qt::AlignHCenter); - - QLabel outLabel(outText, &group); - QComboBox outRowInput(&group); - int outRow, outCol; - decode_pos(*outCell, &outRow, &outCol); - outRowInput.addItems(rows); - outRowInput.setCurrentIndex(outRow); - QComboBox outColInput(&group); - outColInput.addItems(cols); - outColInput.setCurrentIndex(outCol); - - QPushButton cancelButton(tr("Cancel"), &addDialog); - connect(&cancelButton, SIGNAL(clicked()), &addDialog, SLOT(reject())); - - QPushButton okButton(tr("OK"), &addDialog); - okButton.setDefault(true); - connect(&okButton, SIGNAL(clicked()), &addDialog, SLOT(accept())); - - QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(&okButton); - buttonsLayout->addSpacing(10); - buttonsLayout->addWidget(&cancelButton); - - QVBoxLayout *dialogLayout = new QVBoxLayout(&addDialog); - dialogLayout->addWidget(&group); - dialogLayout->addStretch(1); - dialogLayout->addItem(buttonsLayout); - - QHBoxLayout *cell1Layout = new QHBoxLayout; - cell1Layout->addWidget(&cell1Label); - cell1Layout->addSpacing(10); - cell1Layout->addWidget(&cell1ColInput); - cell1Layout->addSpacing(10); - cell1Layout->addWidget(&cell1RowInput); - - QHBoxLayout *cell2Layout = new QHBoxLayout; - cell2Layout->addWidget(&cell2Label); - cell2Layout->addSpacing(10); - cell2Layout->addWidget(&cell2ColInput); - cell2Layout->addSpacing(10); - cell2Layout->addWidget(&cell2RowInput); - - QHBoxLayout *outLayout = new QHBoxLayout; - outLayout->addWidget(&outLabel); - outLayout->addSpacing(10); - outLayout->addWidget(&outColInput); - outLayout->addSpacing(10); - outLayout->addWidget(&outRowInput); - - QVBoxLayout *vLayout = new QVBoxLayout(&group); - vLayout->addItem(cell1Layout); - vLayout->addWidget(&operatorLabel); - vLayout->addItem(cell2Layout); - vLayout->addWidget(&equalsLabel); - vLayout->addStretch(1); - vLayout->addItem(outLayout); - - if (addDialog.exec()) { - *cell1 = cell1ColInput.currentText() + cell1RowInput.currentText(); - *cell2 = cell2ColInput.currentText() + cell2RowInput.currentText(); - *outCell = outColInput.currentText() + outRowInput.currentText(); - return true; - } - - return false; -} - -void SpreadSheet::actionSum() -{ - int row_first = 0; - int row_last = 0; - int row_cur = 0; - - int col_first = 0; - int col_last = 0; - int col_cur = 0; - - QList selected = table->selectedItems(); - - if (!selected.isEmpty()) { - QTableWidgetItem *first = selected.first(); - QTableWidgetItem *last = selected.last(); - row_first = table->row(first); - row_last = table->row(last); - col_first = table->column(first); - col_last = table->column(last); - } - - QTableWidgetItem *current = table->currentItem(); - - if (current) { - row_cur = table->row(current); - col_cur = table->column(current); - } - - QString cell1 = encode_pos(row_first, col_first); - QString cell2 = encode_pos(row_last, col_last); - QString out = encode_pos(row_cur, col_cur); - - if (runInputDialog(tr("Sum cells"), tr("First cell:"), tr("Last cell:"), - QString("%1").arg(QChar(0x03a3)), tr("Output to:"), - &cell1, &cell2, &out)) { - int row, col; - decode_pos(out, &row, &col); - table->item(row, col)->setText(tr("sum %1 %2").arg(cell1, cell2)); - } -} - -void SpreadSheet::actionMath_helper(const QString &title, const QString &op) -{ - QString cell1 = "C1"; - QString cell2 = "C2"; - QString out = "C3"; - - QTableWidgetItem *current = table->currentItem(); - if (current) - out = encode_pos(table->currentRow(), table->currentColumn()); - - if (runInputDialog(title, tr("Cell 1"), tr("Cell 2"), op, tr("Output to:"), - &cell1, &cell2, &out)) { - int row, col; - decode_pos(out, &row, &col); - table->item(row, col)->setText(tr("%1 %2 %3").arg(op, cell1, cell2)); - } -} - -void SpreadSheet::actionAdd() -{ - actionMath_helper(tr("Addition"), "+"); -} - -void SpreadSheet::actionSubtract() -{ - actionMath_helper(tr("Subtraction"), "-"); -} - -void SpreadSheet::actionMultiply() -{ - actionMath_helper(tr("Multiplication"), "*"); -} -void SpreadSheet::actionDivide() -{ - actionMath_helper(tr("Division"), "/"); -} - -void SpreadSheet::clear() -{ - foreach (QTableWidgetItem *i, table->selectedItems()) - i->setText(""); -} - -void SpreadSheet::setupContextMenu() -{ - addAction(cell_addAction); - addAction(cell_subAction); - addAction(cell_mulAction); - addAction(cell_divAction); - addAction(cell_sumAction); - addAction(firstSeparator); - addAction(colorAction); - addAction(fontAction); - addAction(secondSeparator); - addAction(clearAction); - setContextMenuPolicy(Qt::ActionsContextMenu); -} - -void SpreadSheet::setupContents() -{ - QColor titleBackground(Qt::lightGray); - QFont titleFont = table->font(); - titleFont.setBold(true); - - // column 0 - table->setItem(0, 0, new SpreadSheetItem("Item")); - table->item(0, 0)->setBackgroundColor(titleBackground); - table->item(0, 0)->setToolTip("This column shows the purchased item/service"); - table->item(0, 0)->setFont(titleFont); - - table->setItem(1, 0, new SpreadSheetItem("AirportBus")); - table->setItem(2, 0, new SpreadSheetItem("Flight (Munich)")); - table->setItem(3, 0, new SpreadSheetItem("Lunch")); - table->setItem(4, 0, new SpreadSheetItem("Flight (LA)")); - table->setItem(5, 0, new SpreadSheetItem("Taxi")); - table->setItem(6, 0, new SpreadSheetItem("Dinner")); - table->setItem(7, 0, new SpreadSheetItem("Hotel")); - table->setItem(8, 0, new SpreadSheetItem("Flight (Oslo)")); - table->setItem(9, 0, new SpreadSheetItem("Total:")); - - table->item(9, 0)->setFont(titleFont); - table->item(9, 0)->setBackgroundColor(Qt::lightGray); - - // column 1 - table->setItem(0, 1, new SpreadSheetItem("Date")); - table->item(0, 1)->setBackgroundColor(titleBackground); - table->item(0, 1)->setToolTip("This column shows the purchase date, double click to change"); - table->item(0, 1)->setFont(titleFont); - - table->setItem(1, 1, new SpreadSheetItem("15/6/2006")); - table->setItem(2, 1, new SpreadSheetItem("15/6/2006")); - table->setItem(3, 1, new SpreadSheetItem("15/6/2006")); - table->setItem(4, 1, new SpreadSheetItem("21/5/2006")); - table->setItem(5, 1, new SpreadSheetItem("16/6/2006")); - table->setItem(6, 1, new SpreadSheetItem("16/6/2006")); - table->setItem(7, 1, new SpreadSheetItem("16/6/2006")); - table->setItem(8, 1, new SpreadSheetItem("18/6/2006")); - - table->setItem(9, 1, new SpreadSheetItem()); - table->item(9, 1)->setBackgroundColor(Qt::lightGray); - - // column 2 - table->setItem(0, 2, new SpreadSheetItem("Price")); - table->item(0, 2)->setBackgroundColor(titleBackground); - table->item(0, 2)->setToolTip("This column shows the price of the purchase"); - table->item(0, 2)->setFont(titleFont); - - table->setItem(1, 2, new SpreadSheetItem("150")); - table->setItem(2, 2, new SpreadSheetItem("2350")); - table->setItem(3, 2, new SpreadSheetItem("-14")); - table->setItem(4, 2, new SpreadSheetItem("980")); - table->setItem(5, 2, new SpreadSheetItem("5")); - table->setItem(6, 2, new SpreadSheetItem("120")); - table->setItem(7, 2, new SpreadSheetItem("300")); - table->setItem(8, 2, new SpreadSheetItem("1240")); - - table->setItem(9, 2, new SpreadSheetItem()); - table->item(9, 2)->setBackgroundColor(Qt::lightGray); - - // column 3 - table->setItem(0, 3, new SpreadSheetItem("Currency")); - table->item(0, 3)->setBackgroundColor(titleBackground); - table->item(0, 3)->setToolTip("This column shows the currency"); - table->item(0, 3)->setFont(titleFont); - - table->setItem(1, 3, new SpreadSheetItem("NOK")); - table->setItem(2, 3, new SpreadSheetItem("NOK")); - table->setItem(3, 3, new SpreadSheetItem("EUR")); - table->setItem(4, 3, new SpreadSheetItem("EUR")); - table->setItem(5, 3, new SpreadSheetItem("USD")); - table->setItem(6, 3, new SpreadSheetItem("USD")); - table->setItem(7, 3, new SpreadSheetItem("USD")); - table->setItem(8, 3, new SpreadSheetItem("USD")); - - table->setItem(9, 3, new SpreadSheetItem()); - table->item(9,3)->setBackgroundColor(Qt::lightGray); - - // column 4 - table->setItem(0, 4, new SpreadSheetItem("Ex. Rate")); - table->item(0, 4)->setBackgroundColor(titleBackground); - table->item(0, 4)->setToolTip("This column shows the exchange rate to NOK"); - table->item(0, 4)->setFont(titleFont); - - table->setItem(1, 4, new SpreadSheetItem("1")); - table->setItem(2, 4, new SpreadSheetItem("1")); - table->setItem(3, 4, new SpreadSheetItem("8")); - table->setItem(4, 4, new SpreadSheetItem("8")); - table->setItem(5, 4, new SpreadSheetItem("7")); - table->setItem(6, 4, new SpreadSheetItem("7")); - table->setItem(7, 4, new SpreadSheetItem("7")); - table->setItem(8, 4, new SpreadSheetItem("7")); - - table->setItem(9, 4, new SpreadSheetItem()); - table->item(9,4)->setBackgroundColor(Qt::lightGray); - - // column 5 - table->setItem(0, 5, new SpreadSheetItem("NOK")); - table->item(0, 5)->setBackgroundColor(titleBackground); - table->item(0, 5)->setToolTip("This column shows the expenses in NOK"); - table->item(0, 5)->setFont(titleFont); - - table->setItem(1, 5, new SpreadSheetItem("* C2 E2")); - table->setItem(2, 5, new SpreadSheetItem("* C3 E3")); - table->setItem(3, 5, new SpreadSheetItem("* C4 E4")); - table->setItem(4, 5, new SpreadSheetItem("* C5 E5")); - table->setItem(5, 5, new SpreadSheetItem("* C6 E6")); - table->setItem(6, 5, new SpreadSheetItem("* C7 E7")); - table->setItem(7, 5, new SpreadSheetItem("* C8 E8")); - table->setItem(8, 5, new SpreadSheetItem("* C9 E9")); - - table->setItem(9, 5, new SpreadSheetItem("sum F2 F9")); - table->item(9,5)->setBackgroundColor(Qt::lightGray); -} - -const char *htmlText = -"" -"

    This demo shows use of QTableWidget with custom handling for" -" individual cells.

    " -"

    Using a customized table item we make it possible to have dynamic" -" output in different cells. The content that is implemented for this" -" particular demo is:" -"

      " -"
    • Adding two cells.
    • " -"
    • Subtracting one cell from another.
    • " -"
    • Multiplying two cells.
    • " -"
    • Dividing one cell with another.
    • " -"
    • Summing the contents of an arbitrary number of cells.
    • " -""; - -void SpreadSheet::showAbout() -{ - QMessageBox::about(this, "About Spreadsheet", htmlText); -} - -void decode_pos(const QString &pos, int *row, int *col) -{ - if (pos.isEmpty()) { - *col = -1; - *row = -1; - } else { - *col = pos.at(0).toLatin1() - 'A'; - *row = pos.right(pos.size() - 1).toInt() - 1; - } -} - -QString encode_pos(int row, int col) -{ - return QString(col + 'A') + QString::number(row + 1); -} - - -void SpreadSheet::print() -{ -#ifndef QT_NO_PRINTER - QPrinter printer(QPrinter::ScreenResolution); - QPrintPreviewDialog dlg(&printer); - PrintView view; - view.setModel(table->model()); - connect(&dlg, SIGNAL(paintRequested(QPrinter*)), - &view, SLOT(print(QPrinter*))); - dlg.exec(); -#endif -} - diff --git a/examples/itemviews/spreadsheet/spreadsheet.h b/examples/itemviews/spreadsheet/spreadsheet.h deleted file mode 100644 index d2b76c9063..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheet.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SPREADSHEET_H -#define SPREADSHEET_H - -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QLabel; -class QLineEdit; -class QToolBar; -class QTableWidgetItem; -class QTableWidget; -QT_END_NAMESPACE - -class SpreadSheet : public QMainWindow -{ - Q_OBJECT - -public: - - SpreadSheet(int rows, int cols, QWidget *parent = 0); - -public slots: - void updateStatus(QTableWidgetItem *item); - void updateColor(QTableWidgetItem *item); - void updateLineEdit(QTableWidgetItem *item); - void returnPressed(); - void selectColor(); - void selectFont(); - void clear(); - void showAbout(); - - void print(); - - void actionSum(); - void actionSubtract(); - void actionAdd(); - void actionMultiply(); - void actionDivide(); - -protected: - void setupContextMenu(); - void setupContents(); - - void setupMenuBar(); - void createActions(); - - void actionMath_helper(const QString &title, const QString &op); - bool runInputDialog(const QString &title, - const QString &c1Text, - const QString &c2Text, - const QString &opText, - const QString &outText, - QString *cell1, QString *cell2, QString *outCell); -private: - QToolBar *toolBar; - QAction *colorAction; - QAction *fontAction; - QAction *firstSeparator; - QAction *cell_sumAction; - QAction *cell_addAction; - QAction *cell_subAction; - QAction *cell_mulAction; - QAction *cell_divAction; - QAction *secondSeparator; - QAction *clearAction; - QAction *aboutSpreadSheet; - QAction *exitAction; - - QAction *printAction; - - QLabel *cellLabel; - QTableWidget *table; - QLineEdit *formulaInput; - -}; - -void decode_pos(const QString &pos, int *row, int *col); -QString encode_pos(int row, int col); - - -#endif // SPREADSHEET_H - diff --git a/examples/itemviews/spreadsheet/spreadsheet.pro b/examples/itemviews/spreadsheet/spreadsheet.pro deleted file mode 100644 index 48fd07e7fd..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheet.pro +++ /dev/null @@ -1,23 +0,0 @@ -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport -#unix:contains(QT_CONFIG, dbus):QT += dbus widgets - -HEADERS += printview.h spreadsheet.h spreadsheetdelegate.h spreadsheetitem.h -SOURCES += main.cpp \ - printview.cpp \ - spreadsheet.cpp \ - spreadsheetdelegate.cpp \ - spreadsheetitem.cpp -RESOURCES += spreadsheet.qrc - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/spreadsheet -sources.files = $$SOURCES $$RESOURCES *.pro images $$HEADERS -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/spreadsheet -INSTALLS += target sources - diff --git a/examples/itemviews/spreadsheet/spreadsheet.qrc b/examples/itemviews/spreadsheet/spreadsheet.qrc deleted file mode 100644 index 13f496d8e3..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheet.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/interview.png - - diff --git a/examples/itemviews/spreadsheet/spreadsheetdelegate.cpp b/examples/itemviews/spreadsheet/spreadsheetdelegate.cpp deleted file mode 100644 index d5e747dc2f..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheetdelegate.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "spreadsheetdelegate.h" -#include - -SpreadSheetDelegate::SpreadSheetDelegate(QObject *parent) - : QItemDelegate(parent) {} - -QWidget *SpreadSheetDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem &, - const QModelIndex &index) const -{ - if (index.column() == 1) { - QDateTimeEdit *editor = new QDateTimeEdit(parent); - editor->setDisplayFormat("dd/M/yyyy"); - editor->setCalendarPopup(true); - return editor; - } - - QLineEdit *editor = new QLineEdit(parent); - - // create a completer with the strings in the column as model - QStringList allStrings; - for (int i = 1; irowCount(); i++) { - QString strItem(index.model()->data(index.sibling(i, index.column()), - Qt::EditRole).toString()); - - if (!allStrings.contains(strItem)) - allStrings.append(strItem); - } - - QCompleter *autoComplete = new QCompleter(allStrings); - editor->setCompleter(autoComplete); - connect(editor, SIGNAL(editingFinished()), - this, SLOT(commitAndCloseEditor())); - return editor; -} - -void SpreadSheetDelegate::commitAndCloseEditor() -{ - QLineEdit *editor = qobject_cast(sender()); - emit commitData(editor); - emit closeEditor(editor); -} - -void SpreadSheetDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - QLineEdit *edit = qobject_cast(editor); - if (edit) { - edit->setText(index.model()->data(index, Qt::EditRole).toString()); - } else { - QDateTimeEdit *dateEditor = qobject_cast(editor); - if (dateEditor) { - dateEditor->setDate(QDate::fromString( - index.model()->data(index, Qt::EditRole).toString(), - "d/M/yyyy")); - } - } -} - -void SpreadSheetDelegate::setModelData(QWidget *editor, - QAbstractItemModel *model, const QModelIndex &index) const -{ - QLineEdit *edit = qobject_cast(editor); - if (edit) { - model->setData(index, edit->text()); - } else { - QDateTimeEdit *dateEditor = qobject_cast(editor); - if (dateEditor) { - model->setData(index, dateEditor->date().toString("dd/M/yyyy")); - } - } -} - diff --git a/examples/itemviews/spreadsheet/spreadsheetdelegate.h b/examples/itemviews/spreadsheet/spreadsheetdelegate.h deleted file mode 100644 index 3487b16ab7..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheetdelegate.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SPREADSHEETDELEGATE_H -#define SPREADSHEETDELEGATE_H - -#include -#include "spreadsheet.h" - -class SpreadSheetDelegate : public QItemDelegate -{ - Q_OBJECT - -public: - SpreadSheetDelegate(QObject *parent = 0); - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, - const QModelIndex &index) const; - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; - -private slots: - void commitAndCloseEditor(); -}; - -#endif // SPREADSHEETDELEGATE_H - diff --git a/examples/itemviews/spreadsheet/spreadsheetitem.cpp b/examples/itemviews/spreadsheet/spreadsheetitem.cpp deleted file mode 100644 index 88f8afa325..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheetitem.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "spreadsheetitem.h" - -SpreadSheetItem::SpreadSheetItem() - : QTableWidgetItem(), isResolving(false) -{ -} - -SpreadSheetItem::SpreadSheetItem(const QString &text) - : QTableWidgetItem(text), isResolving(false) -{ -} - -QTableWidgetItem *SpreadSheetItem::clone() const -{ - SpreadSheetItem *item = new SpreadSheetItem(); - *item = *this; - return item; -} - -QVariant SpreadSheetItem::data(int role) const -{ - if (role == Qt::EditRole || role == Qt::StatusTipRole) - return formula(); - - if (role == Qt::DisplayRole) - return display(); - - QString t = display().toString(); - bool isNumber = false; - int number = t.toInt(&isNumber); - - if (role == Qt::TextColorRole) { - if (!isNumber) - return QVariant::fromValue(QColor(Qt::black)); - else if (number < 0) - return QVariant::fromValue(QColor(Qt::red)); - return QVariant::fromValue(QColor(Qt::blue)); - } - - if (role == Qt::TextAlignmentRole) - if (!t.isEmpty() && (t.at(0).isNumber() || t.at(0) == '-')) - return (int)(Qt::AlignRight | Qt::AlignVCenter); - - return QTableWidgetItem::data(role); - } - -void SpreadSheetItem::setData(int role, const QVariant &value) -{ - QTableWidgetItem::setData(role, value); - if (tableWidget()) - tableWidget()->viewport()->update(); -} - -QVariant SpreadSheetItem::display() const -{ - // avoid circular dependencies - if (isResolving) - return QVariant(); - - isResolving = true; - QVariant result = computeFormula(formula(), tableWidget(), this); - isResolving = false; - return result; -} - -QVariant SpreadSheetItem::computeFormula(const QString &formula, - const QTableWidget *widget, - const QTableWidgetItem *self) -{ - // check if the s tring is actually a formula or not - QStringList list = formula.split(' '); - if (list.isEmpty() || !widget) - return formula; // it is a normal string - - QString op = list.value(0).toLower(); - - int firstRow = -1; - int firstCol = -1; - int secondRow = -1; - int secondCol = -1; - - if (list.count() > 1) - decode_pos(list.value(1), &firstRow, &firstCol); - - if (list.count() > 2) - decode_pos(list.value(2), &secondRow, &secondCol); - - const QTableWidgetItem *start = widget->item(firstRow, firstCol); - const QTableWidgetItem *end = widget->item(secondRow, secondCol); - - int firstVal = start ? start->text().toInt() : 0; - int secondVal = end ? end->text().toInt() : 0; - - QVariant result; - if (op == "sum") { - int sum = 0; - for (int r = firstRow; r <= secondRow; ++r) { - for (int c = firstCol; c <= secondCol; ++c) { - const QTableWidgetItem *tableItem = widget->item(r, c); - if (tableItem && tableItem != self) - sum += tableItem->text().toInt(); - } - } - - result = sum; - } else if (op == "+") { - result = (firstVal + secondVal); - } else if (op == "-") { - result = (firstVal - secondVal); - } else if (op == "*") { - result = (firstVal * secondVal); - } else if (op == "/") { - if (secondVal == 0) - result = QString("nan"); - else - result = (firstVal / secondVal); - } else if (op == "=") { - if (start) - result = start->text(); - } else { - result = formula; - } - - return result; -} - diff --git a/examples/itemviews/spreadsheet/spreadsheetitem.h b/examples/itemviews/spreadsheet/spreadsheetitem.h deleted file mode 100644 index e61138c08b..0000000000 --- a/examples/itemviews/spreadsheet/spreadsheetitem.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SPREADSHEETITEM_H -#define SPREADSHEETITEM_H - -#include -#include -#include "spreadsheet.h" - -class SpreadSheetItem : public QTableWidgetItem -{ -public: - SpreadSheetItem(); - SpreadSheetItem(const QString &text); - - QTableWidgetItem *clone() const; - - QVariant data(int role) const; - void setData(int role, const QVariant &value); - QVariant display() const; - - inline QString formula() const - { return QTableWidgetItem::data(Qt::DisplayRole).toString(); } - - static QVariant computeFormula(const QString &formula, - const QTableWidget *widget, - const QTableWidgetItem *self = 0); - -private: - mutable bool isResolving; -}; - -#endif // SPREADSHEETITEM_H - diff --git a/examples/itemviews/stardelegate/main.cpp b/examples/itemviews/stardelegate/main.cpp deleted file mode 100644 index 3c988e0a8a..0000000000 --- a/examples/itemviews/stardelegate/main.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "stardelegate.h" -#include "stareditor.h" -#include "starrating.h" - -//! [0] -void populateTableWidget(QTableWidget *tableWidget) -{ - static const struct { - const char *title; - const char *genre; - const char *artist; - int rating; - } staticData[] = { -//! [0] //! [1] - { "Mass in B-Minor", "Baroque", "J.S. Bach", 5 }, -//! [1] - { "Three More Foxes", "Jazz", "Maynard Ferguson", 4 }, - { "Sex Bomb", "Pop", "Tom Jones", 3 }, - { "Barbie Girl", "Pop", "Aqua", 5 }, -//! [2] - { 0, 0, 0, 0 } -//! [2] //! [3] - }; -//! [3] //! [4] - - for (int row = 0; staticData[row].title != 0; ++row) { - QTableWidgetItem *item0 = new QTableWidgetItem(staticData[row].title); - QTableWidgetItem *item1 = new QTableWidgetItem(staticData[row].genre); - QTableWidgetItem *item2 = new QTableWidgetItem(staticData[row].artist); - QTableWidgetItem *item3 = new QTableWidgetItem; - item3->setData(0, - QVariant::fromValue(StarRating(staticData[row].rating))); - - tableWidget->setItem(row, 0, item0); - tableWidget->setItem(row, 1, item1); - tableWidget->setItem(row, 2, item2); - tableWidget->setItem(row, 3, item3); - } -} -//! [4] - -//! [5] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QTableWidget tableWidget(4, 4); - tableWidget.setItemDelegate(new StarDelegate); - tableWidget.setEditTriggers(QAbstractItemView::DoubleClicked - | QAbstractItemView::SelectedClicked); - tableWidget.setSelectionBehavior(QAbstractItemView::SelectRows); - - QStringList headerLabels; - headerLabels << "Title" << "Genre" << "Artist" << "Rating"; - tableWidget.setHorizontalHeaderLabels(headerLabels); - - populateTableWidget(&tableWidget); - - tableWidget.resizeColumnsToContents(); - tableWidget.resize(500, 300); - tableWidget.show(); - - return app.exec(); -} -//! [5] diff --git a/examples/itemviews/stardelegate/stardelegate.cpp b/examples/itemviews/stardelegate/stardelegate.cpp deleted file mode 100644 index 3032c20088..0000000000 --- a/examples/itemviews/stardelegate/stardelegate.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "stardelegate.h" -#include "stareditor.h" -#include "starrating.h" - -//! [0] -void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - if (index.data().canConvert()) { - StarRating starRating = qvariant_cast(index.data()); - - if (option.state & QStyle::State_Selected) - painter->fillRect(option.rect, option.palette.highlight()); - - starRating.paint(painter, option.rect, option.palette, - StarRating::ReadOnly); - } else { - QStyledItemDelegate::paint(painter, option, index); - } -//! [0] -} - -//! [1] -QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - if (index.data().canConvert()) { - StarRating starRating = qvariant_cast(index.data()); - return starRating.sizeHint(); - } else { - return QStyledItemDelegate::sizeHint(option, index); - } -} -//! [1] - -//! [2] -QWidget *StarDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem &option, - const QModelIndex &index) const - -{ - if (index.data().canConvert()) { - StarEditor *editor = new StarEditor(parent); - connect(editor, SIGNAL(editingFinished()), - this, SLOT(commitAndCloseEditor())); - return editor; - } else { - return QStyledItemDelegate::createEditor(parent, option, index); - } -} -//! [2] - -//! [3] -void StarDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - if (index.data().canConvert()) { - StarRating starRating = qvariant_cast(index.data()); - StarEditor *starEditor = qobject_cast(editor); - starEditor->setStarRating(starRating); - } else { - QStyledItemDelegate::setEditorData(editor, index); - } -} -//! [3] - -//! [4] -void StarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - if (index.data().canConvert()) { - StarEditor *starEditor = qobject_cast(editor); - model->setData(index, QVariant::fromValue(starEditor->starRating())); - } else { - QStyledItemDelegate::setModelData(editor, model, index); - } -} -//! [4] - -//! [5] -void StarDelegate::commitAndCloseEditor() -{ - StarEditor *editor = qobject_cast(sender()); - emit commitData(editor); - emit closeEditor(editor); -} -//! [5] diff --git a/examples/itemviews/stardelegate/stardelegate.desktop b/examples/itemviews/stardelegate/stardelegate.desktop deleted file mode 100644 index d508c3b286..0000000000 --- a/examples/itemviews/stardelegate/stardelegate.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Star Delegate -Exec=/opt/usr/bin/stardelegate -Icon=stardelegate -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/itemviews/stardelegate/stardelegate.h b/examples/itemviews/stardelegate/stardelegate.h deleted file mode 100644 index 6c53ab8833..0000000000 --- a/examples/itemviews/stardelegate/stardelegate.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 STARDELEGATE_H -#define STARDELEGATE_H - -#include - -//! [0] -class StarDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - StarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {} - - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const; - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; - -private slots: - void commitAndCloseEditor(); -}; -//! [0] - -#endif diff --git a/examples/itemviews/stardelegate/stardelegate.pro b/examples/itemviews/stardelegate/stardelegate.pro deleted file mode 100644 index 915c26a524..0000000000 --- a/examples/itemviews/stardelegate/stardelegate.pro +++ /dev/null @@ -1,17 +0,0 @@ -HEADERS = stardelegate.h \ - stareditor.h \ - starrating.h -SOURCES = main.cpp \ - stardelegate.cpp \ - stareditor.cpp \ - starrating.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/stardelegate -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/stardelegate -INSTALLS += target sources - - -QT += widgets -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/itemviews/stardelegate/stareditor.cpp b/examples/itemviews/stardelegate/stareditor.cpp deleted file mode 100644 index 795a748941..0000000000 --- a/examples/itemviews/stardelegate/stareditor.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "stareditor.h" -#include "starrating.h" - -//! [0] -StarEditor::StarEditor(QWidget *parent) - : QWidget(parent) -{ - setMouseTracking(true); - setAutoFillBackground(true); -} -//! [0] - -QSize StarEditor::sizeHint() const -{ - return myStarRating.sizeHint(); -} - -//! [1] -void StarEditor::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - myStarRating.paint(&painter, rect(), this->palette(), - StarRating::Editable); -} -//! [1] - -//! [2] -void StarEditor::mouseMoveEvent(QMouseEvent *event) -{ - int star = starAtPosition(event->x()); - - if (star != myStarRating.starCount() && star != -1) { - myStarRating.setStarCount(star); - update(); - } -} -//! [2] - -//! [3] -void StarEditor::mouseReleaseEvent(QMouseEvent * /* event */) -{ - emit editingFinished(); -} -//! [3] - -//! [4] -int StarEditor::starAtPosition(int x) -{ - int star = (x / (myStarRating.sizeHint().width() - / myStarRating.maxStarCount())) + 1; - if (star <= 0 || star > myStarRating.maxStarCount()) - return -1; - - return star; -} -//! [4] diff --git a/examples/itemviews/stardelegate/stareditor.h b/examples/itemviews/stardelegate/stareditor.h deleted file mode 100644 index 88bee7d28d..0000000000 --- a/examples/itemviews/stardelegate/stareditor.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 STAREDITOR_H -#define STAREDITOR_H - -#include - -#include "starrating.h" - -//! [0] -class StarEditor : public QWidget -{ - Q_OBJECT - -public: - StarEditor(QWidget *parent = 0); - - QSize sizeHint() const; - void setStarRating(const StarRating &starRating) { - myStarRating = starRating; - } - StarRating starRating() { return myStarRating; } - -signals: - void editingFinished(); - -protected: - void paintEvent(QPaintEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - -private: - int starAtPosition(int x); - - StarRating myStarRating; -}; -//! [0] - -#endif diff --git a/examples/itemviews/stardelegate/starrating.cpp b/examples/itemviews/stardelegate/starrating.cpp deleted file mode 100644 index cea9330db2..0000000000 --- a/examples/itemviews/stardelegate/starrating.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#include "starrating.h" - -const int PaintingScaleFactor = 20; - -//! [0] -StarRating::StarRating(int starCount, int maxStarCount) -{ - myStarCount = starCount; - myMaxStarCount = maxStarCount; - - starPolygon << QPointF(1.0, 0.5); - for (int i = 1; i < 5; ++i) - starPolygon << QPointF(0.5 + 0.5 * cos(0.8 * i * 3.14), - 0.5 + 0.5 * sin(0.8 * i * 3.14)); - - diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4) - << QPointF(0.6, 0.5) << QPointF(0.5, 0.6) - << QPointF(0.4, 0.5); -} -//! [0] - -//! [1] -QSize StarRating::sizeHint() const -{ - return PaintingScaleFactor * QSize(myMaxStarCount, 1); -} -//! [1] - -//! [2] -void StarRating::paint(QPainter *painter, const QRect &rect, - const QPalette &palette, EditMode mode) const -{ - painter->save(); - - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(Qt::NoPen); - - if (mode == Editable) { - painter->setBrush(palette.highlight()); - } else { - painter->setBrush(palette.foreground()); - } - - int yOffset = (rect.height() - PaintingScaleFactor) / 2; - painter->translate(rect.x(), rect.y() + yOffset); - painter->scale(PaintingScaleFactor, PaintingScaleFactor); - - for (int i = 0; i < myMaxStarCount; ++i) { - if (i < myStarCount) { - painter->drawPolygon(starPolygon, Qt::WindingFill); - } else if (mode == Editable) { - painter->drawPolygon(diamondPolygon, Qt::WindingFill); - } - painter->translate(1.0, 0.0); - } - - painter->restore(); -} -//! [2] diff --git a/examples/itemviews/stardelegate/starrating.h b/examples/itemviews/stardelegate/starrating.h deleted file mode 100644 index 04fae2509a..0000000000 --- a/examples/itemviews/stardelegate/starrating.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 STARRATING_H -#define STARRATING_H - -#include -#include -#include - -//! [0] -class StarRating -{ -public: - enum EditMode { Editable, ReadOnly }; - - StarRating(int starCount = 1, int maxStarCount = 5); - - void paint(QPainter *painter, const QRect &rect, - const QPalette &palette, EditMode mode) const; - QSize sizeHint() const; - int starCount() const { return myStarCount; } - int maxStarCount() const { return myMaxStarCount; } - void setStarCount(int starCount) { myStarCount = starCount; } - void setMaxStarCount(int maxStarCount) { myMaxStarCount = maxStarCount; } - -private: - QPolygonF starPolygon; - QPolygonF diamondPolygon; - int myStarCount; - int myMaxStarCount; -}; -//! [0] - -//! [1] -Q_DECLARE_METATYPE(StarRating) -//! [1] - -#endif diff --git a/examples/layouts/README b/examples/layouts/README deleted file mode 100644 index 589400280d..0000000000 --- a/examples/layouts/README +++ /dev/null @@ -1,10 +0,0 @@ -Qt uses a layout-based approach to widget management. Widgets are arranged in -the optimal positions in windows based on simple layout rules, leading to a -consistent look and feel. - -Custom layouts can be used to provide more control over the positions and -sizes of child widgets. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/layouts/basiclayouts/basiclayouts.desktop b/examples/layouts/basiclayouts/basiclayouts.desktop deleted file mode 100644 index 6c612eed09..0000000000 --- a/examples/layouts/basiclayouts/basiclayouts.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Basic Layouts -Exec=/opt/usr/bin/basiclayouts -Icon=basiclayouts -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/layouts/basiclayouts/basiclayouts.pro b/examples/layouts/basiclayouts/basiclayouts.pro deleted file mode 100644 index b2c4ad896f..0000000000 --- a/examples/layouts/basiclayouts/basiclayouts.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = dialog.h -SOURCES = dialog.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/basiclayouts -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/basiclayouts -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/layouts/basiclayouts/dialog.cpp b/examples/layouts/basiclayouts/dialog.cpp deleted file mode 100644 index ca8ab60923..0000000000 --- a/examples/layouts/basiclayouts/dialog.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -//! [0] -Dialog::Dialog() -{ - createMenu(); - createHorizontalGroupBox(); - createGridGroupBox(); - createFormGroupBox(); -//! [0] - -//! [1] - bigEditor = new QTextEdit; - bigEditor->setPlainText(tr("This widget takes up all the remaining space " - "in the top-level layout.")); - - buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok - | QDialogButtonBox::Cancel); - - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); -//! [1] - -//! [2] - QVBoxLayout *mainLayout = new QVBoxLayout; -//! [2] //! [3] - mainLayout->setMenuBar(menuBar); -//! [3] //! [4] - mainLayout->addWidget(horizontalGroupBox); - mainLayout->addWidget(gridGroupBox); - mainLayout->addWidget(formGroupBox); - mainLayout->addWidget(bigEditor); - mainLayout->addWidget(buttonBox); -//! [4] //! [5] - setLayout(mainLayout); - - setWindowTitle(tr("Basic Layouts")); -} -//! [5] - -//! [6] -void Dialog::createMenu() -{ - menuBar = new QMenuBar; - - fileMenu = new QMenu(tr("&File"), this); - exitAction = fileMenu->addAction(tr("E&xit")); - menuBar->addMenu(fileMenu); - - connect(exitAction, SIGNAL(triggered()), this, SLOT(accept())); -} -//! [6] - -//! [7] -void Dialog::createHorizontalGroupBox() -{ - horizontalGroupBox = new QGroupBox(tr("Horizontal layout")); - QHBoxLayout *layout = new QHBoxLayout; - - for (int i = 0; i < NumButtons; ++i) { - buttons[i] = new QPushButton(tr("Button %1").arg(i + 1)); - layout->addWidget(buttons[i]); - } - horizontalGroupBox->setLayout(layout); -} -//! [7] - -//! [8] -void Dialog::createGridGroupBox() -{ - gridGroupBox = new QGroupBox(tr("Grid layout")); -//! [8] - QGridLayout *layout = new QGridLayout; - -//! [9] - for (int i = 0; i < NumGridRows; ++i) { - labels[i] = new QLabel(tr("Line %1:").arg(i + 1)); - lineEdits[i] = new QLineEdit; - layout->addWidget(labels[i], i + 1, 0); - layout->addWidget(lineEdits[i], i + 1, 1); - } - -//! [9] //! [10] - smallEditor = new QTextEdit; - smallEditor->setPlainText(tr("This widget takes up about two thirds of the " - "grid layout.")); - layout->addWidget(smallEditor, 0, 2, 4, 1); -//! [10] - -//! [11] - layout->setColumnStretch(1, 10); - layout->setColumnStretch(2, 20); - gridGroupBox->setLayout(layout); -} -//! [11] - -//! [12] -void Dialog::createFormGroupBox() -{ - formGroupBox = new QGroupBox(tr("Form layout")); - QFormLayout *layout = new QFormLayout; - layout->addRow(new QLabel(tr("Line 1:")), new QLineEdit); - layout->addRow(new QLabel(tr("Line 2, long text:")), new QComboBox); - layout->addRow(new QLabel(tr("Line 3:")), new QSpinBox); - formGroupBox->setLayout(layout); -} -//! [12] diff --git a/examples/layouts/basiclayouts/dialog.h b/examples/layouts/basiclayouts/dialog.h deleted file mode 100644 index 1d18a683ec..0000000000 --- a/examples/layouts/basiclayouts/dialog.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIALOG_H -#define DIALOG_H - -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QDialogButtonBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QMenu; -class QMenuBar; -class QPushButton; -class QTextEdit; -QT_END_NAMESPACE - -//! [0] -class Dialog : public QDialog -{ - Q_OBJECT - -public: - Dialog(); - -private: - void createMenu(); - void createHorizontalGroupBox(); - void createGridGroupBox(); - void createFormGroupBox(); - - enum { NumGridRows = 3, NumButtons = 4 }; - - QMenuBar *menuBar; - QGroupBox *horizontalGroupBox; - QGroupBox *gridGroupBox; - QGroupBox *formGroupBox; - QTextEdit *smallEditor; - QTextEdit *bigEditor; - QLabel *labels[NumGridRows]; - QLineEdit *lineEdits[NumGridRows]; - QPushButton *buttons[NumButtons]; - QDialogButtonBox *buttonBox; - - QMenu *fileMenu; - QAction *exitAction; -}; -//! [0] - -#endif diff --git a/examples/layouts/basiclayouts/main.cpp b/examples/layouts/basiclayouts/main.cpp deleted file mode 100644 index fd68d43b72..0000000000 --- a/examples/layouts/basiclayouts/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Dialog dialog; - dialog.show(); - - return app.exec(); -} diff --git a/examples/layouts/borderlayout/borderlayout.cpp b/examples/layouts/borderlayout/borderlayout.cpp deleted file mode 100644 index fd08a32fe1..0000000000 --- a/examples/layouts/borderlayout/borderlayout.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "borderlayout.h" - -BorderLayout::BorderLayout(QWidget *parent, int margin, int spacing) - : QLayout(parent) -{ - setMargin(margin); - setSpacing(spacing); -} - -BorderLayout::BorderLayout(int spacing) -{ - setSpacing(spacing); -} - - -BorderLayout::~BorderLayout() -{ - QLayoutItem *l; - while ((l = takeAt(0))) - delete l; -} - -void BorderLayout::addItem(QLayoutItem *item) -{ - add(item, West); -} - -void BorderLayout::addWidget(QWidget *widget, Position position) -{ - add(new QWidgetItem(widget), position); -} - -Qt::Orientations BorderLayout::expandingDirections() const -{ - return Qt::Horizontal | Qt::Vertical; -} - -bool BorderLayout::hasHeightForWidth() const -{ - return false; -} - -int BorderLayout::count() const -{ - return list.size(); -} - -QLayoutItem *BorderLayout::itemAt(int index) const -{ - ItemWrapper *wrapper = list.value(index); - if (wrapper) - return wrapper->item; - else - return 0; -} - -QSize BorderLayout::minimumSize() const -{ - return calculateSize(MinimumSize); -} - -void BorderLayout::setGeometry(const QRect &rect) -{ - ItemWrapper *center = 0; - int eastWidth = 0; - int westWidth = 0; - int northHeight = 0; - int southHeight = 0; - int centerHeight = 0; - int i; - - QLayout::setGeometry(rect); - - for (i = 0; i < list.size(); ++i) { - ItemWrapper *wrapper = list.at(i); - QLayoutItem *item = wrapper->item; - Position position = wrapper->position; - - if (position == North) { - item->setGeometry(QRect(rect.x(), northHeight, rect.width(), - item->sizeHint().height())); - - northHeight += item->geometry().height() + spacing(); - } else if (position == South) { - item->setGeometry(QRect(item->geometry().x(), - item->geometry().y(), rect.width(), - item->sizeHint().height())); - - southHeight += item->geometry().height() + spacing(); - - item->setGeometry(QRect(rect.x(), - rect.y() + rect.height() - southHeight + spacing(), - item->geometry().width(), - item->geometry().height())); - } else if (position == Center) { - center = wrapper; - } - } - - centerHeight = rect.height() - northHeight - southHeight; - - for (i = 0; i < list.size(); ++i) { - ItemWrapper *wrapper = list.at(i); - QLayoutItem *item = wrapper->item; - Position position = wrapper->position; - - if (position == West) { - item->setGeometry(QRect(rect.x() + westWidth, northHeight, - item->sizeHint().width(), centerHeight)); - - westWidth += item->geometry().width() + spacing(); - } else if (position == East) { - item->setGeometry(QRect(item->geometry().x(), item->geometry().y(), - item->sizeHint().width(), centerHeight)); - - eastWidth += item->geometry().width() + spacing(); - - item->setGeometry(QRect( - rect.x() + rect.width() - eastWidth + spacing(), - northHeight, item->geometry().width(), - item->geometry().height())); - } - } - - if (center) - center->item->setGeometry(QRect(westWidth, northHeight, - rect.width() - eastWidth - westWidth, - centerHeight)); -} - -QSize BorderLayout::sizeHint() const -{ - return calculateSize(SizeHint); -} - -QLayoutItem *BorderLayout::takeAt(int index) -{ - if (index >= 0 && index < list.size()) { - ItemWrapper *layoutStruct = list.takeAt(index); - return layoutStruct->item; - } - return 0; -} - -void BorderLayout::add(QLayoutItem *item, Position position) -{ - list.append(new ItemWrapper(item, position)); -} - -QSize BorderLayout::calculateSize(SizeType sizeType) const -{ - QSize totalSize; - - for (int i = 0; i < list.size(); ++i) { - ItemWrapper *wrapper = list.at(i); - Position position = wrapper->position; - QSize itemSize; - - if (sizeType == MinimumSize) - itemSize = wrapper->item->minimumSize(); - else // (sizeType == SizeHint) - itemSize = wrapper->item->sizeHint(); - - if (position == North || position == South || position == Center) - totalSize.rheight() += itemSize.height(); - - if (position == West || position == East || position == Center) - totalSize.rwidth() += itemSize.width(); - } - return totalSize; -} diff --git a/examples/layouts/borderlayout/borderlayout.desktop b/examples/layouts/borderlayout/borderlayout.desktop deleted file mode 100644 index 3fd0641f1c..0000000000 --- a/examples/layouts/borderlayout/borderlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Border Layout -Exec=/opt/usr/bin/borderlayout -Icon=borderlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/layouts/borderlayout/borderlayout.h b/examples/layouts/borderlayout/borderlayout.h deleted file mode 100644 index 937517dc17..0000000000 --- a/examples/layouts/borderlayout/borderlayout.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 BORDERLAYOUT_H -#define BORDERLAYOUT_H - -#include -#include -#include - -class BorderLayout : public QLayout -{ -public: - enum Position { West, North, South, East, Center }; - - BorderLayout(QWidget *parent, int margin = 0, int spacing = -1); - BorderLayout(int spacing = -1); - ~BorderLayout(); - - void addItem(QLayoutItem *item); - void addWidget(QWidget *widget, Position position); - Qt::Orientations expandingDirections() const; - bool hasHeightForWidth() const; - int count() const; - QLayoutItem *itemAt(int index) const; - QSize minimumSize() const; - void setGeometry(const QRect &rect); - QSize sizeHint() const; - QLayoutItem *takeAt(int index); - - void add(QLayoutItem *item, Position position); - -private: - struct ItemWrapper - { - ItemWrapper(QLayoutItem *i, Position p) { - item = i; - position = p; - } - - QLayoutItem *item; - Position position; - }; - - enum SizeType { MinimumSize, SizeHint }; - QSize calculateSize(SizeType sizeType) const; - - QList list; -}; - -#endif diff --git a/examples/layouts/borderlayout/borderlayout.pro b/examples/layouts/borderlayout/borderlayout.pro deleted file mode 100644 index 6727af60d7..0000000000 --- a/examples/layouts/borderlayout/borderlayout.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = borderlayout.h \ - window.h -SOURCES = borderlayout.cpp \ - main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/borderlayout -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/borderlayout -INSTALLS += target sources - -QT += widgets diff --git a/examples/layouts/borderlayout/main.cpp b/examples/layouts/borderlayout/main.cpp deleted file mode 100644 index dcbf1c0449..0000000000 --- a/examples/layouts/borderlayout/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/layouts/borderlayout/window.cpp b/examples/layouts/borderlayout/window.cpp deleted file mode 100644 index 73ad86a826..0000000000 --- a/examples/layouts/borderlayout/window.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "borderlayout.h" -#include "window.h" - -Window::Window() -{ - QTextBrowser *centralWidget = new QTextBrowser; - centralWidget->setPlainText(tr("Central widget")); - - BorderLayout *layout = new BorderLayout; - layout->addWidget(centralWidget, BorderLayout::Center); - layout->addWidget(createLabel("North"), BorderLayout::North); - layout->addWidget(createLabel("West"), BorderLayout::West); - layout->addWidget(createLabel("East 1"), BorderLayout::East); - layout->addWidget(createLabel("East 2") , BorderLayout::East); - layout->addWidget(createLabel("South"), BorderLayout::South); - setLayout(layout); - - setWindowTitle(tr("Border Layout")); -} - -QLabel *Window::createLabel(const QString &text) -{ - QLabel *label = new QLabel(text); - label->setFrameStyle(QFrame::Box | QFrame::Raised); - return label; -} diff --git a/examples/layouts/borderlayout/window.h b/examples/layouts/borderlayout/window.h deleted file mode 100644 index 3db08e1ab3..0000000000 --- a/examples/layouts/borderlayout/window.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QLabel; -QT_END_NAMESPACE - -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -private: - QLabel *createLabel(const QString &text); -}; - -#endif diff --git a/examples/layouts/dynamiclayouts/dialog.cpp b/examples/layouts/dynamiclayouts/dialog.cpp deleted file mode 100644 index e3ebb66944..0000000000 --- a/examples/layouts/dynamiclayouts/dialog.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -Dialog::Dialog(QWidget *parent) - : QDialog(parent) -{ - createRotableGroupBox(); - createOptionsGroupBox(); - createButtonBox(); - - mainLayout = new QGridLayout; - mainLayout->addWidget(rotableGroupBox, 0, 0); - mainLayout->addWidget(optionsGroupBox, 1, 0); - mainLayout->addWidget(buttonBox, 2, 0); - setLayout(mainLayout); - - mainLayout->setSizeConstraint(QLayout::SetMinimumSize); - - setWindowTitle(tr("Dynamic Layouts")); -} - -void Dialog::buttonsOrientationChanged(int index) -{ - mainLayout->setSizeConstraint(QLayout::SetNoConstraint); - setMinimumSize(0, 0); - - Qt::Orientation orientation = Qt::Orientation( - buttonsOrientationComboBox->itemData(index).toInt()); - - if (orientation == buttonBox->orientation()) - return; - - mainLayout->removeWidget(buttonBox); - - int spacing = mainLayout->spacing(); - - QSize oldSizeHint = buttonBox->sizeHint() + QSize(spacing, spacing); - buttonBox->setOrientation(orientation); - QSize newSizeHint = buttonBox->sizeHint() + QSize(spacing, spacing); - - if (orientation == Qt::Horizontal) { - mainLayout->addWidget(buttonBox, 2, 0); - resize(size() + QSize(-oldSizeHint.width(), newSizeHint.height())); - } else { - mainLayout->addWidget(buttonBox, 0, 3, 2, 1); - resize(size() + QSize(newSizeHint.width(), -oldSizeHint.height())); - } - - mainLayout->setSizeConstraint(QLayout::SetDefaultConstraint); -} - -void Dialog::rotateWidgets() -{ - Q_ASSERT(rotableWidgets.count() % 2 == 0); - - foreach (QWidget *widget, rotableWidgets) - rotableLayout->removeWidget(widget); - - rotableWidgets.enqueue(rotableWidgets.dequeue()); - - const int n = rotableWidgets.count(); - for (int i = 0; i < n / 2; ++i) { - rotableLayout->addWidget(rotableWidgets[n - i - 1], 0, i); - rotableLayout->addWidget(rotableWidgets[i], 1, i); - } -} - -void Dialog::help() -{ - QMessageBox::information(this, tr("Dynamic Layouts Help"), - tr("This example shows how to change layouts " - "dynamically.")); -} - -void Dialog::createRotableGroupBox() -{ - rotableGroupBox = new QGroupBox(tr("Rotable Widgets")); - - rotableWidgets.enqueue(new QSpinBox); - rotableWidgets.enqueue(new QSlider); - rotableWidgets.enqueue(new QDial); - rotableWidgets.enqueue(new QProgressBar); - - int n = rotableWidgets.count(); - for (int i = 0; i < n; ++i) { - connect(rotableWidgets[i], SIGNAL(valueChanged(int)), - rotableWidgets[(i + 1) % n], SLOT(setValue(int))); - } - - rotableLayout = new QGridLayout; - rotableGroupBox->setLayout(rotableLayout); - - rotateWidgets(); -} - -void Dialog::createOptionsGroupBox() -{ - optionsGroupBox = new QGroupBox(tr("Options")); - - buttonsOrientationLabel = new QLabel(tr("Orientation of buttons:")); - - buttonsOrientationComboBox = new QComboBox; - buttonsOrientationComboBox->addItem(tr("Horizontal"), Qt::Horizontal); - buttonsOrientationComboBox->addItem(tr("Vertical"), Qt::Vertical); - - connect(buttonsOrientationComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(buttonsOrientationChanged(int))); - - optionsLayout = new QGridLayout; - optionsLayout->addWidget(buttonsOrientationLabel, 0, 0); - optionsLayout->addWidget(buttonsOrientationComboBox, 0, 1); - optionsLayout->setColumnStretch(2, 1); - optionsGroupBox->setLayout(optionsLayout); -} - -void Dialog::createButtonBox() -{ - buttonBox = new QDialogButtonBox; - - closeButton = buttonBox->addButton(QDialogButtonBox::Close); - helpButton = buttonBox->addButton(QDialogButtonBox::Help); - rotateWidgetsButton = buttonBox->addButton(tr("Rotate &Widgets"), - QDialogButtonBox::ActionRole); - - connect(rotateWidgetsButton, SIGNAL(clicked()), this, SLOT(rotateWidgets())); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); - connect(helpButton, SIGNAL(clicked()), this, SLOT(help())); -} diff --git a/examples/layouts/dynamiclayouts/dialog.h b/examples/layouts/dynamiclayouts/dialog.h deleted file mode 100644 index f8321abad4..0000000000 --- a/examples/layouts/dynamiclayouts/dialog.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DIALOG_H -#define DIALOG_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QComboBox; -class QDialogButtonBox; -class QGridLayout; -class QGroupBox; -class QLabel; -class QPushButton; -QT_END_NAMESPACE - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - Dialog(QWidget *parent = 0); - -private slots: - void buttonsOrientationChanged(int index); - void rotateWidgets(); - void help(); - -private: - void createRotableGroupBox(); - void createOptionsGroupBox(); - void createButtonBox(); - - QGroupBox *rotableGroupBox; - QQueue rotableWidgets; - - QGroupBox *optionsGroupBox; - QLabel *buttonsOrientationLabel; - QComboBox *buttonsOrientationComboBox; - - QDialogButtonBox *buttonBox; - QPushButton *closeButton; - QPushButton *helpButton; - QPushButton *rotateWidgetsButton; - - QGridLayout *mainLayout; - QGridLayout *rotableLayout; - QGridLayout *optionsLayout; -}; - -#endif diff --git a/examples/layouts/dynamiclayouts/dynamiclayouts.desktop b/examples/layouts/dynamiclayouts/dynamiclayouts.desktop deleted file mode 100644 index 482286bfb8..0000000000 --- a/examples/layouts/dynamiclayouts/dynamiclayouts.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Dynamic Layouts -Exec=/opt/usr/bin/dynamiclayouts -Icon=dynamiclayouts -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/layouts/dynamiclayouts/dynamiclayouts.pro b/examples/layouts/dynamiclayouts/dynamiclayouts.pro deleted file mode 100644 index 3cc4c084a5..0000000000 --- a/examples/layouts/dynamiclayouts/dynamiclayouts.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = dialog.h -SOURCES = dialog.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/dynamiclayouts -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/dynamiclayouts -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/layouts/dynamiclayouts/main.cpp b/examples/layouts/dynamiclayouts/main.cpp deleted file mode 100644 index b4dd37a9cf..0000000000 --- a/examples/layouts/dynamiclayouts/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "dialog.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Dialog dialog; - dialog.show(); - return app.exec(); -} diff --git a/examples/layouts/flowlayout/flowlayout.cpp b/examples/layouts/flowlayout/flowlayout.cpp deleted file mode 100644 index b7a62c8f03..0000000000 --- a/examples/layouts/flowlayout/flowlayout.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "flowlayout.h" -//! [1] -FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) - : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) -{ - setContentsMargins(margin, margin, margin, margin); -} - -FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) - : m_hSpace(hSpacing), m_vSpace(vSpacing) -{ - setContentsMargins(margin, margin, margin, margin); -} -//! [1] - -//! [2] -FlowLayout::~FlowLayout() -{ - QLayoutItem *item; - while ((item = takeAt(0))) - delete item; -} -//! [2] - -//! [3] -void FlowLayout::addItem(QLayoutItem *item) -{ - itemList.append(item); -} -//! [3] - -//! [4] -int FlowLayout::horizontalSpacing() const -{ - if (m_hSpace >= 0) { - return m_hSpace; - } else { - return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); - } -} - -int FlowLayout::verticalSpacing() const -{ - if (m_vSpace >= 0) { - return m_vSpace; - } else { - return smartSpacing(QStyle::PM_LayoutVerticalSpacing); - } -} -//! [4] - -//! [5] -int FlowLayout::count() const -{ - return itemList.size(); -} - -QLayoutItem *FlowLayout::itemAt(int index) const -{ - return itemList.value(index); -} - -QLayoutItem *FlowLayout::takeAt(int index) -{ - if (index >= 0 && index < itemList.size()) - return itemList.takeAt(index); - else - return 0; -} -//! [5] - -//! [6] -Qt::Orientations FlowLayout::expandingDirections() const -{ - return 0; -} -//! [6] - -//! [7] -bool FlowLayout::hasHeightForWidth() const -{ - return true; -} - -int FlowLayout::heightForWidth(int width) const -{ - int height = doLayout(QRect(0, 0, width, 0), true); - return height; -} -//! [7] - -//! [8] -void FlowLayout::setGeometry(const QRect &rect) -{ - QLayout::setGeometry(rect); - doLayout(rect, false); -} - -QSize FlowLayout::sizeHint() const -{ - return minimumSize(); -} - -QSize FlowLayout::minimumSize() const -{ - QSize size; - QLayoutItem *item; - foreach (item, itemList) - size = size.expandedTo(item->minimumSize()); - - size += QSize(2*margin(), 2*margin()); - return size; -} -//! [8] - -//! [9] -int FlowLayout::doLayout(const QRect &rect, bool testOnly) const -{ - int left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); - int x = effectiveRect.x(); - int y = effectiveRect.y(); - int lineHeight = 0; -//! [9] - -//! [10] - QLayoutItem *item; - foreach (item, itemList) { - QWidget *wid = item->widget(); - int spaceX = horizontalSpacing(); - if (spaceX == -1) - spaceX = wid->style()->layoutSpacing( - QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); - int spaceY = verticalSpacing(); - if (spaceY == -1) - spaceY = wid->style()->layoutSpacing( - QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); -//! [10] -//! [11] - int nextX = x + item->sizeHint().width() + spaceX; - if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { - x = effectiveRect.x(); - y = y + lineHeight + spaceY; - nextX = x + item->sizeHint().width() + spaceX; - lineHeight = 0; - } - - if (!testOnly) - item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); - - x = nextX; - lineHeight = qMax(lineHeight, item->sizeHint().height()); - } - return y + lineHeight - rect.y() + bottom; -} -//! [11] -//! [12] -int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const -{ - QObject *parent = this->parent(); - if (!parent) { - return -1; - } else if (parent->isWidgetType()) { - QWidget *pw = static_cast(parent); - return pw->style()->pixelMetric(pm, 0, pw); - } else { - return static_cast(parent)->spacing(); - } -} -//! [12] diff --git a/examples/layouts/flowlayout/flowlayout.desktop b/examples/layouts/flowlayout/flowlayout.desktop deleted file mode 100644 index 54ea3b0290..0000000000 --- a/examples/layouts/flowlayout/flowlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Flow Layout -Exec=/opt/usr/bin/flowlayout -Icon=flowlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/layouts/flowlayout/flowlayout.h b/examples/layouts/flowlayout/flowlayout.h deleted file mode 100644 index 2a27f93772..0000000000 --- a/examples/layouts/flowlayout/flowlayout.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 FLOWLAYOUT_H -#define FLOWLAYOUT_H - -#include -#include -#include -//! [0] -class FlowLayout : public QLayout -{ -public: - FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); - FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); - ~FlowLayout(); - - void addItem(QLayoutItem *item); - int horizontalSpacing() const; - int verticalSpacing() const; - Qt::Orientations expandingDirections() const; - bool hasHeightForWidth() const; - int heightForWidth(int) const; - int count() const; - QLayoutItem *itemAt(int index) const; - QSize minimumSize() const; - void setGeometry(const QRect &rect); - QSize sizeHint() const; - QLayoutItem *takeAt(int index); - -private: - int doLayout(const QRect &rect, bool testOnly) const; - int smartSpacing(QStyle::PixelMetric pm) const; - - QList itemList; - int m_hSpace; - int m_vSpace; -}; -//! [0] - -#endif diff --git a/examples/layouts/flowlayout/flowlayout.pro b/examples/layouts/flowlayout/flowlayout.pro deleted file mode 100644 index 4ac0a43c26..0000000000 --- a/examples/layouts/flowlayout/flowlayout.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = flowlayout.h \ - window.h -SOURCES = flowlayout.cpp \ - main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/flowlayout -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/flowlayout -INSTALLS += target sources - -QT += widgets diff --git a/examples/layouts/flowlayout/main.cpp b/examples/layouts/flowlayout/main.cpp deleted file mode 100644 index dcbf1c0449..0000000000 --- a/examples/layouts/flowlayout/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/layouts/flowlayout/window.cpp b/examples/layouts/flowlayout/window.cpp deleted file mode 100644 index 8a7dd32eac..0000000000 --- a/examples/layouts/flowlayout/window.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "flowlayout.h" -#include "window.h" -//! [1] -Window::Window() -{ - FlowLayout *flowLayout = new FlowLayout; - - flowLayout->addWidget(new QPushButton(tr("Short"))); - flowLayout->addWidget(new QPushButton(tr("Longer"))); - flowLayout->addWidget(new QPushButton(tr("Different text"))); - flowLayout->addWidget(new QPushButton(tr("More text"))); - flowLayout->addWidget(new QPushButton(tr("Even longer button text"))); - setLayout(flowLayout); - - setWindowTitle(tr("Flow Layout")); -} -//! [1] diff --git a/examples/layouts/flowlayout/window.h b/examples/layouts/flowlayout/window.h deleted file mode 100644 index e29813a91a..0000000000 --- a/examples/layouts/flowlayout/window.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QLabel; -QT_END_NAMESPACE -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); -}; -//! [0] - -#endif diff --git a/examples/layouts/layouts.pro b/examples/layouts/layouts.pro deleted file mode 100644 index 8299052d4f..0000000000 --- a/examples/layouts/layouts.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = basiclayouts \ - borderlayout \ - dynamiclayouts \ - flowlayout - -# install -sources.files = README *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts -INSTALLS += sources - -QT += widgets diff --git a/examples/mainwindows/README b/examples/mainwindows/README deleted file mode 100644 index b63adee6e3..0000000000 --- a/examples/mainwindows/README +++ /dev/null @@ -1,9 +0,0 @@ -All the standard features of application main windows are provided by Qt. - -Main windows can have pull down menus, tool bars, and dock windows. These -separate forms of user input are unified in an integrated action system that -also supports keyboard shortcuts and accelerator keys in menu items. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/mainwindows/application/application.desktop b/examples/mainwindows/application/application.desktop deleted file mode 100644 index b6fab1f1fe..0000000000 --- a/examples/mainwindows/application/application.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Application -Exec=/opt/usr/bin/application -Icon=application -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/mainwindows/application/application.pro b/examples/mainwindows/application/application.pro deleted file mode 100644 index ef866a6d5f..0000000000 --- a/examples/mainwindows/application/application.pro +++ /dev/null @@ -1,16 +0,0 @@ -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp -#! [0] -RESOURCES = application.qrc -#! [0] - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/application -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS application.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/application -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/mainwindows/application/application.qrc b/examples/mainwindows/application/application.qrc deleted file mode 100644 index 0a776fab4d..0000000000 --- a/examples/mainwindows/application/application.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - images/copy.png - images/cut.png - images/new.png - images/open.png - images/paste.png - images/save.png - - diff --git a/examples/mainwindows/application/images/copy.png b/examples/mainwindows/application/images/copy.png deleted file mode 100644 index 2aeb28288f..0000000000 Binary files a/examples/mainwindows/application/images/copy.png and /dev/null differ diff --git a/examples/mainwindows/application/images/cut.png b/examples/mainwindows/application/images/cut.png deleted file mode 100644 index 54638e9386..0000000000 Binary files a/examples/mainwindows/application/images/cut.png and /dev/null differ diff --git a/examples/mainwindows/application/images/new.png b/examples/mainwindows/application/images/new.png deleted file mode 100644 index 12131b0100..0000000000 Binary files a/examples/mainwindows/application/images/new.png and /dev/null differ diff --git a/examples/mainwindows/application/images/open.png b/examples/mainwindows/application/images/open.png deleted file mode 100644 index 45fa2883a7..0000000000 Binary files a/examples/mainwindows/application/images/open.png and /dev/null differ diff --git a/examples/mainwindows/application/images/paste.png b/examples/mainwindows/application/images/paste.png deleted file mode 100644 index c14425cad1..0000000000 Binary files a/examples/mainwindows/application/images/paste.png and /dev/null differ diff --git a/examples/mainwindows/application/images/save.png b/examples/mainwindows/application/images/save.png deleted file mode 100644 index daba865faf..0000000000 Binary files a/examples/mainwindows/application/images/save.png and /dev/null differ diff --git a/examples/mainwindows/application/main.cpp b/examples/mainwindows/application/main.cpp deleted file mode 100644 index 9ff6799574..0000000000 --- a/examples/mainwindows/application/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -//! [0] -#include - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(application); - - QApplication app(argc, argv); - app.setOrganizationName("Trolltech"); - app.setApplicationName("Application Example"); - MainWindow mainWin; - mainWin.show(); - return app.exec(); -} -//! [0] diff --git a/examples/mainwindows/application/mainwindow.cpp b/examples/mainwindows/application/mainwindow.cpp deleted file mode 100644 index 8f60353da9..0000000000 --- a/examples/mainwindows/application/mainwindow.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -//! [0] -#include - -#include "mainwindow.h" -//! [0] - -//! [1] -MainWindow::MainWindow() -//! [1] //! [2] -{ - textEdit = new QPlainTextEdit; - setCentralWidget(textEdit); - - createActions(); - createMenus(); - createToolBars(); - createStatusBar(); - - readSettings(); - - connect(textEdit->document(), SIGNAL(contentsChanged()), - this, SLOT(documentWasModified())); - - setCurrentFile(""); - setUnifiedTitleAndToolBarOnMac(true); -} -//! [2] - -//! [3] -void MainWindow::closeEvent(QCloseEvent *event) -//! [3] //! [4] -{ - if (maybeSave()) { - writeSettings(); - event->accept(); - } else { - event->ignore(); - } -} -//! [4] - -//! [5] -void MainWindow::newFile() -//! [5] //! [6] -{ - if (maybeSave()) { - textEdit->clear(); - setCurrentFile(""); - } -} -//! [6] - -//! [7] -void MainWindow::open() -//! [7] //! [8] -{ - if (maybeSave()) { - QString fileName = QFileDialog::getOpenFileName(this); - if (!fileName.isEmpty()) - loadFile(fileName); - } -} -//! [8] - -//! [9] -bool MainWindow::save() -//! [9] //! [10] -{ - if (curFile.isEmpty()) { - return saveAs(); - } else { - return saveFile(curFile); - } -} -//! [10] - -//! [11] -bool MainWindow::saveAs() -//! [11] //! [12] -{ - QString fileName = QFileDialog::getSaveFileName(this); - if (fileName.isEmpty()) - return false; - - return saveFile(fileName); -} -//! [12] - -//! [13] -void MainWindow::about() -//! [13] //! [14] -{ - QMessageBox::about(this, tr("About Application"), - tr("The Application example demonstrates how to " - "write modern GUI applications using Qt, with a menu bar, " - "toolbars, and a status bar.")); -} -//! [14] - -//! [15] -void MainWindow::documentWasModified() -//! [15] //! [16] -{ - setWindowModified(textEdit->document()->isModified()); -} -//! [16] - -//! [17] -void MainWindow::createActions() -//! [17] //! [18] -{ - newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); - -//! [19] - openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); -//! [18] //! [19] - - saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - - saveAsAct = new QAction(tr("Save &As..."), this); - saveAsAct->setShortcuts(QKeySequence::SaveAs); - saveAsAct->setStatusTip(tr("Save the document under a new name")); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); - -//! [20] - exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); -//! [20] - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); - -//! [21] - cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); -//! [21] - cutAct->setShortcuts(QKeySequence::Cut); - cutAct->setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")); - connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut())); - - copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this); - copyAct->setShortcuts(QKeySequence::Copy); - copyAct->setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")); - connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy())); - - pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this); - pasteAct->setShortcuts(QKeySequence::Paste); - pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")); - connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste())); - - aboutAct = new QAction(tr("&About"), this); - aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - -//! [22] - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); -//! [22] - -//! [23] - cutAct->setEnabled(false); -//! [23] //! [24] - copyAct->setEnabled(false); - connect(textEdit, SIGNAL(copyAvailable(bool)), - cutAct, SLOT(setEnabled(bool))); - connect(textEdit, SIGNAL(copyAvailable(bool)), - copyAct, SLOT(setEnabled(bool))); -} -//! [24] - -//! [25] //! [26] -void MainWindow::createMenus() -//! [25] //! [27] -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newAct); -//! [28] - fileMenu->addAction(openAct); -//! [28] - fileMenu->addAction(saveAct); -//! [26] - fileMenu->addAction(saveAsAct); - fileMenu->addSeparator(); - fileMenu->addAction(exitAct); - - editMenu = menuBar()->addMenu(tr("&Edit")); - editMenu->addAction(cutAct); - editMenu->addAction(copyAct); - editMenu->addAction(pasteAct); - - menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); -} -//! [27] - -//! [29] //! [30] -void MainWindow::createToolBars() -{ - fileToolBar = addToolBar(tr("File")); - fileToolBar->addAction(newAct); -//! [29] //! [31] - fileToolBar->addAction(openAct); -//! [31] - fileToolBar->addAction(saveAct); - - editToolBar = addToolBar(tr("Edit")); - editToolBar->addAction(cutAct); - editToolBar->addAction(copyAct); - editToolBar->addAction(pasteAct); -} -//! [30] - -//! [32] -void MainWindow::createStatusBar() -//! [32] //! [33] -{ - statusBar()->showMessage(tr("Ready")); -} -//! [33] - -//! [34] //! [35] -void MainWindow::readSettings() -//! [34] //! [36] -{ - QSettings settings("Trolltech", "Application Example"); - QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); - QSize size = settings.value("size", QSize(400, 400)).toSize(); - resize(size); - move(pos); -} -//! [35] //! [36] - -//! [37] //! [38] -void MainWindow::writeSettings() -//! [37] //! [39] -{ - QSettings settings("Trolltech", "Application Example"); - settings.setValue("pos", pos()); - settings.setValue("size", size()); -} -//! [38] //! [39] - -//! [40] -bool MainWindow::maybeSave() -//! [40] //! [41] -{ - if (textEdit->document()->isModified()) { - QMessageBox::StandardButton ret; - ret = QMessageBox::warning(this, tr("Application"), - tr("The document has been modified.\n" - "Do you want to save your changes?"), - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - if (ret == QMessageBox::Save) - return save(); - else if (ret == QMessageBox::Cancel) - return false; - } - return true; -} -//! [41] - -//! [42] -void MainWindow::loadFile(const QString &fileName) -//! [42] //! [43] -{ - QFile file(fileName); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, tr("Application"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return; - } - - QTextStream in(&file); -#ifndef QT_NO_CURSOR - QApplication::setOverrideCursor(Qt::WaitCursor); -#endif - textEdit->setPlainText(in.readAll()); -#ifndef QT_NO_CURSOR - QApplication::restoreOverrideCursor(); -#endif - - setCurrentFile(fileName); - statusBar()->showMessage(tr("File loaded"), 2000); -} -//! [43] - -//! [44] -bool MainWindow::saveFile(const QString &fileName) -//! [44] //! [45] -{ - QFile file(fileName); - if (!file.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(this, tr("Application"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return false; - } - - QTextStream out(&file); -#ifndef QT_NO_CURSOR - QApplication::setOverrideCursor(Qt::WaitCursor); -#endif - out << textEdit->toPlainText(); -#ifndef QT_NO_CURSOR - QApplication::restoreOverrideCursor(); -#endif - - setCurrentFile(fileName); - statusBar()->showMessage(tr("File saved"), 2000); - return true; -} -//! [45] - -//! [46] -void MainWindow::setCurrentFile(const QString &fileName) -//! [46] //! [47] -{ - curFile = fileName; - textEdit->document()->setModified(false); - setWindowModified(false); - - QString shownName = curFile; - if (curFile.isEmpty()) - shownName = "untitled.txt"; - setWindowFilePath(shownName); -} -//! [47] - -//! [48] -QString MainWindow::strippedName(const QString &fullFileName) -//! [48] //! [49] -{ - return QFileInfo(fullFileName).fileName(); -} -//! [49] diff --git a/examples/mainwindows/application/mainwindow.h b/examples/mainwindows/application/mainwindow.h deleted file mode 100644 index 7f429e0ea3..0000000000 --- a/examples/mainwindows/application/mainwindow.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAction; -class QMenu; -class QPlainTextEdit; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -protected: - void closeEvent(QCloseEvent *event); - -private slots: - void newFile(); - void open(); - bool save(); - bool saveAs(); - void about(); - void documentWasModified(); - -private: - void createActions(); - void createMenus(); - void createToolBars(); - void createStatusBar(); - void readSettings(); - void writeSettings(); - bool maybeSave(); - void loadFile(const QString &fileName); - bool saveFile(const QString &fileName); - void setCurrentFile(const QString &fileName); - QString strippedName(const QString &fullFileName); - - QPlainTextEdit *textEdit; - QString curFile; - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *helpMenu; - QToolBar *fileToolBar; - QToolBar *editToolBar; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *exitAct; - QAction *cutAct; - QAction *copyAct; - QAction *pasteAct; - QAction *aboutAct; - QAction *aboutQtAct; -}; -//! [0] - -#endif diff --git a/examples/mainwindows/dockwidgets/dockwidgets.desktop b/examples/mainwindows/dockwidgets/dockwidgets.desktop deleted file mode 100644 index 1f57cb613b..0000000000 --- a/examples/mainwindows/dockwidgets/dockwidgets.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Dock Widgets -Exec=/opt/usr/bin/dockwidgets -Icon=dockwidgets -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/mainwindows/dockwidgets/dockwidgets.pro b/examples/mainwindows/dockwidgets/dockwidgets.pro deleted file mode 100644 index 7e0da2496e..0000000000 --- a/examples/mainwindows/dockwidgets/dockwidgets.pro +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp -RESOURCES = dockwidgets.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/dockwidgets -sources.files = $$SOURCES $$HEADERS $$RESOURCES dockwidgets.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/dockwidgets -INSTALLS += target sources - -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/mainwindows/dockwidgets/dockwidgets.qrc b/examples/mainwindows/dockwidgets/dockwidgets.qrc deleted file mode 100644 index 968feac7ea..0000000000 --- a/examples/mainwindows/dockwidgets/dockwidgets.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - images/new.png - images/print.png - images/save.png - images/undo.png - - diff --git a/examples/mainwindows/dockwidgets/images/new.png b/examples/mainwindows/dockwidgets/images/new.png deleted file mode 100644 index dd795cfffc..0000000000 Binary files a/examples/mainwindows/dockwidgets/images/new.png and /dev/null differ diff --git a/examples/mainwindows/dockwidgets/images/print.png b/examples/mainwindows/dockwidgets/images/print.png deleted file mode 100644 index 2afb769ee2..0000000000 Binary files a/examples/mainwindows/dockwidgets/images/print.png and /dev/null differ diff --git a/examples/mainwindows/dockwidgets/images/save.png b/examples/mainwindows/dockwidgets/images/save.png deleted file mode 100644 index 46eac82ad1..0000000000 Binary files a/examples/mainwindows/dockwidgets/images/save.png and /dev/null differ diff --git a/examples/mainwindows/dockwidgets/images/undo.png b/examples/mainwindows/dockwidgets/images/undo.png deleted file mode 100644 index eee23d24a3..0000000000 Binary files a/examples/mainwindows/dockwidgets/images/undo.png and /dev/null differ diff --git a/examples/mainwindows/dockwidgets/main.cpp b/examples/mainwindows/dockwidgets/main.cpp deleted file mode 100644 index 19deafbb86..0000000000 --- a/examples/mainwindows/dockwidgets/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(dockwidgets); - MainWindow mainWin; - mainWin.show(); - return app.exec(); -} diff --git a/examples/mainwindows/dockwidgets/mainwindow.cpp b/examples/mainwindows/dockwidgets/mainwindow.cpp deleted file mode 100644 index da01d56502..0000000000 --- a/examples/mainwindows/dockwidgets/mainwindow.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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$ -** -****************************************************************************/ - -//! [0] -#include -#ifndef QT_NO_PRINTDIALOG -#include -#endif - -#include "mainwindow.h" -//! [0] - -//! [1] -MainWindow::MainWindow() -{ - textEdit = new QTextEdit; - setCentralWidget(textEdit); - - createActions(); - createMenus(); - createToolBars(); - createStatusBar(); - createDockWindows(); - - setWindowTitle(tr("Dock Widgets")); - - newLetter(); - setUnifiedTitleAndToolBarOnMac(true); -} -//! [1] - -//! [2] -void MainWindow::newLetter() -{ - textEdit->clear(); - - QTextCursor cursor(textEdit->textCursor()); - cursor.movePosition(QTextCursor::Start); - QTextFrame *topFrame = cursor.currentFrame(); - QTextFrameFormat topFrameFormat = topFrame->frameFormat(); - topFrameFormat.setPadding(16); - topFrame->setFrameFormat(topFrameFormat); - - QTextCharFormat textFormat; - QTextCharFormat boldFormat; - boldFormat.setFontWeight(QFont::Bold); - QTextCharFormat italicFormat; - italicFormat.setFontItalic(true); - - QTextTableFormat tableFormat; - tableFormat.setBorder(1); - tableFormat.setCellPadding(16); - tableFormat.setAlignment(Qt::AlignRight); - cursor.insertTable(1, 1, tableFormat); - cursor.insertText("The Firm", boldFormat); - cursor.insertBlock(); - cursor.insertText("321 City Street", textFormat); - cursor.insertBlock(); - cursor.insertText("Industry Park"); - cursor.insertBlock(); - cursor.insertText("Some Country"); - cursor.setPosition(topFrame->lastPosition()); - cursor.insertText(QDate::currentDate().toString("d MMMM yyyy"), textFormat); - cursor.insertBlock(); - cursor.insertBlock(); - cursor.insertText("Dear ", textFormat); - cursor.insertText("NAME", italicFormat); - cursor.insertText(",", textFormat); - for (int i = 0; i < 3; ++i) - cursor.insertBlock(); - cursor.insertText(tr("Yours sincerely,"), textFormat); - for (int i = 0; i < 3; ++i) - cursor.insertBlock(); - cursor.insertText("The Boss", textFormat); - cursor.insertBlock(); - cursor.insertText("ADDRESS", italicFormat); -} -//! [2] - -//! [3] -void MainWindow::print() -{ -#ifndef QT_NO_PRINTDIALOG - QTextDocument *document = textEdit->document(); - QPrinter printer; - - QPrintDialog *dlg = new QPrintDialog(&printer, this); - if (dlg->exec() != QDialog::Accepted) - return; - - document->print(&printer); - - statusBar()->showMessage(tr("Ready"), 2000); -#endif -} -//! [3] - -//! [4] -void MainWindow::save() -{ - QString fileName = QFileDialog::getSaveFileName(this, - tr("Choose a file name"), ".", - tr("HTML (*.html *.htm)")); - if (fileName.isEmpty()) - return; - QFile file(fileName); - if (!file.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(this, tr("Dock Widgets"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return; - } - - QTextStream out(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - out << textEdit->toHtml(); - QApplication::restoreOverrideCursor(); - - statusBar()->showMessage(tr("Saved '%1'").arg(fileName), 2000); -} -//! [4] - -//! [5] -void MainWindow::undo() -{ - QTextDocument *document = textEdit->document(); - document->undo(); -} -//! [5] - -//! [6] -void MainWindow::insertCustomer(const QString &customer) -{ - if (customer.isEmpty()) - return; - QStringList customerList = customer.split(", "); - QTextDocument *document = textEdit->document(); - QTextCursor cursor = document->find("NAME"); - if (!cursor.isNull()) { - cursor.beginEditBlock(); - cursor.insertText(customerList.at(0)); - QTextCursor oldcursor = cursor; - cursor = document->find("ADDRESS"); - if (!cursor.isNull()) { - for (int i = 1; i < customerList.size(); ++i) { - cursor.insertBlock(); - cursor.insertText(customerList.at(i)); - } - cursor.endEditBlock(); - } - else - oldcursor.endEditBlock(); - } -} -//! [6] - -//! [7] -void MainWindow::addParagraph(const QString ¶graph) -{ - if (paragraph.isEmpty()) - return; - QTextDocument *document = textEdit->document(); - QTextCursor cursor = document->find(tr("Yours sincerely,")); - if (cursor.isNull()) - return; - cursor.beginEditBlock(); - cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor, 2); - cursor.insertBlock(); - cursor.insertText(paragraph); - cursor.insertBlock(); - cursor.endEditBlock(); - -} -//! [7] - -void MainWindow::about() -{ - QMessageBox::about(this, tr("About Dock Widgets"), - tr("The Dock Widgets example demonstrates how to " - "use Qt's dock widgets. You can enter your own text, " - "click a customer to add a customer name and " - "address, and click standard paragraphs to add them.")); -} - -void MainWindow::createActions() -{ - newLetterAct = new QAction(QIcon(":/images/new.png"), tr("&New Letter"), - this); - newLetterAct->setShortcuts(QKeySequence::New); - newLetterAct->setStatusTip(tr("Create a new form letter")); - connect(newLetterAct, SIGNAL(triggered()), this, SLOT(newLetter())); - - saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save..."), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the current form letter")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - - printAct = new QAction(QIcon(":/images/print.png"), tr("&Print..."), this); - printAct->setShortcuts(QKeySequence::Print); - printAct->setStatusTip(tr("Print the current form letter")); - connect(printAct, SIGNAL(triggered()), this, SLOT(print())); - - undoAct = new QAction(QIcon(":/images/undo.png"), tr("&Undo"), this); - undoAct->setShortcuts(QKeySequence::Undo); - undoAct->setStatusTip(tr("Undo the last editing action")); - connect(undoAct, SIGNAL(triggered()), this, SLOT(undo())); - - quitAct = new QAction(tr("&Quit"), this); - quitAct->setShortcuts(QKeySequence::Quit); - quitAct->setStatusTip(tr("Quit the application")); - connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); - - aboutAct = new QAction(tr("&About"), this); - aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); -} - -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newLetterAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(printAct); - fileMenu->addSeparator(); - fileMenu->addAction(quitAct); - - editMenu = menuBar()->addMenu(tr("&Edit")); - editMenu->addAction(undoAct); - - viewMenu = menuBar()->addMenu(tr("&View")); - - menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); -} - -void MainWindow::createToolBars() -{ - fileToolBar = addToolBar(tr("File")); - fileToolBar->addAction(newLetterAct); - fileToolBar->addAction(saveAct); - fileToolBar->addAction(printAct); - - editToolBar = addToolBar(tr("Edit")); - editToolBar->addAction(undoAct); -} - -//! [8] -void MainWindow::createStatusBar() -{ - statusBar()->showMessage(tr("Ready")); -} -//! [8] - -//! [9] -void MainWindow::createDockWindows() -{ - QDockWidget *dock = new QDockWidget(tr("Customers"), this); - dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - customerList = new QListWidget(dock); - customerList->addItems(QStringList() - << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton" - << "Jane Doe, Memorabilia, 23 Watersedge, Beaton" - << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton" - << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal" - << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston" - << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula"); - dock->setWidget(customerList); - addDockWidget(Qt::RightDockWidgetArea, dock); - viewMenu->addAction(dock->toggleViewAction()); - - dock = new QDockWidget(tr("Paragraphs"), this); - paragraphsList = new QListWidget(dock); - paragraphsList->addItems(QStringList() - << "Thank you for your payment which we have received today." - << "Your order has been dispatched and should be with you " - "within 28 days." - << "We have dispatched those items that were in stock. The " - "rest of your order will be dispatched once all the " - "remaining items have arrived at our warehouse. No " - "additional shipping charges will be made." - << "You made a small overpayment (less than $5) which we " - "will keep on account for you, or return at your request." - << "You made a small underpayment (less than $1), but we have " - "sent your order anyway. We'll add this underpayment to " - "your next bill." - << "Unfortunately you did not send enough money. Please remit " - "an additional $. Your order will be dispatched as soon as " - "the complete amount has been received." - << "You made an overpayment (more than $5). Do you wish to " - "buy more items, or should we return the excess to you?"); - dock->setWidget(paragraphsList); - addDockWidget(Qt::RightDockWidgetArea, dock); - viewMenu->addAction(dock->toggleViewAction()); - - connect(customerList, SIGNAL(currentTextChanged(QString)), - this, SLOT(insertCustomer(QString))); - connect(paragraphsList, SIGNAL(currentTextChanged(QString)), - this, SLOT(addParagraph(QString))); -} -//! [9] diff --git a/examples/mainwindows/dockwidgets/mainwindow.h b/examples/mainwindows/dockwidgets/mainwindow.h deleted file mode 100644 index 9f3eeb4e6b..0000000000 --- a/examples/mainwindows/dockwidgets/mainwindow.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAction; -class QListWidget; -class QMenu; -class QTextEdit; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private slots: - void newLetter(); - void save(); - void print(); - void undo(); - void about(); - void insertCustomer(const QString &customer); - void addParagraph(const QString ¶graph); - -private: - void createActions(); - void createMenus(); - void createToolBars(); - void createStatusBar(); - void createDockWindows(); - - QTextEdit *textEdit; - QListWidget *customerList; - QListWidget *paragraphsList; - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *viewMenu; - QMenu *helpMenu; - QToolBar *fileToolBar; - QToolBar *editToolBar; - QAction *newLetterAct; - QAction *saveAct; - QAction *printAct; - QAction *undoAct; - QAction *aboutAct; - QAction *aboutQtAct; - QAction *quitAct; -}; -//! [0] - -#endif diff --git a/examples/mainwindows/mainwindow/colorswatch.cpp b/examples/mainwindows/mainwindow/colorswatch.cpp deleted file mode 100644 index c84669d377..0000000000 --- a/examples/mainwindows/mainwindow/colorswatch.cpp +++ /dev/null @@ -1,746 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "colorswatch.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef DEBUG_SIZEHINTS - -QColor bgColorForName(const QString &name) -{ - if (name == "Black") - return QColor("#D8D8D8"); - else if (name == "White") - return QColor("#F1F1F1"); - else if (name == "Red") - return QColor("#F1D8D8"); - else if (name == "Green") - return QColor("#D8E4D8"); - else if (name == "Blue") - return QColor("#D8D8F1"); - else if (name == "Yellow") - return QColor("#F1F0D8"); - return QColor(name).light(110); -} - -QColor fgColorForName(const QString &name) -{ - if (name == "Black") - return QColor("#6C6C6C"); - else if (name == "White") - return QColor("#F8F8F8"); - else if (name == "Red") - return QColor("#F86C6C"); - else if (name == "Green") - return QColor("#6CB26C"); - else if (name == "Blue") - return QColor("#6C6CF8"); - else if (name == "Yellow") - return QColor("#F8F76C"); - return QColor(name); -} - -class ColorDock : public QFrame -{ - Q_OBJECT -public: - ColorDock(const QString &c, QWidget *parent); - - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - - void setCustomSizeHint(const QSize &size); - -public slots: - void changeSizeHints(); - -protected: - void paintEvent(QPaintEvent *); - QString color; - QSize szHint, minSzHint; -}; - -ColorDock::ColorDock(const QString &c, QWidget *parent) - : QFrame(parent) , color(c) -{ - QFont font = this->font(); - font.setPointSize(8); - setFont(font); - szHint = QSize(-1, -1); - minSzHint = QSize(125, 75); -} - -QSize ColorDock::sizeHint() const -{ - return szHint; -} - -QSize ColorDock::minimumSizeHint() const -{ - return minSzHint; -} - -void ColorDock::paintEvent(QPaintEvent *) -{ - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - p.fillRect(rect(), bgColorForName(color)); - - p.save(); - - extern void render_qt_text(QPainter *, int, int, const QColor &); - render_qt_text(&p, width(), height(), fgColorForName(color)); - - p.restore(); - -#ifdef DEBUG_SIZEHINTS - p.setRenderHint(QPainter::Antialiasing, false); - - QSize sz = size(); - QSize szHint = sizeHint(); - QSize minSzHint = minimumSizeHint(); - QSize maxSz = maximumSize(); - QString text = QString::fromLatin1("sz: %1x%2\nszHint: %3x%4\nminSzHint: %5x%6\n" - "maxSz: %8x%9") - .arg(sz.width()).arg(sz.height()) - .arg(szHint.width()).arg(szHint.height()) - .arg(minSzHint.width()).arg(minSzHint.height()) - .arg(maxSz.width()).arg(maxSz.height()); - - QRect r = fontMetrics().boundingRect(rect(), Qt::AlignLeft|Qt::AlignTop, text); - r.adjust(-2, -2, 1, 1); - p.translate(4, 4); - QColor bg = Qt::yellow; - bg.setAlpha(120); - p.setBrush(bg); - p.setPen(Qt::black); - p.drawRect(r); - p.drawText(rect(), Qt::AlignLeft|Qt::AlignTop, text); -#endif // DEBUG_SIZEHINTS -} - -static QSpinBox *createSpinBox(int value, QWidget *parent, int max = 1000) -{ - QSpinBox *result = new QSpinBox(parent); - result->setMinimum(-1); - result->setMaximum(max); - result->setValue(value); - return result; -} - -void ColorDock::changeSizeHints() -{ - QDialog dialog(this); - dialog.setWindowTitle(color); - - QVBoxLayout *topLayout = new QVBoxLayout(&dialog); - - QGridLayout *inputLayout = new QGridLayout(); - topLayout->addLayout(inputLayout); - - inputLayout->addWidget(new QLabel(tr("Size Hint:"), &dialog), 0, 0); - inputLayout->addWidget(new QLabel(tr("Min Size Hint:"), &dialog), 1, 0); - inputLayout->addWidget(new QLabel(tr("Max Size:"), &dialog), 2, 0); - inputLayout->addWidget(new QLabel(tr("Dockwgt Max Size:"), &dialog), 3, 0); - - QSpinBox *szHintW = createSpinBox(szHint.width(), &dialog); - inputLayout->addWidget(szHintW, 0, 1); - QSpinBox *szHintH = createSpinBox(szHint.height(), &dialog); - inputLayout->addWidget(szHintH, 0, 2); - - QSpinBox *minSzHintW = createSpinBox(minSzHint.width(), &dialog); - inputLayout->addWidget(minSzHintW, 1, 1); - QSpinBox *minSzHintH = createSpinBox(minSzHint.height(), &dialog); - inputLayout->addWidget(minSzHintH, 1, 2); - - QSize maxSz = maximumSize(); - QSpinBox *maxSzW = createSpinBox(maxSz.width(), &dialog, QWIDGETSIZE_MAX); - inputLayout->addWidget(maxSzW, 2, 1); - QSpinBox *maxSzH = createSpinBox(maxSz.height(), &dialog, QWIDGETSIZE_MAX); - inputLayout->addWidget(maxSzH, 2, 2); - - QSize dwMaxSz = parentWidget()->maximumSize(); - QSpinBox *dwMaxSzW = createSpinBox(dwMaxSz.width(), &dialog, QWIDGETSIZE_MAX); - inputLayout->addWidget(dwMaxSzW, 3, 1); - QSpinBox *dwMaxSzH = createSpinBox(dwMaxSz.height(), &dialog, QWIDGETSIZE_MAX); - inputLayout->addWidget(dwMaxSzH, 3, 2); - - inputLayout->setColumnStretch(1, 1); - inputLayout->setColumnStretch(2, 1); - - topLayout->addStretch(); - - QHBoxLayout *buttonBox = new QHBoxLayout(); - topLayout->addLayout(buttonBox); - - QPushButton *okButton = new QPushButton(tr("Ok"), &dialog); - QPushButton *cancelButton = new QPushButton(tr("Cancel"), &dialog); - connect(okButton, SIGNAL(clicked()), &dialog, SLOT(accept())); - connect(cancelButton, SIGNAL(clicked()), &dialog, SLOT(reject())); - buttonBox->addStretch(); - buttonBox->addWidget(cancelButton); - buttonBox->addWidget(okButton); - - - if (!dialog.exec()) - return; - - szHint = QSize(szHintW->value(), szHintH->value()); - minSzHint = QSize(minSzHintW->value(), minSzHintH->value()); - maxSz = QSize(maxSzW->value(), maxSzH->value()); - setMaximumSize(maxSz); - dwMaxSz = QSize(dwMaxSzW->value(), dwMaxSzH->value()); - parentWidget()->setMaximumSize(dwMaxSz); - updateGeometry(); - update(); -} - -void ColorDock::setCustomSizeHint(const QSize &size) -{ - szHint = size; - updateGeometry(); -} - -ColorSwatch::ColorSwatch(const QString &colorName, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(parent, flags) -{ - setObjectName(colorName + QLatin1String(" Dock Widget")); - setWindowTitle(objectName() + QLatin1String(" [*]")); - - QFrame *swatch = new ColorDock(colorName, this); - swatch->setFrameStyle(QFrame::Box | QFrame::Sunken); - - setWidget(swatch); - - changeSizeHintsAction = new QAction(tr("Change Size Hints"), this); - connect(changeSizeHintsAction, SIGNAL(triggered()), swatch, SLOT(changeSizeHints())); - - closableAction = new QAction(tr("Closable"), this); - closableAction->setCheckable(true); - connect(closableAction, SIGNAL(triggered(bool)), SLOT(changeClosable(bool))); - - movableAction = new QAction(tr("Movable"), this); - movableAction->setCheckable(true); - connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool))); - - floatableAction = new QAction(tr("Floatable"), this); - floatableAction->setCheckable(true); - connect(floatableAction, SIGNAL(triggered(bool)), SLOT(changeFloatable(bool))); - - verticalTitleBarAction = new QAction(tr("Vertical title bar"), this); - verticalTitleBarAction->setCheckable(true); - connect(verticalTitleBarAction, SIGNAL(triggered(bool)), - SLOT(changeVerticalTitleBar(bool))); - - floatingAction = new QAction(tr("Floating"), this); - floatingAction->setCheckable(true); - connect(floatingAction, SIGNAL(triggered(bool)), SLOT(changeFloating(bool))); - - allowedAreasActions = new QActionGroup(this); - allowedAreasActions->setExclusive(false); - - allowLeftAction = new QAction(tr("Allow on Left"), this); - allowLeftAction->setCheckable(true); - connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool))); - - allowRightAction = new QAction(tr("Allow on Right"), this); - allowRightAction->setCheckable(true); - connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool))); - - allowTopAction = new QAction(tr("Allow on Top"), this); - allowTopAction->setCheckable(true); - connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool))); - - allowBottomAction = new QAction(tr("Allow on Bottom"), this); - allowBottomAction->setCheckable(true); - connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool))); - - allowedAreasActions->addAction(allowLeftAction); - allowedAreasActions->addAction(allowRightAction); - allowedAreasActions->addAction(allowTopAction); - allowedAreasActions->addAction(allowBottomAction); - - areaActions = new QActionGroup(this); - areaActions->setExclusive(true); - - leftAction = new QAction(tr("Place on Left") , this); - leftAction->setCheckable(true); - connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool))); - - rightAction = new QAction(tr("Place on Right") , this); - rightAction->setCheckable(true); - connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool))); - - topAction = new QAction(tr("Place on Top") , this); - topAction->setCheckable(true); - connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool))); - - bottomAction = new QAction(tr("Place on Bottom") , this); - bottomAction->setCheckable(true); - connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool))); - - areaActions->addAction(leftAction); - areaActions->addAction(rightAction); - areaActions->addAction(topAction); - areaActions->addAction(bottomAction); - - connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool))); - - connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool))); - - connect(floatableAction, SIGNAL(triggered(bool)), floatingAction, SLOT(setEnabled(bool))); - - connect(floatingAction, SIGNAL(triggered(bool)), floatableAction, SLOT(setDisabled(bool))); - connect(movableAction, SIGNAL(triggered(bool)), floatableAction, SLOT(setEnabled(bool))); - - tabMenu = new QMenu(this); - tabMenu->setTitle(tr("Tab into")); - connect(tabMenu, SIGNAL(triggered(QAction*)), this, SLOT(tabInto(QAction*))); - - splitHMenu = new QMenu(this); - splitHMenu->setTitle(tr("Split horizontally into")); - connect(splitHMenu, SIGNAL(triggered(QAction*)), this, SLOT(splitInto(QAction*))); - - splitVMenu = new QMenu(this); - splitVMenu->setTitle(tr("Split vertically into")); - connect(splitVMenu, SIGNAL(triggered(QAction*)), this, SLOT(splitInto(QAction*))); - - windowModifiedAction = new QAction(tr("Modified"), this); - windowModifiedAction->setCheckable(true); - windowModifiedAction->setChecked(false); - connect(windowModifiedAction, SIGNAL(toggled(bool)), this, SLOT(setWindowModified(bool))); - - menu = new QMenu(colorName, this); - menu->addAction(toggleViewAction()); - QAction *action = menu->addAction(tr("Raise")); - connect(action, SIGNAL(triggered()), this, SLOT(raise())); - menu->addAction(changeSizeHintsAction); - menu->addSeparator(); - menu->addAction(closableAction); - menu->addAction(movableAction); - menu->addAction(floatableAction); - menu->addAction(floatingAction); - menu->addAction(verticalTitleBarAction); - menu->addSeparator(); - menu->addActions(allowedAreasActions->actions()); - menu->addSeparator(); - menu->addActions(areaActions->actions()); - menu->addSeparator(); - menu->addMenu(splitHMenu); - menu->addMenu(splitVMenu); - menu->addMenu(tabMenu); - menu->addSeparator(); - menu->addAction(windowModifiedAction); - - connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); - - if(colorName == "Black") { - leftAction->setShortcut(Qt::CTRL|Qt::Key_W); - rightAction->setShortcut(Qt::CTRL|Qt::Key_E); - toggleViewAction()->setShortcut(Qt::CTRL|Qt::Key_R); - } -} - -void ColorSwatch::updateContextMenu() -{ - QMainWindow *mainWindow = qobject_cast(parentWidget()); - const Qt::DockWidgetArea area = mainWindow->dockWidgetArea(this); - const Qt::DockWidgetAreas areas = allowedAreas(); - - closableAction->setChecked(features() & QDockWidget::DockWidgetClosable); - if (windowType() == Qt::Drawer) { - floatableAction->setEnabled(false); - floatingAction->setEnabled(false); - movableAction->setEnabled(false); - verticalTitleBarAction->setChecked(false); - } else { - floatableAction->setChecked(features() & QDockWidget::DockWidgetFloatable); - floatingAction->setChecked(isWindow()); - // done after floating, to get 'floatable' correctly initialized - movableAction->setChecked(features() & QDockWidget::DockWidgetMovable); - verticalTitleBarAction - ->setChecked(features() & QDockWidget::DockWidgetVerticalTitleBar); - } - - allowLeftAction->setChecked(isAreaAllowed(Qt::LeftDockWidgetArea)); - allowRightAction->setChecked(isAreaAllowed(Qt::RightDockWidgetArea)); - allowTopAction->setChecked(isAreaAllowed(Qt::TopDockWidgetArea)); - allowBottomAction->setChecked(isAreaAllowed(Qt::BottomDockWidgetArea)); - - if (allowedAreasActions->isEnabled()) { - allowLeftAction->setEnabled(area != Qt::LeftDockWidgetArea); - allowRightAction->setEnabled(area != Qt::RightDockWidgetArea); - allowTopAction->setEnabled(area != Qt::TopDockWidgetArea); - allowBottomAction->setEnabled(area != Qt::BottomDockWidgetArea); - } - - leftAction->blockSignals(true); - rightAction->blockSignals(true); - topAction->blockSignals(true); - bottomAction->blockSignals(true); - - leftAction->setChecked(area == Qt::LeftDockWidgetArea); - rightAction->setChecked(area == Qt::RightDockWidgetArea); - topAction->setChecked(area == Qt::TopDockWidgetArea); - bottomAction->setChecked(area == Qt::BottomDockWidgetArea); - - leftAction->blockSignals(false); - rightAction->blockSignals(false); - topAction->blockSignals(false); - bottomAction->blockSignals(false); - - if (areaActions->isEnabled()) { - leftAction->setEnabled(areas & Qt::LeftDockWidgetArea); - rightAction->setEnabled(areas & Qt::RightDockWidgetArea); - topAction->setEnabled(areas & Qt::TopDockWidgetArea); - bottomAction->setEnabled(areas & Qt::BottomDockWidgetArea); - } - - tabMenu->clear(); - splitHMenu->clear(); - splitVMenu->clear(); - QList dock_list = mainWindow->findChildren(); - foreach (ColorSwatch *dock, dock_list) { -// if (!dock->isVisible() || dock->isFloating()) -// continue; - tabMenu->addAction(dock->objectName()); - splitHMenu->addAction(dock->objectName()); - splitVMenu->addAction(dock->objectName()); - } -} - -void ColorSwatch::splitInto(QAction *action) -{ - QMainWindow *mainWindow = qobject_cast(parentWidget()); - QList dock_list = mainWindow->findChildren(); - ColorSwatch *target = 0; - foreach (ColorSwatch *dock, dock_list) { - if (action->text() == dock->objectName()) { - target = dock; - break; - } - } - if (target == 0) - return; - - Qt::Orientation o = action->parent() == splitHMenu - ? Qt::Horizontal : Qt::Vertical; - mainWindow->splitDockWidget(target, this, o); -} - -void ColorSwatch::tabInto(QAction *action) -{ - QMainWindow *mainWindow = qobject_cast(parentWidget()); - QList dock_list = mainWindow->findChildren(); - ColorSwatch *target = 0; - foreach (ColorSwatch *dock, dock_list) { - if (action->text() == dock->objectName()) { - target = dock; - break; - } - } - if (target == 0) - return; - - mainWindow->tabifyDockWidget(target, this); -} - -void ColorSwatch::contextMenuEvent(QContextMenuEvent *event) -{ - event->accept(); - menu->exec(event->globalPos()); -} - -void ColorSwatch::resizeEvent(QResizeEvent *e) -{ - if (BlueTitleBar *btb = qobject_cast(titleBarWidget())) - btb->updateMask(); - - QDockWidget::resizeEvent(e); -} - - -void ColorSwatch::allow(Qt::DockWidgetArea area, bool a) -{ - Qt::DockWidgetAreas areas = allowedAreas(); - areas = a ? areas | area : areas & ~area; - setAllowedAreas(areas); - - if (areaActions->isEnabled()) { - leftAction->setEnabled(areas & Qt::LeftDockWidgetArea); - rightAction->setEnabled(areas & Qt::RightDockWidgetArea); - topAction->setEnabled(areas & Qt::TopDockWidgetArea); - bottomAction->setEnabled(areas & Qt::BottomDockWidgetArea); - } -} - -void ColorSwatch::place(Qt::DockWidgetArea area, bool p) -{ - if (!p) return; - - QMainWindow *mainWindow = qobject_cast(parentWidget()); - mainWindow->addDockWidget(area, this); - - if (allowedAreasActions->isEnabled()) { - allowLeftAction->setEnabled(area != Qt::LeftDockWidgetArea); - allowRightAction->setEnabled(area != Qt::RightDockWidgetArea); - allowTopAction->setEnabled(area != Qt::TopDockWidgetArea); - allowBottomAction->setEnabled(area != Qt::BottomDockWidgetArea); - } -} - -void ColorSwatch::setCustomSizeHint(const QSize &size) -{ - if (ColorDock *dock = qobject_cast(widget())) - dock->setCustomSizeHint(size); -} - -void ColorSwatch::changeClosable(bool on) -{ setFeatures(on ? features() | DockWidgetClosable : features() & ~DockWidgetClosable); } - -void ColorSwatch::changeMovable(bool on) -{ setFeatures(on ? features() | DockWidgetMovable : features() & ~DockWidgetMovable); } - -void ColorSwatch::changeFloatable(bool on) -{ setFeatures(on ? features() | DockWidgetFloatable : features() & ~DockWidgetFloatable); } - -void ColorSwatch::changeFloating(bool floating) -{ setFloating(floating); } - -void ColorSwatch::allowLeft(bool a) -{ allow(Qt::LeftDockWidgetArea, a); } - -void ColorSwatch::allowRight(bool a) -{ allow(Qt::RightDockWidgetArea, a); } - -void ColorSwatch::allowTop(bool a) -{ allow(Qt::TopDockWidgetArea, a); } - -void ColorSwatch::allowBottom(bool a) -{ allow(Qt::BottomDockWidgetArea, a); } - -void ColorSwatch::placeLeft(bool p) -{ place(Qt::LeftDockWidgetArea, p); } - -void ColorSwatch::placeRight(bool p) -{ place(Qt::RightDockWidgetArea, p); } - -void ColorSwatch::placeTop(bool p) -{ place(Qt::TopDockWidgetArea, p); } - -void ColorSwatch::placeBottom(bool p) -{ place(Qt::BottomDockWidgetArea, p); } - -void ColorSwatch::changeVerticalTitleBar(bool on) -{ - setFeatures(on ? features() | DockWidgetVerticalTitleBar - : features() & ~DockWidgetVerticalTitleBar); -} - -QSize BlueTitleBar::minimumSizeHint() const -{ - QDockWidget *dw = qobject_cast(parentWidget()); - Q_ASSERT(dw != 0); - QSize result(leftPm.width() + rightPm.width(), centerPm.height()); - if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) - result.transpose(); - return result; -} - -BlueTitleBar::BlueTitleBar(QWidget *parent) - : QWidget(parent) -{ - leftPm = QPixmap(":/res/titlebarLeft.png"); - centerPm = QPixmap(":/res/titlebarCenter.png"); - rightPm = QPixmap(":/res/titlebarRight.png"); -} - -void BlueTitleBar::paintEvent(QPaintEvent*) -{ - QPainter painter(this); - QRect rect = this->rect(); - - QDockWidget *dw = qobject_cast(parentWidget()); - Q_ASSERT(dw != 0); - - if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) { - QSize s = rect.size(); - s.transpose(); - rect.setSize(s); - - painter.translate(rect.left(), rect.top() + rect.width()); - painter.rotate(-90); - painter.translate(-rect.left(), -rect.top()); - } - - painter.drawPixmap(rect.topLeft(), leftPm); - painter.drawPixmap(rect.topRight() - QPoint(rightPm.width() - 1, 0), rightPm); - QBrush brush(centerPm); - painter.fillRect(rect.left() + leftPm.width(), rect.top(), - rect.width() - leftPm.width() - rightPm.width(), - centerPm.height(), centerPm); -} - -void BlueTitleBar::mousePressEvent(QMouseEvent *event) -{ - QPoint pos = event->pos(); - - QRect rect = this->rect(); - - QDockWidget *dw = qobject_cast(parentWidget()); - Q_ASSERT(dw != 0); - - if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) { - QPoint p = pos; - pos.setX(rect.left() + rect.bottom() - p.y()); - pos.setY(rect.top() + p.x() - rect.left()); - - QSize s = rect.size(); - s.transpose(); - rect.setSize(s); - } - - const int buttonRight = 7; - const int buttonWidth = 20; - int right = rect.right() - pos.x(); - int button = (right - buttonRight)/buttonWidth; - switch (button) { - case 0: - event->accept(); - dw->close(); - break; - case 1: - event->accept(); - dw->setFloating(!dw->isFloating()); - break; - case 2: { - event->accept(); - QDockWidget::DockWidgetFeatures features = dw->features(); - if (features & QDockWidget::DockWidgetVerticalTitleBar) - features &= ~QDockWidget::DockWidgetVerticalTitleBar; - else - features |= QDockWidget::DockWidgetVerticalTitleBar; - dw->setFeatures(features); - break; - } - default: - event->ignore(); - break; - } -} - -void BlueTitleBar::updateMask() -{ - QDockWidget *dw = qobject_cast(parent()); - Q_ASSERT(dw != 0); - - QRect rect = dw->rect(); - QPixmap bitmap(dw->size()); - - { - QPainter painter(&bitmap); - - ///initialize to transparent - painter.fillRect(rect, Qt::color0); - - QRect contents = rect; - contents.setTopLeft(geometry().bottomLeft()); - contents.setRight(geometry().right()); - contents.setBottom(contents.bottom()-y()); - painter.fillRect(contents, Qt::color1); - - - - //let's pait the titlebar - - QRect titleRect = this->geometry(); - - if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) { - QSize s = rect.size(); - s.transpose(); - rect.setSize(s); - - QSize s2 = size(); - s2.transpose(); - titleRect.setSize(s2); - - painter.translate(rect.left(), rect.top() + rect.width()); - painter.rotate(-90); - painter.translate(-rect.left(), -rect.top()); - } - - contents.setTopLeft(titleRect.bottomLeft()); - contents.setRight(titleRect.right()); - contents.setBottom(rect.bottom()-y()); - - QRect rect = titleRect; - - - painter.drawPixmap(rect.topLeft(), leftPm.mask()); - painter.fillRect(rect.left() + leftPm.width(), rect.top(), - rect.width() - leftPm.width() - rightPm.width(), - centerPm.height(), Qt::color1); - painter.drawPixmap(rect.topRight() - QPoint(rightPm.width() - 1, 0), rightPm.mask()); - - painter.fillRect(contents, Qt::color1); - } - - dw->setMask(bitmap); -} - -#include "colorswatch.moc" diff --git a/examples/mainwindows/mainwindow/colorswatch.h b/examples/mainwindows/mainwindow/colorswatch.h deleted file mode 100644 index 794a69cd6c..0000000000 --- a/examples/mainwindows/mainwindow/colorswatch.h +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef COLORSWATCH_H -#define COLORSWATCH_H - -#include - -QT_FORWARD_DECLARE_CLASS(QAction) -QT_FORWARD_DECLARE_CLASS(QActionGroup) -QT_FORWARD_DECLARE_CLASS(QMenu) - -class ColorSwatch : public QDockWidget -{ - Q_OBJECT - - QAction *closableAction; - QAction *movableAction; - QAction *floatableAction; - QAction *floatingAction; - QAction *verticalTitleBarAction; - - QActionGroup *allowedAreasActions; - QAction *allowLeftAction; - QAction *allowRightAction; - QAction *allowTopAction; - QAction *allowBottomAction; - - QActionGroup *areaActions; - QAction *leftAction; - QAction *rightAction; - QAction *topAction; - QAction *bottomAction; - - QAction *changeSizeHintsAction; - - QMenu *tabMenu; - QMenu *splitHMenu; - QMenu *splitVMenu; - - QAction *windowModifiedAction; - -public: - ColorSwatch(const QString &colorName, QWidget *parent = 0, Qt::WindowFlags flags = 0); - - QMenu *menu; - void setCustomSizeHint(const QSize &size); - -protected: - virtual void contextMenuEvent(QContextMenuEvent *event); - virtual void resizeEvent(QResizeEvent *e); - -private: - void allow(Qt::DockWidgetArea area, bool allow); - void place(Qt::DockWidgetArea area, bool place); - -private slots: - void changeClosable(bool on); - void changeMovable(bool on); - void changeFloatable(bool on); - void changeFloating(bool on); - void changeVerticalTitleBar(bool on); - void updateContextMenu(); - - void allowLeft(bool a); - void allowRight(bool a); - void allowTop(bool a); - void allowBottom(bool a); - - void placeLeft(bool p); - void placeRight(bool p); - void placeTop(bool p); - void placeBottom(bool p); - - void splitInto(QAction *action); - void tabInto(QAction *action); -}; - -class BlueTitleBar : public QWidget -{ - Q_OBJECT -public: - BlueTitleBar(QWidget *parent = 0); - - QSize sizeHint() const { return minimumSizeHint(); } - QSize minimumSizeHint() const; -protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); -public slots: - void updateMask(); - -private: - QPixmap leftPm, centerPm, rightPm; -}; - - -#endif diff --git a/examples/mainwindows/mainwindow/main.cpp b/examples/mainwindows/mainwindow/main.cpp deleted file mode 100644 index 2b6342367a..0000000000 --- a/examples/mainwindows/mainwindow/main.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" - -#include -#include -#include -#include -#include - -void render_qt_text(QPainter *painter, int w, int h, const QColor &color) { - QPainterPath path; - path.moveTo(-0.083695, 0.283849); - path.cubicTo(-0.049581, 0.349613, -0.012720, 0.397969, 0.026886, 0.428917); - path.cubicTo(0.066493, 0.459865, 0.111593, 0.477595, 0.162186, 0.482108); - path.lineTo(0.162186, 0.500000); - path.cubicTo(0.115929, 0.498066, 0.066565, 0.487669, 0.014094, 0.468810); - path.cubicTo(-0.038378, 0.449952, -0.088103, 0.423839, -0.135082, 0.390474); - path.cubicTo(-0.182061, 0.357108, -0.222608, 0.321567, -0.256722, 0.283849); - path.cubicTo(-0.304712, 0.262250, -0.342874, 0.239362, -0.371206, 0.215184); - path.cubicTo(-0.411969, 0.179078, -0.443625, 0.134671, -0.466175, 0.081963); - path.cubicTo(-0.488725, 0.029255, -0.500000, -0.033043, -0.500000, -0.104932); - path.cubicTo(-0.500000, -0.218407, -0.467042, -0.312621, -0.401127, -0.387573); - path.cubicTo(-0.335212, -0.462524, -0.255421, -0.500000, -0.161752, -0.500000); - path.cubicTo(-0.072998, -0.500000, 0.003903, -0.462444, 0.068951, -0.387331); - path.cubicTo(0.133998, -0.312218, 0.166522, -0.217440, 0.166522, -0.102998); - path.cubicTo(0.166522, -0.010155, 0.143394, 0.071325, 0.097138, 0.141441); - path.cubicTo(0.050882, 0.211557, -0.009396, 0.259026, -0.083695, 0.283849); - path.moveTo(-0.167823, -0.456963); - path.cubicTo(-0.228823, -0.456963, -0.277826, -0.432624, -0.314831, -0.383946); - path.cubicTo(-0.361665, -0.323340, -0.385082, -0.230335, -0.385082, -0.104932); - path.cubicTo(-0.385082, 0.017569, -0.361376, 0.112025, -0.313964, 0.178433); - path.cubicTo(-0.277248, 0.229368, -0.228534, 0.254836, -0.167823, 0.254836); - path.cubicTo(-0.105088, 0.254836, -0.054496, 0.229368, -0.016045, 0.178433); - path.cubicTo(0.029055, 0.117827, 0.051605, 0.028691, 0.051605, -0.088975); - path.cubicTo(0.051605, -0.179562, 0.039318, -0.255803, 0.014744, -0.317698); - path.cubicTo(-0.004337, -0.365409, -0.029705, -0.400548, -0.061362, -0.423114); - path.cubicTo(-0.093018, -0.445680, -0.128505, -0.456963, -0.167823, -0.456963); - path.moveTo(0.379011, -0.404739); - path.lineTo(0.379011, -0.236460); - path.lineTo(0.486123, -0.236460); - path.lineTo(0.486123, -0.197292); - path.lineTo(0.379011, -0.197292); - path.lineTo(0.379011, 0.134913); - path.cubicTo(0.379011, 0.168117, 0.383276, 0.190442, 0.391804, 0.201886); - path.cubicTo(0.400332, 0.213330, 0.411246, 0.219052, 0.424545, 0.219052); - path.cubicTo(0.435531, 0.219052, 0.446227, 0.215264, 0.456635, 0.207689); - path.cubicTo(0.467042, 0.200113, 0.474993, 0.188910, 0.480486, 0.174081); - path.lineTo(0.500000, 0.174081); - path.cubicTo(0.488436, 0.210509, 0.471957, 0.237911, 0.450564, 0.256286); - path.cubicTo(0.429170, 0.274662, 0.407054, 0.283849, 0.384215, 0.283849); - path.cubicTo(0.368893, 0.283849, 0.353859, 0.279094, 0.339115, 0.269584); - path.cubicTo(0.324371, 0.260074, 0.313530, 0.246534, 0.306592, 0.228965); - path.cubicTo(0.299653, 0.211396, 0.296184, 0.184075, 0.296184, 0.147002); - path.lineTo(0.296184, -0.197292); - path.lineTo(0.223330, -0.197292); - path.lineTo(0.223330, -0.215667); - path.cubicTo(0.241833, -0.224049, 0.260697, -0.237992, 0.279922, -0.257495); - path.cubicTo(0.299147, -0.276999, 0.316276, -0.300129, 0.331310, -0.326886); - path.cubicTo(0.338826, -0.341070, 0.349523, -0.367021, 0.363400, -0.404739); - path.lineTo(0.379011, -0.404739); - path.moveTo(-0.535993, 0.275629); - - painter->translate(w / 2, h / 2); - double scale = qMin(w, h) * 8 / 10.0; - painter->scale(scale, scale); - - painter->setRenderHint(QPainter::Antialiasing); - - painter->save(); - painter->translate(.1, .1); - painter->fillPath(path, QColor(0, 0, 0, 63)); - painter->restore(); - - painter->setBrush(color); - painter->setPen(QPen(Qt::black, 0.02, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin)); - painter->drawPath(path); -} - -void usage() -{ - qWarning() << "Usage: mainwindow [-SizeHint x] ..."; - exit(1); -} - -QMap parseCustomSizeHints(int argc, char **argv) -{ - QMap result; - - for (int i = 1; i < argc; ++i) { - QString arg = QString::fromLocal8Bit(argv[i]); - - if (arg.startsWith(QLatin1String("-SizeHint"))) { - QString name = arg.mid(9); - if (name.isEmpty()) - usage(); - if (++i == argc) - usage(); - QString sizeStr = QString::fromLocal8Bit(argv[i]); - int idx = sizeStr.indexOf(QLatin1Char('x')); - if (idx == -1) - usage(); - bool ok; - int w = sizeStr.left(idx).toInt(&ok); - if (!ok) - usage(); - int h = sizeStr.mid(idx + 1).toInt(&ok); - if (!ok) - usage(); - result[name] = QSize(w, h); - } - } - - return result; -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - QMap customSizeHints = parseCustomSizeHints(argc, argv); - MainWindow mainWin(customSizeHints); - mainWin.resize(800, 600); - mainWin.show(); - return app.exec(); -} diff --git a/examples/mainwindows/mainwindow/mainwindow.cpp b/examples/mainwindows/mainwindow/mainwindow.cpp deleted file mode 100644 index 2ac2b562f2..0000000000 --- a/examples/mainwindows/mainwindow/mainwindow.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" -#include "colorswatch.h" -#include "toolbar.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char * const message = - "

      Qt Main Window Example

      " - - "

      This is a demonstration of the QMainWindow, QToolBar and " - "QDockWidget classes.

      " - - "

      The tool bar and dock widgets can be dragged around and rearranged " - "using the mouse or via the menu.

      " - - "

      Each dock widget contains a colored frame and a context " - "(right-click) menu.

      " - -#ifdef Q_OS_MAC - "

      On Mac OS X, the \"Black\" dock widget has been created as a " - "Drawer, which is a special kind of QDockWidget.

      " -#endif - ; - -Q_DECLARE_METATYPE(QDockWidget::DockWidgetFeatures) - -MainWindow::MainWindow(const QMap &customSizeHints, - QWidget *parent, Qt::WindowFlags flags) - : QMainWindow(parent, flags) -{ - setObjectName("MainWindow"); - setWindowTitle("Qt Main Window Example"); - - center = new QTextEdit(this); - center->setReadOnly(true); - center->setMinimumSize(400, 205); - setCentralWidget(center); - - setupToolBar(); - setupMenuBar(); - setupDockWidgets(customSizeHints); - - statusBar()->showMessage(tr("Status Bar")); -} - -void MainWindow::actionTriggered(QAction *action) -{ - qDebug("action '%s' triggered", action->text().toLocal8Bit().data()); -} - -void MainWindow::setupToolBar() -{ - for (int i = 0; i < 3; ++i) { - ToolBar *tb = new ToolBar(QString::fromLatin1("Tool Bar %1").arg(i + 1), this); - toolBars.append(tb); - addToolBar(tb); - } -} - -void MainWindow::setupMenuBar() -{ - QMenu *menu = menuBar()->addMenu(tr("&File")); - - QAction *action = menu->addAction(tr("Save layout...")); - connect(action, SIGNAL(triggered()), this, SLOT(saveLayout())); - - action = menu->addAction(tr("Load layout...")); - connect(action, SIGNAL(triggered()), this, SLOT(loadLayout())); - - action = menu->addAction(tr("Switch layout direction")); - connect(action, SIGNAL(triggered()), this, SLOT(switchLayoutDirection())); - - menu->addSeparator(); - - menu->addAction(tr("&Quit"), this, SLOT(close())); - - mainWindowMenu = menuBar()->addMenu(tr("Main window")); - - action = mainWindowMenu->addAction(tr("Animated docks")); - action->setCheckable(true); - action->setChecked(dockOptions() & AnimatedDocks); - connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions())); - - action = mainWindowMenu->addAction(tr("Allow nested docks")); - action->setCheckable(true); - action->setChecked(dockOptions() & AllowNestedDocks); - connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions())); - - action = mainWindowMenu->addAction(tr("Allow tabbed docks")); - action->setCheckable(true); - action->setChecked(dockOptions() & AllowTabbedDocks); - connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions())); - - action = mainWindowMenu->addAction(tr("Force tabbed docks")); - action->setCheckable(true); - action->setChecked(dockOptions() & ForceTabbedDocks); - connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions())); - - action = mainWindowMenu->addAction(tr("Vertical tabs")); - action->setCheckable(true); - action->setChecked(dockOptions() & VerticalTabs); - connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions())); - - QMenu *toolBarMenu = menuBar()->addMenu(tr("Tool bars")); - for (int i = 0; i < toolBars.count(); ++i) - toolBarMenu->addMenu(toolBars.at(i)->menu); - - dockWidgetMenu = menuBar()->addMenu(tr("&Dock Widgets")); -} - -void MainWindow::setDockOptions() -{ - DockOptions opts; - QList actions = mainWindowMenu->actions(); - - if (actions.at(0)->isChecked()) - opts |= AnimatedDocks; - if (actions.at(1)->isChecked()) - opts |= AllowNestedDocks; - if (actions.at(2)->isChecked()) - opts |= AllowTabbedDocks; - if (actions.at(3)->isChecked()) - opts |= ForceTabbedDocks; - if (actions.at(4)->isChecked()) - opts |= VerticalTabs; - - QMainWindow::setDockOptions(opts); -} - -void MainWindow::saveLayout() -{ - QString fileName - = QFileDialog::getSaveFileName(this, tr("Save layout")); - if (fileName.isEmpty()) - return; - QFile file(fileName); - if (!file.open(QFile::WriteOnly)) { - QString msg = tr("Failed to open %1\n%2") - .arg(fileName) - .arg(file.errorString()); - QMessageBox::warning(this, tr("Error"), msg); - return; - } - - QByteArray geo_data = saveGeometry(); - QByteArray layout_data = saveState(); - - bool ok = file.putChar((uchar)geo_data.size()); - if (ok) - ok = file.write(geo_data) == geo_data.size(); - if (ok) - ok = file.write(layout_data) == layout_data.size(); - - if (!ok) { - QString msg = tr("Error writing to %1\n%2") - .arg(fileName) - .arg(file.errorString()); - QMessageBox::warning(this, tr("Error"), msg); - return; - } -} - -void MainWindow::loadLayout() -{ - QString fileName - = QFileDialog::getOpenFileName(this, tr("Load layout")); - if (fileName.isEmpty()) - return; - QFile file(fileName); - if (!file.open(QFile::ReadOnly)) { - QString msg = tr("Failed to open %1\n%2") - .arg(fileName) - .arg(file.errorString()); - QMessageBox::warning(this, tr("Error"), msg); - return; - } - - uchar geo_size; - QByteArray geo_data; - QByteArray layout_data; - - bool ok = file.getChar((char*)&geo_size); - if (ok) { - geo_data = file.read(geo_size); - ok = geo_data.size() == geo_size; - } - if (ok) { - layout_data = file.readAll(); - ok = layout_data.size() > 0; - } - - if (ok) - ok = restoreGeometry(geo_data); - if (ok) - ok = restoreState(layout_data); - - if (!ok) { - QString msg = tr("Error reading %1") - .arg(fileName); - QMessageBox::warning(this, tr("Error"), msg); - return; - } -} - -QAction *addAction(QMenu *menu, const QString &text, QActionGroup *group, QSignalMapper *mapper, - int id) -{ - bool first = group->actions().isEmpty(); - QAction *result = menu->addAction(text); - result->setCheckable(true); - result->setChecked(first); - group->addAction(result); - QObject::connect(result, SIGNAL(triggered()), mapper, SLOT(map())); - mapper->setMapping(result, id); - return result; -} - -void MainWindow::setupDockWidgets(const QMap &customSizeHints) -{ - qRegisterMetaType(); - - mapper = new QSignalMapper(this); - connect(mapper, SIGNAL(mapped(int)), this, SLOT(setCorner(int))); - - QMenu *corner_menu = dockWidgetMenu->addMenu(tr("Top left corner")); - QActionGroup *group = new QActionGroup(this); - group->setExclusive(true); - ::addAction(corner_menu, tr("Top dock area"), group, mapper, 0); - ::addAction(corner_menu, tr("Left dock area"), group, mapper, 1); - - corner_menu = dockWidgetMenu->addMenu(tr("Top right corner")); - group = new QActionGroup(this); - group->setExclusive(true); - ::addAction(corner_menu, tr("Top dock area"), group, mapper, 2); - ::addAction(corner_menu, tr("Right dock area"), group, mapper, 3); - - corner_menu = dockWidgetMenu->addMenu(tr("Bottom left corner")); - group = new QActionGroup(this); - group->setExclusive(true); - ::addAction(corner_menu, tr("Bottom dock area"), group, mapper, 4); - ::addAction(corner_menu, tr("Left dock area"), group, mapper, 5); - - corner_menu = dockWidgetMenu->addMenu(tr("Bottom right corner")); - group = new QActionGroup(this); - group->setExclusive(true); - ::addAction(corner_menu, tr("Bottom dock area"), group, mapper, 6); - ::addAction(corner_menu, tr("Right dock area"), group, mapper, 7); - - dockWidgetMenu->addSeparator(); - - static const struct Set { - const char * name; - uint flags; - Qt::DockWidgetArea area; - } sets [] = { -#ifndef Q_OS_MAC - { "Black", 0, Qt::LeftDockWidgetArea }, -#else - { "Black", Qt::Drawer, Qt::LeftDockWidgetArea }, -#endif - { "White", 0, Qt::RightDockWidgetArea }, - { "Red", 0, Qt::TopDockWidgetArea }, - { "Green", 0, Qt::TopDockWidgetArea }, - { "Blue", 0, Qt::BottomDockWidgetArea }, - { "Yellow", 0, Qt::BottomDockWidgetArea } - }; - const int setCount = sizeof(sets) / sizeof(Set); - - for (int i = 0; i < setCount; ++i) { - ColorSwatch *swatch = new ColorSwatch(tr(sets[i].name), this, Qt::WindowFlags(sets[i].flags)); - if (i%2) - swatch->setWindowIcon(QIcon(QPixmap(":/res/qt.png"))); - if (qstrcmp(sets[i].name, "Blue") == 0) { - BlueTitleBar *titlebar = new BlueTitleBar(swatch); - swatch->setTitleBarWidget(titlebar); - connect(swatch, SIGNAL(topLevelChanged(bool)), titlebar, SLOT(updateMask())); - connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask()), Qt::QueuedConnection); - - } - - QString name = QString::fromLatin1(sets[i].name); - if (customSizeHints.contains(name)) - swatch->setCustomSizeHint(customSizeHints.value(name)); - - addDockWidget(sets[i].area, swatch); - dockWidgetMenu->addMenu(swatch->menu); - } - - createDockWidgetAction = new QAction(tr("Add dock widget..."), this); - connect(createDockWidgetAction, SIGNAL(triggered()), this, SLOT(createDockWidget())); - destroyDockWidgetMenu = new QMenu(tr("Destroy dock widget"), this); - destroyDockWidgetMenu->setEnabled(false); - connect(destroyDockWidgetMenu, SIGNAL(triggered(QAction*)), this, SLOT(destroyDockWidget(QAction*))); - - dockWidgetMenu->addSeparator(); - dockWidgetMenu->addAction(createDockWidgetAction); - dockWidgetMenu->addMenu(destroyDockWidgetMenu); -} - -void MainWindow::setCorner(int id) -{ - switch (id) { - case 0: - QMainWindow::setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea); - break; - case 1: - QMainWindow::setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - break; - case 2: - QMainWindow::setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); - break; - case 3: - QMainWindow::setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); - break; - case 4: - QMainWindow::setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea); - break; - case 5: - QMainWindow::setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - break; - case 6: - QMainWindow::setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); - break; - case 7: - QMainWindow::setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - break; - } -} - -void MainWindow::showEvent(QShowEvent *event) -{ - QMainWindow::showEvent(event); -} - -void MainWindow::switchLayoutDirection() -{ - if (layoutDirection() == Qt::LeftToRight) - qApp->setLayoutDirection(Qt::RightToLeft); - else - qApp->setLayoutDirection(Qt::LeftToRight); -} - -class CreateDockWidgetDialog : public QDialog -{ -public: - CreateDockWidgetDialog(QWidget *parent = 0); - - QString objectName() const; - Qt::DockWidgetArea location() const; - -private: - QLineEdit *m_objectName; - QComboBox *m_location; -}; - -CreateDockWidgetDialog::CreateDockWidgetDialog(QWidget *parent) - : QDialog(parent) -{ - QGridLayout *layout = new QGridLayout(this); - - layout->addWidget(new QLabel(tr("Object name:")), 0, 0); - m_objectName = new QLineEdit; - layout->addWidget(m_objectName, 0, 1); - - layout->addWidget(new QLabel(tr("Location:")), 1, 0); - m_location = new QComboBox; - m_location->setEditable(false); - m_location->addItem(tr("Top")); - m_location->addItem(tr("Left")); - m_location->addItem(tr("Right")); - m_location->addItem(tr("Bottom")); - m_location->addItem(tr("Restore")); - layout->addWidget(m_location, 1, 1); - - QHBoxLayout *buttonLayout = new QHBoxLayout; - layout->addLayout(buttonLayout, 2, 0, 1, 2); - buttonLayout->addStretch(); - - QPushButton *cancelButton = new QPushButton(tr("Cancel")); - connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); - buttonLayout->addWidget(cancelButton); - QPushButton *okButton = new QPushButton(tr("Ok")); - connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); - buttonLayout->addWidget(okButton); - - okButton->setDefault(true); -} - -QString CreateDockWidgetDialog::objectName() const -{ - return m_objectName->text(); -} - -Qt::DockWidgetArea CreateDockWidgetDialog::location() const -{ - switch (m_location->currentIndex()) { - case 0: return Qt::TopDockWidgetArea; - case 1: return Qt::LeftDockWidgetArea; - case 2: return Qt::RightDockWidgetArea; - case 3: return Qt::BottomDockWidgetArea; - default: - break; - } - return Qt::NoDockWidgetArea; -} - -void MainWindow::createDockWidget() -{ - CreateDockWidgetDialog dialog(this); - int ret = dialog.exec(); - if (ret == QDialog::Rejected) - return; - - QDockWidget *dw = new QDockWidget; - dw->setObjectName(dialog.objectName()); - dw->setWindowTitle(dialog.objectName()); - dw->setWidget(new QTextEdit); - - Qt::DockWidgetArea area = dialog.location(); - switch (area) { - case Qt::LeftDockWidgetArea: - case Qt::RightDockWidgetArea: - case Qt::TopDockWidgetArea: - case Qt::BottomDockWidgetArea: - addDockWidget(area, dw); - break; - default: - if (!restoreDockWidget(dw)) { - QMessageBox::warning(this, QString(), tr("Failed to restore dock widget")); - delete dw; - return; - } - break; - } - - extraDockWidgets.append(dw); - destroyDockWidgetMenu->setEnabled(true); - destroyDockWidgetMenu->addAction(new QAction(dialog.objectName(), this)); -} - -void MainWindow::destroyDockWidget(QAction *action) -{ - int index = destroyDockWidgetMenu->actions().indexOf(action); - delete extraDockWidgets.takeAt(index); - destroyDockWidgetMenu->removeAction(action); - action->deleteLater(); - - if (destroyDockWidgetMenu->isEmpty()) - destroyDockWidgetMenu->setEnabled(false); -} diff --git a/examples/mainwindows/mainwindow/mainwindow.h b/examples/mainwindows/mainwindow/mainwindow.h deleted file mode 100644 index 51969acaa3..0000000000 --- a/examples/mainwindows/mainwindow/mainwindow.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include - -class ToolBar; -QT_FORWARD_DECLARE_CLASS(QMenu) -QT_FORWARD_DECLARE_CLASS(QSignalMapper) - -class MainWindow : public QMainWindow -{ - Q_OBJECT - - QTextEdit *center; - QList toolBars; - QMenu *dockWidgetMenu; - QMenu *mainWindowMenu; - QSignalMapper *mapper; - QList extraDockWidgets; - QAction *createDockWidgetAction; - QMenu *destroyDockWidgetMenu; - -public: - MainWindow(const QMap &customSizeHints, - QWidget *parent = 0, Qt::WindowFlags flags = 0); - -protected: - void showEvent(QShowEvent *event); - -public slots: - void actionTriggered(QAction *action); - void saveLayout(); - void loadLayout(); - void setCorner(int id); - void switchLayoutDirection(); - void setDockOptions(); - - void createDockWidget(); - void destroyDockWidget(QAction *action); - -private: - void setupToolBar(); - void setupMenuBar(); - void setupDockWidgets(const QMap &customSizeHints); -}; - - -#endif diff --git a/examples/mainwindows/mainwindow/mainwindow.pro b/examples/mainwindows/mainwindow/mainwindow.pro deleted file mode 100644 index 1381c460c2..0000000000 --- a/examples/mainwindows/mainwindow/mainwindow.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -HEADERS += colorswatch.h mainwindow.h toolbar.h -SOURCES += colorswatch.cpp mainwindow.cpp toolbar.cpp main.cpp -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -RESOURCES += mainwindow.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mainwindow -sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.png *.jpg *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mainwindow -INSTALLS += target sources - -QT += widgets diff --git a/examples/mainwindows/mainwindow/mainwindow.qrc b/examples/mainwindows/mainwindow/mainwindow.qrc deleted file mode 100644 index 47ff22a3e4..0000000000 --- a/examples/mainwindows/mainwindow/mainwindow.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - qt.png - titlebarLeft.png - titlebarCenter.png - titlebarRight.png - - diff --git a/examples/mainwindows/mainwindow/qt.png b/examples/mainwindows/mainwindow/qt.png deleted file mode 100644 index 48fa9fc2ef..0000000000 Binary files a/examples/mainwindows/mainwindow/qt.png and /dev/null differ diff --git a/examples/mainwindows/mainwindow/titlebarCenter.png b/examples/mainwindows/mainwindow/titlebarCenter.png deleted file mode 100644 index 5cc141355c..0000000000 Binary files a/examples/mainwindows/mainwindow/titlebarCenter.png and /dev/null differ diff --git a/examples/mainwindows/mainwindow/titlebarLeft.png b/examples/mainwindows/mainwindow/titlebarLeft.png deleted file mode 100644 index 315166202b..0000000000 Binary files a/examples/mainwindows/mainwindow/titlebarLeft.png and /dev/null differ diff --git a/examples/mainwindows/mainwindow/titlebarRight.png b/examples/mainwindows/mainwindow/titlebarRight.png deleted file mode 100644 index a4505268ec..0000000000 Binary files a/examples/mainwindows/mainwindow/titlebarRight.png and /dev/null differ diff --git a/examples/mainwindows/mainwindow/toolbar.cpp b/examples/mainwindows/mainwindow/toolbar.cpp deleted file mode 100644 index d10eccb46d..0000000000 --- a/examples/mainwindows/mainwindow/toolbar.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "toolbar.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -static QPixmap genIcon(const QSize &iconSize, const QString &, const QColor &color) -{ - int w = iconSize.width(); - int h = iconSize.height(); - - QImage image(w, h, QImage::Format_ARGB32_Premultiplied); - image.fill(0); - - QPainter p(&image); - - extern void render_qt_text(QPainter *, int, int, const QColor &); - render_qt_text(&p, w, h, color); - - return QPixmap::fromImage(image, Qt::DiffuseDither | Qt::DiffuseAlphaDither); -} - -static QPixmap genIcon(const QSize &iconSize, int number, const QColor &color) -{ return genIcon(iconSize, QString::number(number), color); } - -ToolBar::ToolBar(const QString &title, QWidget *parent) - : QToolBar(parent), spinbox(0), spinboxAction(0) -{ - tip = 0; - setWindowTitle(title); - setObjectName(title); - - setIconSize(QSize(32, 32)); - - QColor bg(palette().background().color()); - menu = new QMenu("One", this); - menu->setIcon(genIcon(iconSize(), 1, Qt::black)); - menu->addAction(genIcon(iconSize(), "A", Qt::blue), "A"); - menu->addAction(genIcon(iconSize(), "B", Qt::blue), "B"); - menu->addAction(genIcon(iconSize(), "C", Qt::blue), "C"); - addAction(menu->menuAction()); - - QAction *two = addAction(genIcon(iconSize(), 2, Qt::white), "Two"); - QFont boldFont; - boldFont.setBold(true); - two->setFont(boldFont); - - addAction(genIcon(iconSize(), 3, Qt::red), "Three"); - addAction(genIcon(iconSize(), 4, Qt::green), "Four"); - addAction(genIcon(iconSize(), 5, Qt::blue), "Five"); - addAction(genIcon(iconSize(), 6, Qt::yellow), "Six"); - orderAction = new QAction(this); - orderAction->setText(tr("Order Items in Tool Bar")); - connect(orderAction, SIGNAL(triggered()), SLOT(order())); - - randomizeAction = new QAction(this); - randomizeAction->setText(tr("Randomize Items in Tool Bar")); - connect(randomizeAction, SIGNAL(triggered()), SLOT(randomize())); - - addSpinBoxAction = new QAction(this); - addSpinBoxAction->setText(tr("Add Spin Box")); - connect(addSpinBoxAction, SIGNAL(triggered()), SLOT(addSpinBox())); - - removeSpinBoxAction = new QAction(this); - removeSpinBoxAction->setText(tr("Remove Spin Box")); - removeSpinBoxAction->setEnabled(false); - connect(removeSpinBoxAction, SIGNAL(triggered()), SLOT(removeSpinBox())); - - movableAction = new QAction(tr("Movable"), this); - movableAction->setCheckable(true); - connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool))); - - allowedAreasActions = new QActionGroup(this); - allowedAreasActions->setExclusive(false); - - allowLeftAction = new QAction(tr("Allow on Left"), this); - allowLeftAction->setCheckable(true); - connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool))); - - allowRightAction = new QAction(tr("Allow on Right"), this); - allowRightAction->setCheckable(true); - connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool))); - - allowTopAction = new QAction(tr("Allow on Top"), this); - allowTopAction->setCheckable(true); - connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool))); - - allowBottomAction = new QAction(tr("Allow on Bottom"), this); - allowBottomAction->setCheckable(true); - connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool))); - - allowedAreasActions->addAction(allowLeftAction); - allowedAreasActions->addAction(allowRightAction); - allowedAreasActions->addAction(allowTopAction); - allowedAreasActions->addAction(allowBottomAction); - - areaActions = new QActionGroup(this); - areaActions->setExclusive(true); - - leftAction = new QAction(tr("Place on Left") , this); - leftAction->setCheckable(true); - connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool))); - - rightAction = new QAction(tr("Place on Right") , this); - rightAction->setCheckable(true); - connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool))); - - topAction = new QAction(tr("Place on Top") , this); - topAction->setCheckable(true); - connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool))); - - bottomAction = new QAction(tr("Place on Bottom") , this); - bottomAction->setCheckable(true); - connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool))); - - areaActions->addAction(leftAction); - areaActions->addAction(rightAction); - areaActions->addAction(topAction); - areaActions->addAction(bottomAction); - - toolBarBreakAction = new QAction(tr("Insert break"), this); - connect(toolBarBreakAction, SIGNAL(triggered(bool)), this, SLOT(insertToolBarBreak())); - - connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool))); - - connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool))); - - menu = new QMenu(title, this); - menu->addAction(toggleViewAction()); - menu->addSeparator(); - menu->addAction(orderAction); - menu->addAction(randomizeAction); - menu->addSeparator(); - menu->addAction(addSpinBoxAction); - menu->addAction(removeSpinBoxAction); - menu->addSeparator(); - menu->addAction(movableAction); - menu->addSeparator(); - menu->addActions(allowedAreasActions->actions()); - menu->addSeparator(); - menu->addActions(areaActions->actions()); - menu->addSeparator(); - menu->addAction(toolBarBreakAction); - - connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); - - randomize(); -} - -void ToolBar::updateMenu() -{ - QMainWindow *mainWindow = qobject_cast(parentWidget()); - Q_ASSERT(mainWindow != 0); - - const Qt::ToolBarArea area = mainWindow->toolBarArea(this); - const Qt::ToolBarAreas areas = allowedAreas(); - - movableAction->setChecked(isMovable()); - - allowLeftAction->setChecked(isAreaAllowed(Qt::LeftToolBarArea)); - allowRightAction->setChecked(isAreaAllowed(Qt::RightToolBarArea)); - allowTopAction->setChecked(isAreaAllowed(Qt::TopToolBarArea)); - allowBottomAction->setChecked(isAreaAllowed(Qt::BottomToolBarArea)); - - if (allowedAreasActions->isEnabled()) { - allowLeftAction->setEnabled(area != Qt::LeftToolBarArea); - allowRightAction->setEnabled(area != Qt::RightToolBarArea); - allowTopAction->setEnabled(area != Qt::TopToolBarArea); - allowBottomAction->setEnabled(area != Qt::BottomToolBarArea); - } - - leftAction->setChecked(area == Qt::LeftToolBarArea); - rightAction->setChecked(area == Qt::RightToolBarArea); - topAction->setChecked(area == Qt::TopToolBarArea); - bottomAction->setChecked(area == Qt::BottomToolBarArea); - - if (areaActions->isEnabled()) { - leftAction->setEnabled(areas & Qt::LeftToolBarArea); - rightAction->setEnabled(areas & Qt::RightToolBarArea); - topAction->setEnabled(areas & Qt::TopToolBarArea); - bottomAction->setEnabled(areas & Qt::BottomToolBarArea); - } -} - -void ToolBar::order() -{ - QList ordered, actions1 = actions(), - actions2 = findChildren(); - while (!actions2.isEmpty()) { - QAction *action = actions2.takeFirst(); - if (!actions1.contains(action)) - continue; - actions1.removeAll(action); - ordered.append(action); - } - - clear(); - addActions(ordered); - - orderAction->setEnabled(false); -} - -void ToolBar::randomize() -{ - QList randomized, actions = this->actions(); - while (!actions.isEmpty()) { - QAction *action = actions.takeAt(rand() % actions.size()); - randomized.append(action); - } - clear(); - addActions(randomized); - - orderAction->setEnabled(true); -} - -void ToolBar::addSpinBox() -{ - if (!spinbox) { - spinbox = new QSpinBox(this); - } - if (!spinboxAction) - spinboxAction = addWidget(spinbox); - else - addAction(spinboxAction); - - addSpinBoxAction->setEnabled(false); - removeSpinBoxAction->setEnabled(true); -} - -void ToolBar::removeSpinBox() -{ - if (spinboxAction) - removeAction(spinboxAction); - - addSpinBoxAction->setEnabled(true); - removeSpinBoxAction->setEnabled(false); -} - -void ToolBar::allow(Qt::ToolBarArea area, bool a) -{ - Qt::ToolBarAreas areas = allowedAreas(); - areas = a ? areas | area : areas & ~area; - setAllowedAreas(areas); - - if (areaActions->isEnabled()) { - leftAction->setEnabled(areas & Qt::LeftToolBarArea); - rightAction->setEnabled(areas & Qt::RightToolBarArea); - topAction->setEnabled(areas & Qt::TopToolBarArea); - bottomAction->setEnabled(areas & Qt::BottomToolBarArea); - } -} - -void ToolBar::place(Qt::ToolBarArea area, bool p) -{ - if (!p) - return; - - QMainWindow *mainWindow = qobject_cast(parentWidget()); - Q_ASSERT(mainWindow != 0); - - mainWindow->addToolBar(area, this); - - if (allowedAreasActions->isEnabled()) { - allowLeftAction->setEnabled(area != Qt::LeftToolBarArea); - allowRightAction->setEnabled(area != Qt::RightToolBarArea); - allowTopAction->setEnabled(area != Qt::TopToolBarArea); - allowBottomAction->setEnabled(area != Qt::BottomToolBarArea); - } -} - -void ToolBar::changeMovable(bool movable) -{ setMovable(movable); } - -void ToolBar::allowLeft(bool a) -{ allow(Qt::LeftToolBarArea, a); } - -void ToolBar::allowRight(bool a) -{ allow(Qt::RightToolBarArea, a); } - -void ToolBar::allowTop(bool a) -{ allow(Qt::TopToolBarArea, a); } - -void ToolBar::allowBottom(bool a) -{ allow(Qt::BottomToolBarArea, a); } - -void ToolBar::placeLeft(bool p) -{ place(Qt::LeftToolBarArea, p); } - -void ToolBar::placeRight(bool p) -{ place(Qt::RightToolBarArea, p); } - -void ToolBar::placeTop(bool p) -{ place(Qt::TopToolBarArea, p); } - -void ToolBar::placeBottom(bool p) -{ place(Qt::BottomToolBarArea, p); } - -void ToolBar::insertToolBarBreak() -{ - QMainWindow *mainWindow = qobject_cast(parentWidget()); - Q_ASSERT(mainWindow != 0); - - mainWindow->insertToolBarBreak(this); -} - -void ToolBar::enterEvent(QEvent*) -{ -/* - These labels on top of toolbars look darn ugly - - if (tip == 0) { - tip = new QLabel(windowTitle(), this); - QPalette pal = tip->palette(); - QColor c = Qt::black; - c.setAlpha(100); - pal.setColor(QPalette::Window, c); - pal.setColor(QPalette::Foreground, Qt::white); - tip->setPalette(pal); - tip->setAutoFillBackground(true); - tip->setMargin(3); - tip->setText(windowTitle()); - } - QPoint c = rect().center(); - QSize hint = tip->sizeHint(); - tip->setGeometry(c.x() - hint.width()/2, c.y() - hint.height()/2, - hint.width(), hint.height()); - - tip->show(); -*/ -} - -void ToolBar::leaveEvent(QEvent*) -{ - if (tip != 0) - tip->hide(); -} diff --git a/examples/mainwindows/mainwindow/toolbar.h b/examples/mainwindows/mainwindow/toolbar.h deleted file mode 100644 index 0ffb1eea5d..0000000000 --- a/examples/mainwindows/mainwindow/toolbar.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TOOLBAR_H -#define TOOLBAR_H - -#include - -QT_FORWARD_DECLARE_CLASS(QAction) -QT_FORWARD_DECLARE_CLASS(QActionGroup) -QT_FORWARD_DECLARE_CLASS(QMenu) -QT_FORWARD_DECLARE_CLASS(QSpinBox) -QT_FORWARD_DECLARE_CLASS(QLabel) - -class ToolBar : public QToolBar -{ - Q_OBJECT - - QSpinBox *spinbox; - QAction *spinboxAction; - - QAction *orderAction; - QAction *randomizeAction; - QAction *addSpinBoxAction; - QAction *removeSpinBoxAction; - - QAction *movableAction; - - QActionGroup *allowedAreasActions; - QAction *allowLeftAction; - QAction *allowRightAction; - QAction *allowTopAction; - QAction *allowBottomAction; - - QActionGroup *areaActions; - QAction *leftAction; - QAction *rightAction; - QAction *topAction; - QAction *bottomAction; - - QAction *toolBarBreakAction; - -public: - ToolBar(const QString &title, QWidget *parent); - - QMenu *menu; - -protected: - void enterEvent(QEvent*); - void leaveEvent(QEvent*); - -private: - void allow(Qt::ToolBarArea area, bool allow); - void place(Qt::ToolBarArea area, bool place); - QLabel *tip; - -private slots: - void order(); - void randomize(); - void addSpinBox(); - void removeSpinBox(); - - void changeMovable(bool movable); - - void allowLeft(bool a); - void allowRight(bool a); - void allowTop(bool a); - void allowBottom(bool a); - - void placeLeft(bool p); - void placeRight(bool p); - void placeTop(bool p); - void placeBottom(bool p); - - void updateMenu(); - void insertToolBarBreak(); - -}; - -#endif diff --git a/examples/mainwindows/mainwindows.pro b/examples/mainwindows/mainwindows.pro deleted file mode 100644 index c30d29e95a..0000000000 --- a/examples/mainwindows/mainwindows.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = application \ - dockwidgets \ - mainwindow \ - mdi \ - menus \ - recentfiles \ - sdi - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mainwindows.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows -INSTALLS += target sources - -QT += widgets diff --git a/examples/mainwindows/mdi/images/copy.png b/examples/mainwindows/mdi/images/copy.png deleted file mode 100644 index 2aeb28288f..0000000000 Binary files a/examples/mainwindows/mdi/images/copy.png and /dev/null differ diff --git a/examples/mainwindows/mdi/images/cut.png b/examples/mainwindows/mdi/images/cut.png deleted file mode 100644 index 54638e9386..0000000000 Binary files a/examples/mainwindows/mdi/images/cut.png and /dev/null differ diff --git a/examples/mainwindows/mdi/images/new.png b/examples/mainwindows/mdi/images/new.png deleted file mode 100644 index 12131b0100..0000000000 Binary files a/examples/mainwindows/mdi/images/new.png and /dev/null differ diff --git a/examples/mainwindows/mdi/images/open.png b/examples/mainwindows/mdi/images/open.png deleted file mode 100644 index 45fa2883a7..0000000000 Binary files a/examples/mainwindows/mdi/images/open.png and /dev/null differ diff --git a/examples/mainwindows/mdi/images/paste.png b/examples/mainwindows/mdi/images/paste.png deleted file mode 100644 index c14425cad1..0000000000 Binary files a/examples/mainwindows/mdi/images/paste.png and /dev/null differ diff --git a/examples/mainwindows/mdi/images/save.png b/examples/mainwindows/mdi/images/save.png deleted file mode 100644 index daba865faf..0000000000 Binary files a/examples/mainwindows/mdi/images/save.png and /dev/null differ diff --git a/examples/mainwindows/mdi/main.cpp b/examples/mainwindows/mdi/main.cpp deleted file mode 100644 index 8beec478a4..0000000000 --- a/examples/mainwindows/mdi/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(mdi); - - QApplication app(argc, argv); - MainWindow mainWin; - mainWin.show(); - return app.exec(); -} diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp deleted file mode 100644 index 6ba15aa224..0000000000 --- a/examples/mainwindows/mdi/mainwindow.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" -#include "mdichild.h" - -MainWindow::MainWindow() -{ - mdiArea = new QMdiArea; - mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setCentralWidget(mdiArea); - connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), - this, SLOT(updateMenus())); - windowMapper = new QSignalMapper(this); - connect(windowMapper, SIGNAL(mapped(QWidget*)), - this, SLOT(setActiveSubWindow(QWidget*))); - - createActions(); - createMenus(); - createToolBars(); - createStatusBar(); - updateMenus(); - - readSettings(); - - setWindowTitle(tr("MDI")); - setUnifiedTitleAndToolBarOnMac(true); -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - mdiArea->closeAllSubWindows(); - if (mdiArea->currentSubWindow()) { - event->ignore(); - } else { - writeSettings(); - event->accept(); - } -} - -void MainWindow::newFile() -{ - MdiChild *child = createMdiChild(); - child->newFile(); - child->show(); -} - -void MainWindow::open() -{ - QString fileName = QFileDialog::getOpenFileName(this); - if (!fileName.isEmpty()) { - QMdiSubWindow *existing = findMdiChild(fileName); - if (existing) { - mdiArea->setActiveSubWindow(existing); - return; - } - - MdiChild *child = createMdiChild(); - if (child->loadFile(fileName)) { - statusBar()->showMessage(tr("File loaded"), 2000); - child->show(); - } else { - child->close(); - } - } -} - -void MainWindow::save() -{ - if (activeMdiChild() && activeMdiChild()->save()) - statusBar()->showMessage(tr("File saved"), 2000); -} - -void MainWindow::saveAs() -{ - if (activeMdiChild() && activeMdiChild()->saveAs()) - statusBar()->showMessage(tr("File saved"), 2000); -} - -#ifndef QT_NO_CLIPBOARD -void MainWindow::cut() -{ - if (activeMdiChild()) - activeMdiChild()->cut(); -} - -void MainWindow::copy() -{ - if (activeMdiChild()) - activeMdiChild()->copy(); -} - -void MainWindow::paste() -{ - if (activeMdiChild()) - activeMdiChild()->paste(); -} -#endif - -void MainWindow::about() -{ - QMessageBox::about(this, tr("About MDI"), - tr("The MDI example demonstrates how to write multiple " - "document interface applications using Qt.")); -} - -void MainWindow::updateMenus() -{ - bool hasMdiChild = (activeMdiChild() != 0); - saveAct->setEnabled(hasMdiChild); - saveAsAct->setEnabled(hasMdiChild); -#ifndef QT_NO_CLIPBOARD - pasteAct->setEnabled(hasMdiChild); -#endif - closeAct->setEnabled(hasMdiChild); - closeAllAct->setEnabled(hasMdiChild); - tileAct->setEnabled(hasMdiChild); - cascadeAct->setEnabled(hasMdiChild); - nextAct->setEnabled(hasMdiChild); - previousAct->setEnabled(hasMdiChild); - separatorAct->setVisible(hasMdiChild); - -#ifndef QT_NO_CLIPBOARD - bool hasSelection = (activeMdiChild() && - activeMdiChild()->textCursor().hasSelection()); - cutAct->setEnabled(hasSelection); - copyAct->setEnabled(hasSelection); -#endif -} - -void MainWindow::updateWindowMenu() -{ - windowMenu->clear(); - windowMenu->addAction(closeAct); - windowMenu->addAction(closeAllAct); - windowMenu->addSeparator(); - windowMenu->addAction(tileAct); - windowMenu->addAction(cascadeAct); - windowMenu->addSeparator(); - windowMenu->addAction(nextAct); - windowMenu->addAction(previousAct); - windowMenu->addAction(separatorAct); - - QList windows = mdiArea->subWindowList(); - separatorAct->setVisible(!windows.isEmpty()); - - for (int i = 0; i < windows.size(); ++i) { - MdiChild *child = qobject_cast(windows.at(i)->widget()); - - QString text; - if (i < 9) { - text = tr("&%1 %2").arg(i + 1) - .arg(child->userFriendlyCurrentFile()); - } else { - text = tr("%1 %2").arg(i + 1) - .arg(child->userFriendlyCurrentFile()); - } - QAction *action = windowMenu->addAction(text); - action->setCheckable(true); - action ->setChecked(child == activeMdiChild()); - connect(action, SIGNAL(triggered()), windowMapper, SLOT(map())); - windowMapper->setMapping(action, windows.at(i)); - } -} - -MdiChild *MainWindow::createMdiChild() -{ - MdiChild *child = new MdiChild; - mdiArea->addSubWindow(child); - -#ifndef QT_NO_CLIPBOARD - connect(child, SIGNAL(copyAvailable(bool)), - cutAct, SLOT(setEnabled(bool))); - connect(child, SIGNAL(copyAvailable(bool)), - copyAct, SLOT(setEnabled(bool))); -#endif - - return child; -} - -void MainWindow::createActions() -{ - newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); - - openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); - - saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - - saveAsAct = new QAction(tr("Save &As..."), this); - saveAsAct->setShortcuts(QKeySequence::SaveAs); - saveAsAct->setStatusTip(tr("Save the document under a new name")); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); - -//! [0] - exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); -//! [0] - -#ifndef QT_NO_CLIPBOARD - cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); - cutAct->setShortcuts(QKeySequence::Cut); - cutAct->setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")); - connect(cutAct, SIGNAL(triggered()), this, SLOT(cut())); - - copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this); - copyAct->setShortcuts(QKeySequence::Copy); - copyAct->setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")); - connect(copyAct, SIGNAL(triggered()), this, SLOT(copy())); - - pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this); - pasteAct->setShortcuts(QKeySequence::Paste); - pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")); - connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste())); -#endif - - closeAct = new QAction(tr("Cl&ose"), this); - closeAct->setStatusTip(tr("Close the active window")); - connect(closeAct, SIGNAL(triggered()), - mdiArea, SLOT(closeActiveSubWindow())); - - closeAllAct = new QAction(tr("Close &All"), this); - closeAllAct->setStatusTip(tr("Close all the windows")); - connect(closeAllAct, SIGNAL(triggered()), - mdiArea, SLOT(closeAllSubWindows())); - - tileAct = new QAction(tr("&Tile"), this); - tileAct->setStatusTip(tr("Tile the windows")); - connect(tileAct, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows())); - - cascadeAct = new QAction(tr("&Cascade"), this); - cascadeAct->setStatusTip(tr("Cascade the windows")); - connect(cascadeAct, SIGNAL(triggered()), mdiArea, SLOT(cascadeSubWindows())); - - nextAct = new QAction(tr("Ne&xt"), this); - nextAct->setShortcuts(QKeySequence::NextChild); - nextAct->setStatusTip(tr("Move the focus to the next window")); - connect(nextAct, SIGNAL(triggered()), - mdiArea, SLOT(activateNextSubWindow())); - - previousAct = new QAction(tr("Pre&vious"), this); - previousAct->setShortcuts(QKeySequence::PreviousChild); - previousAct->setStatusTip(tr("Move the focus to the previous " - "window")); - connect(previousAct, SIGNAL(triggered()), - mdiArea, SLOT(activatePreviousSubWindow())); - - separatorAct = new QAction(this); - separatorAct->setSeparator(true); - - aboutAct = new QAction(tr("&About"), this); - aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); -} - -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newAct); - fileMenu->addAction(openAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(saveAsAct); - fileMenu->addSeparator(); - QAction *action = fileMenu->addAction(tr("Switch layout direction")); - connect(action, SIGNAL(triggered()), this, SLOT(switchLayoutDirection())); - fileMenu->addAction(exitAct); - - editMenu = menuBar()->addMenu(tr("&Edit")); -#ifndef QT_NO_CLIPBOARD - editMenu->addAction(cutAct); - editMenu->addAction(copyAct); - editMenu->addAction(pasteAct); -#endif - - windowMenu = menuBar()->addMenu(tr("&Window")); - updateWindowMenu(); - connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowMenu())); - - menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); -} - -void MainWindow::createToolBars() -{ - fileToolBar = addToolBar(tr("File")); - fileToolBar->addAction(newAct); - fileToolBar->addAction(openAct); - fileToolBar->addAction(saveAct); - -#ifndef QT_NO_CLIPBOARD - editToolBar = addToolBar(tr("Edit")); - editToolBar->addAction(cutAct); - editToolBar->addAction(copyAct); - editToolBar->addAction(pasteAct); -#endif -} - -void MainWindow::createStatusBar() -{ - statusBar()->showMessage(tr("Ready")); -} - -void MainWindow::readSettings() -{ - QSettings settings("Trolltech", "MDI Example"); - QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); - QSize size = settings.value("size", QSize(400, 400)).toSize(); - move(pos); - resize(size); -} - -void MainWindow::writeSettings() -{ - QSettings settings("Trolltech", "MDI Example"); - settings.setValue("pos", pos()); - settings.setValue("size", size()); -} - -MdiChild *MainWindow::activeMdiChild() -{ - if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow()) - return qobject_cast(activeSubWindow->widget()); - return 0; -} - -QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName) -{ - QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath(); - - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { - MdiChild *mdiChild = qobject_cast(window->widget()); - if (mdiChild->currentFile() == canonicalFilePath) - return window; - } - return 0; -} - -void MainWindow::switchLayoutDirection() -{ - if (layoutDirection() == Qt::LeftToRight) - qApp->setLayoutDirection(Qt::RightToLeft); - else - qApp->setLayoutDirection(Qt::LeftToRight); -} - -void MainWindow::setActiveSubWindow(QWidget *window) -{ - if (!window) - return; - mdiArea->setActiveSubWindow(qobject_cast(window)); -} diff --git a/examples/mainwindows/mdi/mainwindow.h b/examples/mainwindows/mdi/mainwindow.h deleted file mode 100644 index 1652ca9749..0000000000 --- a/examples/mainwindows/mdi/mainwindow.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -class MdiChild; -QT_BEGIN_NAMESPACE -class QAction; -class QMenu; -class QMdiArea; -class QMdiSubWindow; -class QSignalMapper; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -protected: - void closeEvent(QCloseEvent *event); - -private slots: - void newFile(); - void open(); - void save(); - void saveAs(); -#ifndef QT_NO_CLIPBOARD - void cut(); - void copy(); - void paste(); -#endif - void about(); - void updateMenus(); - void updateWindowMenu(); - MdiChild *createMdiChild(); - void switchLayoutDirection(); - void setActiveSubWindow(QWidget *window); - -private: - void createActions(); - void createMenus(); - void createToolBars(); - void createStatusBar(); - void readSettings(); - void writeSettings(); - MdiChild *activeMdiChild(); - QMdiSubWindow *findMdiChild(const QString &fileName); - - QMdiArea *mdiArea; - QSignalMapper *windowMapper; - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *windowMenu; - QMenu *helpMenu; - QToolBar *fileToolBar; - QToolBar *editToolBar; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *exitAct; -#ifndef QT_NO_CLIPBOARD - QAction *cutAct; - QAction *copyAct; - QAction *pasteAct; -#endif - QAction *closeAct; - QAction *closeAllAct; - QAction *tileAct; - QAction *cascadeAct; - QAction *nextAct; - QAction *previousAct; - QAction *separatorAct; - QAction *aboutAct; - QAction *aboutQtAct; -}; - -#endif diff --git a/examples/mainwindows/mdi/mdi.desktop b/examples/mainwindows/mdi/mdi.desktop deleted file mode 100644 index 267e6f19d0..0000000000 --- a/examples/mainwindows/mdi/mdi.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=MDI -Exec=/opt/usr/bin/mdi -Icon=mdi -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/mainwindows/mdi/mdi.pro b/examples/mainwindows/mdi/mdi.pro deleted file mode 100644 index a4387fecd6..0000000000 --- a/examples/mainwindows/mdi/mdi.pro +++ /dev/null @@ -1,16 +0,0 @@ -HEADERS = mainwindow.h \ - mdichild.h -SOURCES = main.cpp \ - mainwindow.cpp \ - mdichild.cpp -RESOURCES = mdi.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mdi -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mdi.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mdi -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/mainwindows/mdi/mdi.qrc b/examples/mainwindows/mdi/mdi.qrc deleted file mode 100644 index 0a776fab4d..0000000000 --- a/examples/mainwindows/mdi/mdi.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - images/copy.png - images/cut.png - images/new.png - images/open.png - images/paste.png - images/save.png - - diff --git a/examples/mainwindows/mdi/mdichild.cpp b/examples/mainwindows/mdi/mdichild.cpp deleted file mode 100644 index 2279fe7044..0000000000 --- a/examples/mainwindows/mdi/mdichild.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mdichild.h" - -MdiChild::MdiChild() -{ - setAttribute(Qt::WA_DeleteOnClose); - isUntitled = true; -} - -void MdiChild::newFile() -{ - static int sequenceNumber = 1; - - isUntitled = true; - curFile = tr("document%1.txt").arg(sequenceNumber++); - setWindowTitle(curFile + "[*]"); - - connect(document(), SIGNAL(contentsChanged()), - this, SLOT(documentWasModified())); -} - -bool MdiChild::loadFile(const QString &fileName) -{ - QFile file(fileName); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, tr("MDI"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return false; - } - - QTextStream in(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - setPlainText(in.readAll()); - QApplication::restoreOverrideCursor(); - - setCurrentFile(fileName); - - connect(document(), SIGNAL(contentsChanged()), - this, SLOT(documentWasModified())); - - return true; -} - -bool MdiChild::save() -{ - if (isUntitled) { - return saveAs(); - } else { - return saveFile(curFile); - } -} - -bool MdiChild::saveAs() -{ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), - curFile); - if (fileName.isEmpty()) - return false; - - return saveFile(fileName); -} - -bool MdiChild::saveFile(const QString &fileName) -{ - QFile file(fileName); - if (!file.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(this, tr("MDI"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return false; - } - - QTextStream out(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - out << toPlainText(); - QApplication::restoreOverrideCursor(); - - setCurrentFile(fileName); - return true; -} - -QString MdiChild::userFriendlyCurrentFile() -{ - return strippedName(curFile); -} - -void MdiChild::closeEvent(QCloseEvent *event) -{ - if (maybeSave()) { - event->accept(); - } else { - event->ignore(); - } -} - -void MdiChild::documentWasModified() -{ - setWindowModified(document()->isModified()); -} - -bool MdiChild::maybeSave() -{ - if (document()->isModified()) { - QMessageBox::StandardButton ret; - ret = QMessageBox::warning(this, tr("MDI"), - tr("'%1' has been modified.\n" - "Do you want to save your changes?") - .arg(userFriendlyCurrentFile()), - QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel); - if (ret == QMessageBox::Save) - return save(); - else if (ret == QMessageBox::Cancel) - return false; - } - return true; -} - -void MdiChild::setCurrentFile(const QString &fileName) -{ - curFile = QFileInfo(fileName).canonicalFilePath(); - isUntitled = false; - document()->setModified(false); - setWindowModified(false); - setWindowTitle(userFriendlyCurrentFile() + "[*]"); -} - -QString MdiChild::strippedName(const QString &fullFileName) -{ - return QFileInfo(fullFileName).fileName(); -} diff --git a/examples/mainwindows/mdi/mdichild.h b/examples/mainwindows/mdi/mdichild.h deleted file mode 100644 index aacdd0f0f6..0000000000 --- a/examples/mainwindows/mdi/mdichild.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 MDICHILD_H -#define MDICHILD_H - -#include - -class MdiChild : public QTextEdit -{ - Q_OBJECT - -public: - MdiChild(); - - void newFile(); - bool loadFile(const QString &fileName); - bool save(); - bool saveAs(); - bool saveFile(const QString &fileName); - QString userFriendlyCurrentFile(); - QString currentFile() { return curFile; } - -protected: - void closeEvent(QCloseEvent *event); - -private slots: - void documentWasModified(); - -private: - bool maybeSave(); - void setCurrentFile(const QString &fileName); - QString strippedName(const QString &fullFileName); - - QString curFile; - bool isUntitled; -}; - -#endif diff --git a/examples/mainwindows/menus/main.cpp b/examples/mainwindows/menus/main.cpp deleted file mode 100644 index 09a923477c..0000000000 --- a/examples/mainwindows/menus/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/mainwindows/menus/mainwindow.cpp b/examples/mainwindows/menus/mainwindow.cpp deleted file mode 100644 index e1f3a0c099..0000000000 --- a/examples/mainwindows/menus/mainwindow.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -//! [0] -MainWindow::MainWindow() -{ - QWidget *widget = new QWidget; - setCentralWidget(widget); -//! [0] - -//! [1] - QWidget *topFiller = new QWidget; - topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - infoLabel = new QLabel(tr("Choose a menu option, or right-click to " - "invoke a context menu")); - infoLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - infoLabel->setAlignment(Qt::AlignCenter); - - QWidget *bottomFiller = new QWidget; - bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(5); - layout->addWidget(topFiller); - layout->addWidget(infoLabel); - layout->addWidget(bottomFiller); - widget->setLayout(layout); -//! [1] - -//! [2] - createActions(); - createMenus(); - - QString message = tr("A context menu is available by right-clicking"); - statusBar()->showMessage(message); - - setWindowTitle(tr("Menus")); - setMinimumSize(160, 160); - resize(480, 320); -} -//! [2] - -//! [3] -void MainWindow::contextMenuEvent(QContextMenuEvent *event) -{ - QMenu menu(this); - menu.addAction(cutAct); - menu.addAction(copyAct); - menu.addAction(pasteAct); - menu.exec(event->globalPos()); -} -//! [3] - -void MainWindow::newFile() -{ - infoLabel->setText(tr("Invoked File|New")); -} - -void MainWindow::open() -{ - infoLabel->setText(tr("Invoked File|Open")); -} - -void MainWindow::save() -{ - infoLabel->setText(tr("Invoked File|Save")); -} - -void MainWindow::print() -{ - infoLabel->setText(tr("Invoked File|Print")); -} - -void MainWindow::undo() -{ - infoLabel->setText(tr("Invoked Edit|Undo")); -} - -void MainWindow::redo() -{ - infoLabel->setText(tr("Invoked Edit|Redo")); -} - -void MainWindow::cut() -{ - infoLabel->setText(tr("Invoked Edit|Cut")); -} - -void MainWindow::copy() -{ - infoLabel->setText(tr("Invoked Edit|Copy")); -} - -void MainWindow::paste() -{ - infoLabel->setText(tr("Invoked Edit|Paste")); -} - -void MainWindow::bold() -{ - infoLabel->setText(tr("Invoked Edit|Format|Bold")); -} - -void MainWindow::italic() -{ - infoLabel->setText(tr("Invoked Edit|Format|Italic")); -} - -void MainWindow::leftAlign() -{ - infoLabel->setText(tr("Invoked Edit|Format|Left Align")); -} - -void MainWindow::rightAlign() -{ - infoLabel->setText(tr("Invoked Edit|Format|Right Align")); -} - -void MainWindow::justify() -{ - infoLabel->setText(tr("Invoked Edit|Format|Justify")); -} - -void MainWindow::center() -{ - infoLabel->setText(tr("Invoked Edit|Format|Center")); -} - -void MainWindow::setLineSpacing() -{ - infoLabel->setText(tr("Invoked Edit|Format|Set Line Spacing")); -} - -void MainWindow::setParagraphSpacing() -{ - infoLabel->setText(tr("Invoked Edit|Format|Set Paragraph Spacing")); -} - -void MainWindow::about() -{ - infoLabel->setText(tr("Invoked Help|About")); - QMessageBox::about(this, tr("About Menu"), - tr("The Menu example shows how to create " - "menu-bar menus and context menus.")); -} - -void MainWindow::aboutQt() -{ - infoLabel->setText(tr("Invoked Help|About Qt")); -} - -//! [4] -void MainWindow::createActions() -{ -//! [5] - newAct = new QAction(tr("&New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); -//! [4] - - openAct = new QAction(tr("&Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); -//! [5] - - saveAct = new QAction(tr("&Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - - printAct = new QAction(tr("&Print..."), this); - printAct->setShortcuts(QKeySequence::Print); - printAct->setStatusTip(tr("Print the document")); - connect(printAct, SIGNAL(triggered()), this, SLOT(print())); - - exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); - - undoAct = new QAction(tr("&Undo"), this); - undoAct->setShortcuts(QKeySequence::Undo); - undoAct->setStatusTip(tr("Undo the last operation")); - connect(undoAct, SIGNAL(triggered()), this, SLOT(undo())); - - redoAct = new QAction(tr("&Redo"), this); - redoAct->setShortcuts(QKeySequence::Redo); - redoAct->setStatusTip(tr("Redo the last operation")); - connect(redoAct, SIGNAL(triggered()), this, SLOT(redo())); - - cutAct = new QAction(tr("Cu&t"), this); - cutAct->setShortcuts(QKeySequence::Cut); - cutAct->setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")); - connect(cutAct, SIGNAL(triggered()), this, SLOT(cut())); - - copyAct = new QAction(tr("&Copy"), this); - copyAct->setShortcuts(QKeySequence::Copy); - copyAct->setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")); - connect(copyAct, SIGNAL(triggered()), this, SLOT(copy())); - - pasteAct = new QAction(tr("&Paste"), this); - pasteAct->setShortcuts(QKeySequence::Paste); - pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")); - connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste())); - - boldAct = new QAction(tr("&Bold"), this); - boldAct->setCheckable(true); - boldAct->setShortcut(QKeySequence::Bold); - boldAct->setStatusTip(tr("Make the text bold")); - connect(boldAct, SIGNAL(triggered()), this, SLOT(bold())); - - QFont boldFont = boldAct->font(); - boldFont.setBold(true); - boldAct->setFont(boldFont); - - italicAct = new QAction(tr("&Italic"), this); - italicAct->setCheckable(true); - italicAct->setShortcut(QKeySequence::Italic); - italicAct->setStatusTip(tr("Make the text italic")); - connect(italicAct, SIGNAL(triggered()), this, SLOT(italic())); - - QFont italicFont = italicAct->font(); - italicFont.setItalic(true); - italicAct->setFont(italicFont); - - setLineSpacingAct = new QAction(tr("Set &Line Spacing..."), this); - setLineSpacingAct->setStatusTip(tr("Change the gap between the lines of a " - "paragraph")); - connect(setLineSpacingAct, SIGNAL(triggered()), this, SLOT(setLineSpacing())); - - setParagraphSpacingAct = new QAction(tr("Set &Paragraph Spacing..."), this); - setParagraphSpacingAct->setStatusTip(tr("Change the gap between paragraphs")); - connect(setParagraphSpacingAct, SIGNAL(triggered()), - this, SLOT(setParagraphSpacing())); - - aboutAct = new QAction(tr("&About"), this); - aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt())); - - leftAlignAct = new QAction(tr("&Left Align"), this); - leftAlignAct->setCheckable(true); - leftAlignAct->setShortcut(tr("Ctrl+L")); - leftAlignAct->setStatusTip(tr("Left align the selected text")); - connect(leftAlignAct, SIGNAL(triggered()), this, SLOT(leftAlign())); - - rightAlignAct = new QAction(tr("&Right Align"), this); - rightAlignAct->setCheckable(true); - rightAlignAct->setShortcut(tr("Ctrl+R")); - rightAlignAct->setStatusTip(tr("Right align the selected text")); - connect(rightAlignAct, SIGNAL(triggered()), this, SLOT(rightAlign())); - - justifyAct = new QAction(tr("&Justify"), this); - justifyAct->setCheckable(true); - justifyAct->setShortcut(tr("Ctrl+J")); - justifyAct->setStatusTip(tr("Justify the selected text")); - connect(justifyAct, SIGNAL(triggered()), this, SLOT(justify())); - - centerAct = new QAction(tr("&Center"), this); - centerAct->setCheckable(true); - centerAct->setShortcut(tr("Ctrl+E")); - centerAct->setStatusTip(tr("Center the selected text")); - connect(centerAct, SIGNAL(triggered()), this, SLOT(center())); - -//! [6] //! [7] - alignmentGroup = new QActionGroup(this); - alignmentGroup->addAction(leftAlignAct); - alignmentGroup->addAction(rightAlignAct); - alignmentGroup->addAction(justifyAct); - alignmentGroup->addAction(centerAct); - leftAlignAct->setChecked(true); -//! [6] -} -//! [7] - -//! [8] -void MainWindow::createMenus() -{ -//! [9] //! [10] - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newAct); -//! [9] - fileMenu->addAction(openAct); -//! [10] - fileMenu->addAction(saveAct); - fileMenu->addAction(printAct); -//! [11] - fileMenu->addSeparator(); -//! [11] - fileMenu->addAction(exitAct); - - editMenu = menuBar()->addMenu(tr("&Edit")); - editMenu->addAction(undoAct); - editMenu->addAction(redoAct); - editMenu->addSeparator(); - editMenu->addAction(cutAct); - editMenu->addAction(copyAct); - editMenu->addAction(pasteAct); - editMenu->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); -//! [8] - -//! [12] - formatMenu = editMenu->addMenu(tr("&Format")); - formatMenu->addAction(boldAct); - formatMenu->addAction(italicAct); - formatMenu->addSeparator()->setText(tr("Alignment")); - formatMenu->addAction(leftAlignAct); - formatMenu->addAction(rightAlignAct); - formatMenu->addAction(justifyAct); - formatMenu->addAction(centerAct); - formatMenu->addSeparator(); - formatMenu->addAction(setLineSpacingAct); - formatMenu->addAction(setParagraphSpacingAct); -} -//! [12] diff --git a/examples/mainwindows/menus/mainwindow.h b/examples/mainwindows/menus/mainwindow.h deleted file mode 100644 index ebafb529eb..0000000000 --- a/examples/mainwindows/menus/mainwindow.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAction; -class QActionGroup; -class QLabel; -class QMenu; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -protected: - void contextMenuEvent(QContextMenuEvent *event); -//! [0] - -//! [1] -private slots: - void newFile(); - void open(); - void save(); - void print(); - void undo(); - void redo(); - void cut(); - void copy(); - void paste(); - void bold(); - void italic(); - void leftAlign(); - void rightAlign(); - void justify(); - void center(); - void setLineSpacing(); - void setParagraphSpacing(); - void about(); - void aboutQt(); -//! [1] - -//! [2] -private: - void createActions(); - void createMenus(); -//! [2] - -//! [3] - QMenu *fileMenu; - QMenu *editMenu; - QMenu *formatMenu; - QMenu *helpMenu; - QActionGroup *alignmentGroup; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *printAct; - QAction *exitAct; - QAction *undoAct; - QAction *redoAct; - QAction *cutAct; - QAction *copyAct; - QAction *pasteAct; - QAction *boldAct; - QAction *italicAct; - QAction *leftAlignAct; - QAction *rightAlignAct; - QAction *justifyAct; - QAction *centerAct; - QAction *setLineSpacingAct; - QAction *setParagraphSpacingAct; - QAction *aboutAct; - QAction *aboutQtAct; - QLabel *infoLabel; -}; -//! [3] - -#endif diff --git a/examples/mainwindows/menus/menus.desktop b/examples/mainwindows/menus/menus.desktop deleted file mode 100644 index dc2bda92af..0000000000 --- a/examples/mainwindows/menus/menus.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Menus -Exec=/opt/usr/bin/menus -Icon=menus -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/mainwindows/menus/menus.pro b/examples/mainwindows/menus/menus.pro deleted file mode 100644 index 5ed1e0dae5..0000000000 --- a/examples/mainwindows/menus/menus.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS = mainwindow.h -SOURCES = mainwindow.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/menus -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS menus.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/menus -INSTALLS += target sources - -QT += widgets diff --git a/examples/mainwindows/recentfiles/main.cpp b/examples/mainwindows/recentfiles/main.cpp deleted file mode 100644 index 023357719e..0000000000 --- a/examples/mainwindows/recentfiles/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - app.setOrganizationName("Trolltech"); - app.setApplicationName("Recent Files Example"); - MainWindow *mainWin = new MainWindow; - mainWin->show(); - return app.exec(); -} diff --git a/examples/mainwindows/recentfiles/mainwindow.cpp b/examples/mainwindows/recentfiles/mainwindow.cpp deleted file mode 100644 index b439ae8950..0000000000 --- a/examples/mainwindows/recentfiles/mainwindow.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -MainWindow::MainWindow() -{ - setAttribute(Qt::WA_DeleteOnClose); - - textEdit = new QTextEdit; - setCentralWidget(textEdit); - - createActions(); - createMenus(); - (void)statusBar(); - - setWindowFilePath(QString()); - resize(400, 300); -} - -void MainWindow::newFile() -{ - MainWindow *other = new MainWindow; - other->show(); -} - -void MainWindow::open() -{ - QString fileName = QFileDialog::getOpenFileName(this); - if (!fileName.isEmpty()) - loadFile(fileName); -} - -void MainWindow::save() -{ - if (curFile.isEmpty()) - saveAs(); - else - saveFile(curFile); -} - -void MainWindow::saveAs() -{ - QString fileName = QFileDialog::getSaveFileName(this); - if (fileName.isEmpty()) - return; - - saveFile(fileName); -} - -void MainWindow::openRecentFile() -{ - QAction *action = qobject_cast(sender()); - if (action) - loadFile(action->data().toString()); -} - -void MainWindow::about() -{ - QMessageBox::about(this, tr("About Recent Files"), - tr("The Recent Files example demonstrates how to provide a " - "recently used file menu in a Qt application.")); -} - -void MainWindow::createActions() -{ - newAct = new QAction(tr("&New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); - - openAct = new QAction(tr("&Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); - - saveAct = new QAction(tr("&Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - - saveAsAct = new QAction(tr("Save &As..."), this); - saveAsAct->setShortcuts(QKeySequence::SaveAs); - saveAsAct->setStatusTip(tr("Save the document under a new name")); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); - - for (int i = 0; i < MaxRecentFiles; ++i) { - recentFileActs[i] = new QAction(this); - recentFileActs[i]->setVisible(false); - connect(recentFileActs[i], SIGNAL(triggered()), - this, SLOT(openRecentFile())); - } - - exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); - - aboutAct = new QAction(tr("&About"), this); - aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); -} - -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newAct); - fileMenu->addAction(openAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(saveAsAct); - separatorAct = fileMenu->addSeparator(); - for (int i = 0; i < MaxRecentFiles; ++i) - fileMenu->addAction(recentFileActs[i]); - fileMenu->addSeparator(); - fileMenu->addAction(exitAct); - updateRecentFileActions(); - - menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); -} - -void MainWindow::loadFile(const QString &fileName) -{ - QFile file(fileName); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, tr("Recent Files"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return; - } - - QTextStream in(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - textEdit->setPlainText(in.readAll()); - QApplication::restoreOverrideCursor(); - - setCurrentFile(fileName); - statusBar()->showMessage(tr("File loaded"), 2000); -} - -void MainWindow::saveFile(const QString &fileName) -{ - QFile file(fileName); - if (!file.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(this, tr("Recent Files"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return; - } - - QTextStream out(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - out << textEdit->toPlainText(); - QApplication::restoreOverrideCursor(); - - setCurrentFile(fileName); - statusBar()->showMessage(tr("File saved"), 2000); -} - -void MainWindow::setCurrentFile(const QString &fileName) -{ - curFile = fileName; - setWindowFilePath(curFile); - - QSettings settings; - QStringList files = settings.value("recentFileList").toStringList(); - files.removeAll(fileName); - files.prepend(fileName); - while (files.size() > MaxRecentFiles) - files.removeLast(); - - settings.setValue("recentFileList", files); - - foreach (QWidget *widget, QApplication::topLevelWidgets()) { - MainWindow *mainWin = qobject_cast(widget); - if (mainWin) - mainWin->updateRecentFileActions(); - } -} - -void MainWindow::updateRecentFileActions() -{ - QSettings settings; - QStringList files = settings.value("recentFileList").toStringList(); - - int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); - - for (int i = 0; i < numRecentFiles; ++i) { - QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); - recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); - recentFileActs[i]->setVisible(true); - } - for (int j = numRecentFiles; j < MaxRecentFiles; ++j) - recentFileActs[j]->setVisible(false); - - separatorAct->setVisible(numRecentFiles > 0); -} - -QString MainWindow::strippedName(const QString &fullFileName) -{ - return QFileInfo(fullFileName).fileName(); -} diff --git a/examples/mainwindows/recentfiles/mainwindow.h b/examples/mainwindows/recentfiles/mainwindow.h deleted file mode 100644 index dd548838fc..0000000000 --- a/examples/mainwindows/recentfiles/mainwindow.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QMenu; -class QTextEdit; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private slots: - void newFile(); - void open(); - void save(); - void saveAs(); - void openRecentFile(); - void about(); - -private: - void createActions(); - void createMenus(); - void loadFile(const QString &fileName); - void saveFile(const QString &fileName); - void setCurrentFile(const QString &fileName); - void updateRecentFileActions(); - QString strippedName(const QString &fullFileName); - - QString curFile; - - QTextEdit *textEdit; - QMenu *fileMenu; - QMenu *recentFilesMenu; - QMenu *helpMenu; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *exitAct; - QAction *aboutAct; - QAction *aboutQtAct; - QAction *separatorAct; - - enum { MaxRecentFiles = 5 }; - QAction *recentFileActs[MaxRecentFiles]; -}; - -#endif diff --git a/examples/mainwindows/recentfiles/recentfiles.desktop b/examples/mainwindows/recentfiles/recentfiles.desktop deleted file mode 100644 index c314cf7f7c..0000000000 --- a/examples/mainwindows/recentfiles/recentfiles.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Recent Files -Exec=/opt/usr/bin/recentfiles -Icon=recentfiles -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/mainwindows/recentfiles/recentfiles.pro b/examples/mainwindows/recentfiles/recentfiles.pro deleted file mode 100644 index 5425efc68f..0000000000 --- a/examples/mainwindows/recentfiles/recentfiles.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/recentfiles -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS recentfiles.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/recentfiles -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/mainwindows/sdi/images/copy.png b/examples/mainwindows/sdi/images/copy.png deleted file mode 100644 index 2aeb28288f..0000000000 Binary files a/examples/mainwindows/sdi/images/copy.png and /dev/null differ diff --git a/examples/mainwindows/sdi/images/cut.png b/examples/mainwindows/sdi/images/cut.png deleted file mode 100644 index 54638e9386..0000000000 Binary files a/examples/mainwindows/sdi/images/cut.png and /dev/null differ diff --git a/examples/mainwindows/sdi/images/new.png b/examples/mainwindows/sdi/images/new.png deleted file mode 100644 index 12131b0100..0000000000 Binary files a/examples/mainwindows/sdi/images/new.png and /dev/null differ diff --git a/examples/mainwindows/sdi/images/open.png b/examples/mainwindows/sdi/images/open.png deleted file mode 100644 index 45fa2883a7..0000000000 Binary files a/examples/mainwindows/sdi/images/open.png and /dev/null differ diff --git a/examples/mainwindows/sdi/images/paste.png b/examples/mainwindows/sdi/images/paste.png deleted file mode 100644 index c14425cad1..0000000000 Binary files a/examples/mainwindows/sdi/images/paste.png and /dev/null differ diff --git a/examples/mainwindows/sdi/images/save.png b/examples/mainwindows/sdi/images/save.png deleted file mode 100644 index daba865faf..0000000000 Binary files a/examples/mainwindows/sdi/images/save.png and /dev/null differ diff --git a/examples/mainwindows/sdi/main.cpp b/examples/mainwindows/sdi/main.cpp deleted file mode 100644 index fbbedd9f0d..0000000000 --- a/examples/mainwindows/sdi/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(sdi); - QApplication app(argc, argv); - app.setApplicationName("SDI Example"); - app.setOrganizationName("Trolltech"); - MainWindow *mainWin = new MainWindow; - mainWin->show(); - return app.exec(); -} diff --git a/examples/mainwindows/sdi/mainwindow.cpp b/examples/mainwindows/sdi/mainwindow.cpp deleted file mode 100644 index bc0685fd77..0000000000 --- a/examples/mainwindows/sdi/mainwindow.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -MainWindow::MainWindow() -{ - init(); - setCurrentFile(""); -} - -MainWindow::MainWindow(const QString &fileName) -{ - init(); - loadFile(fileName); -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - if (maybeSave()) { - writeSettings(); - event->accept(); - } else { - event->ignore(); - } -} - -void MainWindow::newFile() -{ - MainWindow *other = new MainWindow; - other->move(x() + 40, y() + 40); - other->show(); -} - -void MainWindow::open() -{ - QString fileName = QFileDialog::getOpenFileName(this); - if (!fileName.isEmpty()) { - MainWindow *existing = findMainWindow(fileName); - if (existing) { - existing->show(); - existing->raise(); - existing->activateWindow(); - return; - } - - if (isUntitled && textEdit->document()->isEmpty() - && !isWindowModified()) { - loadFile(fileName); - } else { - MainWindow *other = new MainWindow(fileName); - if (other->isUntitled) { - delete other; - return; - } - other->move(x() + 40, y() + 40); - other->show(); - } - } -} - -bool MainWindow::save() -{ - if (isUntitled) { - return saveAs(); - } else { - return saveFile(curFile); - } -} - -bool MainWindow::saveAs() -{ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), - curFile); - if (fileName.isEmpty()) - return false; - - return saveFile(fileName); -} - -void MainWindow::about() -{ - QMessageBox::about(this, tr("About SDI"), - tr("The SDI example demonstrates how to write single " - "document interface applications using Qt.")); -} - -void MainWindow::documentWasModified() -{ - setWindowModified(true); -} - -void MainWindow::init() -{ - setAttribute(Qt::WA_DeleteOnClose); - - isUntitled = true; - - textEdit = new QTextEdit; - setCentralWidget(textEdit); - - createActions(); - createMenus(); - createToolBars(); - createStatusBar(); - - readSettings(); - - connect(textEdit->document(), SIGNAL(contentsChanged()), - this, SLOT(documentWasModified())); - - setUnifiedTitleAndToolBarOnMac(true); -} - -void MainWindow::createActions() -{ - newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); - - openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); - - saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - - saveAsAct = new QAction(tr("Save &As..."), this); - saveAsAct->setShortcuts(QKeySequence::SaveAs); - saveAsAct->setStatusTip(tr("Save the document under a new name")); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); - - closeAct = new QAction(tr("&Close"), this); - closeAct->setShortcut(tr("Ctrl+W")); - closeAct->setStatusTip(tr("Close this window")); - connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); - - exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); - - cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); - cutAct->setShortcuts(QKeySequence::Cut); - cutAct->setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")); - connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut())); - - copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this); - copyAct->setShortcuts(QKeySequence::Copy); - copyAct->setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")); - connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy())); - - pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this); - pasteAct->setShortcuts(QKeySequence::Paste); - pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")); - connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste())); - - aboutAct = new QAction(tr("&About"), this); - aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - - - cutAct->setEnabled(false); - copyAct->setEnabled(false); - connect(textEdit, SIGNAL(copyAvailable(bool)), - cutAct, SLOT(setEnabled(bool))); - connect(textEdit, SIGNAL(copyAvailable(bool)), - copyAct, SLOT(setEnabled(bool))); -} - -//! [implicit tr context] -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("&File")); -//! [implicit tr context] - fileMenu->addAction(newAct); - fileMenu->addAction(openAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(saveAsAct); - fileMenu->addSeparator(); - fileMenu->addAction(closeAct); - fileMenu->addAction(exitAct); - - editMenu = menuBar()->addMenu(tr("&Edit")); - editMenu->addAction(cutAct); - editMenu->addAction(copyAct); - editMenu->addAction(pasteAct); - - menuBar()->addSeparator(); - - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); -} - -void MainWindow::createToolBars() -{ -//! [0] - fileToolBar = addToolBar(tr("File")); - fileToolBar->addAction(newAct); - fileToolBar->addAction(openAct); -//! [0] - fileToolBar->addAction(saveAct); - - editToolBar = addToolBar(tr("Edit")); - editToolBar->addAction(cutAct); - editToolBar->addAction(copyAct); - editToolBar->addAction(pasteAct); -} - -void MainWindow::createStatusBar() -{ - statusBar()->showMessage(tr("Ready")); -} - -void MainWindow::readSettings() -{ - QSettings settings; - QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); - QSize size = settings.value("size", QSize(400, 400)).toSize(); - move(pos); - resize(size); -} - -void MainWindow::writeSettings() -{ - QSettings settings; - settings.setValue("pos", pos()); - settings.setValue("size", size()); -} - -bool MainWindow::maybeSave() -{ - if (textEdit->document()->isModified()) { - QMessageBox::StandardButton ret; - ret = QMessageBox::warning(this, tr("SDI"), - tr("The document has been modified.\n" - "Do you want to save your changes?"), - QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel); - if (ret == QMessageBox::Save) - return save(); - else if (ret == QMessageBox::Cancel) - return false; - } - return true; -} - -void MainWindow::loadFile(const QString &fileName) -{ - - QFile file(fileName); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, tr("SDI"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return; - } - - QTextStream in(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - textEdit->setPlainText(in.readAll()); - QApplication::restoreOverrideCursor(); - - setCurrentFile(fileName); - statusBar()->showMessage(tr("File loaded"), 2000); -} - -bool MainWindow::saveFile(const QString &fileName) -{ - QFile file(fileName); - if (!file.open(QFile::WriteOnly | QFile::Text)) { - QMessageBox::warning(this, tr("SDI"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())); - return false; - } - - QTextStream out(&file); - QApplication::setOverrideCursor(Qt::WaitCursor); - out << textEdit->toPlainText(); - QApplication::restoreOverrideCursor(); - - setCurrentFile(fileName); - statusBar()->showMessage(tr("File saved"), 2000); - return true; -} - -void MainWindow::setCurrentFile(const QString &fileName) -{ - static int sequenceNumber = 1; - - isUntitled = fileName.isEmpty(); - if (isUntitled) { - curFile = tr("document%1.txt").arg(sequenceNumber++); - } else { - curFile = QFileInfo(fileName).canonicalFilePath(); - } - - textEdit->document()->setModified(false); - setWindowModified(false); - setWindowFilePath(curFile); -} - -QString MainWindow::strippedName(const QString &fullFileName) -{ - return QFileInfo(fullFileName).fileName(); -} - -MainWindow *MainWindow::findMainWindow(const QString &fileName) -{ - QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath(); - - foreach (QWidget *widget, qApp->topLevelWidgets()) { - MainWindow *mainWin = qobject_cast(widget); - if (mainWin && mainWin->curFile == canonicalFilePath) - return mainWin; - } - return 0; -} diff --git a/examples/mainwindows/sdi/mainwindow.h b/examples/mainwindows/sdi/mainwindow.h deleted file mode 100644 index 4bf5ebe9b5..0000000000 --- a/examples/mainwindows/sdi/mainwindow.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QAction; -class QMenu; -class QTextEdit; -QT_END_NAMESPACE - -//! [class definition with macro] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); -//! [class definition with macro] - MainWindow(const QString &fileName); - -protected: - void closeEvent(QCloseEvent *event); - -private slots: - void newFile(); - void open(); - bool save(); - bool saveAs(); - void about(); - void documentWasModified(); - -private: - void init(); - void createActions(); - void createMenus(); - void createToolBars(); - void createStatusBar(); - void readSettings(); - void writeSettings(); - bool maybeSave(); - void loadFile(const QString &fileName); - bool saveFile(const QString &fileName); - void setCurrentFile(const QString &fileName); - QString strippedName(const QString &fullFileName); - MainWindow *findMainWindow(const QString &fileName); - - QTextEdit *textEdit; - QString curFile; - bool isUntitled; - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *helpMenu; - QToolBar *fileToolBar; - QToolBar *editToolBar; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *closeAct; - QAction *exitAct; - QAction *cutAct; - QAction *copyAct; - QAction *pasteAct; - QAction *aboutAct; - QAction *aboutQtAct; -}; - -#endif diff --git a/examples/mainwindows/sdi/sdi.desktop b/examples/mainwindows/sdi/sdi.desktop deleted file mode 100644 index 06d7289c8b..0000000000 --- a/examples/mainwindows/sdi/sdi.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=SDI -Exec=/opt/usr/bin/sdi -Icon=sdi -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/mainwindows/sdi/sdi.pro b/examples/mainwindows/sdi/sdi.pro deleted file mode 100644 index cd5e0f1616..0000000000 --- a/examples/mainwindows/sdi/sdi.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp -RESOURCES = sdi.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/sdi -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sdi.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/sdi -INSTALLS += target sources - -QT += widgets - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/mainwindows/sdi/sdi.qrc b/examples/mainwindows/sdi/sdi.qrc deleted file mode 100644 index 0a776fab4d..0000000000 --- a/examples/mainwindows/sdi/sdi.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - images/copy.png - images/cut.png - images/new.png - images/open.png - images/paste.png - images/save.png - - diff --git a/examples/painting/README b/examples/painting/README deleted file mode 100644 index 541c553159..0000000000 --- a/examples/painting/README +++ /dev/null @@ -1,11 +0,0 @@ -Qt's painting system is able to render vector graphics, images, and outline -font-based text with sub-pixel accuracy accuracy using anti-aliasing to -improve rendering quality. - -These examples show the most common techniques that are used when painting -with Qt, from basic concepts such as drawing simple primitives to the use of -transformations. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/painting/affine/affine.pro b/examples/painting/affine/affine.pro deleted file mode 100644 index 0977ea1c5b..0000000000 --- a/examples/painting/affine/affine.pro +++ /dev/null @@ -1,24 +0,0 @@ -SOURCES += main.cpp xform.cpp -HEADERS += xform.h - -contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl -} -QT += widgets - -SHARED_FOLDER = ../shared - -include($$SHARED_FOLDER/shared.pri) - -RESOURCES += affine.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/affine -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.jpg -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/affine -INSTALLS += target sources - -wince*: { - DEPLOYMENT_PLUGIN += qjpeg -} diff --git a/examples/painting/affine/affine.qrc b/examples/painting/affine/affine.qrc deleted file mode 100644 index d8a7ae40cb..0000000000 --- a/examples/painting/affine/affine.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - xform.cpp - xform.html - bg1.jpg - - diff --git a/examples/painting/affine/bg1.jpg b/examples/painting/affine/bg1.jpg deleted file mode 100644 index dfc7cee6ad..0000000000 Binary files a/examples/painting/affine/bg1.jpg and /dev/null differ diff --git a/examples/painting/affine/main.cpp b/examples/painting/affine/main.cpp deleted file mode 100644 index c27e3331f1..0000000000 --- a/examples/painting/affine/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xform.h" - -#include - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(affine); - - QApplication app(argc, argv); - - XFormWidget xformWidget(0); - QStyle *arthurStyle = new ArthurStyle(); - xformWidget.setStyle(arthurStyle); - - QList widgets = xformWidget.findChildren(); - foreach (QWidget *w, widgets) { - w->setStyle(arthurStyle); - w->setAttribute(Qt::WA_AcceptTouchEvents); - } - - xformWidget.show(); - - return app.exec(); -} diff --git a/examples/painting/affine/xform.cpp b/examples/painting/affine/xform.cpp deleted file mode 100644 index 8c9d37406c..0000000000 --- a/examples/painting/affine/xform.cpp +++ /dev/null @@ -1,902 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xform.h" -#include "hoverpoints.h" - -#include -#include -#include - -const int alpha = 155; - -XFormView::XFormView(QWidget *parent) - : ArthurFrame(parent) -{ - setAttribute(Qt::WA_MouseTracking); - m_type = VectorType; - m_rotation = 0.0; - m_scale = 1.0; - m_shear = 0.0; - - m_pixmap = QPixmap(":res/affine/bg1.jpg"); - pts = new HoverPoints(this, HoverPoints::CircleShape); - pts->setConnectionType(HoverPoints::LineConnection); - pts->setEditable(false); - pts->setPointSize(QSize(15, 15)); - pts->setShapeBrush(QBrush(QColor(151, 0, 0, alpha))); - pts->setShapePen(QPen(QColor(255, 100, 50, alpha))); - pts->setConnectionPen(QPen(QColor(151, 0, 0, 50))); - pts->setBoundingRect(QRectF(0, 0, 500, 500)); - ctrlPoints << QPointF(250, 250) << QPointF(350, 250); - pts->setPoints(ctrlPoints); - connect(pts, SIGNAL(pointsChanged(QPolygonF)), - this, SLOT(updateCtrlPoints(QPolygonF))); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -} - -XFormView::XFormType XFormView::type() const -{ - return m_type; -} - -QPixmap XFormView::pixmap() const -{ - return m_pixmap; -} - -QString XFormView::text() const -{ - return m_text; -} - -void XFormView::setText(const QString &t) -{ - m_text = t; - update(); -} - -void XFormView::setPixmap(const QPixmap &p) -{ - m_pixmap = p; - update(); -} - -void XFormView::setType(XFormType t) -{ - m_type = t; - update(); -} - -void XFormView::mousePressEvent(QMouseEvent *) -{ - setDescriptionEnabled(false); -} - -void XFormView::resizeEvent(QResizeEvent *e) -{ - pts->setBoundingRect(rect()); - ArthurFrame::resizeEvent(e); -} - -void XFormView::paint(QPainter *p) -{ - p->save(); - p->setRenderHint(QPainter::Antialiasing); - p->setRenderHint(QPainter::SmoothPixmapTransform); - switch (m_type) { - case VectorType: - drawVectorType(p); - break; - case PixmapType: - drawPixmapType(p); - break; - case TextType: - drawTextType(p); - break; - } - p->restore(); -} - -void XFormView::updateCtrlPoints(const QPolygonF &points) -{ - QPointF trans = points.at(0) - ctrlPoints.at(0); - - if (qAbs(points.at(0).x() - points.at(1).x()) < 10 - && qAbs(points.at(0).y() - points.at(1).y()) < 10) - pts->setPoints(ctrlPoints); - if (!trans.isNull()) { - ctrlPoints[0] = points.at(0); - ctrlPoints[1] += trans; - pts->setPoints(ctrlPoints); - } - ctrlPoints = points; - - QLineF line(ctrlPoints.at(0), ctrlPoints.at(1)); - m_rotation = line.angle(QLineF(0, 0, 1, 0)); - if (line.dy() < 0) - m_rotation = 360 - m_rotation; - - if (trans.isNull()) - emit rotationChanged(int(m_rotation*10)); -} - -void XFormView::setVectorType() -{ - m_type = VectorType; - update(); -} - -void XFormView::setPixmapType() -{ - m_type = PixmapType; - update(); -} - -void XFormView::setTextType() -{ - m_type = TextType; - update(); -} - -void XFormView::setAnimation(bool animate) -{ - timer.stop(); - if (animate) - timer.start(25, this); -} - -void XFormView::changeRotation(int r) -{ - setRotation(qreal(r) / 10); -} - -void XFormView::changeScale(int s) -{ - setScale(qreal(s) / 1000); -} - -void XFormView::changeShear(int s) -{ - setShear(qreal(s) / 1000); -} - -void XFormView::setShear(qreal s) -{ - m_shear = s; - update(); -} - -void XFormView::setScale(qreal s) -{ - m_scale = s; - update(); -} - -void XFormView::setRotation(qreal r) -{ - qreal old_rot = m_rotation; - m_rotation = r; - - QPointF center(pts->points().at(0)); - QMatrix m; - m.translate(center.x(), center.y()); - m.rotate(m_rotation - old_rot); - m.translate(-center.x(), -center.y()); - pts->setPoints(pts->points() * m); - - update(); -} - -void XFormView::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == timer.timerId()) { - QPointF center(pts->points().at(0)); - QMatrix m; - m.translate(center.x(), center.y()); - m.rotate(0.2); - m.translate(-center.x(), -center.y()); - pts->setPoints(pts->points() * m); - - setUpdatesEnabled(false); - static qreal scale_inc = 0.003; - static qreal shear_inc = -0.001; - emit scaleChanged(int((m_scale + scale_inc) * 1000)); - emit shearChanged(int((m_shear + shear_inc) * 1000)); - if (m_scale >= 4.0 || m_scale <= 0.1) - scale_inc = -scale_inc; - if (m_shear >= 1.0 || m_shear <= -1.0) - shear_inc = -shear_inc; - setUpdatesEnabled(true); - - pts->firePointChange(); - } -} - -void XFormView::wheelEvent(QWheelEvent *e) -{ - m_scale += e->delta() / qreal(600); - m_scale = qMax(qreal(0.1), qMin(qreal(4), m_scale)); - emit scaleChanged(int(m_scale*1000)); -} - -void XFormView::reset() -{ - emit rotationChanged(0); - emit scaleChanged(1000); - emit shearChanged(0); - ctrlPoints = QPolygonF(); - ctrlPoints << QPointF(250, 250) << QPointF(350, 250); - pts->setPoints(ctrlPoints); - pts->firePointChange(); -} - -void XFormView::drawPixmapType(QPainter *painter) -{ - QPointF center(m_pixmap.width() / qreal(2), m_pixmap.height() / qreal(2)); - painter->translate(ctrlPoints.at(0) - center); - - painter->translate(center); - painter->rotate(m_rotation); - painter->scale(m_scale, m_scale); - painter->shear(0, m_shear); - painter->translate(-center); - - painter->drawPixmap(QPointF(0, 0), m_pixmap); - painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); - painter->setBrush(Qt::NoBrush); - painter->drawRect(QRectF(0, 0, m_pixmap.width(), m_pixmap.height()).adjusted(-2, -2, 2, 2)); -} - -void XFormView::drawTextType(QPainter *painter) -{ - QPainterPath path; - QFont f("times new roman,utopia"); - f.setStyleStrategy(QFont::ForceOutline); - f.setPointSize(72); - f.setStyleHint(QFont::Times); - path.addText(0, 0, f, m_text); - - QFontMetrics fm(f); - QRectF br(fm.boundingRect(m_text)); - QPointF center(br.center()); - painter->translate(ctrlPoints.at(0) - center); - - painter->translate(center); - painter->rotate(m_rotation); - painter->scale(m_scale, m_scale); - painter->shear(0, m_shear); - painter->translate(-center); - - painter->fillPath(path, Qt::black); - - painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); - painter->setBrush(Qt::NoBrush); - painter->drawRect(br.adjusted(-1, -1, 1, 1)); -} - -void XFormView::drawVectorType(QPainter *painter) -{ - QPainterPath path; - painter->translate(ctrlPoints.at(0) - QPointF(250,250)); - - painter->scale(0.77, 0.77); - painter->translate(98.9154 + 30 , -217.691 - 20); - - QRect br(-55, 275, 500, 590); - QPoint center = br.center(); - painter->translate(center.x(), center.y()); - painter->rotate(m_rotation); - painter->scale(m_scale, m_scale); - painter->shear(0, m_shear); - painter->translate(-center.x(), -center.y()); - - painter->setPen(Qt::NoPen); - path.moveTo(120, 470); - path.lineTo(60+245, 470); - path.lineTo(60+245, 470+350); - path.lineTo(60, 470+350); - path.lineTo(60, 470+80); - - painter->setBrush(Qt::white); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor( 193, 193, 191, 255)); - path.moveTo(329.336, 727.552); - path.cubicTo(QPointF(315.224, 726.328), QPointF(304.136, 715.816), QPointF(303.128, 694.936)); - path.cubicTo(QPointF(306.368, 639.496), QPointF(309.608, 582.112), QPointF(271.232, 545.104)); - path.cubicTo(QPointF(265.256, 499.024), QPointF(244.016, 482.104), QPointF(234.008, 452.512)); - path.lineTo(218.24, 441.208); - path.lineTo(237.104, 411.688); - path.lineTo(245.168, 411.904); - path.lineTo(323.936, 571.168); - path.lineTo(340.424, 651.448); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(136.232, 439.696); - path.cubicTo(QPointF(133.856, 455.248), QPointF(132.56, 470.512), QPointF(134.792, 485.272)); - path.cubicTo(QPointF(118.376, 507.592), QPointF(105.92, 530.128), QPointF(104.48, 553.312)); - path.cubicTo(QPointF(92.024, 586.504), QPointF(62.432, 614.584), QPointF(67.544, 680.104)); - path.cubicTo(QPointF(84.176, 697.456), QPointF(107.432, 713.584), QPointF(127.376, 730.36)); - path.cubicTo(QPointF(152.432, 751.312), QPointF(137.528, 778.96), QPointF(102.248, 772.408)); - path.cubicTo(QPointF(94.4, 763.768), QPointF(76.616, 709.624), QPointF(42.92, 676.288)); - path.lineTo(49.544, 632.584); - path.lineTo(81.368, 547.408); - path.lineTo(120.968, 484.048); - path.lineTo(125.36, 456.688); - path.lineTo(119.816, 386.776); - path.lineTo(124.424, 361.216); - path.lineTo(136.232, 439.696); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(115.64, 341.416); - path.cubicTo(QPointF(116.576, 336.376), QPointF(117.8, 331.624), QPointF(119.312, 327.16)); - path.lineTo(121.688, 342.784); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(120.968, 500.464); - path.cubicTo(QPointF(108.368, 523.792), QPointF(103.976, 546.256), QPointF(132.92, 550.216)); - path.cubicTo(QPointF(117.008, 553.888), QPointF(97.208, 568.648), QPointF(77.192, 593.488)); - path.lineTo(77.624, 543.016); - path.lineTo(101.456, 503.272); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(-33.256, 818.488); - path.cubicTo(QPointF(10.52, 838.144), QPointF(41.408, 837.064), QPointF(69.272, 850.96)); - path.cubicTo(QPointF(91.304, 862.552), QPointF(113.552, 861.184), QPointF(126.944, 847.144)); - path.cubicTo(QPointF(138.32, 832.456), QPointF(146.744, 831.736), QPointF(163.52, 830.224)); - path.cubicTo(QPointF(190.952, 828.568), QPointF(217.736, 828.28), QPointF(241.928, 830.8)); - path.lineTo(269.576, 833.032); - path.cubicTo(QPointF(269.072, 864.064), QPointF(328.04, 867.88), QPointF(345.392, 844.336)); - path.cubicTo(QPointF(366.344, 819.424), QPointF(395.144, 808.264), QPointF(419.84, 790.192)); - path.lineTo(289.304, 725.536); - path.cubicTo(QPointF(255.824, 806.464), QPointF(131.048, 827.632), QPointF(113.768, 763.264)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(286.424, 711.568); - path.cubicTo(QPointF(273.824, 711.496), QPointF(260.936, 715.6), QPointF(261.944, 732.16)); - path.lineTo(266.192, 776.44); - path.lineTo(304.424, 756.64); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(0, 0, 0, 255)); - path.moveTo(-37.36, 821.224); - path.cubicTo(QPointF(7.136, 840.88), QPointF(38.6, 839.728), QPointF(66.968, 853.696)); - path.cubicTo(QPointF(89.36, 865.216), QPointF(111.968, 863.92), QPointF(125.648, 849.808)); - path.cubicTo(QPointF(137.24, 835.192), QPointF(145.808, 834.472), QPointF(162.872, 832.96)); - path.cubicTo(QPointF(190.736, 831.232), QPointF(218.024, 831.016), QPointF(242.648, 833.464)); - path.lineTo(270.728, 835.768); - path.cubicTo(QPointF(270.224, 866.8), QPointF(330.272, 870.544), QPointF(347.912, 847)); - path.cubicTo(QPointF(369.224, 822.088), QPointF(398.528, 811), QPointF(423.656, 792.856)); - path.lineTo(290.816, 728.272); - path.cubicTo(QPointF(256.76, 809.128), QPointF(129.824, 830.296), QPointF(112.256, 766)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(183, 114, 0, 255)); - path.moveTo(382.328, 691.984); - path.cubicTo(QPointF(403.64, 698.968), QPointF(389.888, 720.28), QPointF(400.76, 732.52)); - path.cubicTo(QPointF(405.44, 742.888), QPointF(415.304, 752.032), QPointF(431.792, 760.528)); - path.cubicTo(QPointF(459.368, 774.424), QPointF(426.248, 799.336), QPointF(392.768, 812.08)); - path.cubicTo(QPointF(351.944, 825.616), QPointF(344.024, 862.912), QPointF(299.312, 851.896)); - path.cubicTo(QPointF(283.112, 846.496), QPointF(278.36, 831.808), QPointF(278.864, 809.128)); - path.cubicTo(QPointF(284.264, 762.76), QPointF(277.784, 730.432), QPointF(278.792, 698.824)); - path.cubicTo(QPointF(278.72, 686.152), QPointF(283.544, 684.64), QPointF(307.232, 687.952)); - path.cubicTo(QPointF(310.04, 726.328), QPointF(352.376, 727.336), QPointF(382.328, 691.984)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(242, 183, 0, 255)); - path.moveTo(339.632, 826.624); - path.cubicTo(QPointF(371.6, 814.312), QPointF(403.856, 798.112), QPointF(429.848, 782.128)); - path.cubicTo(QPointF(437.84, 777.448), QPointF(438.92, 765.928), QPointF(427.688, 762.328)); - path.cubicTo(QPointF(403.352, 748.504), QPointF(390.104, 731.224), QPointF(392.912, 708.76)); - path.cubicTo(QPointF(393.344, 700.912), QPointF(383.696, 692.56), QPointF(381.104, 700.048)); - path.cubicTo(QPointF(359.864, 771.472), QPointF(291.32, 767.656), QPointF(300.752, 696.952)); - path.cubicTo(QPointF(301.256, 694.864), QPointF(301.76, 692.776), QPointF(302.264, 690.76)); - path.cubicTo(QPointF(289.952, 688.24), QPointF(285.2, 690.976), QPointF(285.776, 700.408)); - path.lineTo(295.28, 806.608); - path.cubicTo(QPointF(297.656, 830.8), QPointF(317.312, 836.128), QPointF(339.632, 826.624)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(0, 0, 0, 255)); - path.moveTo(354.464, 537.544); - path.cubicTo(QPointF(379.16, 569.8), QPointF(404.432, 651.088), QPointF(384.416, 691.552)); - path.cubicTo(QPointF(360.944, 737.776), QPointF(307.808, 743.248), QPointF(305.504, 695.8)); - path.cubicTo(QPointF(308.816, 639.64), QPointF(311.984, 581.536), QPointF(273.68, 544.096)); - path.cubicTo(QPointF(267.704, 497.368), QPointF(246.392, 480.232), QPointF(236.384, 450.28)); - path.lineTo(203.12, 426.088); - path.lineTo(133.568, 435.088); - path.cubicTo(QPointF(130.76, 452.152), QPointF(129.104, 468.784), QPointF(131.552, 484.912)); - path.cubicTo(QPointF(115.064, 507.376), QPointF(102.608, 530.056), QPointF(101.168, 553.312)); - path.cubicTo(QPointF(88.712, 586.648), QPointF(59.12, 614.944), QPointF(64.232, 680.752)); - path.cubicTo(QPointF(80.864, 698.248), QPointF(104.12, 714.448), QPointF(124.064, 731.296)); - path.cubicTo(QPointF(149.12, 752.392), QPointF(135.512, 776.296), QPointF(100.232, 769.672)); - path.cubicTo(QPointF(78.848, 746.056), QPointF(56.744, 722.872), QPointF(35.288, 699.328)); - path.cubicTo(QPointF(12.392, 683.056), QPointF(3.896, 662.176), QPointF(27.368, 630.496)); - path.cubicTo(QPointF(43.424, 609.04), QPointF(47.96, 562.456), QPointF(62, 543.664)); - path.cubicTo(QPointF(74.312, 525.16), QPointF(92.24, 508.6), QPointF(105.272, 490.096)); - path.cubicTo(QPointF(112.184, 477.928), QPointF(114.344, 468.568), QPointF(113.264, 454.456)); - path.lineTo(110.312, 369.136); - path.cubicTo(QPointF(108.368, 307.216), QPointF(142.424, 274.24), QPointF(189.8, 275.248)); - path.cubicTo(QPointF(243.512, 275.752), QPointF(287.576, 312.472), QPointF(288.152, 378.28)); - path.cubicTo(QPointF(292.688, 410.32), QPointF(283.256, 428.68), QPointF(308.672, 474.472)); - path.cubicTo(QPointF(334.52, 522.712), QPointF(338.552, 520.12), QPointF(354.464, 537.544)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(261.296, 503.632); - path.lineTo(263.528, 512.2); - path.cubicTo(QPointF(257.696, 501.688), QPointF(250.712, 483.616), QPointF(241.928, 475.696)); - path.cubicTo(QPointF(239.264, 473.536), QPointF(235.808, 473.608), QPointF(233.72, 475.624)); - path.cubicTo(QPointF(222.056, 486.928), QPointF(193.112, 510.112), QPointF(169.928, 507.088)); - path.cubicTo(QPointF(152.072, 505.288), QPointF(134.648, 493.264), QPointF(130.832, 480.232)); - path.cubicTo(QPointF(128.816, 470.872), QPointF(129.752, 463.168), QPointF(130.976, 455.32)); - path.lineTo(240.704, 453.52); - path.cubicTo(QPointF(238.472, 463.168), QPointF(253.088, 487), QPointF(261.296, 503.632)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(143.144, 363.232); - path.cubicTo(QPointF(154.088, 363.232), QPointF(163.88, 376.84), QPointF(163.808, 395.632)); - path.cubicTo(QPointF(163.736, 408.232), QPointF(155.528, 411.472), QPointF(149.336, 417.016)); - path.cubicTo(QPointF(146.6, 419.536), QPointF(145.952, 433.144), QPointF(142.568, 433.144)); - path.cubicTo(QPointF(131.696, 433.144), QPointF(123.488, 413.776), QPointF(123.488, 395.632)); - path.cubicTo(QPointF(123.488, 377.56), QPointF(132.272, 363.232), QPointF(143.144, 363.232)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(255, 255, 255, 255)); - path.moveTo(144.368, 375.04); - path.cubicTo(QPointF(154.088, 375.04), QPointF(160.856, 379.936), QPointF(161.648, 391.312)); - path.cubicTo(QPointF(162.224, 399.16), QPointF(160.136, 411.76), QPointF(154.664, 414.424)); - path.cubicTo(QPointF(152.144, 415.648), QPointF(143.432, 426.664), QPointF(140.408, 426.52)); - path.cubicTo(QPointF(128.096, 425.944), QPointF(125, 402.112), QPointF(125.936, 390.736)); - path.cubicTo(QPointF(126.8, 379.36), QPointF(134.72, 375.04), QPointF(144.368, 375.04)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(0, 0, 0, 255)); - path.moveTo(141.848, 382.672); - path.cubicTo(QPointF(148.544, 382.096), QPointF(154.736, 389.728), QPointF(155.6, 399.664)); - path.cubicTo(QPointF(156.464, 409.6), QPointF(151.64, 418.24), QPointF(144.944, 418.816)); - path.cubicTo(QPointF(138.248, 419.392), QPointF(132.056, 411.76), QPointF(131.192, 401.752)); - path.cubicTo(QPointF(130.328, 391.816), QPointF(135.152, 383.248), QPointF(141.848, 382.672)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(151.064, 397.288); - path.cubicTo(QPointF(151.424, 399.088), QPointF(149.408, 400.024), QPointF(148.832, 398.224)); - path.cubicTo(QPointF(148.256, 395.992), QPointF(146.888, 393.328), QPointF(145.088, 391.168)); - path.cubicTo(QPointF(143.936, 389.872), QPointF(145.088, 388.432), QPointF(146.528, 389.44)); - path.cubicTo(QPointF(149.048, 391.528), QPointF(150.488, 394.12), QPointF(151.064, 397.288)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(216.944, 360.712); - path.cubicTo(QPointF(232.712, 360.712), QPointF(245.6, 377.416), QPointF(245.6, 397.792)); - path.cubicTo(QPointF(245.6, 418.24), QPointF(232.712, 434.872), QPointF(216.944, 434.872)); - path.cubicTo(QPointF(201.176, 434.872), QPointF(188.432, 418.24), QPointF(188.432, 397.792)); - path.cubicTo(QPointF(188.432, 377.416), QPointF(201.176, 360.712), QPointF(216.944, 360.712)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(255, 255, 255, 255)); - path.moveTo(224.792, 374.968); - path.cubicTo(QPointF(235.664, 378.856), QPointF(241.928, 387.424), QPointF(242.72, 396.568)); - path.cubicTo(QPointF(243.656, 407.08), QPointF(239.408, 418.96), QPointF(230.264, 425.944)); - path.cubicTo(QPointF(227.672, 427.888), QPointF(197.72, 416.08), QPointF(195.992, 411.616)); - path.cubicTo(QPointF(193.4, 405.208), QPointF(191.816, 392.896), QPointF(193.76, 385.624)); - path.cubicTo(QPointF(194.552, 382.744), QPointF(197.216, 378.568), QPointF(201.176, 376.336)); - path.cubicTo(QPointF(207.44, 372.808), QPointF(216.656, 372.088), QPointF(224.792, 374.968)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(0, 0, 0, 255)); - path.moveTo(216.872, 380.944); - path.cubicTo(QPointF(225.584, 380.944), QPointF(232.712, 389.296), QPointF(232.712, 399.448)); - path.cubicTo(QPointF(232.712, 409.672), QPointF(225.584, 418.024), QPointF(216.872, 418.024)); - path.cubicTo(QPointF(208.16, 418.024), QPointF(201.032, 409.672), QPointF(201.032, 399.448)); - path.cubicTo(QPointF(201.032, 389.296), QPointF(208.16, 380.944), QPointF(216.872, 380.944)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(227.096, 392.392); - path.cubicTo(QPointF(228.104, 394.048), QPointF(226.448, 395.776), QPointF(225.224, 394.12)); - path.cubicTo(QPointF(223.784, 392.104), QPointF(221.408, 389.944), QPointF(218.888, 388.432)); - path.cubicTo(QPointF(217.232, 387.568), QPointF(217.808, 385.624), QPointF(219.68, 386.2)); - path.cubicTo(QPointF(222.92, 387.28), QPointF(225.368, 389.368), QPointF(227.096, 392.392)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(183, 114, 0, 255)); - path.moveTo(164.96, 404.488); - path.cubicTo(QPointF(172.376, 402.328), QPointF(184.112, 403.048), QPointF(192.248, 404.632)); - path.cubicTo(QPointF(200.384, 406.792), QPointF(222.056, 418.24), QPointF(245.024, 430.696)); - path.cubicTo(QPointF(247.976, 432.208), QPointF(248.84, 437.104), QPointF(245.024, 438.688)); - path.cubicTo(QPointF(239.12, 439.12), QPointF(249.272, 453.664), QPointF(238.904, 458.848)); - path.cubicTo(QPointF(223.352, 462.88), QPointF(198.44, 485.992), QPointF(186.128, 487.864)); - path.cubicTo(QPointF(179.288, 489.376), QPointF(172.232, 489.592), QPointF(164.6, 487.864)); - path.cubicTo(QPointF(140.552, 482.968), QPointF(134.216, 455.608), QPointF(122.912, 450.064)); - path.cubicTo(QPointF(119.816, 446.824), QPointF(121.4, 441.208), QPointF(122.408, 440.056)); - path.cubicTo(QPointF(123.632, 434.224), QPointF(149.696, 406.216), QPointF(164.96, 404.488)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(242, 183, 0, 255)); - path.moveTo(185.408, 405.856); - path.cubicTo(QPointF(198.44, 407.296), QPointF(226.088, 423.928), QPointF(239.408, 430.624)); - path.cubicTo(QPointF(242.72, 432.424), QPointF(242.504, 437.824), QPointF(239.552, 438.688)); - path.cubicTo(QPointF(236.384, 440.488), QPointF(235.448, 438.256), QPointF(232.928, 437.896)); - path.cubicTo(QPointF(228.896, 435.736), QPointF(222.272, 440.92), QPointF(217.016, 444.88)); - path.cubicTo(QPointF(186.704, 467.776), QPointF(180.656, 465.256), QPointF(156.176, 462.664)); - path.cubicTo(QPointF(147.68, 460.576), QPointF(142.136, 457.984), QPointF(139.688, 455.968)); - path.cubicTo(QPointF(141.488, 445.888), QPointF(160.496, 407.656), QPointF(166.76, 406.792)); - path.cubicTo(QPointF(168.344, 404.704), QPointF(179.936, 404.632), QPointF(185.408, 405.856)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(183, 114, 0, 255)); - path.moveTo(190.664, 412.048); - path.lineTo(193.76, 413.416); - path.cubicTo(QPointF(196.064, 414.712), QPointF(193.256, 418.168), QPointF(190.736, 417.088)); - path.lineTo(186.2, 415.504); - path.cubicTo(QPointF(183.536, 413.272), QPointF(186.704, 410.104), QPointF(190.664, 412.048)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(268.568, 452.368); - path.cubicTo(QPointF(273.032, 454.384), QPointF(279.224, 457.192), QPointF(282.536, 460.144)); - path.cubicTo(QPointF(285.488, 464.104), QPointF(286.784, 468.064), QPointF(286.424, 472.024)); - path.cubicTo(QPointF(285.776, 474.544), QPointF(284.12, 476.344), QPointF(281.24, 477.424)); - path.cubicTo(QPointF(277.856, 478.216), QPointF(273.68, 477.424), QPointF(271.376, 474.112)); - path.cubicTo(QPointF(269.864, 471.448), QPointF(265.256, 462.16), QPointF(263.96, 460.576)); - path.cubicTo(QPointF(262.232, 457.12), QPointF(261.944, 454.456), QPointF(262.88, 452.368)); - path.cubicTo(QPointF(264.032, 451.288), QPointF(266.048, 451), QPointF(268.568, 452.368)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(255, 255, 255, 255)); - path.moveTo(273.752, 461.584); - path.cubicTo(QPointF(275.48, 462.376), QPointF(277.928, 463.456), QPointF(279.224, 464.68)); - path.cubicTo(QPointF(280.376, 466.264), QPointF(280.88, 467.776), QPointF(280.736, 469.36)); - path.cubicTo(QPointF(280.52, 470.296), QPointF(279.8, 471.016), QPointF(278.72, 471.448)); - path.cubicTo(QPointF(277.352, 471.808), QPointF(275.768, 471.448), QPointF(274.832, 470.152)); - path.cubicTo(QPointF(274.256, 469.144), QPointF(272.456, 465.472), QPointF(271.952, 464.824)); - path.cubicTo(QPointF(271.232, 463.456), QPointF(271.088, 462.448), QPointF(271.448, 461.584)); - path.cubicTo(QPointF(271.952, 461.152), QPointF(272.744, 461.08), QPointF(273.752, 461.584)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(238.616, 358.552); - path.cubicTo(QPointF(239.048, 359.2), QPointF(238.976, 359.776), QPointF(238.4, 360.28)); - path.cubicTo(QPointF(237.896, 360.784), QPointF(237.176, 360.712), QPointF(236.24, 360.208)); - path.lineTo(231.632, 356.248); - path.cubicTo(QPointF(231.056, 355.744), QPointF(230.912, 354.952), QPointF(231.272, 354.088)); - path.cubicTo(QPointF(232.28, 353.44), QPointF(233.144, 353.44), QPointF(233.936, 354.088)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(235.592, 305.992); - path.cubicTo(QPointF(239.624, 308.224), QPointF(240.848, 313.912), QPointF(238.184, 318.592)); - path.cubicTo(QPointF(235.592, 323.2), QPointF(230.12, 325.144), QPointF(226.016, 322.84)); - path.cubicTo(QPointF(221.984, 320.536), QPointF(220.76, 314.92), QPointF(223.424, 310.24)); - path.cubicTo(QPointF(226.016, 305.56), QPointF(231.488, 303.688), QPointF(235.592, 305.992)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(374.912, 680.536); - path.cubicTo(QPointF(378.296, 683.128), QPointF(373.256, 687.376), QPointF(371.024, 686.296)); - path.cubicTo(QPointF(369.152, 685.648), QPointF(367.784, 683.488), QPointF(366.92, 682.408)); - path.cubicTo(QPointF(366.128, 681.184), QPointF(366.2, 679.168), QPointF(366.92, 678.448)); - path.cubicTo(QPointF(367.712, 677.44), QPointF(369.728, 677.656), QPointF(371.024, 678.52)); - path.cubicTo(QPointF(372.32, 679.168), QPointF(373.616, 679.888), QPointF(374.912, 680.536)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(297.44, 551.512); - path.cubicTo(QPointF(338.984, 572.896), QPointF(350, 611.56), QPointF(332.072, 664.192)); - path.cubicTo(QPointF(330.992, 666.64), QPointF(334.16, 668.368), QPointF(335.24, 666.064)); - path.cubicTo(QPointF(354.824, 610.336), QPointF(341.432, 571.312), QPointF(299.024, 548.56)); - path.cubicTo(QPointF(296.864, 547.552), QPointF(295.28, 550.432), QPointF(297.44, 551.512)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(72.008, 569.512); - path.cubicTo(QPointF(38.312, 627.256), QPointF(38.096, 662.68), QPointF(62.504, 681.328)); - path.cubicTo(QPointF(63.728, 682.264), QPointF(64.448, 680.032), QPointF(63.296, 679.168)); - path.cubicTo(QPointF(36.296, 655.48), QPointF(48.896, 615.52), QPointF(74.168, 570.88)); - path.cubicTo(QPointF(74.888, 569.584), QPointF(72.512, 568.432), QPointF(72.008, 569.512)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(289.376, 586.864); - path.cubicTo(QPointF(289.232, 589.168), QPointF(288.368, 589.528), QPointF(286.424, 587.368)); - path.cubicTo(QPointF(279.8, 575.848), QPointF(235.088, 551.44), QPointF(213.344, 548.704)); - path.cubicTo(QPointF(209.24, 547.264), QPointF(209.456, 545.392), QPointF(213.488, 544.816)); - path.cubicTo(QPointF(229.184, 544.816), QPointF(241.28, 537.904), QPointF(254.96, 537.904)); - path.cubicTo(QPointF(258.704, 538.048), QPointF(262.304, 539.488), QPointF(264.392, 541.648)); - path.cubicTo(QPointF(269.504, 544.96), QPointF(288.08, 570.592), QPointF(289.376, 586.864)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(180.152, 546.832); - path.cubicTo(QPointF(180.872, 550.792), QPointF(163.808, 545.68), QPointF(164.744, 556.696)); - path.cubicTo(QPointF(165.032, 559.72), QPointF(160.496, 561.376), QPointF(160.64, 556.696)); - path.cubicTo(QPointF(160.64, 548.272), QPointF(161.072, 548.416), QPointF(152.72, 546.832)); - path.cubicTo(QPointF(151.208, 546.76), QPointF(151.352, 544.528), QPointF(152.72, 544.816)); - path.lineTo(152.72, 544.816); - path.cubicTo(QPointF(158.696, 546.472), QPointF(166.76, 542.872), QPointF(166.4, 538.84)); - path.cubicTo(QPointF(166.256, 537.472), QPointF(168.56, 537.688), QPointF(168.488, 538.84)); - path.cubicTo(QPointF(167.984, 545.248), QPointF(181.664, 542.152), QPointF(180.152, 546.832)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(193, 193, 191, 255)); - path.moveTo(151.568, 705.376); - path.cubicTo(QPointF(151.64, 708.328), QPointF(148.76, 707.68), QPointF(148.544, 705.592)); - path.cubicTo(QPointF(140.192, 680.536), QPointF(143.72, 618.832), QPointF(151.856, 598.96)); - path.cubicTo(QPointF(152.432, 596.08), QPointF(156.248, 596.944), QPointF(155.744, 598.96)); - path.cubicTo(QPointF(147.104, 635.464), QPointF(147.248, 673.048), QPointF(151.568, 705.376)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(183, 114, 0, 255)); - path.moveTo(51.704, 684.424); - path.cubicTo(QPointF(75.68, 707.824), QPointF(91.376, 743.248), QPointF(114.632, 775.288)); - path.cubicTo(QPointF(148.472, 816.04), QPointF(121.472, 858.304), QPointF(66.464, 845.56)); - path.cubicTo(QPointF(38.888, 835.192), QPointF(-0.784, 836.344), QPointF(-32.68, 825.832)); - path.cubicTo(QPointF(-55.072, 820.36), QPointF(-55.864, 809.272), QPointF(-44.416, 787.6)); - path.cubicTo(QPointF(-40.384, 773.776), QPointF(-40.024, 751.312), QPointF(-43.768, 732.592)); - path.cubicTo(QPointF(-45.784, 718.408), QPointF(-39.232, 710.488), QPointF(-24.112, 708.832)); - path.lineTo(-24.112, 708.832); - path.cubicTo(QPointF(-11.296, 708.688), QPointF(6.56, 713.872), QPointF(16.28, 686.44)); - path.cubicTo(QPointF(23.552, 673.336), QPointF(40.976, 672.976), QPointF(51.704, 684.424)); - path.closeSubpath(); - painter->drawPath(path); - path = QPainterPath(); - - painter->setBrush(QColor(242, 183, 0, 255)); - path.moveTo(24.632, 699.04); - path.cubicTo(QPointF(23.84, 680.968), QPointF(39.32, 677.296), QPointF(49.688, 688.312)); - path.cubicTo(QPointF(68.192, 710.992), QPointF(85.112, 736.048), QPointF(100.376, 764.992)); - path.cubicTo(QPointF(124.712, 804.16), QPointF(104.624, 842.68), QPointF(67.904, 828.064)); - path.cubicTo(QPointF(49.688, 817.84), QPointF(6.128, 813.304), QPointF(-17.344, 809.128)); - path.cubicTo(QPointF(-33.04, 807.832), QPointF(-35.128, 797.608), QPointF(-29.152, 791.848)); - path.cubicTo(QPointF(-20.944, 782.416), QPointF(-20.08, 759.808), QPointF(-27.856, 740.512)); - path.cubicTo(QPointF(-35.56, 728.56), QPointF(-21.088, 715.384), QPointF(-9.712, 720.856)); - path.cubicTo(QPointF(0.8, 727.048), QPointF(25.64, 713.08), QPointF(24.632, 699.04)); - path.closeSubpath(); - painter->drawPath(path); - - painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); - painter->setBrush(Qt::NoBrush); - painter->drawRect(br.adjusted(-1, -1, 1, 1)); -} - - -XFormWidget::XFormWidget(QWidget *parent) - : QWidget(parent), textEditor(new QLineEdit) -{ - setWindowTitle(tr("Affine Transformations")); - - view = new XFormView(this); - view->setMinimumSize(200, 200); - - QGroupBox *mainGroup = new QGroupBox(this); - mainGroup->setFixedWidth(180); - mainGroup->setTitle(tr("Affine Transformations")); - - QGroupBox *rotateGroup = new QGroupBox(mainGroup); - rotateGroup->setTitle(tr("Rotate")); - QSlider *rotateSlider = new QSlider(Qt::Horizontal, rotateGroup); - rotateSlider->setRange(0, 3600); - rotateSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - QGroupBox *scaleGroup = new QGroupBox(mainGroup); - scaleGroup->setTitle(tr("Scale")); - QSlider *scaleSlider = new QSlider(Qt::Horizontal, scaleGroup); - scaleSlider->setRange(1, 4000); - scaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - QGroupBox *shearGroup = new QGroupBox(mainGroup); - shearGroup->setTitle(tr("Shear")); - QSlider *shearSlider = new QSlider(Qt::Horizontal, shearGroup); - shearSlider->setRange(-990, 990); - shearSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - QGroupBox *typeGroup = new QGroupBox(mainGroup); - typeGroup->setTitle(tr("Type")); - QRadioButton *vectorType = new QRadioButton(typeGroup); - QRadioButton *pixmapType = new QRadioButton(typeGroup); - QRadioButton *textType= new QRadioButton(typeGroup); - vectorType->setText(tr("Vector Image")); - pixmapType->setText(tr("Pixmap")); - textType->setText(tr("Text")); - - QPushButton *resetButton = new QPushButton(mainGroup); - resetButton->setText(tr("Reset Transform")); - - QPushButton *animateButton = new QPushButton(mainGroup); - animateButton->setText(tr("Animate")); - animateButton->setCheckable(true); - - QPushButton *showSourceButton = new QPushButton(mainGroup); - showSourceButton->setText(tr("Show Source")); -#ifdef QT_OPENGL_SUPPORT - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(view->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); -#endif - QPushButton *whatsThisButton = new QPushButton(mainGroup); - whatsThisButton->setText(tr("What's This?")); - whatsThisButton->setCheckable(true); - - QHBoxLayout *viewLayout = new QHBoxLayout(this); - viewLayout->addWidget(view); - viewLayout->addWidget(mainGroup); - - QVBoxLayout *rotateGroupLayout = new QVBoxLayout(rotateGroup); - rotateGroupLayout->addWidget(rotateSlider); - - QVBoxLayout *scaleGroupLayout = new QVBoxLayout(scaleGroup); - scaleGroupLayout->addWidget(scaleSlider); - - QVBoxLayout *shearGroupLayout = new QVBoxLayout(shearGroup); - shearGroupLayout->addWidget(shearSlider); - - QVBoxLayout *typeGroupLayout = new QVBoxLayout(typeGroup); - typeGroupLayout->addWidget(vectorType); - typeGroupLayout->addWidget(pixmapType); - typeGroupLayout->addWidget(textType); - typeGroupLayout->addSpacing(4); - typeGroupLayout->addWidget(textEditor); - - QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); - mainGroupLayout->addWidget(rotateGroup); - mainGroupLayout->addWidget(scaleGroup); - mainGroupLayout->addWidget(shearGroup); - mainGroupLayout->addWidget(typeGroup); - mainGroupLayout->addStretch(1); - mainGroupLayout->addWidget(resetButton); - mainGroupLayout->addWidget(animateButton); - mainGroupLayout->addWidget(showSourceButton); -#ifdef QT_OPENGL_SUPPORT - mainGroupLayout->addWidget(enableOpenGLButton); -#endif - mainGroupLayout->addWidget(whatsThisButton); - - connect(rotateSlider, SIGNAL(valueChanged(int)), view, SLOT(changeRotation(int))); - connect(shearSlider, SIGNAL(valueChanged(int)), view, SLOT(changeShear(int))); - connect(scaleSlider, SIGNAL(valueChanged(int)), view, SLOT(changeScale(int))); - - connect(vectorType, SIGNAL(clicked()), view, SLOT(setVectorType())); - connect(pixmapType, SIGNAL(clicked()), view, SLOT(setPixmapType())); - connect(textType, SIGNAL(clicked()), view, SLOT(setTextType())); - connect(textType, SIGNAL(toggled(bool)), textEditor, SLOT(setEnabled(bool))); - connect(textEditor, SIGNAL(textChanged(QString)), view, SLOT(setText(QString))); - - connect(view, SIGNAL(rotationChanged(int)), rotateSlider, SLOT(setValue(int))); - connect(view, SIGNAL(scaleChanged(int)), scaleSlider, SLOT(setValue(int))); - connect(view, SIGNAL(shearChanged(int)), shearSlider, SLOT(setValue(int))); - - connect(resetButton, SIGNAL(clicked()), view, SLOT(reset())); - connect(animateButton, SIGNAL(clicked(bool)), view, SLOT(setAnimation(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), view->hoverPoints(), SLOT(setDisabled(bool))); - connect(view, SIGNAL(descriptionEnabledChanged(bool)), view->hoverPoints(), SLOT(setDisabled(bool))); - connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool))); - connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource())); -#ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool))); -#endif - view->loadSourceFile(":res/affine/xform.cpp"); - view->loadDescription(":res/affine/xform.html"); - - // defaults - view->reset(); - vectorType->setChecked(true); - textEditor->setText("Qt Affine Transformation Example"); - textEditor->setEnabled(false); - - animateButton->animateClick(); -} diff --git a/examples/painting/affine/xform.h b/examples/painting/affine/xform.h deleted file mode 100644 index d710f5175e..0000000000 --- a/examples/painting/affine/xform.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XFORM_H -#define XFORM_H - -#include "arthurwidgets.h" - -#include -#include - -class HoverPoints; -QT_FORWARD_DECLARE_CLASS(QLineEdit) - -class XFormView : public ArthurFrame -{ -public: - Q_OBJECT - - Q_PROPERTY(XFormType type READ type WRITE setType) - Q_PROPERTY(bool animation READ animation WRITE setAnimation) - Q_PROPERTY(qreal shear READ shear WRITE setShear) - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) - Q_PROPERTY(qreal scale READ scale WRITE setScale) - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) - Q_ENUMS(XFormType) - -public: - enum XFormType { VectorType, PixmapType, TextType }; - - XFormView(QWidget *parent); - void paint(QPainter *); - void drawVectorType(QPainter *painter); - void drawPixmapType(QPainter *painter); - void drawTextType(QPainter *painter); - QSize sizeHint() const { return QSize(500, 500); } - - void mousePressEvent(QMouseEvent *e); - void resizeEvent(QResizeEvent *e); - HoverPoints *hoverPoints() { return pts; } - - bool animation() const { return timer.isActive(); } - qreal shear() const { return m_shear; } - qreal scale() const { return m_scale; } - qreal rotation() const { return m_rotation; } - void setShear(qreal s); - void setScale(qreal s); - void setRotation(qreal r); - - XFormType type() const; - QPixmap pixmap() const; - QString text() const; - -public slots: - void setAnimation(bool animate); - void updateCtrlPoints(const QPolygonF &); - void changeRotation(int rotation); - void changeScale(int scale); - void changeShear(int shear); - - void setText(const QString &); - void setPixmap(const QPixmap &); - void setType(XFormType t); - - void setVectorType(); - void setPixmapType(); - void setTextType(); - void reset(); - -signals: - void rotationChanged(int rotation); - void scaleChanged(int scale); - void shearChanged(int shear); - -protected: - void timerEvent(QTimerEvent *e); - void wheelEvent(QWheelEvent *); - -private: - QPolygonF ctrlPoints; - HoverPoints *pts; - qreal m_rotation; - qreal m_scale; - qreal m_shear; - XFormType m_type; - QPixmap m_pixmap; - QString m_text; - QBasicTimer timer; -}; - -class XFormWidget : public QWidget -{ - Q_OBJECT -public: - XFormWidget(QWidget *parent); - -private: - XFormView *view; - QLineEdit *textEditor; -}; - -#endif // XFORM_H diff --git a/examples/painting/affine/xform.html b/examples/painting/affine/xform.html deleted file mode 100644 index 17325ac2a0..0000000000 --- a/examples/painting/affine/xform.html +++ /dev/null @@ -1,23 +0,0 @@ - -
      -

      Affine Transformations

      -
      - -

      In this demo we demonstrate Qt's ability to perform affine transformations -on painting operations.

      - -

      Transformations can be performed on any kind of graphics drawn using -QPainter. The transformations used to display the vector graphics, images, -and text can be adjusted in the following ways:

      - -
        -
      • Dragging the red circle in the centre of each drawing moves it to a new - position.
      • -
      • Dragging the displaced red circle causes the current drawing to be - rotated about the central circle. Rotation can also be controlled with - the Rotate slider.
      • -
      • Scaling is controlled with the Scale slider.
      • -
      • Each drawing can be sheared with the Shear slider.
      • -
      - - diff --git a/examples/painting/basicdrawing/basicdrawing.desktop b/examples/painting/basicdrawing/basicdrawing.desktop deleted file mode 100644 index 7f178ec8a7..0000000000 --- a/examples/painting/basicdrawing/basicdrawing.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Basic Drawing -Exec=/opt/usr/bin/basicdrawing -Icon=basicdrawing -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/basicdrawing/basicdrawing.pro b/examples/painting/basicdrawing/basicdrawing.pro deleted file mode 100644 index 0e0328e61f..0000000000 --- a/examples/painting/basicdrawing/basicdrawing.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = renderarea.h \ - window.h -SOURCES = main.cpp \ - renderarea.cpp \ - window.cpp -RESOURCES = basicdrawing.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/basicdrawing -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS basicdrawing.pro images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/basicdrawing -INSTALLS += target sources - -QT += widgets diff --git a/examples/painting/basicdrawing/basicdrawing.qrc b/examples/painting/basicdrawing/basicdrawing.qrc deleted file mode 100644 index 9d8a23a1c8..0000000000 --- a/examples/painting/basicdrawing/basicdrawing.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/brick.png - images/qt-logo.png - - diff --git a/examples/painting/basicdrawing/images/brick.png b/examples/painting/basicdrawing/images/brick.png deleted file mode 100644 index 87e7df5b04..0000000000 Binary files a/examples/painting/basicdrawing/images/brick.png and /dev/null differ diff --git a/examples/painting/basicdrawing/images/qt-logo.png b/examples/painting/basicdrawing/images/qt-logo.png deleted file mode 100644 index a8b452e07a..0000000000 Binary files a/examples/painting/basicdrawing/images/qt-logo.png and /dev/null differ diff --git a/examples/painting/basicdrawing/main.cpp b/examples/painting/basicdrawing/main.cpp deleted file mode 100644 index d80c9a2daa..0000000000 --- a/examples/painting/basicdrawing/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(basicdrawing); - - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/painting/basicdrawing/renderarea.cpp b/examples/painting/basicdrawing/renderarea.cpp deleted file mode 100644 index 9fb4ab589d..0000000000 --- a/examples/painting/basicdrawing/renderarea.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "renderarea.h" - -//! [0] -RenderArea::RenderArea(QWidget *parent) - : QWidget(parent) -{ - shape = Polygon; - antialiased = false; - transformed = false; - pixmap.load(":/images/qt-logo.png"); - - setBackgroundRole(QPalette::Base); - setAutoFillBackground(true); -} -//! [0] - -//! [1] -QSize RenderArea::minimumSizeHint() const -{ - return QSize(100, 100); -} -//! [1] - -//! [2] -QSize RenderArea::sizeHint() const -{ - return QSize(400, 200); -} -//! [2] - -//! [3] -void RenderArea::setShape(Shape shape) -{ - this->shape = shape; - update(); -} -//! [3] - -//! [4] -void RenderArea::setPen(const QPen &pen) -{ - this->pen = pen; - update(); -} -//! [4] - -//! [5] -void RenderArea::setBrush(const QBrush &brush) -{ - this->brush = brush; - update(); -} -//! [5] - -//! [6] -void RenderArea::setAntialiased(bool antialiased) -{ - this->antialiased = antialiased; - update(); -} -//! [6] - -//! [7] -void RenderArea::setTransformed(bool transformed) -{ - this->transformed = transformed; - update(); -} -//! [7] - -//! [8] -void RenderArea::paintEvent(QPaintEvent * /* event */) -{ - static const QPoint points[4] = { - QPoint(10, 80), - QPoint(20, 10), - QPoint(80, 30), - QPoint(90, 70) - }; - - QRect rect(10, 20, 80, 60); - - QPainterPath path; - path.moveTo(20, 80); - path.lineTo(20, 30); - path.cubicTo(80, 0, 50, 50, 80, 80); - - int startAngle = 20 * 16; - int arcLength = 120 * 16; -//! [8] - -//! [9] - QPainter painter(this); - painter.setPen(pen); - painter.setBrush(brush); - if (antialiased) - painter.setRenderHint(QPainter::Antialiasing, true); -//! [9] - -//! [10] - for (int x = 0; x < width(); x += 100) { - for (int y = 0; y < height(); y += 100) { - painter.save(); - painter.translate(x, y); -//! [10] //! [11] - if (transformed) { - painter.translate(50, 50); - painter.rotate(60.0); - painter.scale(0.6, 0.9); - painter.translate(-50, -50); - } -//! [11] - -//! [12] - switch (shape) { - case Line: - painter.drawLine(rect.bottomLeft(), rect.topRight()); - break; - case Points: - painter.drawPoints(points, 4); - break; - case Polyline: - painter.drawPolyline(points, 4); - break; - case Polygon: - painter.drawPolygon(points, 4); - break; - case Rect: - painter.drawRect(rect); - break; - case RoundedRect: - painter.drawRoundedRect(rect, 25, 25, Qt::RelativeSize); - break; - case Ellipse: - painter.drawEllipse(rect); - break; - case Arc: - painter.drawArc(rect, startAngle, arcLength); - break; - case Chord: - painter.drawChord(rect, startAngle, arcLength); - break; - case Pie: - painter.drawPie(rect, startAngle, arcLength); - break; - case Path: - painter.drawPath(path); - break; - case Text: - painter.drawText(rect, Qt::AlignCenter, tr("Qt by\nNokia")); - break; - case Pixmap: - painter.drawPixmap(10, 10, pixmap); - } -//! [12] //! [13] - painter.restore(); - } - } - - painter.setRenderHint(QPainter::Antialiasing, false); - painter.setPen(palette().dark().color()); - painter.setBrush(Qt::NoBrush); - painter.drawRect(QRect(0, 0, width() - 1, height() - 1)); -} -//! [13] diff --git a/examples/painting/basicdrawing/renderarea.h b/examples/painting/basicdrawing/renderarea.h deleted file mode 100644 index 3ed9eb6321..0000000000 --- a/examples/painting/basicdrawing/renderarea.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 RENDERAREA_H -#define RENDERAREA_H - -#include -#include -#include -#include - -//! [0] -class RenderArea : public QWidget -{ - Q_OBJECT - -public: - enum Shape { Line, Points, Polyline, Polygon, Rect, RoundedRect, Ellipse, Arc, - Chord, Pie, Path, Text, Pixmap }; - - RenderArea(QWidget *parent = 0); - - QSize minimumSizeHint() const; - QSize sizeHint() const; - -public slots: - void setShape(Shape shape); - void setPen(const QPen &pen); - void setBrush(const QBrush &brush); - void setAntialiased(bool antialiased); - void setTransformed(bool transformed); - -protected: - void paintEvent(QPaintEvent *event); - -private: - Shape shape; - QPen pen; - QBrush brush; - bool antialiased; - bool transformed; - QPixmap pixmap; -}; -//! [0] - -#endif diff --git a/examples/painting/basicdrawing/window.cpp b/examples/painting/basicdrawing/window.cpp deleted file mode 100644 index 9579e40ae2..0000000000 --- a/examples/painting/basicdrawing/window.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "renderarea.h" -#include "window.h" - -//! [0] -const int IdRole = Qt::UserRole; -//! [0] - -//! [1] -Window::Window() -{ - renderArea = new RenderArea; - - shapeComboBox = new QComboBox; - shapeComboBox->addItem(tr("Polygon"), RenderArea::Polygon); - shapeComboBox->addItem(tr("Rectangle"), RenderArea::Rect); - shapeComboBox->addItem(tr("Rounded Rectangle"), RenderArea::RoundedRect); - shapeComboBox->addItem(tr("Ellipse"), RenderArea::Ellipse); - shapeComboBox->addItem(tr("Pie"), RenderArea::Pie); - shapeComboBox->addItem(tr("Chord"), RenderArea::Chord); - shapeComboBox->addItem(tr("Path"), RenderArea::Path); - shapeComboBox->addItem(tr("Line"), RenderArea::Line); - shapeComboBox->addItem(tr("Polyline"), RenderArea::Polyline); - shapeComboBox->addItem(tr("Arc"), RenderArea::Arc); - shapeComboBox->addItem(tr("Points"), RenderArea::Points); - shapeComboBox->addItem(tr("Text"), RenderArea::Text); - shapeComboBox->addItem(tr("Pixmap"), RenderArea::Pixmap); - - shapeLabel = new QLabel(tr("&Shape:")); - shapeLabel->setBuddy(shapeComboBox); -//! [1] - -//! [2] - penWidthSpinBox = new QSpinBox; - penWidthSpinBox->setRange(0, 20); - penWidthSpinBox->setSpecialValueText(tr("0 (cosmetic pen)")); - - penWidthLabel = new QLabel(tr("Pen &Width:")); - penWidthLabel->setBuddy(penWidthSpinBox); -//! [2] - -//! [3] - penStyleComboBox = new QComboBox; - penStyleComboBox->addItem(tr("Solid"), Qt::SolidLine); - penStyleComboBox->addItem(tr("Dash"), Qt::DashLine); - penStyleComboBox->addItem(tr("Dot"), Qt::DotLine); - penStyleComboBox->addItem(tr("Dash Dot"), Qt::DashDotLine); - penStyleComboBox->addItem(tr("Dash Dot Dot"), Qt::DashDotDotLine); - penStyleComboBox->addItem(tr("None"), Qt::NoPen); - - penStyleLabel = new QLabel(tr("&Pen Style:")); - penStyleLabel->setBuddy(penStyleComboBox); - - penCapComboBox = new QComboBox; - penCapComboBox->addItem(tr("Flat"), Qt::FlatCap); - penCapComboBox->addItem(tr("Square"), Qt::SquareCap); - penCapComboBox->addItem(tr("Round"), Qt::RoundCap); - - penCapLabel = new QLabel(tr("Pen &Cap:")); - penCapLabel->setBuddy(penCapComboBox); - - penJoinComboBox = new QComboBox; - penJoinComboBox->addItem(tr("Miter"), Qt::MiterJoin); - penJoinComboBox->addItem(tr("Bevel"), Qt::BevelJoin); - penJoinComboBox->addItem(tr("Round"), Qt::RoundJoin); - - penJoinLabel = new QLabel(tr("Pen &Join:")); - penJoinLabel->setBuddy(penJoinComboBox); -//! [3] - -//! [4] - brushStyleComboBox = new QComboBox; - brushStyleComboBox->addItem(tr("Linear Gradient"), - Qt::LinearGradientPattern); - brushStyleComboBox->addItem(tr("Radial Gradient"), - Qt::RadialGradientPattern); - brushStyleComboBox->addItem(tr("Conical Gradient"), - Qt::ConicalGradientPattern); - brushStyleComboBox->addItem(tr("Texture"), Qt::TexturePattern); - brushStyleComboBox->addItem(tr("Solid"), Qt::SolidPattern); - brushStyleComboBox->addItem(tr("Horizontal"), Qt::HorPattern); - brushStyleComboBox->addItem(tr("Vertical"), Qt::VerPattern); - brushStyleComboBox->addItem(tr("Cross"), Qt::CrossPattern); - brushStyleComboBox->addItem(tr("Backward Diagonal"), Qt::BDiagPattern); - brushStyleComboBox->addItem(tr("Forward Diagonal"), Qt::FDiagPattern); - brushStyleComboBox->addItem(tr("Diagonal Cross"), Qt::DiagCrossPattern); - brushStyleComboBox->addItem(tr("Dense 1"), Qt::Dense1Pattern); - brushStyleComboBox->addItem(tr("Dense 2"), Qt::Dense2Pattern); - brushStyleComboBox->addItem(tr("Dense 3"), Qt::Dense3Pattern); - brushStyleComboBox->addItem(tr("Dense 4"), Qt::Dense4Pattern); - brushStyleComboBox->addItem(tr("Dense 5"), Qt::Dense5Pattern); - brushStyleComboBox->addItem(tr("Dense 6"), Qt::Dense6Pattern); - brushStyleComboBox->addItem(tr("Dense 7"), Qt::Dense7Pattern); - brushStyleComboBox->addItem(tr("None"), Qt::NoBrush); - - brushStyleLabel = new QLabel(tr("&Brush:")); - brushStyleLabel->setBuddy(brushStyleComboBox); -//! [4] - -//! [5] - otherOptionsLabel = new QLabel(tr("Options:")); -//! [5] //! [6] - antialiasingCheckBox = new QCheckBox(tr("&Antialiasing")); -//! [6] //! [7] - transformationsCheckBox = new QCheckBox(tr("&Transformations")); -//! [7] - -//! [8] - connect(shapeComboBox, SIGNAL(activated(int)), - this, SLOT(shapeChanged())); - connect(penWidthSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(penChanged())); - connect(penStyleComboBox, SIGNAL(activated(int)), - this, SLOT(penChanged())); - connect(penCapComboBox, SIGNAL(activated(int)), - this, SLOT(penChanged())); - connect(penJoinComboBox, SIGNAL(activated(int)), - this, SLOT(penChanged())); - connect(brushStyleComboBox, SIGNAL(activated(int)), - this, SLOT(brushChanged())); - connect(antialiasingCheckBox, SIGNAL(toggled(bool)), - renderArea, SLOT(setAntialiased(bool))); - connect(transformationsCheckBox, SIGNAL(toggled(bool)), - renderArea, SLOT(setTransformed(bool))); -//! [8] - -//! [9] - QGridLayout *mainLayout = new QGridLayout; -//! [9] //! [10] - mainLayout->setColumnStretch(0, 1); - mainLayout->setColumnStretch(3, 1); - mainLayout->addWidget(renderArea, 0, 0, 1, 4); - mainLayout->addWidget(shapeLabel, 2, 0, Qt::AlignRight); - mainLayout->addWidget(shapeComboBox, 2, 1); - mainLayout->addWidget(penWidthLabel, 3, 0, Qt::AlignRight); - mainLayout->addWidget(penWidthSpinBox, 3, 1); - mainLayout->addWidget(penStyleLabel, 4, 0, Qt::AlignRight); - mainLayout->addWidget(penStyleComboBox, 4, 1); - mainLayout->addWidget(penCapLabel, 3, 2, Qt::AlignRight); - mainLayout->addWidget(penCapComboBox, 3, 3); - mainLayout->addWidget(penJoinLabel, 2, 2, Qt::AlignRight); - mainLayout->addWidget(penJoinComboBox, 2, 3); - mainLayout->addWidget(brushStyleLabel, 4, 2, Qt::AlignRight); - mainLayout->addWidget(brushStyleComboBox, 4, 3); - mainLayout->addWidget(otherOptionsLabel, 5, 0, Qt::AlignRight); - mainLayout->addWidget(antialiasingCheckBox, 5, 1, 1, 1, Qt::AlignRight); - mainLayout->addWidget(transformationsCheckBox, 5, 2, 1, 2, Qt::AlignRight); - setLayout(mainLayout); - - shapeChanged(); - penChanged(); - brushChanged(); - antialiasingCheckBox->setChecked(true); - - setWindowTitle(tr("Basic Drawing")); -} -//! [10] - -//! [11] -void Window::shapeChanged() -{ - RenderArea::Shape shape = RenderArea::Shape(shapeComboBox->itemData( - shapeComboBox->currentIndex(), IdRole).toInt()); - renderArea->setShape(shape); -} -//! [11] - -//! [12] -void Window::penChanged() -{ - int width = penWidthSpinBox->value(); - Qt::PenStyle style = Qt::PenStyle(penStyleComboBox->itemData( - penStyleComboBox->currentIndex(), IdRole).toInt()); - Qt::PenCapStyle cap = Qt::PenCapStyle(penCapComboBox->itemData( - penCapComboBox->currentIndex(), IdRole).toInt()); - Qt::PenJoinStyle join = Qt::PenJoinStyle(penJoinComboBox->itemData( - penJoinComboBox->currentIndex(), IdRole).toInt()); - - renderArea->setPen(QPen(Qt::blue, width, style, cap, join)); -} -//! [12] - -//! [13] -void Window::brushChanged() -{ - Qt::BrushStyle style = Qt::BrushStyle(brushStyleComboBox->itemData( -//! [13] - brushStyleComboBox->currentIndex(), IdRole).toInt()); - -//! [14] - if (style == Qt::LinearGradientPattern) { - QLinearGradient linearGradient(0, 0, 100, 100); - linearGradient.setColorAt(0.0, Qt::white); - linearGradient.setColorAt(0.2, Qt::green); - linearGradient.setColorAt(1.0, Qt::black); - renderArea->setBrush(linearGradient); -//! [14] //! [15] - } else if (style == Qt::RadialGradientPattern) { - QRadialGradient radialGradient(50, 50, 50, 70, 70); - radialGradient.setColorAt(0.0, Qt::white); - radialGradient.setColorAt(0.2, Qt::green); - radialGradient.setColorAt(1.0, Qt::black); - renderArea->setBrush(radialGradient); - } else if (style == Qt::ConicalGradientPattern) { - QConicalGradient conicalGradient(50, 50, 150); - conicalGradient.setColorAt(0.0, Qt::white); - conicalGradient.setColorAt(0.2, Qt::green); - conicalGradient.setColorAt(1.0, Qt::black); - renderArea->setBrush(conicalGradient); -//! [15] //! [16] - } else if (style == Qt::TexturePattern) { - renderArea->setBrush(QBrush(QPixmap(":/images/brick.png"))); -//! [16] //! [17] - } else { - renderArea->setBrush(QBrush(Qt::green, style)); - } -} -//! [17] diff --git a/examples/painting/basicdrawing/window.h b/examples/painting/basicdrawing/window.h deleted file mode 100644 index 3f2c8fd561..0000000000 --- a/examples/painting/basicdrawing/window.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QComboBox; -class QLabel; -class QSpinBox; -QT_END_NAMESPACE -class RenderArea; - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -private slots: - void shapeChanged(); - void penChanged(); - void brushChanged(); - -private: - RenderArea *renderArea; - QLabel *shapeLabel; - QLabel *penWidthLabel; - QLabel *penStyleLabel; - QLabel *penCapLabel; - QLabel *penJoinLabel; - QLabel *brushStyleLabel; - QLabel *otherOptionsLabel; - QComboBox *shapeComboBox; - QSpinBox *penWidthSpinBox; - QComboBox *penStyleComboBox; - QComboBox *penCapComboBox; - QComboBox *penJoinComboBox; - QComboBox *brushStyleComboBox; - QCheckBox *antialiasingCheckBox; - QCheckBox *transformationsCheckBox; -}; -//! [0] - -#endif diff --git a/examples/painting/composition/composition.cpp b/examples/painting/composition/composition.cpp deleted file mode 100644 index f46a658c17..0000000000 --- a/examples/painting/composition/composition.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "composition.h" -#include -#include -#include -#include -#include -#include -#include - -const int animationInterval = 15; // update every 16 ms = ~60FPS - -CompositionWidget::CompositionWidget(QWidget *parent) - : QWidget(parent) -{ - CompositionRenderer *view = new CompositionRenderer(this); - - QGroupBox *mainGroup = new QGroupBox(parent); - mainGroup->setTitle(tr("Composition Modes")); - - QGroupBox *modesGroup = new QGroupBox(mainGroup); - modesGroup->setTitle(tr("Mode")); - - rbClear = new QRadioButton(tr("Clear"), modesGroup); - connect(rbClear, SIGNAL(clicked()), view, SLOT(setClearMode())); - rbSource = new QRadioButton(tr("Source"), modesGroup); - connect(rbSource, SIGNAL(clicked()), view, SLOT(setSourceMode())); - rbDest = new QRadioButton(tr("Destination"), modesGroup); - connect(rbDest, SIGNAL(clicked()), view, SLOT(setDestMode())); - rbSourceOver = new QRadioButton(tr("Source Over"), modesGroup); - connect(rbSourceOver, SIGNAL(clicked()), view, SLOT(setSourceOverMode())); - rbDestOver = new QRadioButton(tr("Destination Over"), modesGroup); - connect(rbDestOver, SIGNAL(clicked()), view, SLOT(setDestOverMode())); - rbSourceIn = new QRadioButton(tr("Source In"), modesGroup); - connect(rbSourceIn, SIGNAL(clicked()), view, SLOT(setSourceInMode())); - rbDestIn = new QRadioButton(tr("Dest In"), modesGroup); - connect(rbDestIn, SIGNAL(clicked()), view, SLOT(setDestInMode())); - rbSourceOut = new QRadioButton(tr("Source Out"), modesGroup); - connect(rbSourceOut, SIGNAL(clicked()), view, SLOT(setSourceOutMode())); - rbDestOut = new QRadioButton(tr("Dest Out"), modesGroup); - connect(rbDestOut, SIGNAL(clicked()), view, SLOT(setDestOutMode())); - rbSourceAtop = new QRadioButton(tr("Source Atop"), modesGroup); - connect(rbSourceAtop, SIGNAL(clicked()), view, SLOT(setSourceAtopMode())); - rbDestAtop = new QRadioButton(tr("Dest Atop"), modesGroup); - connect(rbDestAtop, SIGNAL(clicked()), view, SLOT(setDestAtopMode())); - rbXor = new QRadioButton(tr("Xor"), modesGroup); - connect(rbXor, SIGNAL(clicked()), view, SLOT(setXorMode())); - - rbPlus = new QRadioButton(tr("Plus"), modesGroup); - connect(rbPlus, SIGNAL(clicked()), view, SLOT(setPlusMode())); - rbMultiply = new QRadioButton(tr("Multiply"), modesGroup); - connect(rbMultiply, SIGNAL(clicked()), view, SLOT(setMultiplyMode())); - rbScreen = new QRadioButton(tr("Screen"), modesGroup); - connect(rbScreen, SIGNAL(clicked()), view, SLOT(setScreenMode())); - rbOverlay = new QRadioButton(tr("Overlay"), modesGroup); - connect(rbOverlay, SIGNAL(clicked()), view, SLOT(setOverlayMode())); - rbDarken = new QRadioButton(tr("Darken"), modesGroup); - connect(rbDarken, SIGNAL(clicked()), view, SLOT(setDarkenMode())); - rbLighten = new QRadioButton(tr("Lighten"), modesGroup); - connect(rbLighten, SIGNAL(clicked()), view, SLOT(setLightenMode())); - rbColorDodge = new QRadioButton(tr("Color Dodge"), modesGroup); - connect(rbColorDodge, SIGNAL(clicked()), view, SLOT(setColorDodgeMode())); - rbColorBurn = new QRadioButton(tr("Color Burn"), modesGroup); - connect(rbColorBurn, SIGNAL(clicked()), view, SLOT(setColorBurnMode())); - rbHardLight = new QRadioButton(tr("Hard Light"), modesGroup); - connect(rbHardLight, SIGNAL(clicked()), view, SLOT(setHardLightMode())); - rbSoftLight = new QRadioButton(tr("Soft Light"), modesGroup); - connect(rbSoftLight, SIGNAL(clicked()), view, SLOT(setSoftLightMode())); - rbDifference = new QRadioButton(tr("Difference"), modesGroup); - connect(rbDifference, SIGNAL(clicked()), view, SLOT(setDifferenceMode())); - rbExclusion = new QRadioButton(tr("Exclusion"), modesGroup); - connect(rbExclusion, SIGNAL(clicked()), view, SLOT(setExclusionMode())); - - QGroupBox *circleColorGroup = new QGroupBox(mainGroup); - circleColorGroup->setTitle(tr("Circle color")); - QSlider *circleColorSlider = new QSlider(Qt::Horizontal, circleColorGroup); - circleColorSlider->setRange(0, 359); - circleColorSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - connect(circleColorSlider, SIGNAL(valueChanged(int)), view, SLOT(setCircleColor(int))); - - QGroupBox *circleAlphaGroup = new QGroupBox(mainGroup); - circleAlphaGroup->setTitle(tr("Circle alpha")); - QSlider *circleAlphaSlider = new QSlider(Qt::Horizontal, circleAlphaGroup); - circleAlphaSlider->setRange(0, 255); - circleAlphaSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - connect(circleAlphaSlider, SIGNAL(valueChanged(int)), view, SLOT(setCircleAlpha(int))); - - QPushButton *showSourceButton = new QPushButton(mainGroup); - showSourceButton->setText(tr("Show Source")); -#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(view->usesOpenGL()); - - if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) - enableOpenGLButton->hide(); -#endif - QPushButton *whatsThisButton = new QPushButton(mainGroup); - whatsThisButton->setText(tr("What's This?")); - whatsThisButton->setCheckable(true); - - QPushButton *animateButton = new QPushButton(mainGroup); - animateButton->setText(tr("Animated")); - animateButton->setCheckable(true); - animateButton->setChecked(true); - - QHBoxLayout *viewLayout = new QHBoxLayout(this); - viewLayout->addWidget(view); - viewLayout->addWidget(mainGroup); - - QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); - mainGroupLayout->addWidget(circleColorGroup); - mainGroupLayout->addWidget(circleAlphaGroup); - mainGroupLayout->addWidget(modesGroup); - mainGroupLayout->addStretch(); - mainGroupLayout->addWidget(animateButton); - mainGroupLayout->addWidget(whatsThisButton); - mainGroupLayout->addWidget(showSourceButton); -#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES) - mainGroupLayout->addWidget(enableOpenGLButton); -#endif - - QGridLayout *modesLayout = new QGridLayout(modesGroup); - modesLayout->addWidget(rbClear, 0, 0); - modesLayout->addWidget(rbSource, 1, 0); - modesLayout->addWidget(rbDest, 2, 0); - modesLayout->addWidget(rbSourceOver, 3, 0); - modesLayout->addWidget(rbDestOver, 4, 0); - modesLayout->addWidget(rbSourceIn, 5, 0); - modesLayout->addWidget(rbDestIn, 6, 0); - modesLayout->addWidget(rbSourceOut, 7, 0); - modesLayout->addWidget(rbDestOut, 8, 0); - modesLayout->addWidget(rbSourceAtop, 9, 0); - modesLayout->addWidget(rbDestAtop, 10, 0); - modesLayout->addWidget(rbXor, 11, 0); - - modesLayout->addWidget(rbPlus, 0, 1); - modesLayout->addWidget(rbMultiply, 1, 1); - modesLayout->addWidget(rbScreen, 2, 1); - modesLayout->addWidget(rbOverlay, 3, 1); - modesLayout->addWidget(rbDarken, 4, 1); - modesLayout->addWidget(rbLighten, 5, 1); - modesLayout->addWidget(rbColorDodge, 6, 1); - modesLayout->addWidget(rbColorBurn, 7, 1); - modesLayout->addWidget(rbHardLight, 8, 1); - modesLayout->addWidget(rbSoftLight, 9, 1); - modesLayout->addWidget(rbDifference, 10, 1); - modesLayout->addWidget(rbExclusion, 11, 1); - - - QVBoxLayout *circleColorLayout = new QVBoxLayout(circleColorGroup); - circleColorLayout->addWidget(circleColorSlider); - - QVBoxLayout *circleAlphaLayout = new QVBoxLayout(circleAlphaGroup); - circleAlphaLayout->addWidget(circleAlphaSlider); - - view->loadDescription(":res/composition/composition.html"); - view->loadSourceFile(":res/composition/composition.cpp"); - - connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool))); - connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool))); - connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource())); -#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES) - connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool))); -#endif - connect(animateButton, SIGNAL(toggled(bool)), view, SLOT(setAnimationEnabled(bool))); - - circleColorSlider->setValue(270); - circleAlphaSlider->setValue(200); - rbSourceOut->animateClick(); - - setWindowTitle(tr("Composition Modes")); -} - - -void CompositionWidget::nextMode() -{ - /* - if (!m_animation_enabled) - return; - if (rbClear->isChecked()) rbSource->animateClick(); - if (rbSource->isChecked()) rbDest->animateClick(); - if (rbDest->isChecked()) rbSourceOver->animateClick(); - if (rbSourceOver->isChecked()) rbDestOver->animateClick(); - if (rbDestOver->isChecked()) rbSourceIn->animateClick(); - if (rbSourceIn->isChecked()) rbDestIn->animateClick(); - if (rbDestIn->isChecked()) rbSourceOut->animateClick(); - if (rbSourceOut->isChecked()) rbDestOut->animateClick(); - if (rbDestOut->isChecked()) rbSourceAtop->animateClick(); - if (rbSourceAtop->isChecked()) rbDestAtop->animateClick(); - if (rbDestAtop->isChecked()) rbXor->animateClick(); - if (rbXor->isChecked()) rbClear->animateClick(); - */ -} - -CompositionRenderer::CompositionRenderer(QWidget *parent) - : ArthurFrame(parent) -{ - m_animation_enabled = true; - m_animationTimer = startTimer(animationInterval); - m_image = QImage(":res/composition/flower.jpg"); - m_image.setAlphaChannel(QImage(":res/composition/flower_alpha.jpg")); - m_circle_alpha = 127; - m_circle_hue = 255; - m_current_object = NoObject; - m_composition_mode = QPainter::CompositionMode_SourceOut; - - m_circle_pos = QPoint(200, 100); - - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -#ifdef QT_OPENGL_SUPPORT - m_pbuffer = 0; - m_pbuffer_size = 1024; -#endif -} - -QRectF rectangle_around(const QPointF &p, const QSizeF &size = QSize(250, 200)) -{ - QRectF rect(p, size); - rect.translate(-size.width()/2, -size.height()/2); - return rect; -} - -void CompositionRenderer::setAnimationEnabled(bool enabled) -{ - if (m_animation_enabled == enabled) - return; - m_animation_enabled = enabled; - if (enabled) { - Q_ASSERT(!m_animationTimer); - m_animationTimer = startTimer(animationInterval); - } else { - killTimer(m_animationTimer); - m_animationTimer = 0; - } -} - -void CompositionRenderer::updateCirclePos() -{ - if (m_current_object != NoObject) - return; - QDateTime dt = QDateTime::currentDateTime(); - qreal t = (dt.toTime_t() * 1000 + dt.time().msec()) / 1000.0; - - qreal x = width() / qreal(2) + (qCos(t*8/11) + qSin(-t)) * width() / qreal(4); - qreal y = height() / qreal(2) + (qSin(t*6/7) + qCos(t * qreal(1.5))) * height() / qreal(4); - - setCirclePos(QLineF(m_circle_pos, QPointF(x, y)).pointAt(0.02)); -} - -void CompositionRenderer::drawBase(QPainter &p) -{ - p.setPen(Qt::NoPen); - - QLinearGradient rect_gradient(0, 0, 0, height()); - rect_gradient.setColorAt(0, Qt::red); - rect_gradient.setColorAt(.17, Qt::yellow); - rect_gradient.setColorAt(.33, Qt::green); - rect_gradient.setColorAt(.50, Qt::cyan); - rect_gradient.setColorAt(.66, Qt::blue); - rect_gradient.setColorAt(.81, Qt::magenta); - rect_gradient.setColorAt(1, Qt::red); - p.setBrush(rect_gradient); - p.drawRect(width() / 2, 0, width() / 2, height()); - - QLinearGradient alpha_gradient(0, 0, width(), 0); - alpha_gradient.setColorAt(0, Qt::white); - alpha_gradient.setColorAt(0.2, Qt::white); - alpha_gradient.setColorAt(0.5, Qt::transparent); - alpha_gradient.setColorAt(0.8, Qt::white); - alpha_gradient.setColorAt(1, Qt::white); - - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - p.setBrush(alpha_gradient); - p.drawRect(0, 0, width(), height()); - - p.setCompositionMode(QPainter::CompositionMode_DestinationOver); - - p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::SmoothPixmapTransform); - p.drawImage(rect(), m_image); -} - -void CompositionRenderer::drawSource(QPainter &p) -{ - p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::Antialiasing); - p.setCompositionMode(m_composition_mode); - - QRectF circle_rect = rectangle_around(m_circle_pos); - QColor color = QColor::fromHsvF(m_circle_hue / 360.0, 1, 1, m_circle_alpha / 255.0); - QLinearGradient circle_gradient(circle_rect.topLeft(), circle_rect.bottomRight()); - circle_gradient.setColorAt(0, color.light()); - circle_gradient.setColorAt(0.5, color); - circle_gradient.setColorAt(1, color.dark()); - p.setBrush(circle_gradient); - - p.drawEllipse(circle_rect); -} - -void CompositionRenderer::paint(QPainter *painter) -{ -#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES) - if (usesOpenGL()) { - - int new_pbuf_size = m_pbuffer_size; - if (size().width() > m_pbuffer_size || - size().height() > m_pbuffer_size) - new_pbuf_size *= 2; - - if (size().width() < m_pbuffer_size/2 && - size().height() < m_pbuffer_size/2) - new_pbuf_size /= 2; - - if (!m_pbuffer || new_pbuf_size != m_pbuffer_size) { - if (m_pbuffer) { - m_pbuffer->deleteTexture(m_base_tex); - m_pbuffer->deleteTexture(m_compositing_tex); - delete m_pbuffer; - } - - m_pbuffer = new QGLPixelBuffer(QSize(new_pbuf_size, new_pbuf_size), QGLFormat::defaultFormat(), glWidget()); - m_pbuffer->makeCurrent(); - m_base_tex = m_pbuffer->generateDynamicTexture(); - m_compositing_tex = m_pbuffer->generateDynamicTexture(); - m_pbuffer_size = new_pbuf_size; - } - - if (size() != m_previous_size) { - m_previous_size = size(); - QPainter p(m_pbuffer); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent); - drawBase(p); - p.end(); - m_pbuffer->updateDynamicTexture(m_base_tex); - } - - qreal x_fraction = width()/float(m_pbuffer->width()); - qreal y_fraction = height()/float(m_pbuffer->height()); - - { - QPainter p(m_pbuffer); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent); - - p.save(); // Needed when using the GL1 engine - p.beginNativePainting(); // Needed when using the GL2 engine - - glBindTexture(GL_TEXTURE_2D, m_base_tex); - glEnable(GL_TEXTURE_2D); - glColor4f(1.,1.,1.,1.); - - glBegin(GL_QUADS); - { - glTexCoord2f(0, 1.0); - glVertex2f(0, 0); - - glTexCoord2f(x_fraction, 1.0); - glVertex2f(width(), 0); - - glTexCoord2f(x_fraction, 1.0-y_fraction); - glVertex2f(width(), height()); - - glTexCoord2f(0, 1.0-y_fraction); - glVertex2f(0, height()); - } - glEnd(); - - glDisable(GL_TEXTURE_2D); - - p.endNativePainting(); // Needed when using the GL2 engine - p.restore(); // Needed when using the GL1 engine - - drawSource(p); - p.end(); - m_pbuffer->updateDynamicTexture(m_compositing_tex); - } - - painter->beginNativePainting(); // Needed when using the GL2 engine - glWidget()->makeCurrent(); // Needed when using the GL1 engine - glBindTexture(GL_TEXTURE_2D, m_compositing_tex); - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(1.,1.,1.,1.); - glBegin(GL_QUADS); - { - glTexCoord2f(0, 1.0); - glVertex2f(0, 0); - - glTexCoord2f(x_fraction, 1.0); - glVertex2f(width(), 0); - - glTexCoord2f(x_fraction, 1.0-y_fraction); - glVertex2f(width(), height()); - - glTexCoord2f(0, 1.0-y_fraction); - glVertex2f(0, height()); - } - glEnd(); - glDisable(GL_TEXTURE_2D); - painter->endNativePainting(); // Needed when using the GL2 engine - } else -#endif - { - // using a QImage - if (m_buffer.size() != size()) { - m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); - m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); - - m_base_buffer.fill(0); - - QPainter p(&m_base_buffer); - - drawBase(p); - } - - memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.byteCount()); - - { - QPainter p(&m_buffer); - drawSource(p); - } - - painter->drawImage(0, 0, m_buffer); - } -} - -void CompositionRenderer::mousePressEvent(QMouseEvent *e) -{ - setDescriptionEnabled(false); - - QRectF circle = rectangle_around(m_circle_pos); - - if (circle.contains(e->pos())) { - m_current_object = Circle; - m_offset = circle.center() - e->pos(); - } else { - m_current_object = NoObject; - } - if (m_animation_enabled) { - killTimer(m_animationTimer); - m_animationTimer = 0; - } -} - -void CompositionRenderer::mouseMoveEvent(QMouseEvent *e) -{ - if (m_current_object == Circle) setCirclePos(e->pos() + m_offset); -} - -void CompositionRenderer::mouseReleaseEvent(QMouseEvent *) -{ - m_current_object = NoObject; - - if (m_animation_enabled) { - Q_ASSERT(!m_animationTimer); - m_animationTimer = startTimer(animationInterval); - } -} - -void CompositionRenderer::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == m_animationTimer) - updateCirclePos(); -} - -void CompositionRenderer::setCirclePos(const QPointF &pos) -{ - const QRect oldRect = rectangle_around(m_circle_pos).toAlignedRect(); - m_circle_pos = pos; - const QRect newRect = rectangle_around(m_circle_pos).toAlignedRect(); -#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES) - if (usesOpenGL()) - update(); - else -#endif - update(oldRect | newRect); -} - diff --git a/examples/painting/composition/composition.h b/examples/painting/composition/composition.h deleted file mode 100644 index ebf278f145..0000000000 --- a/examples/painting/composition/composition.h +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef COMPOSITION_H -#define COMPOSITION_H - -#include "arthurwidgets.h" - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QPushButton) -QT_FORWARD_DECLARE_CLASS(QRadioButton) - -#ifdef QT_OPENGL_SUPPORT -#include -#endif - -class CompositionWidget : public QWidget -{ - Q_OBJECT - -public: - CompositionWidget(QWidget *parent); - -public slots: -void nextMode(); - -private: - bool m_cycle_enabled; - - QRadioButton *rbClear; - QRadioButton *rbSource; - QRadioButton *rbDest; - QRadioButton *rbSourceOver; - QRadioButton *rbDestOver; - QRadioButton *rbSourceIn; - QRadioButton *rbDestIn; - QRadioButton *rbSourceOut; - QRadioButton *rbDestOut; - QRadioButton *rbSourceAtop; - QRadioButton *rbDestAtop; - QRadioButton *rbXor; - - QRadioButton *rbPlus; - QRadioButton *rbMultiply; - QRadioButton *rbScreen; - QRadioButton *rbOverlay; - QRadioButton *rbDarken; - QRadioButton *rbLighten; - QRadioButton *rbColorDodge; - QRadioButton *rbColorBurn; - QRadioButton *rbHardLight; - QRadioButton *rbSoftLight; - QRadioButton *rbDifference; - QRadioButton *rbExclusion; -}; - -class CompositionRenderer : public ArthurFrame -{ - Q_OBJECT - - enum ObjectType { NoObject, Circle, Rectangle, Image }; - - Q_PROPERTY(int circleColor READ circleColor WRITE setCircleColor) - Q_PROPERTY(int circleAlpha READ circleAlpha WRITE setCircleAlpha) - Q_PROPERTY(bool animation READ animationEnabled WRITE setAnimationEnabled) - -public: - CompositionRenderer(QWidget *parent); - - void paint(QPainter *); - - void setCirclePos(const QPointF &pos); - - QSize sizeHint() const { return QSize(500, 400); } - - bool animationEnabled() const { return m_animation_enabled; } - int circleColor() const { return m_circle_hue; } - int circleAlpha() const { return m_circle_alpha; } - -protected: - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void timerEvent(QTimerEvent *); - -public slots: - void setClearMode() { m_composition_mode = QPainter::CompositionMode_Clear; update(); } - void setSourceMode() { m_composition_mode = QPainter::CompositionMode_Source; update(); } - void setDestMode() { m_composition_mode = QPainter::CompositionMode_Destination; update(); } - void setSourceOverMode() { m_composition_mode = QPainter::CompositionMode_SourceOver; update(); } - void setDestOverMode() { m_composition_mode = QPainter::CompositionMode_DestinationOver; update(); } - void setSourceInMode() { m_composition_mode = QPainter::CompositionMode_SourceIn; update(); } - void setDestInMode() { m_composition_mode = QPainter::CompositionMode_DestinationIn; update(); } - void setSourceOutMode() { m_composition_mode = QPainter::CompositionMode_SourceOut; update(); } - void setDestOutMode() { m_composition_mode = QPainter::CompositionMode_DestinationOut; update(); } - void setSourceAtopMode() { m_composition_mode = QPainter::CompositionMode_SourceAtop; update(); } - void setDestAtopMode() { m_composition_mode = QPainter::CompositionMode_DestinationAtop; update(); } - void setXorMode() { m_composition_mode = QPainter::CompositionMode_Xor; update(); } - - void setPlusMode() { m_composition_mode = QPainter::CompositionMode_Plus; update(); } - void setMultiplyMode() { m_composition_mode = QPainter::CompositionMode_Multiply; update(); } - void setScreenMode() { m_composition_mode = QPainter::CompositionMode_Screen; update(); } - void setOverlayMode() { m_composition_mode = QPainter::CompositionMode_Overlay; update(); } - void setDarkenMode() { m_composition_mode = QPainter::CompositionMode_Darken; update(); } - void setLightenMode() { m_composition_mode = QPainter::CompositionMode_Lighten; update(); } - void setColorDodgeMode() { m_composition_mode = QPainter::CompositionMode_ColorDodge; update(); } - void setColorBurnMode() { m_composition_mode = QPainter::CompositionMode_ColorBurn; update(); } - void setHardLightMode() { m_composition_mode = QPainter::CompositionMode_HardLight; update(); } - void setSoftLightMode() { m_composition_mode = QPainter::CompositionMode_SoftLight; update(); } - void setDifferenceMode() { m_composition_mode = QPainter::CompositionMode_Difference; update(); } - void setExclusionMode() { m_composition_mode = QPainter::CompositionMode_Exclusion; update(); } - - void setCircleAlpha(int alpha) { m_circle_alpha = alpha; update(); } - void setCircleColor(int hue) { m_circle_hue = hue; update(); } - void setAnimationEnabled(bool enabled); - -private: - void updateCirclePos(); - void drawBase(QPainter &p); - void drawSource(QPainter &p); - - QPainter::CompositionMode m_composition_mode; - - QImage m_image; - QImage m_buffer; - QImage m_base_buffer; - - int m_circle_alpha; - int m_circle_hue; - - QPointF m_circle_pos; - QPointF m_offset; - - ObjectType m_current_object; - bool m_animation_enabled; - int m_animationTimer; - -#ifdef QT_OPENGL_SUPPORT - QGLPixelBuffer *m_pbuffer; - GLuint m_base_tex; - GLuint m_compositing_tex; - int m_pbuffer_size; // width==height==size of pbuffer - QSize m_previous_size; -#endif -}; - -#endif // COMPOSITION_H diff --git a/examples/painting/composition/composition.html b/examples/painting/composition/composition.html deleted file mode 100644 index 82b8991e8f..0000000000 --- a/examples/painting/composition/composition.html +++ /dev/null @@ -1,23 +0,0 @@ - - -

      Example for composition modes

      - -

      - This example shows some of the more advanced composition modes supported by Qt. -

      - -

      - The two most common forms of composition are Source and SourceOver. - Source is used to draw opaque objects onto a paint device. In this mode, - each pixel in the source replaces the corresponding pixel in the destination. - In SourceOver composition mode, the source object is transparent and is - drawn on top of the destination. -

      - -

      - In addition to these standard modes, Qt defines the complete set of composition - modes as defined by Thomas Porter and Tom Duff. See the QPainter documentation - for details. -

      - - diff --git a/examples/painting/composition/composition.pro b/examples/painting/composition/composition.pro deleted file mode 100644 index eb63d0c47a..0000000000 --- a/examples/painting/composition/composition.pro +++ /dev/null @@ -1,29 +0,0 @@ -SOURCES += main.cpp composition.cpp -HEADERS += composition.h - -SHARED_FOLDER = ../shared - -include($$SHARED_FOLDER/shared.pri) - -RESOURCES += composition.qrc -contains(QT_CONFIG, opengl) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl -} -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/composition -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.png *.jpg *.pro *.html -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/composition -INSTALLS += target sources - - -win32-msvc* { - QMAKE_CXXFLAGS += /Zm500 - QMAKE_CFLAGS += /Zm500 -} - -wince* { - DEPLOYMENT_PLUGIN += qjpeg -} diff --git a/examples/painting/composition/composition.qrc b/examples/painting/composition/composition.qrc deleted file mode 100644 index d02c397ee8..0000000000 --- a/examples/painting/composition/composition.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - composition.cpp - composition.html - flower.jpg - flower_alpha.jpg - - diff --git a/examples/painting/composition/flower.jpg b/examples/painting/composition/flower.jpg deleted file mode 100644 index f8e022c98c..0000000000 Binary files a/examples/painting/composition/flower.jpg and /dev/null differ diff --git a/examples/painting/composition/flower_alpha.jpg b/examples/painting/composition/flower_alpha.jpg deleted file mode 100644 index 6a3c2a02ef..0000000000 Binary files a/examples/painting/composition/flower_alpha.jpg and /dev/null differ diff --git a/examples/painting/composition/main.cpp b/examples/painting/composition/main.cpp deleted file mode 100644 index 370069a33a..0000000000 --- a/examples/painting/composition/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "composition.h" - -#include -#ifdef QT_OPENGL_SUPPORT -#include -#endif - -int main(int argc, char **argv) -{ - // Q_INIT_RESOURCE(deform); - - QApplication app(argc, argv); - - CompositionWidget compWidget(0); - QStyle *arthurStyle = new ArthurStyle(); - compWidget.setStyle(arthurStyle); - - QList widgets = compWidget.findChildren(); - foreach (QWidget *w, widgets) - w->setStyle(arthurStyle); - compWidget.show(); - - return app.exec(); -} diff --git a/examples/painting/concentriccircles/circlewidget.cpp b/examples/painting/concentriccircles/circlewidget.cpp deleted file mode 100644 index 2691f20602..0000000000 --- a/examples/painting/concentriccircles/circlewidget.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "circlewidget.h" - -#include - -//! [0] -CircleWidget::CircleWidget(QWidget *parent) - : QWidget(parent) -{ - floatBased = false; - antialiased = false; - frameNo = 0; - - setBackgroundRole(QPalette::Base); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -} -//! [0] - -//! [1] -void CircleWidget::setFloatBased(bool floatBased) -{ - this->floatBased = floatBased; - update(); -} -//! [1] - -//! [2] -void CircleWidget::setAntialiased(bool antialiased) -{ - this->antialiased = antialiased; - update(); -} -//! [2] - -//! [3] -QSize CircleWidget::minimumSizeHint() const -{ - return QSize(50, 50); -} -//! [3] - -//! [4] -QSize CircleWidget::sizeHint() const -{ - return QSize(180, 180); -} -//! [4] - -//! [5] -void CircleWidget::nextAnimationFrame() -{ - ++frameNo; - update(); -} -//! [5] - -//! [6] -void CircleWidget::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, antialiased); - painter.translate(width() / 2, height() / 2); -//! [6] - -//! [7] - for (int diameter = 0; diameter < 256; diameter += 9) { - int delta = abs((frameNo % 128) - diameter / 2); - int alpha = 255 - (delta * delta) / 4 - diameter; -//! [7] //! [8] - if (alpha > 0) { - painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3)); - - if (floatBased) { - painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0, - diameter, diameter)); - } else { - painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, - diameter, diameter)); - } - } - } -} -//! [8] diff --git a/examples/painting/concentriccircles/circlewidget.h b/examples/painting/concentriccircles/circlewidget.h deleted file mode 100644 index c2d4de7092..0000000000 --- a/examples/painting/concentriccircles/circlewidget.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 CIRCLEWIDGET_H -#define CIRCLEWIDGET_H - -#include - -//! [0] -class CircleWidget : public QWidget -{ - Q_OBJECT - -public: - CircleWidget(QWidget *parent = 0); - - void setFloatBased(bool floatBased); - void setAntialiased(bool antialiased); - - QSize minimumSizeHint() const; - QSize sizeHint() const; - -public slots: - void nextAnimationFrame(); - -protected: - void paintEvent(QPaintEvent *event); - -private: - bool floatBased; - bool antialiased; - int frameNo; -}; -//! [0] - -#endif diff --git a/examples/painting/concentriccircles/concentriccircles.desktop b/examples/painting/concentriccircles/concentriccircles.desktop deleted file mode 100644 index 7007f192bc..0000000000 --- a/examples/painting/concentriccircles/concentriccircles.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Concentric Circles -Exec=/opt/usr/bin/concentriccircles -Icon=concentriccircles -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/concentriccircles/concentriccircles.pro b/examples/painting/concentriccircles/concentriccircles.pro deleted file mode 100644 index 0f87b991ed..0000000000 --- a/examples/painting/concentriccircles/concentriccircles.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = circlewidget.h \ - window.h -SOURCES = circlewidget.cpp \ - main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/concentriccircles -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS concentriccircles.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/concentriccircles -INSTALLS += target sources - -QT += widgets - diff --git a/examples/painting/concentriccircles/main.cpp b/examples/painting/concentriccircles/main.cpp deleted file mode 100644 index dcbf1c0449..0000000000 --- a/examples/painting/concentriccircles/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#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/concentriccircles/window.cpp b/examples/painting/concentriccircles/window.cpp deleted file mode 100644 index d946842029..0000000000 --- a/examples/painting/concentriccircles/window.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "circlewidget.h" -#include "window.h" - -//! [0] -Window::Window() -{ - aliasedLabel = createLabel(tr("Aliased")); - antialiasedLabel = createLabel(tr("Antialiased")); - intLabel = createLabel(tr("Int")); - floatLabel = createLabel(tr("Float")); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(aliasedLabel, 0, 1); - layout->addWidget(antialiasedLabel, 0, 2); - layout->addWidget(intLabel, 1, 0); - layout->addWidget(floatLabel, 2, 0); -//! [0] - -//! [1] - QTimer *timer = new QTimer(this); - - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < 2; ++j) { - circleWidgets[i][j] = new CircleWidget; - circleWidgets[i][j]->setAntialiased(j != 0); - circleWidgets[i][j]->setFloatBased(i != 0); - - connect(timer, SIGNAL(timeout()), - circleWidgets[i][j], SLOT(nextAnimationFrame())); - - layout->addWidget(circleWidgets[i][j], i + 1, j + 1); - } - } -//! [1] //! [2] - timer->start(100); - setLayout(layout); - - setWindowTitle(tr("Concentric Circles")); -} -//! [2] - -//! [3] -QLabel *Window::createLabel(const QString &text) -{ - QLabel *label = new QLabel(text); - label->setAlignment(Qt::AlignCenter); - label->setMargin(2); - label->setFrameStyle(QFrame::Box | QFrame::Sunken); - return label; -} -//! [3] diff --git a/examples/painting/concentriccircles/window.h b/examples/painting/concentriccircles/window.h deleted file mode 100644 index a066ddb702..0000000000 --- a/examples/painting/concentriccircles/window.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QLabel; -QT_END_NAMESPACE -class CircleWidget; - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -private: - QLabel *createLabel(const QString &text); - - QLabel *aliasedLabel; - QLabel *antialiasedLabel; - QLabel *intLabel; - QLabel *floatLabel; - CircleWidget *circleWidgets[2][2]; -}; -//! [0] - -#endif diff --git a/examples/painting/deform/deform.pro b/examples/painting/deform/deform.pro deleted file mode 100644 index 527133e7e5..0000000000 --- a/examples/painting/deform/deform.pro +++ /dev/null @@ -1,20 +0,0 @@ -SOURCES += main.cpp pathdeform.cpp -HEADERS += pathdeform.h - -SHARED_FOLDER = ../shared - -include($$SHARED_FOLDER/shared.pri) - -RESOURCES += deform.qrc - -contains(QT_CONFIG, opengl) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl -} -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/deform -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/deform -INSTALLS += target sources diff --git a/examples/painting/deform/deform.qrc b/examples/painting/deform/deform.qrc deleted file mode 100644 index 2e59ebcfc5..0000000000 --- a/examples/painting/deform/deform.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - pathdeform.cpp - pathdeform.html - - diff --git a/examples/painting/deform/main.cpp b/examples/painting/deform/main.cpp deleted file mode 100644 index eeed9b8939..0000000000 --- a/examples/painting/deform/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "pathdeform.h" - -#include -#include - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(deform); - - QApplication app(argc, argv); - - bool smallScreen = QApplication::arguments().contains("-small-screen"); - - PathDeformWidget deformWidget(0, smallScreen); - - QStyle *arthurStyle = new ArthurStyle(); - deformWidget.setStyle(arthurStyle); - QList widgets = deformWidget.findChildren(); - foreach (QWidget *w, widgets) - w->setStyle(arthurStyle); - - if (smallScreen) - deformWidget.showFullScreen(); - else - deformWidget.show(); - -#ifdef QT_KEYPAD_NAVIGATION - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif - return app.exec(); -} diff --git a/examples/painting/deform/pathdeform.cpp b/examples/painting/deform/pathdeform.cpp deleted file mode 100644 index d5880fb786..0000000000 --- a/examples/painting/deform/pathdeform.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "pathdeform.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -PathDeformControls::PathDeformControls(QWidget *parent, PathDeformRenderer* renderer, bool smallScreen) - : QWidget(parent) -{ - m_renderer = renderer; - - if (smallScreen) - layoutForSmallScreen(); - else - layoutForDesktop(); -} - - -void PathDeformControls::layoutForDesktop() -{ - QGroupBox* mainGroup = new QGroupBox(this); - mainGroup->setTitle(tr("Controls")); - - QGroupBox *radiusGroup = new QGroupBox(mainGroup); - radiusGroup->setTitle(tr("Lens Radius")); - QSlider *radiusSlider = new QSlider(Qt::Horizontal, radiusGroup); - radiusSlider->setRange(15, 150); - radiusSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - QGroupBox *deformGroup = new QGroupBox(mainGroup); - deformGroup->setTitle(tr("Deformation")); - QSlider *deformSlider = new QSlider(Qt::Horizontal, deformGroup); - deformSlider->setRange(-100, 100); - deformSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - QGroupBox *fontSizeGroup = new QGroupBox(mainGroup); - fontSizeGroup->setTitle(tr("Font Size")); - QSlider *fontSizeSlider = new QSlider(Qt::Horizontal, fontSizeGroup); - fontSizeSlider->setRange(16, 200); - fontSizeSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - QGroupBox *textGroup = new QGroupBox(mainGroup); - textGroup->setTitle(tr("Text")); - QLineEdit *textInput = new QLineEdit(textGroup); - - QPushButton *animateButton = new QPushButton(mainGroup); - animateButton->setText(tr("Animated")); - animateButton->setCheckable(true); - - QPushButton *showSourceButton = new QPushButton(mainGroup); - showSourceButton->setText(tr("Show Source")); - -#ifdef QT_OPENGL_SUPPORT - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); -#endif - - QPushButton *whatsThisButton = new QPushButton(mainGroup); - whatsThisButton->setText(tr("What's This?")); - whatsThisButton->setCheckable(true); - - - mainGroup->setFixedWidth(180); - - QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); - mainGroupLayout->addWidget(radiusGroup); - mainGroupLayout->addWidget(deformGroup); - mainGroupLayout->addWidget(fontSizeGroup); - mainGroupLayout->addWidget(textGroup); - mainGroupLayout->addWidget(animateButton); - mainGroupLayout->addStretch(1); -#ifdef QT_OPENGL_SUPPORT - mainGroupLayout->addWidget(enableOpenGLButton); -#endif - mainGroupLayout->addWidget(showSourceButton); - mainGroupLayout->addWidget(whatsThisButton); - - QVBoxLayout *radiusGroupLayout = new QVBoxLayout(radiusGroup); - radiusGroupLayout->addWidget(radiusSlider); - - QVBoxLayout *deformGroupLayout = new QVBoxLayout(deformGroup); - deformGroupLayout->addWidget(deformSlider); - - QVBoxLayout *fontSizeGroupLayout = new QVBoxLayout(fontSizeGroup); - fontSizeGroupLayout->addWidget(fontSizeSlider); - - QVBoxLayout *textGroupLayout = new QVBoxLayout(textGroup); - textGroupLayout->addWidget(textInput); - - QVBoxLayout * mainLayout = new QVBoxLayout(this); - mainLayout->addWidget(mainGroup); - mainLayout->setMargin(0); - - connect(radiusSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setRadius(int))); - connect(deformSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setIntensity(int))); - connect(fontSizeSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setFontSize(int))); - connect(animateButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setAnimated(bool))); -#ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); -#endif - - connect(textInput, SIGNAL(textChanged(QString)), m_renderer, SLOT(setText(QString))); - connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), - whatsThisButton, SLOT(setChecked(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool))); - connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource())); - - animateButton->animateClick(); - deformSlider->setValue(80); - fontSizeSlider->setValue(120); - radiusSlider->setValue(100); - textInput->setText(tr("Qt")); -} - -void PathDeformControls::layoutForSmallScreen() -{ - QGroupBox* mainGroup = new QGroupBox(this); - mainGroup->setTitle(tr("Controls")); - - QLabel *radiusLabel = new QLabel(mainGroup); - radiusLabel->setText(tr("Lens Radius:")); - QSlider *radiusSlider = new QSlider(Qt::Horizontal, mainGroup); - radiusSlider->setRange(15, 150); - radiusSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - QLabel *deformLabel = new QLabel(mainGroup); - deformLabel->setText(tr("Deformation:")); - QSlider *deformSlider = new QSlider(Qt::Horizontal, mainGroup); - deformSlider->setRange(-100, 100); - deformSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - QLabel *fontSizeLabel = new QLabel(mainGroup); - fontSizeLabel->setText(tr("Font Size:")); - QSlider *fontSizeSlider = new QSlider(Qt::Horizontal, mainGroup); - fontSizeSlider->setRange(16, 200); - fontSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - QPushButton *animateButton = new QPushButton(tr("Animated"), mainGroup); - animateButton->setCheckable(true); - -#ifdef QT_OPENGL_SUPPORT - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(mainGroup); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); -#endif - - QPushButton *quitButton = new QPushButton(tr("Quit"), mainGroup); - QPushButton *okButton = new QPushButton(tr("OK"), mainGroup); - - - QGridLayout *mainGroupLayout = new QGridLayout(mainGroup); - mainGroupLayout->setMargin(0); - mainGroupLayout->addWidget(radiusLabel, 0, 0, Qt::AlignRight); - mainGroupLayout->addWidget(radiusSlider, 0, 1); - mainGroupLayout->addWidget(deformLabel, 1, 0, Qt::AlignRight); - mainGroupLayout->addWidget(deformSlider, 1, 1); - mainGroupLayout->addWidget(fontSizeLabel, 2, 0, Qt::AlignRight); - mainGroupLayout->addWidget(fontSizeSlider, 2, 1); - mainGroupLayout->addWidget(animateButton, 3,0, 1,2); -#ifdef QT_OPENGL_SUPPORT - mainGroupLayout->addWidget(enableOpenGLButton, 4,0, 1,2); -#endif - - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->addWidget(mainGroup); - mainLayout->addStretch(1); - mainLayout->addWidget(okButton); - mainLayout->addWidget(quitButton); - - connect(quitButton, SIGNAL(clicked()), this, SLOT(emitQuitSignal())); - connect(okButton, SIGNAL(clicked()), this, SLOT(emitOkSignal())); - connect(radiusSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setRadius(int))); - connect(deformSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setIntensity(int))); - connect(fontSizeSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setFontSize(int))); - connect(animateButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setAnimated(bool))); -#ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); -#endif - - - animateButton->animateClick(); - deformSlider->setValue(80); - fontSizeSlider->setValue(120); - - QRect screen_size = QApplication::desktop()->screenGeometry(); - radiusSlider->setValue(qMin(screen_size.width(), screen_size.height())/5); - - m_renderer->setText(tr("Qt")); -} - - -void PathDeformControls::emitQuitSignal() -{ emit quitPressed(); } - -void PathDeformControls::emitOkSignal() -{ emit okPressed(); } - - -PathDeformWidget::PathDeformWidget(QWidget *parent, bool smallScreen) - : QWidget(parent) -{ - setWindowTitle(tr("Vector Deformation")); - - m_renderer = new PathDeformRenderer(this, smallScreen); - m_renderer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - // Layouts - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->addWidget(m_renderer); - - m_controls = new PathDeformControls(0, m_renderer, smallScreen); - m_controls->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); - - if (!smallScreen) - mainLayout->addWidget(m_controls); - - m_renderer->loadSourceFile(":res/deform/pathdeform.cpp"); - m_renderer->loadDescription(":res/deform/pathdeform.html"); - m_renderer->setDescriptionEnabled(false); - - connect(m_renderer, SIGNAL(clicked()), this, SLOT(showControls())); - connect(m_controls, SIGNAL(okPressed()), this, SLOT(hideControls())); - connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit())); -} - - -void PathDeformWidget::showControls() -{ - m_controls->showFullScreen(); -} - -void PathDeformWidget::hideControls() -{ - m_controls->hide(); -} - -void PathDeformWidget::setStyle( QStyle * style ) -{ - QWidget::setStyle(style); - if (m_controls != 0) - { - m_controls->setStyle(style); - - QList widgets = m_controls->findChildren(); - foreach (QWidget *w, widgets) - w->setStyle(style); - } -} - -static inline QRect circle_bounds(const QPointF ¢er, qreal radius, qreal compensation) -{ - return QRect(qRound(center.x() - radius - compensation), - qRound(center.y() - radius - compensation), - qRound((radius + compensation) * 2), - qRound((radius + compensation) * 2)); - -} - -const int LENS_EXTENT = 10; - -PathDeformRenderer::PathDeformRenderer(QWidget *widget, bool smallScreen) - : ArthurFrame(widget) -{ - m_radius = 100; - m_pos = QPointF(m_radius, m_radius); - m_direction = QPointF(1, 1); - m_fontSize = 24; - m_animated = true; - m_repaintTimer.start(25, this); - m_repaintTracker.start(); - m_intensity = 100; - m_smallScreen = smallScreen; - -// m_fpsTimer.start(1000, this); -// m_fpsCounter = 0; - - generateLensPixmap(); -} - -void PathDeformRenderer::setText(const QString &text) -{ - m_text = text; - - QFont f("times new roman,utopia"); - f.setStyleStrategy(QFont::ForceOutline); - f.setPointSize(m_fontSize); - f.setStyleHint(QFont::Times); - - QFontMetrics fm(f); - - m_paths.clear(); - m_pathBounds = QRect(); - - QPointF advance(0, 0); - - bool do_quick = true; - for (int i=0; i= 0x4ff && text.at(i).unicode() <= 0x1e00) { - do_quick = false; - break; - } - } - - if (do_quick) { - for (int i=0; itimerId() == m_repaintTimer.timerId()) { - - if (QLineF(QPointF(0,0), m_direction).length() > 1) - m_direction *= 0.995; - qreal time = m_repaintTracker.restart(); - - QRect rectBefore = circle_bounds(m_pos, m_radius, m_fontSize); - - qreal dx = m_direction.x(); - qreal dy = m_direction.y(); - if (time > 0) { - dx = dx * time * .1; - dy = dy * time * .1; - } - - m_pos += QPointF(dx, dy); - - - - if (m_pos.x() - m_radius < 0) { - m_direction.setX(-m_direction.x()); - m_pos.setX(m_radius); - } else if (m_pos.x() + m_radius > width()) { - m_direction.setX(-m_direction.x()); - m_pos.setX(width() - m_radius); - } - - if (m_pos.y() - m_radius < 0) { - m_direction.setY(-m_direction.y()); - m_pos.setY(m_radius); - } else if (m_pos.y() + m_radius > height()) { - m_direction.setY(-m_direction.y()); - m_pos.setY(height() - m_radius); - } - -#ifdef QT_OPENGL_SUPPORT - if (usesOpenGL()) { - update(); - } else -#endif - { - QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize); - update(rectAfter | rectBefore); - } - } -// else if (e->timerId() == m_fpsTimer.timerId()) { -// printf("fps: %d\n", m_fpsCounter); -// emit frameRate(m_fpsCounter); -// m_fpsCounter = 0; - -// } -} - -void PathDeformRenderer::mousePressEvent(QMouseEvent *e) -{ - setDescriptionEnabled(false); - - m_repaintTimer.stop(); - m_offset = QPointF(); - if (QLineF(m_pos, e->pos()).length() <= m_radius) - m_offset = m_pos - e->pos(); - - m_mousePress = e->pos(); - - // If we're not running in small screen mode, always assume we're dragging - m_mouseDrag = !m_smallScreen; - - mouseMoveEvent(e); -} - -void PathDeformRenderer::mouseReleaseEvent(QMouseEvent *e) -{ - if (e->buttons() == Qt::NoButton && m_animated) { - m_repaintTimer.start(10, this); - m_repaintTracker.start(); - } - - if (!m_mouseDrag && m_smallScreen) - emit clicked(); -} - -void PathDeformRenderer::mouseMoveEvent(QMouseEvent *e) -{ - if (!m_mouseDrag && (QLineF(m_mousePress, e->pos()).length() > 25.0) ) - m_mouseDrag = true; - - if (m_mouseDrag) { - QRect rectBefore = circle_bounds(m_pos, m_radius, m_fontSize); - if (e->type() == QEvent::MouseMove) { - QLineF line(m_pos, e->pos() + m_offset); - line.setLength(line.length() * .1); - QPointF dir(line.dx(), line.dy()); - m_direction = (m_direction + dir) / 2; - } - m_pos = e->pos() + m_offset; -#ifdef QT_OPENGL_SUPPORT - if (usesOpenGL()) { - update(); - } else -#endif - { - QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize); - update(rectBefore | rectAfter); - } - } -} - -QPainterPath PathDeformRenderer::lensDeform(const QPainterPath &source, const QPointF &offset) -{ - QPainterPath path; - path.addPath(source); - - qreal flip = m_intensity / qreal(100); - - for (int i=0; i 0) { - path.setElementPositionAt(i, - x + flip * dx * len / m_radius, - y + flip * dy * len / m_radius); - } else { - path.setElementPositionAt(i, x, y); - } - - } - - return path; -} - - -void PathDeformRenderer::paint(QPainter *painter) -{ - int pad_x = 5; - int pad_y = 5; - - int skip_x = qRound(m_pathBounds.width() + pad_x + m_fontSize/2); - int skip_y = qRound(m_pathBounds.height() + pad_y); - - painter->setPen(Qt::NoPen); - painter->setBrush(Qt::black); - - QRectF clip(painter->clipPath().boundingRect()); - - int overlap = pad_x / 2; - - for (int start_y=0; start_y < height(); start_y += skip_y) { - - if (start_y > clip.bottom()) - break; - - int start_x = -overlap; - for (; start_x < width(); start_x += skip_x) { - - if (start_y + skip_y >= clip.top() && - start_x + skip_x >= clip.left() && - start_x <= clip.right()) { - for (int i=0; idrawPath(path); - } - } - } - overlap = skip_x - (start_x - width()); - - } - - if (preferImage()) { - painter->drawImage(m_pos - QPointF(m_radius + LENS_EXTENT, m_radius + LENS_EXTENT), - m_lens_image); - } else { - painter->drawPixmap(m_pos - QPointF(m_radius + LENS_EXTENT, m_radius + LENS_EXTENT), - m_lens_pixmap); - } -} - - - -void PathDeformRenderer::setRadius(int radius) -{ - qreal max = qMax(m_radius, (qreal)radius); - m_radius = radius; - generateLensPixmap(); - if (!m_animated || m_radius < max) { -#ifdef QT_OPENGL_SUPPORT - if (usesOpenGL()) { - update(); - } else -#endif - { - update(circle_bounds(m_pos, max, m_fontSize)); - } - } -} - -void PathDeformRenderer::setIntensity(int intensity) -{ - m_intensity = intensity; - if (!m_animated) { -#ifdef QT_OPENGL_SUPPORT - if (usesOpenGL()) { - update(); - } else -#endif - { - update(circle_bounds(m_pos, m_radius, m_fontSize)); - } - } -} diff --git a/examples/painting/deform/pathdeform.h b/examples/painting/deform/pathdeform.h deleted file mode 100644 index 6f0d647f4e..0000000000 --- a/examples/painting/deform/pathdeform.h +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PATHDEFORM_H -#define PATHDEFORM_H - -#include "arthurwidgets.h" - -#include -#include -#include - -class PathDeformRenderer : public ArthurFrame -{ - Q_OBJECT - Q_PROPERTY(bool animated READ animated WRITE setAnimated) - Q_PROPERTY(int radius READ radius WRITE setRadius) - Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize) - Q_PROPERTY(int intensity READ intensity WRITE setIntensity) - Q_PROPERTY(QString text READ text WRITE setText) - -public: - PathDeformRenderer(QWidget *widget, bool smallScreen = false); - - void paint(QPainter *painter); - - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void timerEvent(QTimerEvent *e); - - QSize sizeHint() const { return QSize(600, 500); } - - bool animated() const { return m_animated; } - int radius() const { return int(m_radius); } - int fontSize() const { return m_fontSize; } - int intensity() const { return int(m_intensity); } - QString text() const { return m_text; } - -public slots: - void setRadius(int radius); - void setFontSize(int fontSize) { m_fontSize = fontSize; setText(m_text); } - void setText(const QString &text); - void setIntensity(int intensity); - - void setAnimated(bool animated); - -signals: - void clicked(); -// void frameRate(double fps); - -private: - void generateLensPixmap(); - QPainterPath lensDeform(const QPainterPath &source, const QPointF &offset); - - QBasicTimer m_repaintTimer; -// QBasicTimer m_fpsTimer; -// int m_fpsCounter; - QTime m_repaintTracker; - - QVector m_paths; - QVector m_advances; - QRectF m_pathBounds; - QString m_text; - - QPixmap m_lens_pixmap; - QImage m_lens_image; - - int m_fontSize; - bool m_animated; - - qreal m_intensity; - qreal m_radius; - QPointF m_pos; - QPointF m_offset; - QPointF m_direction; - QPointF m_mousePress; - bool m_mouseDrag; - bool m_smallScreen; -}; - -class PathDeformControls : public QWidget -{ - Q_OBJECT -public: - PathDeformControls(QWidget *parent, PathDeformRenderer* renderer, bool smallScreen); -signals: - void okPressed(); - void quitPressed(); -private: - PathDeformRenderer* m_renderer; - void layoutForDesktop(); - void layoutForSmallScreen(); -private slots: - void emitQuitSignal(); - void emitOkSignal(); -}; - -class PathDeformWidget : public QWidget -{ - Q_OBJECT -public: - PathDeformWidget(QWidget *parent, bool smallScreen); - void setStyle ( QStyle * style ); - -private: - PathDeformRenderer *m_renderer; - PathDeformControls *m_controls; - -private slots: - void showControls(); - void hideControls(); -}; - -#endif // PATHDEFORM_H diff --git a/examples/painting/deform/pathdeform.html b/examples/painting/deform/pathdeform.html deleted file mode 100644 index b3f63a8e0a..0000000000 --- a/examples/painting/deform/pathdeform.html +++ /dev/null @@ -1,24 +0,0 @@ - -
      -

      Vector deformation

      -
      - -

      This demo shows how to use advanced vector techniques to draw text -using a QPainterPath.

      - -

      We define a vector deformation field in the shape of a lens and apply -this to all points in a path. This means that what is rendered on -screen is not pixel manipulation, but modified vector representations of -the glyphs themselves. This is visible from the high quality of the -antialiased edges for the deformed glyphs.

      - -

      To get a fairly complex path we allow the user to type in text and -convert the text to paths. This is done using the -QPainterPath::addText() function.

      - -

      The lens is drawn using a single call to drawEllipse(), using -a QRadialGradient to fill it with a specialized color table, -giving the effect of the Sun's reflection and a drop shadow. The lens -is cached as a pixmap for better performance.

      - - diff --git a/examples/painting/fontsampler/fontsampler.desktop b/examples/painting/fontsampler/fontsampler.desktop deleted file mode 100644 index 8582891fcf..0000000000 --- a/examples/painting/fontsampler/fontsampler.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Font Sampler -Exec=/opt/usr/bin/fontsampler -Icon=fontsampler -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/fontsampler/fontsampler.pro b/examples/painting/fontsampler/fontsampler.pro deleted file mode 100644 index b918c51837..0000000000 --- a/examples/painting/fontsampler/fontsampler.pro +++ /dev/null @@ -1,13 +0,0 @@ -FORMS = mainwindowbase.ui -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/fontsampler -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS fontsampler.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/fontsampler -INSTALLS += target sources - -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport diff --git a/examples/painting/fontsampler/main.cpp b/examples/painting/fontsampler/main.cpp deleted file mode 100644 index 09a923477c..0000000000 --- a/examples/painting/fontsampler/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/painting/fontsampler/mainwindow.cpp b/examples/painting/fontsampler/mainwindow.cpp deleted file mode 100644 index ae45613abf..0000000000 --- a/examples/painting/fontsampler/mainwindow.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#ifndef QT_NO_PRINTER -#include -#include -#include -#endif - -#include "mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - setupUi(this); - - - sampleSizes << 32 << 24 << 16 << 14 << 12 << 8 << 4 << 2 << 1; - markedCount = 0; - setupFontTree(); - - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(fontTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(showFont(QTreeWidgetItem*))); - connect(fontTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(updateStyles(QTreeWidgetItem*,int))); - - fontTree->setItemSelected(fontTree->topLevelItem(0), true); - showFont(fontTree->topLevelItem(0)); -} - -void MainWindow::setupFontTree() -{ - QFontDatabase database; - fontTree->setColumnCount(1); - fontTree->setHeaderLabels(QStringList() << tr("Font")); - - foreach (QString family, database.families()) { - const QStringList styles = database.styles(family); - if (styles.isEmpty()) - continue; - - QTreeWidgetItem *familyItem = new QTreeWidgetItem(fontTree); - familyItem->setText(0, family); - familyItem->setCheckState(0, Qt::Unchecked); - - foreach (QString style, styles) { - QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem); - styleItem->setText(0, style); - styleItem->setCheckState(0, Qt::Unchecked); - styleItem->setData(0, Qt::UserRole, - QVariant(database.weight(family, style))); - styleItem->setData(0, Qt::UserRole + 1, - QVariant(database.italic(family, style))); - } - } -} - -void MainWindow::on_clearAction_triggered() -{ - QTreeWidgetItem *currentItem = fontTree->currentItem(); - foreach (QTreeWidgetItem *item, fontTree->selectedItems()) - fontTree->setItemSelected(item, false); - fontTree->setItemSelected(currentItem, true); -} - -void MainWindow::on_markAction_triggered() -{ - markUnmarkFonts(Qt::Checked); -} - -void MainWindow::on_unmarkAction_triggered() -{ - markUnmarkFonts(Qt::Unchecked); -} - -void MainWindow::markUnmarkFonts(Qt::CheckState state) -{ - QList items = fontTree->selectedItems(); - foreach (QTreeWidgetItem *item, items) { - if (item->checkState(0) != state) - item->setCheckState(0, state); - } -} - -void MainWindow::showFont(QTreeWidgetItem *item) -{ - if (!item) - return; - - QString family; - QString style; - int weight; - bool italic; - - if (item->parent()) { - family = item->parent()->text(0); - style = item->text(0); - weight = item->data(0, Qt::UserRole).toInt(); - italic = item->data(0, Qt::UserRole + 1).toBool(); - } else { - family = item->text(0); - style = item->child(0)->text(0); - weight = item->child(0)->data(0, Qt::UserRole).toInt(); - italic = item->child(0)->data(0, Qt::UserRole + 1).toBool(); - } - - QString oldText = textEdit->toPlainText().trimmed(); - bool modified = textEdit->document()->isModified(); - textEdit->clear(); - textEdit->document()->setDefaultFont(QFont(family, 32, weight, italic)); - - QTextCursor cursor = textEdit->textCursor(); - QTextBlockFormat blockFormat; - blockFormat.setAlignment(Qt::AlignCenter); - cursor.insertBlock(blockFormat); - - if (modified) - cursor.insertText(QString(oldText)); - else - cursor.insertText(QString("%1 %2").arg(family).arg(style)); - - textEdit->document()->setModified(modified); -} - -void MainWindow::updateStyles(QTreeWidgetItem *item, int column) -{ - if (!item || column != 0) - return; - - Qt::CheckState state = item->checkState(0); - QTreeWidgetItem *parent = item->parent(); - - if (parent) { - - // Only count style items. - if (state == Qt::Checked) - ++markedCount; - else - --markedCount; - - if (state == Qt::Checked && - parent->checkState(0) == Qt::Unchecked) { - // Mark parent items when child items are checked. - parent->setCheckState(0, Qt::Checked); - - } else if (state == Qt::Unchecked && - parent->checkState(0) == Qt::Checked) { - - bool marked = false; - for (int row = 0; row < parent->childCount(); ++row) { - if (parent->child(row)->checkState(0) == Qt::Checked) { - marked = true; - break; - } - } - // Unmark parent items when all child items are unchecked. - if (!marked) - parent->setCheckState(0, Qt::Unchecked); - } - } else { - int row; - int number = 0; - for (row = 0; row < item->childCount(); ++row) { - if (item->child(row)->checkState(0) == Qt::Checked) - ++number; - } - - // Mark/unmark all child items when marking/unmarking top-level - // items. - if (state == Qt::Checked && number == 0) { - for (row = 0; row < item->childCount(); ++row) { - if (item->child(row)->checkState(0) == Qt::Unchecked) - item->child(row)->setCheckState(0, Qt::Checked); - } - } else if (state == Qt::Unchecked && number > 0) { - for (row = 0; row < item->childCount(); ++row) { - if (item->child(row)->checkState(0) == Qt::Checked) - item->child(row)->setCheckState(0, Qt::Unchecked); - } - } - } - - printAction->setEnabled(markedCount > 0); - printPreviewAction->setEnabled(markedCount > 0); -} - -QMap MainWindow::currentPageMap() -{ - QMap pageMap; - - for (int row = 0; row < fontTree->topLevelItemCount(); ++row) { - QTreeWidgetItem *familyItem = fontTree->topLevelItem(row); - QString family; - - if (familyItem->checkState(0) == Qt::Checked) { - family = familyItem->text(0); - pageMap[family] = StyleItems(); - } - - for (int childRow = 0; childRow < familyItem->childCount(); ++childRow) { - QTreeWidgetItem *styleItem = familyItem->child(childRow); - if (styleItem->checkState(0) == Qt::Checked) - pageMap[family].append(styleItem); - } - } - - return pageMap; -} - -#ifndef QT_NO_PRINTER -void MainWindow::on_printAction_triggered() -{ - pageMap = currentPageMap(); - - if (pageMap.count() == 0) - return; - - QPrinter printer(QPrinter::HighResolution); - QPrintDialog dialog(&printer, this); - if (dialog.exec() != QDialog::Accepted) - return; - - int from = printer.fromPage(); - int to = printer.toPage(); - if (from <= 0 && to <= 0) - printer.setFromTo(1, pageMap.keys().count()); - - printDocument(&printer); -} - -void MainWindow::printDocument(QPrinter *printer) -{ - printer->setFromTo(1, pageMap.count()); - - QProgressDialog progress(tr("Preparing font samples..."), tr("&Cancel"), - 0, pageMap.count(), this); - progress.setWindowModality(Qt::ApplicationModal); - progress.setWindowTitle(tr("Font Sampler")); - progress.setMinimum(printer->fromPage() - 1); - progress.setMaximum(printer->toPage()); - - QPainter painter; - painter.begin(printer); - bool firstPage = true; - - for (int page = printer->fromPage(); page <= printer->toPage(); ++page) { - - if (!firstPage) - printer->newPage(); - - qApp->processEvents(); - if (progress.wasCanceled()) - break; - - printPage(page - 1, &painter, printer); - progress.setValue(page); - firstPage = false; - } - - painter.end(); -} - -void MainWindow::on_printPreviewAction_triggered() -{ - pageMap = currentPageMap(); - - if (pageMap.count() == 0) - return; - - QPrinter printer(QPrinter::HighResolution); - QPrintPreviewDialog preview(&printer, this); - connect(&preview, SIGNAL(paintRequested(QPrinter*)), - this, SLOT(printDocument(QPrinter*))); - preview.exec(); -} - -void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer) -{ - QString family = pageMap.keys()[index]; - StyleItems items = pageMap[family]; - - // Find the dimensions of the text on each page. - qreal width = 0.0; - qreal height = 0.0; - foreach (QTreeWidgetItem *item, items) { - QString style = item->text(0); - int weight = item->data(0, Qt::UserRole).toInt(); - bool italic = item->data(0, Qt::UserRole + 1).toBool(); - - // Calculate the maximum width and total height of the text. - foreach (int size, sampleSizes) { - QFont font(family, size, weight, italic); - font = QFont(font, painter->device()); - QFontMetricsF fontMetrics(font); - QRectF rect = fontMetrics.boundingRect( - QString("%1 %2").arg(family).arg(style)); - width = qMax(rect.width(), width); - height += rect.height(); - } - } - - qreal xScale = printer->pageRect().width() / width; - qreal yScale = printer->pageRect().height() / height; - qreal scale = qMin(xScale, yScale); - - qreal remainingHeight = printer->pageRect().height()/scale - height; - qreal spaceHeight = (remainingHeight/4.0) / (items.count() + 1); - qreal interLineHeight = (remainingHeight/4.0) / (sampleSizes.count() * items.count()); - - painter->save(); - painter->translate(printer->pageRect().width()/2.0, printer->pageRect().height()/2.0); - painter->scale(scale, scale); - painter->setBrush(QBrush(Qt::black)); - - qreal x = -width/2.0; - qreal y = -height/2.0 - remainingHeight/4.0 + spaceHeight; - - foreach (QTreeWidgetItem *item, items) { - QString style = item->text(0); - int weight = item->data(0, Qt::UserRole).toInt(); - bool italic = item->data(0, Qt::UserRole + 1).toBool(); - - // Draw each line of text. - foreach (int size, sampleSizes) { - QFont font(family, size, weight, italic); - font = QFont(font, painter->device()); - QFontMetricsF fontMetrics(font); - QRectF rect = fontMetrics.boundingRect(QString("%1 %2").arg( - font.family()).arg(style)); - y += rect.height(); - painter->setFont(font); - painter->drawText(QPointF(x, y), - QString("%1 %2").arg(family).arg(style)); - y += interLineHeight; - } - y += spaceHeight; - } - - painter->restore(); -} -#endif diff --git a/examples/painting/fontsampler/mainwindow.h b/examples/painting/fontsampler/mainwindow.h deleted file mode 100644 index fbb99333db..0000000000 --- a/examples/painting/fontsampler/mainwindow.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "ui_mainwindowbase.h" - -QT_BEGIN_NAMESPACE -class QPrinter; -class QTextEdit; -class QTreeWidget; -class QTreeWidgetItem; -QT_END_NAMESPACE - -typedef QList StyleItems; - -class MainWindow : public QMainWindow, private Ui::MainWindowBase -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - -public slots: - void on_clearAction_triggered(); - void on_markAction_triggered(); -#ifndef QT_NO_PRINTER - void on_printAction_triggered(); - void on_printPreviewAction_triggered(); -#endif - void on_unmarkAction_triggered(); -#ifndef QT_NO_PRINTER - void printDocument(QPrinter *printer); - void printPage(int index, QPainter *painter, QPrinter *printer); -#endif - void showFont(QTreeWidgetItem *item); - void updateStyles(QTreeWidgetItem *item, int column); - -private: - QMap currentPageMap(); - void markUnmarkFonts(Qt::CheckState state); - void setupFontTree(); - - QList sampleSizes; - QMap pageMap; - int markedCount; -}; - -#endif diff --git a/examples/painting/fontsampler/mainwindowbase.ui b/examples/painting/fontsampler/mainwindowbase.ui deleted file mode 100644 index 1a95ebd6d1..0000000000 --- a/examples/painting/fontsampler/mainwindowbase.ui +++ /dev/null @@ -1,142 +0,0 @@ - - - MainWindowBase - - - - 0 - 0 - 800 - 345 - - - - Font Sampler - - - - - 6 - - - 9 - - - - - - - - - - 0 - 0 - 800 - 18 - - - - - &Selection - - - - - - - - &File - - - - - - - - - - - - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable - - - Available Fonts - - - 1 - - - - - 6 - - - 9 - - - - - QAbstractItemView::ExtendedSelection - - - - 1 - - - - - - - - - - false - - - &Print... - - - Ctrl+P - - - - - E&xit - - - Ctrl+Q - - - - - &Mark - - - Ctrl+M - - - - - &Unmark - - - Ctrl+U - - - - - &Clear - - - - - false - - - Print Preview... - - - - - - diff --git a/examples/painting/gradients/gradients.cpp b/examples/painting/gradients/gradients.cpp deleted file mode 100644 index 9dad51a8e4..0000000000 --- a/examples/painting/gradients/gradients.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gradients.h" -#include "hoverpoints.h" - -ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) - : QWidget(parent), m_shade_type(type), m_alpha_gradient(QLinearGradient(0, 0, 0, 0)) -{ - - // Checkers background - if (m_shade_type == ARGBShade) { - QPixmap pm(20, 20); - QPainter pmp(&pm); - pmp.fillRect(0, 0, 10, 10, Qt::lightGray); - pmp.fillRect(10, 10, 10, 10, Qt::lightGray); - pmp.fillRect(0, 10, 10, 10, Qt::darkGray); - pmp.fillRect(10, 0, 10, 10, Qt::darkGray); - pmp.end(); - QPalette pal = palette(); - pal.setBrush(backgroundRole(), QBrush(pm)); - setAutoFillBackground(true); - setPalette(pal); - - } else { - setAttribute(Qt::WA_NoBackground); - - } - - QPolygonF points; - points << QPointF(0, sizeHint().height()) - << QPointF(sizeHint().width(), 0); - - m_hoverPoints = new HoverPoints(this, HoverPoints::CircleShape); -// m_hoverPoints->setConnectionType(HoverPoints::LineConnection); - m_hoverPoints->setPoints(points); - m_hoverPoints->setPointLock(0, HoverPoints::LockToLeft); - m_hoverPoints->setPointLock(1, HoverPoints::LockToRight); - m_hoverPoints->setSortType(HoverPoints::XSort); - - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged())); -} - - -QPolygonF ShadeWidget::points() const -{ - return m_hoverPoints->points(); -} - - -uint ShadeWidget::colorAt(int x) -{ - generateShade(); - - QPolygonF pts = m_hoverPoints->points(); - for (int i=1; i < pts.size(); ++i) { - if (pts.at(i-1).x() <= x && pts.at(i).x() >= x) { - QLineF l(pts.at(i-1), pts.at(i)); - l.setLength(l.length() * ((x - l.x1()) / l.dx())); - return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))), - qRound(qMin(l.y2(), qreal(m_shade.height() - 1)))); - } - } - return 0; -} - - -void ShadeWidget::setGradientStops(const QGradientStops &stops) -{ - if (m_shade_type == ARGBShade) { - m_alpha_gradient = QLinearGradient(0, 0, width(), 0); - - for (int i=0; isetSpacing(1); - vbox->setMargin(1); - - m_red_shade = new ShadeWidget(ShadeWidget::RedShade, this); - m_green_shade = new ShadeWidget(ShadeWidget::GreenShade, this); - m_blue_shade = new ShadeWidget(ShadeWidget::BlueShade, this); - m_alpha_shade = new ShadeWidget(ShadeWidget::ARGBShade, this); - - vbox->addWidget(m_red_shade); - vbox->addWidget(m_green_shade); - vbox->addWidget(m_blue_shade); - vbox->addWidget(m_alpha_shade); - - connect(m_red_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_green_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_blue_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); -} - - -inline static bool x_less_than(const QPointF &p1, const QPointF &p2) -{ - return p1.x() < p2.x(); -} - - -void GradientEditor::pointsUpdated() -{ - qreal w = m_alpha_shade->width(); - - QGradientStops stops; - - QPolygonF points; - - points += m_red_shade->points(); - points += m_green_shade->points(); - points += m_blue_shade->points(); - points += m_alpha_shade->points(); - - qSort(points.begin(), points.end(), x_less_than); - - for (int i=0; icolorAt(int(x))) >> 16, - (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8, - (0x000000ff & m_blue_shade->colorAt(int(x))), - (0xff000000 & m_alpha_shade->colorAt(int(x))) >> 24); - - if (x / w > 1) - return; - - stops << QGradientStop(x / w, color); - } - - m_alpha_shade->setGradientStops(stops); - - emit gradientStopsChanged(stops); -} - - -static void set_shade_points(const QPolygonF &points, ShadeWidget *shade) -{ - shade->hoverPoints()->setPoints(points); - shade->hoverPoints()->setPointLock(0, HoverPoints::LockToLeft); - shade->hoverPoints()->setPointLock(points.size() - 1, HoverPoints::LockToRight); - shade->update(); -} - -void GradientEditor::setGradientStops(const QGradientStops &stops) -{ - QPolygonF pts_red, pts_green, pts_blue, pts_alpha; - - qreal h_red = m_red_shade->height(); - qreal h_green = m_green_shade->height(); - qreal h_blue = m_blue_shade->height(); - qreal h_alpha = m_alpha_shade->height(); - - for (int i=0; iwidth(), h_red - qRed(color) * h_red / 255); - pts_green << QPointF(pos * m_green_shade->width(), h_green - qGreen(color) * h_green / 255); - pts_blue << QPointF(pos * m_blue_shade->width(), h_blue - qBlue(color) * h_blue / 255); - pts_alpha << QPointF(pos * m_alpha_shade->width(), h_alpha - qAlpha(color) * h_alpha / 255); - } - - set_shade_points(pts_red, m_red_shade); - set_shade_points(pts_green, m_green_shade); - set_shade_points(pts_blue, m_blue_shade); - set_shade_points(pts_alpha, m_alpha_shade); - -} - -GradientWidget::GradientWidget(QWidget *parent) - : QWidget(parent) -{ - setWindowTitle(tr("Gradients")); - - m_renderer = new GradientRenderer(this); - - QGroupBox *mainGroup = new QGroupBox(this); - mainGroup->setTitle(tr("Gradients")); - - QGroupBox *editorGroup = new QGroupBox(mainGroup); - editorGroup->setTitle(tr("Color Editor")); - m_editor = new GradientEditor(editorGroup); - - QGroupBox *typeGroup = new QGroupBox(mainGroup); - typeGroup->setTitle(tr("Gradient Type")); - m_linearButton = new QRadioButton(tr("Linear Gradient"), typeGroup); - m_radialButton = new QRadioButton(tr("Radial Gradient"), typeGroup); - m_conicalButton = new QRadioButton(tr("Conical Gradient"), typeGroup); - - QGroupBox *spreadGroup = new QGroupBox(mainGroup); - spreadGroup->setTitle(tr("Spread Method")); - m_padSpreadButton = new QRadioButton(tr("Pad Spread"), spreadGroup); - m_reflectSpreadButton = new QRadioButton(tr("Reflect Spread"), spreadGroup); - m_repeatSpreadButton = new QRadioButton(tr("Repeat Spread"), spreadGroup); - - QGroupBox *defaultsGroup = new QGroupBox(mainGroup); - defaultsGroup->setTitle(tr("Defaults")); - QPushButton *default1Button = new QPushButton(tr("1"), defaultsGroup); - QPushButton *default2Button = new QPushButton(tr("2"), defaultsGroup); - QPushButton *default3Button = new QPushButton(tr("3"), defaultsGroup); - QPushButton *default4Button = new QPushButton(tr("Reset"), editorGroup); - - QPushButton *showSourceButton = new QPushButton(mainGroup); - showSourceButton->setText(tr("Show Source")); -#ifdef QT_OPENGL_SUPPORT - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); -#endif - QPushButton *whatsThisButton = new QPushButton(mainGroup); - whatsThisButton->setText(tr("What's This?")); - whatsThisButton->setCheckable(true); - - // Layouts - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->addWidget(m_renderer); - mainLayout->addWidget(mainGroup); - - mainGroup->setFixedWidth(180); - QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); - mainGroupLayout->addWidget(editorGroup); - mainGroupLayout->addWidget(typeGroup); - mainGroupLayout->addWidget(spreadGroup); - mainGroupLayout->addWidget(defaultsGroup); - mainGroupLayout->addStretch(1); - mainGroupLayout->addWidget(showSourceButton); -#ifdef QT_OPENGL_SUPPORT - mainGroupLayout->addWidget(enableOpenGLButton); -#endif - mainGroupLayout->addWidget(whatsThisButton); - - QVBoxLayout *editorGroupLayout = new QVBoxLayout(editorGroup); - editorGroupLayout->addWidget(m_editor); - - QVBoxLayout *typeGroupLayout = new QVBoxLayout(typeGroup); - typeGroupLayout->addWidget(m_linearButton); - typeGroupLayout->addWidget(m_radialButton); - typeGroupLayout->addWidget(m_conicalButton); - - QVBoxLayout *spreadGroupLayout = new QVBoxLayout(spreadGroup); - spreadGroupLayout->addWidget(m_padSpreadButton); - spreadGroupLayout->addWidget(m_repeatSpreadButton); - spreadGroupLayout->addWidget(m_reflectSpreadButton); - - QHBoxLayout *defaultsGroupLayout = new QHBoxLayout(defaultsGroup); - defaultsGroupLayout->addWidget(default1Button); - defaultsGroupLayout->addWidget(default2Button); - defaultsGroupLayout->addWidget(default3Button); - editorGroupLayout->addWidget(default4Button); - - connect(m_editor, SIGNAL(gradientStopsChanged(QGradientStops)), - m_renderer, SLOT(setGradientStops(QGradientStops))); - - connect(m_linearButton, SIGNAL(clicked()), m_renderer, SLOT(setLinearGradient())); - connect(m_radialButton, SIGNAL(clicked()), m_renderer, SLOT(setRadialGradient())); - connect(m_conicalButton, SIGNAL(clicked()), m_renderer, SLOT(setConicalGradient())); - - connect(m_padSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setPadSpread())); - connect(m_reflectSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setReflectSpread())); - connect(m_repeatSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setRepeatSpread())); - - connect(default1Button, SIGNAL(clicked()), this, SLOT(setDefault1())); - connect(default2Button, SIGNAL(clicked()), this, SLOT(setDefault2())); - connect(default3Button, SIGNAL(clicked()), this, SLOT(setDefault3())); - connect(default4Button, SIGNAL(clicked()), this, SLOT(setDefault4())); - - connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource())); -#ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); -#endif - connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), - m_renderer->hoverPoints(), SLOT(setDisabled(bool))); - connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), - whatsThisButton, SLOT(setChecked(bool))); - connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), - m_renderer->hoverPoints(), SLOT(setDisabled(bool))); - - m_renderer->loadSourceFile(":res/gradients/gradients.cpp"); - m_renderer->loadDescription(":res/gradients/gradients.html"); - - QTimer::singleShot(50, this, SLOT(setDefault1())); -} - -void GradientWidget::setDefault(int config) -{ - QGradientStops stops; - QPolygonF points; - switch (config) { - case 1: - stops << QGradientStop(0.00, QColor::fromRgba(0)); - stops << QGradientStop(0.04, QColor::fromRgba(0xff131360)); - stops << QGradientStop(0.08, QColor::fromRgba(0xff202ccc)); - stops << QGradientStop(0.42, QColor::fromRgba(0xff93d3f9)); - stops << QGradientStop(0.51, QColor::fromRgba(0xffb3e6ff)); - stops << QGradientStop(0.73, QColor::fromRgba(0xffffffec)); - stops << QGradientStop(0.92, QColor::fromRgba(0xff5353d9)); - stops << QGradientStop(0.96, QColor::fromRgba(0xff262666)); - stops << QGradientStop(1.00, QColor::fromRgba(0)); - m_linearButton->animateClick(); - m_repeatSpreadButton->animateClick(); - break; - - case 2: - stops << QGradientStop(0.00, QColor::fromRgba(0xffffffff)); - stops << QGradientStop(0.11, QColor::fromRgba(0xfff9ffa0)); - stops << QGradientStop(0.13, QColor::fromRgba(0xfff9ff99)); - stops << QGradientStop(0.14, QColor::fromRgba(0xfff3ff86)); - stops << QGradientStop(0.49, QColor::fromRgba(0xff93b353)); - stops << QGradientStop(0.87, QColor::fromRgba(0xff264619)); - stops << QGradientStop(0.96, QColor::fromRgba(0xff0c1306)); - stops << QGradientStop(1.00, QColor::fromRgba(0)); - m_radialButton->animateClick(); - m_padSpreadButton->animateClick(); - break; - - case 3: - stops << QGradientStop(0.00, QColor::fromRgba(0)); - stops << QGradientStop(0.10, QColor::fromRgba(0xffe0cc73)); - stops << QGradientStop(0.17, QColor::fromRgba(0xffc6a006)); - stops << QGradientStop(0.46, QColor::fromRgba(0xff600659)); - stops << QGradientStop(0.72, QColor::fromRgba(0xff0680ac)); - stops << QGradientStop(0.92, QColor::fromRgba(0xffb9d9e6)); - stops << QGradientStop(1.00, QColor::fromRgba(0)); - m_conicalButton->animateClick(); - m_padSpreadButton->animateClick(); - break; - - case 4: - stops << QGradientStop(0.00, QColor::fromRgba(0xff000000)); - stops << QGradientStop(1.00, QColor::fromRgba(0xffffffff)); - break; - - default: - qWarning("bad default: %d\n", config); - break; - } - - QPolygonF pts; - int h_off = m_renderer->width() / 10; - int v_off = m_renderer->height() / 8; - pts << QPointF(m_renderer->width() / 2, m_renderer->height() / 2) - << QPointF(m_renderer->width() / 2 - h_off, m_renderer->height() / 2 - v_off); - - m_editor->setGradientStops(stops); - m_renderer->hoverPoints()->setPoints(pts); - m_renderer->setGradientStops(stops); -} - - -GradientRenderer::GradientRenderer(QWidget *parent) - : ArthurFrame(parent) -{ - m_hoverPoints = new HoverPoints(this, HoverPoints::CircleShape); - m_hoverPoints->setPointSize(QSize(20, 20)); - m_hoverPoints->setConnectionType(HoverPoints::NoConnection); - m_hoverPoints->setEditable(false); - - QVector points; - points << QPointF(100, 100) << QPointF(200, 200); - m_hoverPoints->setPoints(points); - - m_spread = QGradient::PadSpread; - m_gradientType = Qt::LinearGradientPattern; -} - -void GradientRenderer::setGradientStops(const QGradientStops &stops) -{ - m_stops = stops; - update(); -} - - -void GradientRenderer::mousePressEvent(QMouseEvent *) -{ - setDescriptionEnabled(false); -} - -void GradientRenderer::paint(QPainter *p) -{ - QPolygonF pts = m_hoverPoints->points(); - - QGradient g; - - if (m_gradientType == Qt::LinearGradientPattern) { - g = QLinearGradient(pts.at(0), pts.at(1)); - - } else if (m_gradientType == Qt::RadialGradientPattern) { - g = QRadialGradient(pts.at(0), qMin(width(), height()) / 3.0, pts.at(1)); - - } else { - QLineF l(pts.at(0), pts.at(1)); - qreal angle = l.angle(QLineF(0, 0, 1, 0)); - if (l.dy() > 0) - angle = 360 - angle; - g = QConicalGradient(pts.at(0), angle); - } - - for (int i=0; isetBrush(g); - p->setPen(Qt::NoPen); - - p->drawRect(rect()); - -} diff --git a/examples/painting/gradients/gradients.h b/examples/painting/gradients/gradients.h deleted file mode 100644 index 0fed2de82a..0000000000 --- a/examples/painting/gradients/gradients.h +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRADIENTS_H -#define GRADIENTS_H - -#include "arthurwidgets.h" - -#include - -class HoverPoints; - - -class ShadeWidget : public QWidget -{ - Q_OBJECT -public: - enum ShadeType { - RedShade, - GreenShade, - BlueShade, - ARGBShade - }; - - ShadeWidget(ShadeType type, QWidget *parent); - - void setGradientStops(const QGradientStops &stops); - - void paintEvent(QPaintEvent *e); - - QSize sizeHint() const { return QSize(150, 40); } - QPolygonF points() const; - - HoverPoints *hoverPoints() const { return m_hoverPoints; } - - uint colorAt(int x); - -signals: - void colorsChanged(); - -private: - void generateShade(); - - ShadeType m_shade_type; - QImage m_shade; - HoverPoints *m_hoverPoints; - QLinearGradient m_alpha_gradient; -}; - -class GradientEditor : public QWidget -{ - Q_OBJECT -public: - GradientEditor(QWidget *parent); - - void setGradientStops(const QGradientStops &stops); - -public slots: - void pointsUpdated(); - -signals: - void gradientStopsChanged(const QGradientStops &stops); - -private: - ShadeWidget *m_red_shade; - ShadeWidget *m_green_shade; - ShadeWidget *m_blue_shade; - ShadeWidget *m_alpha_shade; -}; - - -class GradientRenderer : public ArthurFrame -{ - Q_OBJECT -public: - GradientRenderer(QWidget *parent); - void paint(QPainter *p); - - QSize sizeHint() const { return QSize(400, 400); } - - HoverPoints *hoverPoints() const { return m_hoverPoints; } - void mousePressEvent(QMouseEvent *e); - -public slots: - void setGradientStops(const QGradientStops &stops); - - void setPadSpread() { m_spread = QGradient::PadSpread; update(); } - void setRepeatSpread() { m_spread = QGradient::RepeatSpread; update(); } - void setReflectSpread() { m_spread = QGradient::ReflectSpread; update(); } - - void setLinearGradient() { m_gradientType = Qt::LinearGradientPattern; update(); } - void setRadialGradient() { m_gradientType = Qt::RadialGradientPattern; update(); } - void setConicalGradient() { m_gradientType = Qt::ConicalGradientPattern; update(); } - - -private: - QGradientStops m_stops; - HoverPoints *m_hoverPoints; - - QGradient::Spread m_spread; - Qt::BrushStyle m_gradientType; -}; - - -class GradientWidget : public QWidget -{ - Q_OBJECT -public: - GradientWidget(QWidget *parent); - -public slots: - void setDefault1() { setDefault(1); } - void setDefault2() { setDefault(2); } - void setDefault3() { setDefault(3); } - void setDefault4() { setDefault(4); } - -private: - void setDefault(int i); - - GradientRenderer *m_renderer; - GradientEditor *m_editor; - - QRadioButton *m_linearButton; - QRadioButton *m_radialButton; - QRadioButton *m_conicalButton; - QRadioButton *m_padSpreadButton; - QRadioButton *m_reflectSpreadButton; - QRadioButton *m_repeatSpreadButton; - -}; - -#endif // GRADIENTS_H diff --git a/examples/painting/gradients/gradients.html b/examples/painting/gradients/gradients.html deleted file mode 100644 index 1ea2c0ed6c..0000000000 --- a/examples/painting/gradients/gradients.html +++ /dev/null @@ -1,31 +0,0 @@ - -
      -

      Gradients

      -
      - -

      In this demo we show the various types of gradients that can -be used in Qt.

      - -

      There are three types of gradients: - -

        -
      • Linear gradients interpolate colors between start and end - points.
      • -
      • Radial gradients interpolate colors between a focal point and the - points on a circle surrounding it.
      • -
      • Conical gradients interpolate colors around a center point.
      • -
      - -

      - -

      The panel on the right contains a color table editor that defines -the colors in the gradient. The three topmost controls determine the red, -green and blue components while the last defines the alpha of the -gradient. You can move points, and add new ones, by clicking with the left -mouse button, and remove points by clicking with the right button.

      - -

      There are three default configurations available at the bottom of -the page that are provided as suggestions on how a color table could be -configured.

      - - diff --git a/examples/painting/gradients/gradients.pro b/examples/painting/gradients/gradients.pro deleted file mode 100644 index 4362d283ee..0000000000 --- a/examples/painting/gradients/gradients.pro +++ /dev/null @@ -1,20 +0,0 @@ -SOURCES += main.cpp gradients.cpp -HEADERS += gradients.h - -SHARED_FOLDER = ../shared - -include($$SHARED_FOLDER/shared.pri) - -RESOURCES += gradients.qrc -contains(QT_CONFIG, opengl) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl -} -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/gradients -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/gradients -INSTALLS += target sources - diff --git a/examples/painting/gradients/gradients.qrc b/examples/painting/gradients/gradients.qrc deleted file mode 100644 index fb971eb17b..0000000000 --- a/examples/painting/gradients/gradients.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - gradients.cpp - gradients.html - - diff --git a/examples/painting/gradients/main.cpp b/examples/painting/gradients/main.cpp deleted file mode 100644 index eaf8bdc333..0000000000 --- a/examples/painting/gradients/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gradients.h" - -#include - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(gradients); - - QApplication app(argc, argv); - - GradientWidget gradientWidget(0); - QStyle *arthurStyle = new ArthurStyle(); - gradientWidget.setStyle(arthurStyle); - QList widgets = gradientWidget.findChildren(); - foreach (QWidget *w, widgets) { - w->setStyle(arthurStyle); - w->setAttribute(Qt::WA_AcceptTouchEvents); - } - gradientWidget.show(); - - return app.exec(); -} diff --git a/examples/painting/imagecomposition/imagecomposer.cpp b/examples/painting/imagecomposition/imagecomposer.cpp deleted file mode 100644 index 38b04a27b0..0000000000 --- a/examples/painting/imagecomposition/imagecomposer.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "imagecomposer.h" - -//! [0] -static const QSize resultSize(200, 200); -//! [0] - -//! [1] -ImageComposer::ImageComposer() -{ - sourceButton = new QToolButton; - sourceButton->setIconSize(resultSize); - - operatorComboBox = new QComboBox; - addOp(QPainter::CompositionMode_SourceOver, tr("SourceOver")); - addOp(QPainter::CompositionMode_DestinationOver, tr("DestinationOver")); - addOp(QPainter::CompositionMode_Clear, tr("Clear")); - addOp(QPainter::CompositionMode_Source, tr("Source")); - addOp(QPainter::CompositionMode_Destination, tr("Destination")); - addOp(QPainter::CompositionMode_SourceIn, tr("SourceIn")); - addOp(QPainter::CompositionMode_DestinationIn, tr("DestinationIn")); - addOp(QPainter::CompositionMode_SourceOut, tr("SourceOut")); - addOp(QPainter::CompositionMode_DestinationOut, tr("DestinationOut")); - addOp(QPainter::CompositionMode_SourceAtop, tr("SourceAtop")); - addOp(QPainter::CompositionMode_DestinationAtop, tr("DestinationAtop")); - addOp(QPainter::CompositionMode_Xor, tr("Xor")); - addOp(QPainter::CompositionMode_Plus, tr("Plus")); - addOp(QPainter::CompositionMode_Multiply, tr("Multiply")); - addOp(QPainter::CompositionMode_Screen, tr("Screen")); - addOp(QPainter::CompositionMode_Overlay, tr("Overlay")); - addOp(QPainter::CompositionMode_Darken, tr("Darken")); - addOp(QPainter::CompositionMode_Lighten, tr("Lighten")); - addOp(QPainter::CompositionMode_ColorDodge, tr("ColorDodge")); - addOp(QPainter::CompositionMode_ColorBurn, tr("ColorBurn")); - addOp(QPainter::CompositionMode_HardLight, tr("HardLight")); - addOp(QPainter::CompositionMode_SoftLight, tr("SoftLight")); - addOp(QPainter::CompositionMode_Difference, tr("Difference")); - addOp(QPainter::CompositionMode_Exclusion, tr("Exclusion")); -//! [1] - -//! [2] - destinationButton = new QToolButton; - destinationButton->setIconSize(resultSize); - - equalLabel = new QLabel(tr("=")); - - resultLabel = new QLabel; - resultLabel->setMinimumWidth(resultSize.width()); -//! [2] - -//! [3] - connect(sourceButton, SIGNAL(clicked()), this, SLOT(chooseSource())); - connect(operatorComboBox, SIGNAL(activated(int)), - this, SLOT(recalculateResult())); - connect(destinationButton, SIGNAL(clicked()), - this, SLOT(chooseDestination())); -//! [3] - -//! [4] - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(sourceButton, 0, 0, 3, 1); - mainLayout->addWidget(operatorComboBox, 1, 1); - mainLayout->addWidget(destinationButton, 0, 2, 3, 1); - mainLayout->addWidget(equalLabel, 1, 3); - mainLayout->addWidget(resultLabel, 0, 4, 3, 1); - mainLayout->setSizeConstraint(QLayout::SetFixedSize); - setLayout(mainLayout); -//! [4] - -//! [5] - resultImage = QImage(resultSize, QImage::Format_ARGB32_Premultiplied); - - loadImage(":/images/butterfly.png", &sourceImage, sourceButton); - loadImage(":/images/checker.png", &destinationImage, destinationButton); - - setWindowTitle(tr("Image Composition")); -} -//! [5] - -//! [6] -void ImageComposer::chooseSource() -{ - chooseImage(tr("Choose Source Image"), &sourceImage, sourceButton); -} -//! [6] - -//! [7] -void ImageComposer::chooseDestination() -{ - chooseImage(tr("Choose Destination Image"), &destinationImage, - destinationButton); -} -//! [7] - -//! [8] -void ImageComposer::recalculateResult() -{ - QPainter::CompositionMode mode = currentMode(); - - QPainter painter(&resultImage); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(resultImage.rect(), Qt::transparent); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.drawImage(0, 0, destinationImage); - painter.setCompositionMode(mode); - painter.drawImage(0, 0, sourceImage); - painter.setCompositionMode(QPainter::CompositionMode_DestinationOver); - painter.fillRect(resultImage.rect(), Qt::white); - painter.end(); - - resultLabel->setPixmap(QPixmap::fromImage(resultImage)); -} -//! [8] - -//! [9] -void ImageComposer::addOp(QPainter::CompositionMode mode, const QString &name) -{ - operatorComboBox->addItem(name, mode); -} -//! [9] - -//! [10] -void ImageComposer::chooseImage(const QString &title, QImage *image, - QToolButton *button) -{ - QString fileName = QFileDialog::getOpenFileName(this, title); - if (!fileName.isEmpty()) - loadImage(fileName, image, button); -} -//! [10] - -//! [11] -void ImageComposer::loadImage(const QString &fileName, QImage *image, - QToolButton *button) -{ - image->load(fileName); - - // Scale the image to given size - *image = image->scaled(resultSize, Qt::KeepAspectRatio); - - QImage fixedImage(resultSize, QImage::Format_ARGB32_Premultiplied); - QPainter painter(&fixedImage); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(fixedImage.rect(), Qt::transparent); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.drawImage(imagePos(*image), *image); - painter.end(); - button->setIcon(QPixmap::fromImage(fixedImage)); - - *image = fixedImage; - - recalculateResult(); -} -//! [11] - -//! [12] -QPainter::CompositionMode ImageComposer::currentMode() const -{ - return (QPainter::CompositionMode) - operatorComboBox->itemData(operatorComboBox->currentIndex()).toInt(); -} -//! [12] - -//! [13] -QPoint ImageComposer::imagePos(const QImage &image) const -{ - return QPoint((resultSize.width() - image.width()) / 2, - (resultSize.height() - image.height()) / 2); -} -//! [13] diff --git a/examples/painting/imagecomposition/imagecomposer.h b/examples/painting/imagecomposition/imagecomposer.h deleted file mode 100644 index 7ec0207e2c..0000000000 --- a/examples/painting/imagecomposition/imagecomposer.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 IMAGECOMPOSER_H -#define IMAGECOMPOSER_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QComboBox; -class QLabel; -class QToolButton; -QT_END_NAMESPACE - -//! [0] -class ImageComposer : public QWidget -{ - Q_OBJECT - -public: - ImageComposer(); - -private slots: - void chooseSource(); - void chooseDestination(); - void recalculateResult(); -//! [0] - -//! [1] -private: - void addOp(QPainter::CompositionMode mode, const QString &name); - void chooseImage(const QString &title, QImage *image, QToolButton *button); - void loadImage(const QString &fileName, QImage *image, QToolButton *button); - QPainter::CompositionMode currentMode() const; - QPoint imagePos(const QImage &image) const; - - QToolButton *sourceButton; - QToolButton *destinationButton; - QComboBox *operatorComboBox; - QLabel *equalLabel; - QLabel *resultLabel; - - QImage sourceImage; - QImage destinationImage; - QImage resultImage; -}; -//! [1] - -#endif diff --git a/examples/painting/imagecomposition/imagecomposition.desktop b/examples/painting/imagecomposition/imagecomposition.desktop deleted file mode 100644 index 854fc862f0..0000000000 --- a/examples/painting/imagecomposition/imagecomposition.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Image Composition -Exec=/opt/usr/bin/imagecomposition -Icon=imagecomposition -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/imagecomposition/imagecomposition.pro b/examples/painting/imagecomposition/imagecomposition.pro deleted file mode 100644 index edf434f5d2..0000000000 --- a/examples/painting/imagecomposition/imagecomposition.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = imagecomposer.h -SOURCES = imagecomposer.cpp \ - main.cpp -RESOURCES = imagecomposition.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/imagecomposition -sources.files = $$SOURCES $$HEADERS $$RESOURCES images *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/imagecomposition -INSTALLS += target sources - -QT += widgets - diff --git a/examples/painting/imagecomposition/imagecomposition.qrc b/examples/painting/imagecomposition/imagecomposition.qrc deleted file mode 100644 index ebba7b2913..0000000000 --- a/examples/painting/imagecomposition/imagecomposition.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/butterfly.png - images/checker.png - - diff --git a/examples/painting/imagecomposition/images/background.png b/examples/painting/imagecomposition/images/background.png deleted file mode 100644 index f6ad899823..0000000000 Binary files a/examples/painting/imagecomposition/images/background.png and /dev/null differ diff --git a/examples/painting/imagecomposition/images/blackrectangle.png b/examples/painting/imagecomposition/images/blackrectangle.png deleted file mode 100644 index 5f2ecf8318..0000000000 Binary files a/examples/painting/imagecomposition/images/blackrectangle.png and /dev/null differ diff --git a/examples/painting/imagecomposition/images/butterfly.png b/examples/painting/imagecomposition/images/butterfly.png deleted file mode 100644 index f3e050eca2..0000000000 Binary files a/examples/painting/imagecomposition/images/butterfly.png and /dev/null differ diff --git a/examples/painting/imagecomposition/images/checker.png b/examples/painting/imagecomposition/images/checker.png deleted file mode 100644 index 546609de3f..0000000000 Binary files a/examples/painting/imagecomposition/images/checker.png and /dev/null differ diff --git a/examples/painting/imagecomposition/main.cpp b/examples/painting/imagecomposition/main.cpp deleted file mode 100644 index 6b17c4d370..0000000000 --- a/examples/painting/imagecomposition/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "imagecomposer.h" - -//! [0] -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(imagecomposition); - - QApplication app(argc, argv); - ImageComposer composer; - composer.show(); - return app.exec(); -} -//! [0] diff --git a/examples/painting/painterpaths/main.cpp b/examples/painting/painterpaths/main.cpp deleted file mode 100644 index dcbf1c0449..0000000000 --- a/examples/painting/painterpaths/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#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/painterpaths/painterpaths.desktop b/examples/painting/painterpaths/painterpaths.desktop deleted file mode 100644 index ae92f2c589..0000000000 --- a/examples/painting/painterpaths/painterpaths.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Painter Paths -Exec=/opt/usr/bin/painterpaths -Icon=painterpaths -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/painterpaths/painterpaths.pro b/examples/painting/painterpaths/painterpaths.pro deleted file mode 100644 index c988ba26e0..0000000000 --- a/examples/painting/painterpaths/painterpaths.pro +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS = renderarea.h \ - window.h -SOURCES = main.cpp \ - renderarea.cpp \ - window.cpp -unix:!mac:!vxworks:!integrity:LIBS += -lm - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/painterpaths -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS painterpaths.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/painterpaths -INSTALLS += target sources - -QT += widgets - diff --git a/examples/painting/painterpaths/renderarea.cpp b/examples/painting/painterpaths/renderarea.cpp deleted file mode 100644 index 0b3f1fdc0d..0000000000 --- a/examples/painting/painterpaths/renderarea.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "renderarea.h" - -//! [0] -RenderArea::RenderArea(const QPainterPath &path, QWidget *parent) - : QWidget(parent), path(path) -{ - penWidth = 1; - rotationAngle = 0; - setBackgroundRole(QPalette::Base); -} -//! [0] - -//! [1] -QSize RenderArea::minimumSizeHint() const -{ - return QSize(50, 50); -} -//! [1] - -//! [2] -QSize RenderArea::sizeHint() const -{ - return QSize(100, 100); -} -//! [2] - -//! [3] -void RenderArea::setFillRule(Qt::FillRule rule) -{ - path.setFillRule(rule); - update(); -} -//! [3] - -//! [4] -void RenderArea::setFillGradient(const QColor &color1, const QColor &color2) -{ - fillColor1 = color1; - fillColor2 = color2; - update(); -} -//! [4] - -//! [5] -void RenderArea::setPenWidth(int width) -{ - penWidth = width; - update(); -} -//! [5] - -//! [6] -void RenderArea::setPenColor(const QColor &color) -{ - penColor = color; - update(); -} -//! [6] - -//! [7] -void RenderArea::setRotationAngle(int degrees) -{ - rotationAngle = degrees; - update(); -} -//! [7] - -//! [8] -void RenderArea::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); -//! [8] //! [9] - painter.scale(width() / 100.0, height() / 100.0); - painter.translate(50.0, 50.0); - painter.rotate(-rotationAngle); - painter.translate(-50.0, -50.0); - -//! [9] //! [10] - painter.setPen(QPen(penColor, penWidth, Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); - QLinearGradient gradient(0, 0, 0, 100); - gradient.setColorAt(0.0, fillColor1); - gradient.setColorAt(1.0, fillColor2); - painter.setBrush(gradient); - painter.drawPath(path); -} -//! [10] diff --git a/examples/painting/painterpaths/renderarea.h b/examples/painting/painterpaths/renderarea.h deleted file mode 100644 index 5c310fdf62..0000000000 --- a/examples/painting/painterpaths/renderarea.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 RENDERAREA_H -#define RENDERAREA_H - -#include -#include - -//! [0] -class RenderArea : public QWidget -{ - Q_OBJECT - -public: - RenderArea(const QPainterPath &path, QWidget *parent = 0); - - QSize minimumSizeHint() const; - QSize sizeHint() const; - -public slots: - void setFillRule(Qt::FillRule rule); - void setFillGradient(const QColor &color1, const QColor &color2); - void setPenWidth(int width); - void setPenColor(const QColor &color); - void setRotationAngle(int degrees); - -protected: - void paintEvent(QPaintEvent *event); -//! [0] - -//! [1] -private: - QPainterPath path; - QColor fillColor1; - QColor fillColor2; - int penWidth; - QColor penColor; - int rotationAngle; -}; -//! [1] - -#endif diff --git a/examples/painting/painterpaths/window.cpp b/examples/painting/painterpaths/window.cpp deleted file mode 100644 index 3d3eef9d2b..0000000000 --- a/examples/painting/painterpaths/window.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include - -#include "renderarea.h" -#include "window.h" - -//! [0] -const float Pi = 3.14159f; -//! [0] - -//! [1] -Window::Window() -{ - QPainterPath rectPath; - rectPath.moveTo(20.0, 30.0); - rectPath.lineTo(80.0, 30.0); - rectPath.lineTo(80.0, 70.0); - rectPath.lineTo(20.0, 70.0); - rectPath.closeSubpath(); -//! [1] - -//! [2] - QPainterPath roundRectPath; - roundRectPath.moveTo(80.0, 35.0); - roundRectPath.arcTo(70.0, 30.0, 10.0, 10.0, 0.0, 90.0); - roundRectPath.lineTo(25.0, 30.0); - roundRectPath.arcTo(20.0, 30.0, 10.0, 10.0, 90.0, 90.0); - roundRectPath.lineTo(20.0, 65.0); - roundRectPath.arcTo(20.0, 60.0, 10.0, 10.0, 180.0, 90.0); - roundRectPath.lineTo(75.0, 70.0); - roundRectPath.arcTo(70.0, 60.0, 10.0, 10.0, 270.0, 90.0); - roundRectPath.closeSubpath(); -//! [2] - -//! [3] - QPainterPath ellipsePath; - ellipsePath.moveTo(80.0, 50.0); - ellipsePath.arcTo(20.0, 30.0, 60.0, 40.0, 0.0, 360.0); -//! [3] - -//! [4] - QPainterPath piePath; - piePath.moveTo(50.0, 50.0); - piePath.arcTo(20.0, 30.0, 60.0, 40.0, 60.0, 240.0); - piePath.closeSubpath(); -//! [4] - -//! [5] - QPainterPath polygonPath; - polygonPath.moveTo(10.0, 80.0); - polygonPath.lineTo(20.0, 10.0); - polygonPath.lineTo(80.0, 30.0); - polygonPath.lineTo(90.0, 70.0); - polygonPath.closeSubpath(); -//! [5] - -//! [6] - QPainterPath groupPath; - groupPath.moveTo(60.0, 40.0); - groupPath.arcTo(20.0, 20.0, 40.0, 40.0, 0.0, 360.0); - groupPath.moveTo(40.0, 40.0); - groupPath.lineTo(40.0, 80.0); - groupPath.lineTo(80.0, 80.0); - groupPath.lineTo(80.0, 40.0); - groupPath.closeSubpath(); -//! [6] - -//! [7] - QPainterPath textPath; - QFont timesFont("Times", 50); - timesFont.setStyleStrategy(QFont::ForceOutline); - textPath.addText(10, 70, timesFont, tr("Qt")); -//! [7] - -//! [8] - QPainterPath bezierPath; - bezierPath.moveTo(20, 30); - bezierPath.cubicTo(80, 0, 50, 50, 80, 80); -//! [8] - -//! [9] - QPainterPath starPath; - starPath.moveTo(90, 50); - for (int i = 1; i < 5; ++i) { - starPath.lineTo(50 + 40 * cos(0.8 * i * Pi), - 50 + 40 * sin(0.8 * i * Pi)); - } - starPath.closeSubpath(); -//! [9] - -//! [10] - renderAreas.push_back(new RenderArea(rectPath)); - renderAreas.push_back(new RenderArea(roundRectPath)); - renderAreas.push_back(new RenderArea(ellipsePath)); - renderAreas.push_back(new RenderArea(piePath)); - renderAreas.push_back(new RenderArea(polygonPath)); - renderAreas.push_back(new RenderArea(groupPath)); - renderAreas.push_back(new RenderArea(textPath)); - renderAreas.push_back(new RenderArea(bezierPath)); - renderAreas.push_back(new RenderArea(starPath)); -//! [10] - -//! [11] - fillRuleComboBox = new QComboBox; - fillRuleComboBox->addItem(tr("Odd Even"), Qt::OddEvenFill); - fillRuleComboBox->addItem(tr("Winding"), Qt::WindingFill); - - fillRuleLabel = new QLabel(tr("Fill &Rule:")); - fillRuleLabel->setBuddy(fillRuleComboBox); -//! [11] - -//! [12] - fillColor1ComboBox = new QComboBox; - populateWithColors(fillColor1ComboBox); - fillColor1ComboBox->setCurrentIndex( - fillColor1ComboBox->findText("mediumslateblue")); - - fillColor2ComboBox = new QComboBox; - populateWithColors(fillColor2ComboBox); - fillColor2ComboBox->setCurrentIndex( - fillColor2ComboBox->findText("cornsilk")); - - fillGradientLabel = new QLabel(tr("&Fill Gradient:")); - fillGradientLabel->setBuddy(fillColor1ComboBox); - - fillToLabel = new QLabel(tr("to")); - fillToLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - - penWidthSpinBox = new QSpinBox; - penWidthSpinBox->setRange(0, 20); - - penWidthLabel = new QLabel(tr("&Pen Width:")); - penWidthLabel->setBuddy(penWidthSpinBox); - - penColorComboBox = new QComboBox; - populateWithColors(penColorComboBox); - penColorComboBox->setCurrentIndex( - penColorComboBox->findText("darkslateblue")); - - penColorLabel = new QLabel(tr("Pen &Color:")); - penColorLabel->setBuddy(penColorComboBox); - - rotationAngleSpinBox = new QSpinBox; - rotationAngleSpinBox->setRange(0, 359); - rotationAngleSpinBox->setWrapping(true); - rotationAngleSpinBox->setSuffix(QLatin1String("\xB0")); - - rotationAngleLabel = new QLabel(tr("&Rotation Angle:")); - rotationAngleLabel->setBuddy(rotationAngleSpinBox); -//! [12] - -//! [16] - connect(fillRuleComboBox, SIGNAL(activated(int)), - this, SLOT(fillRuleChanged())); - connect(fillColor1ComboBox, SIGNAL(activated(int)), - this, SLOT(fillGradientChanged())); - connect(fillColor2ComboBox, SIGNAL(activated(int)), - this, SLOT(fillGradientChanged())); - connect(penColorComboBox, SIGNAL(activated(int)), - this, SLOT(penColorChanged())); - - for(QList::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) { - connect(penWidthSpinBox, SIGNAL(valueChanged(int)), - *it, SLOT(setPenWidth(int))); - connect(rotationAngleSpinBox, SIGNAL(valueChanged(int)), - *it, SLOT(setRotationAngle(int))); - } - -//! [16] //! [17] - QGridLayout *topLayout = new QGridLayout; - - int i=0; - for(QList::iterator it = renderAreas.begin(); it != renderAreas.end(); it++, i++) - topLayout->addWidget(*it, i / 3, i % 3); - - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addLayout(topLayout, 0, 0, 1, 4); - mainLayout->addWidget(fillRuleLabel, 1, 0); - mainLayout->addWidget(fillRuleComboBox, 1, 1, 1, 3); - mainLayout->addWidget(fillGradientLabel, 2, 0); - mainLayout->addWidget(fillColor1ComboBox, 2, 1); - mainLayout->addWidget(fillToLabel, 2, 2); - mainLayout->addWidget(fillColor2ComboBox, 2, 3); - mainLayout->addWidget(penWidthLabel, 3, 0); - mainLayout->addWidget(penWidthSpinBox, 3, 1, 1, 3); - mainLayout->addWidget(penColorLabel, 4, 0); - mainLayout->addWidget(penColorComboBox, 4, 1, 1, 3); - mainLayout->addWidget(rotationAngleLabel, 5, 0); - mainLayout->addWidget(rotationAngleSpinBox, 5, 1, 1, 3); - setLayout(mainLayout); -//! [17] - -//! [18] - fillRuleChanged(); - fillGradientChanged(); - penColorChanged(); - penWidthSpinBox->setValue(2); - - setWindowTitle(tr("Painter Paths")); -} -//! [18] - -//! [19] -void Window::fillRuleChanged() -{ - Qt::FillRule rule = (Qt::FillRule)currentItemData(fillRuleComboBox).toInt(); - - for(QList::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) - (*it)->setFillRule(rule); -} -//! [19] - -//! [20] -void Window::fillGradientChanged() -{ - QColor color1 = qvariant_cast(currentItemData(fillColor1ComboBox)); - QColor color2 = qvariant_cast(currentItemData(fillColor2ComboBox)); - - for(QList::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) - (*it)->setFillGradient(color1, color2); -} -//! [20] - -//! [21] -void Window::penColorChanged() -{ - QColor color = qvariant_cast(currentItemData(penColorComboBox)); - - for(QList::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) - (*it)->setPenColor(color); -} -//! [21] - -//! [22] -void Window::populateWithColors(QComboBox *comboBox) -{ - QStringList colorNames = QColor::colorNames(); - foreach (QString name, colorNames) - comboBox->addItem(name, QColor(name)); -} -//! [22] - -//! [23] -QVariant Window::currentItemData(QComboBox *comboBox) -{ - return comboBox->itemData(comboBox->currentIndex()); -} -//! [23] diff --git a/examples/painting/painterpaths/window.h b/examples/painting/painterpaths/window.h deleted file mode 100644 index 4c01719b16..0000000000 --- a/examples/painting/painterpaths/window.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -QT_BEGIN_NAMESPACE -class QComboBox; -class QLabel; -class QSpinBox; -QT_END_NAMESPACE -class RenderArea; - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -private slots: - void fillRuleChanged(); - void fillGradientChanged(); - void penColorChanged(); -//! [0] - -//! [1] -private: - void populateWithColors(QComboBox *comboBox); - QVariant currentItemData(QComboBox *comboBox); -//! [1] - -//! [2] - QList renderAreas; - QLabel *fillRuleLabel; - QLabel *fillGradientLabel; - QLabel *fillToLabel; - QLabel *penWidthLabel; - QLabel *penColorLabel; - QLabel *rotationAngleLabel; - QComboBox *fillRuleComboBox; - QComboBox *fillColor1ComboBox; - QComboBox *fillColor2ComboBox; - QSpinBox *penWidthSpinBox; - QComboBox *penColorComboBox; - QSpinBox *rotationAngleSpinBox; -}; -//! [2] - -#endif diff --git a/examples/painting/painting.pro b/examples/painting/painting.pro deleted file mode 100644 index 927d94006b..0000000000 --- a/examples/painting/painting.pro +++ /dev/null @@ -1,36 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = basicdrawing \ - concentriccircles \ - examples_affine \ - examples_composition \ - examples_deform \ - examples_gradients \ - examples_pathstroke \ - painting_shared \ - imagecomposition \ - painterpaths \ - transformations \ - fontsampler - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS painting.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting -INSTALLS += target sources - -QT += widgets - -examples_affine.subdir = affine -examples_composition.subdir = composition -examples_deform.subdir = deform -examples_gradients.subdir = gradients -examples_pathstroke.subdir = pathstroke -painting_shared.subdir = shared - -!ordered { - examples_affine.depends = painting_shared - examples_deform.depends = painting_shared - examples_gradients.depends = painting_shared - examples_composition.depends = painting_shared - examples_pathstroke.depends = painting_shared -} diff --git a/examples/painting/pathstroke/main.cpp b/examples/painting/pathstroke/main.cpp deleted file mode 100644 index c969d975a3..0000000000 --- a/examples/painting/pathstroke/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "pathstroke.h" -#include - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(pathstroke); - - QApplication app(argc, argv); - - bool smallScreen = QApplication::arguments().contains("-small-screen"); - - PathStrokeWidget pathStrokeWidget(smallScreen); - QStyle *arthurStyle = new ArthurStyle(); - pathStrokeWidget.setStyle(arthurStyle); - QList widgets = pathStrokeWidget.findChildren(); - foreach (QWidget *w, widgets) { - w->setStyle(arthurStyle); - w->setAttribute(Qt::WA_AcceptTouchEvents); - } - - if (smallScreen) - pathStrokeWidget.showFullScreen(); - else - pathStrokeWidget.show(); - -#ifdef QT_KEYPAD_NAVIGATION - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif - return app.exec(); -} diff --git a/examples/painting/pathstroke/pathstroke.cpp b/examples/painting/pathstroke/pathstroke.cpp deleted file mode 100644 index 76495cafea..0000000000 --- a/examples/painting/pathstroke/pathstroke.cpp +++ /dev/null @@ -1,685 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "pathstroke.h" -#include "arthurstyle.h" -#include "arthurwidgets.h" - -#include - -extern void draw_round_rect(QPainter *p, const QRect &bounds, int radius); - - -PathStrokeControls::PathStrokeControls(QWidget* parent, PathStrokeRenderer* renderer, bool smallScreen) - : QWidget(parent) -{ - m_renderer = renderer; - - if (smallScreen) - layoutForSmallScreens(); - else - layoutForDesktop(); -} - -void PathStrokeControls::createCommonControls(QWidget* parent) -{ - m_capGroup = new QGroupBox(parent); - m_capGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - QRadioButton *flatCap = new QRadioButton(m_capGroup); - QRadioButton *squareCap = new QRadioButton(m_capGroup); - QRadioButton *roundCap = new QRadioButton(m_capGroup); - m_capGroup->setTitle(tr("Cap Style")); - flatCap->setText(tr("Flat")); - squareCap->setText(tr("Square")); - roundCap->setText(tr("Round")); - flatCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - squareCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - roundCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - - m_joinGroup = new QGroupBox(parent); - m_joinGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - QRadioButton *bevelJoin = new QRadioButton(m_joinGroup); - QRadioButton *miterJoin = new QRadioButton(m_joinGroup); - QRadioButton *roundJoin = new QRadioButton(m_joinGroup); - m_joinGroup->setTitle(tr("Join Style")); - bevelJoin->setText(tr("Bevel")); - miterJoin->setText(tr("Miter")); - roundJoin->setText(tr("Round")); - - m_styleGroup = new QGroupBox(parent); - m_styleGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - QRadioButton *solidLine = new QRadioButton(m_styleGroup); - QRadioButton *dashLine = new QRadioButton(m_styleGroup); - QRadioButton *dotLine = new QRadioButton(m_styleGroup); - QRadioButton *dashDotLine = new QRadioButton(m_styleGroup); - QRadioButton *dashDotDotLine = new QRadioButton(m_styleGroup); - QRadioButton *customDashLine = new QRadioButton(m_styleGroup); - m_styleGroup->setTitle(tr("Pen Style")); - - QPixmap line_solid(":res/images/line_solid.png"); - solidLine->setIcon(line_solid); - solidLine->setIconSize(line_solid.size()); - QPixmap line_dashed(":res/images/line_dashed.png"); - dashLine->setIcon(line_dashed); - dashLine->setIconSize(line_dashed.size()); - QPixmap line_dotted(":res/images/line_dotted.png"); - dotLine->setIcon(line_dotted); - dotLine->setIconSize(line_dotted.size()); - QPixmap line_dash_dot(":res/images/line_dash_dot.png"); - dashDotLine->setIcon(line_dash_dot); - dashDotLine->setIconSize(line_dash_dot.size()); - QPixmap line_dash_dot_dot(":res/images/line_dash_dot_dot.png"); - dashDotDotLine->setIcon(line_dash_dot_dot); - dashDotDotLine->setIconSize(line_dash_dot_dot.size()); - customDashLine->setText(tr("Custom")); - - int fixedHeight = bevelJoin->sizeHint().height(); - solidLine->setFixedHeight(fixedHeight); - dashLine->setFixedHeight(fixedHeight); - dotLine->setFixedHeight(fixedHeight); - dashDotLine->setFixedHeight(fixedHeight); - dashDotDotLine->setFixedHeight(fixedHeight); - - m_pathModeGroup = new QGroupBox(parent); - m_pathModeGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - QRadioButton *curveMode = new QRadioButton(m_pathModeGroup); - QRadioButton *lineMode = new QRadioButton(m_pathModeGroup); - m_pathModeGroup->setTitle(tr("Line Style")); - curveMode->setText(tr("Curves")); - lineMode->setText(tr("Lines")); - - - // Layouts - QVBoxLayout *capGroupLayout = new QVBoxLayout(m_capGroup); - capGroupLayout->addWidget(flatCap); - capGroupLayout->addWidget(squareCap); - capGroupLayout->addWidget(roundCap); - - QVBoxLayout *joinGroupLayout = new QVBoxLayout(m_joinGroup); - joinGroupLayout->addWidget(bevelJoin); - joinGroupLayout->addWidget(miterJoin); - joinGroupLayout->addWidget(roundJoin); - - QVBoxLayout *styleGroupLayout = new QVBoxLayout(m_styleGroup); - styleGroupLayout->addWidget(solidLine); - styleGroupLayout->addWidget(dashLine); - styleGroupLayout->addWidget(dotLine); - styleGroupLayout->addWidget(dashDotLine); - styleGroupLayout->addWidget(dashDotDotLine); - styleGroupLayout->addWidget(customDashLine); - - QVBoxLayout *pathModeGroupLayout = new QVBoxLayout(m_pathModeGroup); - pathModeGroupLayout->addWidget(curveMode); - pathModeGroupLayout->addWidget(lineMode); - - - // Connections - connect(flatCap, SIGNAL(clicked()), m_renderer, SLOT(setFlatCap())); - connect(squareCap, SIGNAL(clicked()), m_renderer, SLOT(setSquareCap())); - connect(roundCap, SIGNAL(clicked()), m_renderer, SLOT(setRoundCap())); - - connect(bevelJoin, SIGNAL(clicked()), m_renderer, SLOT(setBevelJoin())); - connect(miterJoin, SIGNAL(clicked()), m_renderer, SLOT(setMiterJoin())); - connect(roundJoin, SIGNAL(clicked()), m_renderer, SLOT(setRoundJoin())); - - connect(curveMode, SIGNAL(clicked()), m_renderer, SLOT(setCurveMode())); - connect(lineMode, SIGNAL(clicked()), m_renderer, SLOT(setLineMode())); - - connect(solidLine, SIGNAL(clicked()), m_renderer, SLOT(setSolidLine())); - connect(dashLine, SIGNAL(clicked()), m_renderer, SLOT(setDashLine())); - connect(dotLine, SIGNAL(clicked()), m_renderer, SLOT(setDotLine())); - connect(dashDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotLine())); - connect(dashDotDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotDotLine())); - connect(customDashLine, SIGNAL(clicked()), m_renderer, SLOT(setCustomDashLine())); - - // Set the defaults: - flatCap->setChecked(true); - bevelJoin->setChecked(true); - curveMode->setChecked(true); - solidLine->setChecked(true); -} - - -void PathStrokeControls::layoutForDesktop() -{ - QGroupBox *mainGroup = new QGroupBox(this); - mainGroup->setFixedWidth(180); - mainGroup->setTitle(tr("Path Stroking")); - - createCommonControls(mainGroup); - - QGroupBox* penWidthGroup = new QGroupBox(mainGroup); - QSlider *penWidth = new QSlider(Qt::Horizontal, penWidthGroup); - penWidth->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - penWidthGroup->setTitle(tr("Pen Width")); - penWidth->setRange(0, 500); - - QPushButton *animated = new QPushButton(mainGroup); - animated->setText(tr("Animate")); - animated->setCheckable(true); - - QPushButton *showSourceButton = new QPushButton(mainGroup); - showSourceButton->setText(tr("Show Source")); -#ifdef QT_OPENGL_SUPPORT - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); -#endif - QPushButton *whatsThisButton = new QPushButton(mainGroup); - whatsThisButton->setText(tr("What's This?")); - whatsThisButton->setCheckable(true); - - - // Layouts: - QVBoxLayout *penWidthLayout = new QVBoxLayout(penWidthGroup); - penWidthLayout->addWidget(penWidth); - - QVBoxLayout * mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(0); - mainLayout->addWidget(mainGroup); - - QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); - mainGroupLayout->setMargin(3); - mainGroupLayout->addWidget(m_capGroup); - mainGroupLayout->addWidget(m_joinGroup); - mainGroupLayout->addWidget(m_styleGroup); - mainGroupLayout->addWidget(penWidthGroup); - mainGroupLayout->addWidget(m_pathModeGroup); - mainGroupLayout->addWidget(animated); - mainGroupLayout->addStretch(1); - mainGroupLayout->addWidget(showSourceButton); -#ifdef QT_OPENGL_SUPPORT - mainGroupLayout->addWidget(enableOpenGLButton); -#endif - mainGroupLayout->addWidget(whatsThisButton); - - - // Set up connections - connect(animated, SIGNAL(toggled(bool)), - m_renderer, SLOT(setAnimation(bool))); - - connect(penWidth, SIGNAL(valueChanged(int)), - m_renderer, SLOT(setPenWidth(int))); - - connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource())); -#ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); -#endif - connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool))); - connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), - whatsThisButton, SLOT(setChecked(bool))); - - - // Set the defaults - animated->setChecked(true); - penWidth->setValue(50); - -} - -void PathStrokeControls::layoutForSmallScreens() -{ - createCommonControls(this); - - m_capGroup->layout()->setMargin(0); - m_joinGroup->layout()->setMargin(0); - m_styleGroup->layout()->setMargin(0); - m_pathModeGroup->layout()->setMargin(0); - - QPushButton* okBtn = new QPushButton(tr("OK"), this); - okBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - okBtn->setMinimumSize(100,okBtn->minimumSize().height()); - - QPushButton* quitBtn = new QPushButton(tr("Quit"), this); - quitBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - quitBtn->setMinimumSize(100, okBtn->minimumSize().height()); - - QLabel *penWidthLabel = new QLabel(tr(" Width:")); - QSlider *penWidth = new QSlider(Qt::Horizontal, this); - penWidth->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - penWidth->setRange(0, 500); - -#ifdef QT_OPENGL_SUPPORT - QPushButton *enableOpenGLButton = new QPushButton(this); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); -#endif - - // Layouts: - QHBoxLayout *penWidthLayout = new QHBoxLayout(0); - penWidthLayout->addWidget(penWidthLabel, 0, Qt::AlignRight); - penWidthLayout->addWidget(penWidth); - - QVBoxLayout *leftLayout = new QVBoxLayout(0); - leftLayout->addWidget(m_capGroup); - leftLayout->addWidget(m_joinGroup); -#ifdef QT_OPENGL_SUPPORT - leftLayout->addWidget(enableOpenGLButton); -#endif - leftLayout->addLayout(penWidthLayout); - - QVBoxLayout *rightLayout = new QVBoxLayout(0); - rightLayout->addWidget(m_styleGroup); - rightLayout->addWidget(m_pathModeGroup); - - QGridLayout *mainLayout = new QGridLayout(this); - mainLayout->setMargin(0); - - // Add spacers around the form items so we don't look stupid at higher resolutions - mainLayout->addItem(new QSpacerItem(0,0), 0, 0, 1, 4); - mainLayout->addItem(new QSpacerItem(0,0), 1, 0, 2, 1); - mainLayout->addItem(new QSpacerItem(0,0), 1, 3, 2, 1); - mainLayout->addItem(new QSpacerItem(0,0), 3, 0, 1, 4); - - mainLayout->addLayout(leftLayout, 1, 1); - mainLayout->addLayout(rightLayout, 1, 2); - mainLayout->addWidget(quitBtn, 2, 1, Qt::AlignHCenter | Qt::AlignTop); - mainLayout->addWidget(okBtn, 2, 2, Qt::AlignHCenter | Qt::AlignTop); - -#ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); -#endif - - connect(penWidth, SIGNAL(valueChanged(int)), m_renderer, SLOT(setPenWidth(int))); - connect(quitBtn, SIGNAL(clicked()), this, SLOT(emitQuitSignal())); - connect(okBtn, SIGNAL(clicked()), this, SLOT(emitOkSignal())); - - m_renderer->setAnimation(true); - penWidth->setValue(50); -} - -void PathStrokeControls::emitQuitSignal() -{ emit quitPressed(); } - -void PathStrokeControls::emitOkSignal() -{ emit okPressed(); } - - -PathStrokeWidget::PathStrokeWidget(bool smallScreen) -{ - setWindowTitle(tr("Path Stroking")); - - // Widget construction and property setting - m_renderer = new PathStrokeRenderer(this, smallScreen); - - m_controls = new PathStrokeControls(0, m_renderer, smallScreen); - - // Layouting - QHBoxLayout *viewLayout = new QHBoxLayout(this); - viewLayout->addWidget(m_renderer); - - if (!smallScreen) - viewLayout->addWidget(m_controls); - - m_renderer->loadSourceFile(":res/pathstroke/pathstroke.cpp"); - m_renderer->loadDescription(":res/pathstroke/pathstroke.html"); - - connect(m_renderer, SIGNAL(clicked()), this, SLOT(showControls())); - connect(m_controls, SIGNAL(okPressed()), this, SLOT(hideControls())); - connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit())); -} - - -void PathStrokeWidget::showControls() -{ - m_controls->showFullScreen(); -} - - -void PathStrokeWidget::hideControls() -{ - m_controls->hide(); -} - - -void PathStrokeWidget::setStyle( QStyle * style ) -{ - QWidget::setStyle(style); - if (m_controls != 0) - { - m_controls->setStyle(style); - - QList widgets = m_controls->findChildren(); - foreach (QWidget *w, widgets) - w->setStyle(style); - } -} - - -PathStrokeRenderer::PathStrokeRenderer(QWidget *parent, bool smallScreen) - : ArthurFrame(parent) -{ - m_smallScreen = smallScreen; - m_pointSize = 10; - m_activePoint = -1; - m_capStyle = Qt::FlatCap; - m_joinStyle = Qt::BevelJoin; - m_pathMode = CurveMode; - m_penWidth = 1; - m_penStyle = Qt::SolidLine; - m_wasAnimated = true; - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - setAttribute(Qt::WA_AcceptTouchEvents); -} - -void PathStrokeRenderer::paint(QPainter *painter) -{ - if (m_points.isEmpty()) - initializePoints(); - - painter->setRenderHint(QPainter::Antialiasing); - - QPalette pal = palette(); - painter->setPen(Qt::NoPen); - - // Construct the path - QPainterPath path; - path.moveTo(m_points.at(0)); - - if (m_pathMode == LineMode) { - for (int i=1; i dashes; - qreal space = 4; - dashes << 1 << space - << 3 << space - << 9 << space - << 27 << space - << 9 << space - << 3 << space; - stroker.setDashPattern(dashes); - QPainterPath stroke = stroker.createStroke(path); - painter->fillPath(stroke, lg); - - } else { - QPen pen(lg, m_penWidth, m_penStyle, m_capStyle, m_joinStyle); - painter->strokePath(path, pen); - } - } - - if (1) { - // Draw the control points - painter->setPen(QColor(50, 100, 120, 200)); - painter->setBrush(QColor(200, 200, 210, 120)); - for (int i=0; idrawEllipse(QRectF(pos.x() - m_pointSize, - pos.y() - m_pointSize, - m_pointSize*2, m_pointSize*2)); - } - painter->setPen(QPen(Qt::lightGray, 0, Qt::SolidLine)); - painter->setBrush(Qt::NoBrush); - painter->drawPolyline(m_points); - } - -} - -void PathStrokeRenderer::initializePoints() -{ - const int count = 7; - m_points.clear(); - m_vectors.clear(); - - QMatrix m; - qreal rot = 360 / count; - QPointF center(width() / 2, height() / 2); - QMatrix vm; - vm.shear(2, -1); - vm.scale(3, 3); - - for (int i=0; i right) { - vec.setX(-vec.x()); - pos.setX(pos.x() < left ? left : right); - } if (pos.y() < top || pos.y() > bottom) { - vec.setY(-vec.y()); - pos.setY(pos.y() < top ? top : bottom); - } - m_points[i] = pos; - m_vectors[i] = vec; - } - update(); -} - -void PathStrokeRenderer::mousePressEvent(QMouseEvent *e) -{ - if (!m_fingerPointMapping.isEmpty()) - return; - setDescriptionEnabled(false); - m_activePoint = -1; - qreal distance = -1; - for (int i=0; ipos(), m_points.at(i)).length(); - if ((distance < 0 && d < 8 * m_pointSize) || d < distance) { - distance = d; - m_activePoint = i; - } - } - - if (m_activePoint != -1) { - m_wasAnimated = m_timer.isActive(); - setAnimation(false); - mouseMoveEvent(e); - } - - // If we're not running in small screen mode, always assume we're dragging - m_mouseDrag = !m_smallScreen; - m_mousePress = e->pos(); -} - -void PathStrokeRenderer::mouseMoveEvent(QMouseEvent *e) -{ - if (!m_fingerPointMapping.isEmpty()) - return; - // If we've moved more then 25 pixels, assume user is dragging - if (!m_mouseDrag && QPoint(m_mousePress - e->pos()).manhattanLength() > 25) - m_mouseDrag = true; - - if (m_mouseDrag && m_activePoint >= 0 && m_activePoint < m_points.size()) { - m_points[m_activePoint] = e->pos(); - update(); - } -} - -void PathStrokeRenderer::mouseReleaseEvent(QMouseEvent *) -{ - if (!m_fingerPointMapping.isEmpty()) - return; - m_activePoint = -1; - setAnimation(m_wasAnimated); - - if (!m_mouseDrag && m_smallScreen) - emit clicked(); -} - -void PathStrokeRenderer::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == m_timer.timerId()) { - updatePoints(); - } // else if (e->timerId() == m_fpsTimer.timerId()) { -// emit frameRate(m_frameCount); -// m_frameCount = 0; -// } -} - -bool PathStrokeRenderer::event(QEvent *e) -{ - bool touchBegin = false; - switch (e->type()) { - case QEvent::TouchBegin: - touchBegin = true; - case QEvent::TouchUpdate: - { - const QTouchEvent *const event = static_cast(e); - const QList points = event->touchPoints(); - foreach (const QTouchEvent::TouchPoint &touchPoint, points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: - { - // find the point, move it - QSet activePoints = QSet::fromList(m_fingerPointMapping.values()); - int activePoint = -1; - qreal distance = -1; - const int pointsCount = m_points.size(); - for (int i=0; i::iterator it = m_fingerPointMapping.find(id); - m_points[it.value()] = touchPoint.pos(); - m_fingerPointMapping.erase(it); - } - break; - case Qt::TouchPointMoved: - { - // move the point - const int pointIdx = m_fingerPointMapping.value(id, -1); - if (pointIdx >= 0) - m_points[pointIdx] = touchPoint.pos(); - } - break; - default: - break; - } - } - if (m_fingerPointMapping.isEmpty()) { - e->ignore(); - return false; - } else { - if (touchBegin) { - m_wasAnimated = m_timer.isActive(); - setAnimation(false); - } - update(); - return true; - } - } - break; - case QEvent::TouchEnd: - if (m_fingerPointMapping.isEmpty()) { - e->ignore(); - return false; - } - m_fingerPointMapping.clear(); - setAnimation(m_wasAnimated); - return true; - break; - default: - break; - } - return QWidget::event(e); -} - -void PathStrokeRenderer::setAnimation(bool animation) -{ - m_timer.stop(); -// m_fpsTimer.stop(); - - if (animation) { - m_timer.start(25, this); -// m_fpsTimer.start(1000, this); -// m_frameCount = 0; - } -} diff --git a/examples/painting/pathstroke/pathstroke.h b/examples/painting/pathstroke/pathstroke.h deleted file mode 100644 index 743a757b0a..0000000000 --- a/examples/painting/pathstroke/pathstroke.h +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PATHSTROKE_H -#define PATHSTROKE_H - -#include "arthurwidgets.h" -#include - -class PathStrokeRenderer : public ArthurFrame -{ - Q_OBJECT - Q_PROPERTY(bool animation READ animation WRITE setAnimation) - Q_PROPERTY(qreal penWidth READ realPenWidth WRITE setRealPenWidth) -public: - enum PathMode { CurveMode, LineMode }; - - PathStrokeRenderer(QWidget *parent, bool smallScreen = false); - - void paint(QPainter *); - void mousePressEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void timerEvent(QTimerEvent *e); - bool event(QEvent *e); - - QSize sizeHint() const { return QSize(500, 500); } - - bool animation() const { return m_timer.isActive(); } - - qreal realPenWidth() const { return m_penWidth; } - void setRealPenWidth(qreal penWidth) { m_penWidth = penWidth; update(); } - -signals: - void clicked(); - -public slots: - void setPenWidth(int penWidth) { m_penWidth = penWidth / 10.0; update(); } - void setAnimation(bool animation); - - void setFlatCap() { m_capStyle = Qt::FlatCap; update(); } - void setSquareCap() { m_capStyle = Qt::SquareCap; update(); } - void setRoundCap() { m_capStyle = Qt::RoundCap; update(); } - - void setBevelJoin() { m_joinStyle = Qt::BevelJoin; update(); } - void setMiterJoin() { m_joinStyle = Qt::MiterJoin; update(); } - void setRoundJoin() { m_joinStyle = Qt::RoundJoin; update(); } - - void setCurveMode() { m_pathMode = CurveMode; update(); } - void setLineMode() { m_pathMode = LineMode; update(); } - - void setSolidLine() { m_penStyle = Qt::SolidLine; update(); } - void setDashLine() { m_penStyle = Qt::DashLine; update(); } - void setDotLine() { m_penStyle = Qt::DotLine; update(); } - void setDashDotLine() { m_penStyle = Qt::DashDotLine; update(); } - void setDashDotDotLine() { m_penStyle = Qt::DashDotDotLine; update(); } - void setCustomDashLine() { m_penStyle = Qt::NoPen; update(); } - -private: - void initializePoints(); - void updatePoints(); - - QBasicTimer m_timer; - - PathMode m_pathMode; - - bool m_wasAnimated; - - qreal m_penWidth; - int m_pointCount; - int m_pointSize; - int m_activePoint; - QVector m_points; - QVector m_vectors; - - Qt::PenJoinStyle m_joinStyle; - Qt::PenCapStyle m_capStyle; - - Qt::PenStyle m_penStyle; - - bool m_smallScreen; - QPoint m_mousePress; - bool m_mouseDrag; - - QHash m_fingerPointMapping; -}; - -class PathStrokeControls : public QWidget -{ - Q_OBJECT -public: - PathStrokeControls(QWidget* parent, PathStrokeRenderer* renderer, bool smallScreen); - -signals: - void okPressed(); - void quitPressed(); - -private: - PathStrokeRenderer* m_renderer; - - QGroupBox *m_capGroup; - QGroupBox *m_joinGroup; - QGroupBox *m_styleGroup; - QGroupBox *m_pathModeGroup; - - void createCommonControls(QWidget* parent); - void layoutForDesktop(); - void layoutForSmallScreens(); - -private slots: - void emitQuitSignal(); - void emitOkSignal(); - -}; - -class PathStrokeWidget : public QWidget -{ - Q_OBJECT -public: - PathStrokeWidget(bool smallScreen); - void setStyle ( QStyle * style ); - -private: - PathStrokeRenderer *m_renderer; - PathStrokeControls *m_controls; - -private slots: - void showControls(); - void hideControls(); - -}; - -#endif // PATHSTROKE_H diff --git a/examples/painting/pathstroke/pathstroke.html b/examples/painting/pathstroke/pathstroke.html deleted file mode 100644 index 9e7e50de76..0000000000 --- a/examples/painting/pathstroke/pathstroke.html +++ /dev/null @@ -1,20 +0,0 @@ - -
      -

      Primitive Stroking

      -
      - -

      In this demo we show some of the various types of pens that can be -used in Qt.

      - -

      Qt defines cap styles for how the end points are treated and join -styles for how path segments are joined together. A standard set of -predefined dash patterns are also included that can be used with -QPen.

      - -

      In addition to the predefined patterns available in -QPen we also demonstrate direct use of the -QPainterPathStroker class which can be used to define -custom dash patterns. You can see this by enabling the -Custom Pattern option.

      - - diff --git a/examples/painting/pathstroke/pathstroke.pro b/examples/painting/pathstroke/pathstroke.pro deleted file mode 100644 index 916866d1f2..0000000000 --- a/examples/painting/pathstroke/pathstroke.pro +++ /dev/null @@ -1,21 +0,0 @@ -SOURCES += main.cpp pathstroke.cpp -HEADERS += pathstroke.h - -SHARED_FOLDER = ../shared - -include($$SHARED_FOLDER/shared.pri) - -RESOURCES += pathstroke.qrc - -contains(QT_CONFIG, opengl) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl -} -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/pathstroke -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/pathstroke -INSTALLS += target sources - diff --git a/examples/painting/pathstroke/pathstroke.qrc b/examples/painting/pathstroke/pathstroke.qrc deleted file mode 100644 index a9a723409e..0000000000 --- a/examples/painting/pathstroke/pathstroke.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - pathstroke.cpp - pathstroke.html - - diff --git a/examples/painting/shared/arthurstyle.cpp b/examples/painting/shared/arthurstyle.cpp deleted file mode 100644 index 4bd34464bf..0000000000 --- a/examples/painting/shared/arthurstyle.cpp +++ /dev/null @@ -1,452 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "arthurstyle.h" -#include "arthurwidgets.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QPixmap cached(const QString &img) -{ - if (QPixmap *p = QPixmapCache::find(img)) - return *p; - - QPixmap pm; - pm = QPixmap::fromImage(QImage(img), Qt::OrderedDither | Qt::OrderedAlphaDither); - if (pm.isNull()) - return QPixmap(); - - QPixmapCache::insert(img, pm); - return pm; -} - - -ArthurStyle::ArthurStyle() - : QWindowsStyle() -{ - Q_INIT_RESOURCE(shared); -} - - -void ArthurStyle::drawHoverRect(QPainter *painter, const QRect &r) const -{ - qreal h = r.height(); - qreal h2 = r.height() / qreal(2); - QPainterPath path; - path.addRect(r.x() + h2, r.y() + 0, r.width() - h2 * 2, r.height()); - path.addEllipse(r.x(), r.y(), h, h); - path.addEllipse(r.x() + r.width() - h, r.y(), h, h); - path.setFillRule(Qt::WindingFill); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor(191, 215, 191)); - painter->setRenderHint(QPainter::Antialiasing); - painter->drawPath(path); -} - - -void ArthurStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const -{ - - Q_ASSERT(option); - switch (element) { - case PE_FrameFocusRect: - break; - - case PE_IndicatorRadioButton: - if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); - painter->save(); - QPixmap radio; - if (hover) - drawHoverRect(painter, widget->rect()); - - if (button->state & State_Sunken) - radio = cached(":res/images/radiobutton-on.png"); - else if (button->state & State_On) - radio = cached(":res/images/radiobutton_on.png"); - else - radio = cached(":res/images/radiobutton_off.png"); - painter->drawPixmap(button->rect.topLeft(), radio); - - painter->restore(); - } - break; - - case PE_PanelButtonCommand: - if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); - - painter->save(); - const QPushButton *pushButton = qobject_cast(widget); - Q_ASSERT(pushButton); - QWidget *parent = pushButton->parentWidget(); - if (parent && qobject_cast(parent)) { - QLinearGradient lg(0, 0, 0, parent->height()); - lg.setColorAt(0, QColor(224,224,224)); - lg.setColorAt(1, QColor(255,255,255)); - painter->setPen(Qt::NoPen); - painter->setBrush(lg); - painter->setBrushOrigin(-widget->mapToParent(QPoint(0,0))); - painter->drawRect(button->rect); - painter->setBrushOrigin(0,0); - } - - bool down = (button->state & State_Sunken) || (button->state & State_On); - - QPixmap left, right, mid; - if (down) { - left = cached(":res/images/button_pressed_cap_left.png"); - right = cached(":res/images/button_pressed_cap_right.png"); - mid = cached(":res/images/button_pressed_stretch.png"); - } else { - left = cached(":res/images/button_normal_cap_left.png"); - right = cached(":res/images/button_normal_cap_right.png"); - mid = cached(":res/images/button_normal_stretch.png"); - } - painter->drawPixmap(button->rect.topLeft(), left); - painter->drawTiledPixmap(QRect(button->rect.x() + left.width(), - button->rect.y(), - button->rect.width() - left.width() - right.width(), - left.height()), - mid); - painter->drawPixmap(button->rect.x() + button->rect.width() - right.width(), - button->rect.y(), - right); - if (hover) - painter->fillRect(widget->rect().adjusted(3,5,-3,-5), QColor(31,127,31,63)); - painter->restore(); - } - break; - - case PE_FrameGroupBox: - if (const QStyleOptionFrameV2 *group - = qstyleoption_cast(option)) { - const QRect &r = group->rect; - - painter->save(); - int radius = 14; - int radius2 = radius*2; - QPainterPath clipPath; - clipPath.moveTo(radius, 0); - clipPath.arcTo(r.right() - radius2, 0, radius2, radius2, 90, -90); - clipPath.arcTo(r.right() - radius2, r.bottom() - radius2, radius2, radius2, 0, -90); - clipPath.arcTo(r.left(), r.bottom() - radius2, radius2, radius2, 270, -90); - clipPath.arcTo(r.left(), r.top(), radius2, radius2, 180, -90); - painter->setClipPath(clipPath); - QPixmap titleStretch = cached(":res/images/title_stretch.png"); - QPixmap topLeft = cached(":res/images/groupframe_topleft.png"); - QPixmap topRight = cached(":res/images/groupframe_topright.png"); - QPixmap bottomLeft = cached(":res/images/groupframe_bottom_left.png"); - QPixmap bottomRight = cached(":res/images/groupframe_bottom_right.png"); - QPixmap leftStretch = cached(":res/images/groupframe_left_stretch.png"); - QPixmap topStretch = cached(":res/images/groupframe_top_stretch.png"); - QPixmap rightStretch = cached(":res/images/groupframe_right_stretch.png"); - QPixmap bottomStretch = cached(":res/images/groupframe_bottom_stretch.png"); - QLinearGradient lg(0, 0, 0, r.height()); - lg.setColorAt(0, QColor(224,224,224)); - lg.setColorAt(1, QColor(255,255,255)); - painter->setPen(Qt::NoPen); - painter->setBrush(lg); - painter->drawRect(r.adjusted(0, titleStretch.height()/2, 0, 0)); - painter->setClipping(false); - - int topFrameOffset = titleStretch.height()/2 - 2; - painter->drawPixmap(r.topLeft() + QPoint(0, topFrameOffset), topLeft); - painter->drawPixmap(r.topRight() - QPoint(topRight.width()-1, 0) - + QPoint(0, topFrameOffset), topRight); - painter->drawPixmap(r.bottomLeft() - QPoint(0, bottomLeft.height()-1), bottomLeft); - painter->drawPixmap(r.bottomRight() - QPoint(bottomRight.width()-1, - bottomRight.height()-1), bottomRight); - - QRect left = r; - left.setY(r.y() + topLeft.height() + topFrameOffset); - left.setWidth(leftStretch.width()); - left.setHeight(r.height() - topLeft.height() - bottomLeft.height() - topFrameOffset); - painter->drawTiledPixmap(left, leftStretch); - - QRect top = r; - top.setX(r.x() + topLeft.width()); - top.setY(r.y() + topFrameOffset); - top.setWidth(r.width() - topLeft.width() - topRight.width()); - top.setHeight(topLeft.height()); - painter->drawTiledPixmap(top, topStretch); - - QRect right = r; - right.setX(r.right() - rightStretch.width()+1); - right.setY(r.y() + topRight.height() + topFrameOffset); - right.setWidth(rightStretch.width()); - right.setHeight(r.height() - topRight.height() - - bottomRight.height() - topFrameOffset); - painter->drawTiledPixmap(right, rightStretch); - - QRect bottom = r; - bottom.setX(r.x() + bottomLeft.width()); - bottom.setY(r.bottom() - bottomStretch.height()+1); - bottom.setWidth(r.width() - bottomLeft.width() - bottomRight.width()); - bottom.setHeight(bottomLeft.height()); - painter->drawTiledPixmap(bottom, bottomStretch); - painter->restore(); - } - break; - - default: - QWindowsStyle::drawPrimitive(element, option, painter, widget); - break; - } - return; -} - - -void ArthurStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const -{ - switch (control) { - case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget); - QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget); - - painter->save(); - - bool hover = (slider->state & State_Enabled) && (slider->state & State_MouseOver); - if (hover) { - QRect moderated = widget->rect().adjusted(0, 4, 0, -4); - drawHoverRect(painter, moderated); - } - - if ((option->subControls & SC_SliderGroove) && groove.isValid()) { - QPixmap grv = cached(":res/images/slider_bar.png"); - painter->drawPixmap(QRect(groove.x() + 5, groove.y(), - groove.width() - 10, grv.height()), - grv); - } - if ((option->subControls & SC_SliderHandle) && handle.isValid()) { - QPixmap hndl = cached(":res/images/slider_thumb_on.png"); - painter->drawPixmap(handle.topLeft(), hndl); - } - - painter->restore(); - } - break; - case CC_GroupBox: - if (const QStyleOptionGroupBox *groupBox - = qstyleoption_cast(option)) { - QStyleOptionGroupBox groupBoxCopy(*groupBox); - groupBoxCopy.subControls &= ~SC_GroupBoxLabel; - QWindowsStyle::drawComplexControl(control, &groupBoxCopy, painter, widget); - - if (groupBox->subControls & SC_GroupBoxLabel) { - const QRect &r = groupBox->rect; - QPixmap titleLeft = cached(":res/images/title_cap_left.png"); - QPixmap titleRight = cached(":res/images/title_cap_right.png"); - QPixmap titleStretch = cached(":res/images/title_stretch.png"); - int txt_width = groupBox->fontMetrics.width(groupBox->text) + 20; - painter->drawPixmap(r.center().x() - txt_width/2, 0, titleLeft); - QRect tileRect = subControlRect(control, groupBox, SC_GroupBoxLabel, widget); - painter->drawTiledPixmap(tileRect, titleStretch); - painter->drawPixmap(tileRect.x() + tileRect.width(), 0, titleRight); - int opacity = 31; - painter->setPen(QColor(0, 0, 0, opacity)); - painter->drawText(tileRect.translated(0, 1), - Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); - painter->drawText(tileRect.translated(2, 1), - Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); - painter->setPen(QColor(0, 0, 0, opacity * 2)); - painter->drawText(tileRect.translated(1, 1), - Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); - painter->setPen(Qt::white); - painter->drawText(tileRect, Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); - } - } - break; - default: - QWindowsStyle::drawComplexControl(control, option, painter, widget); - break; - } - return; -} - -QRect ArthurStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, - SubControl subControl, const QWidget *widget) const -{ - QRect rect; - - switch (control) { - default: - rect = QWindowsStyle::subControlRect(control, option, subControl, widget); - break; - case CC_GroupBox: - if (const QStyleOptionGroupBox *group - = qstyleoption_cast(option)) { - switch (subControl) { - default: - rect = QWindowsStyle::subControlRect(control, option, subControl, widget); - break; - case SC_GroupBoxContents: - rect = QWindowsStyle::subControlRect(control, option, subControl, widget); - rect.adjust(0, -8, 0, 0); - break; - case SC_GroupBoxFrame: - rect = group->rect; - break; - case SC_GroupBoxLabel: - QPixmap titleLeft = cached(":res/images/title_cap_left.png"); - QPixmap titleRight = cached(":res/images/title_cap_right.png"); - QPixmap titleStretch = cached(":res/images/title_stretch.png"); - int txt_width = group->fontMetrics.width(group->text) + 20; - rect = QRect(group->rect.center().x() - txt_width/2 + titleLeft.width(), 0, - txt_width - titleLeft.width() - titleRight.width(), - titleStretch.height()); - break; - } - } - break; - } - - if (control == CC_Slider && subControl == SC_SliderHandle) { - rect.setWidth(13); - rect.setHeight(27); - } else if (control == CC_Slider && subControl == SC_SliderGroove) { - rect.setHeight(9); - rect.moveTop(27/2 - 9/2); - } - return rect; -} - -QSize ArthurStyle::sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const -{ - QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); - - - switch (type) { - case CT_RadioButton: - newSize += QSize(20, 0); - break; - - case CT_PushButton: - newSize.setHeight(26); - break; - - case CT_Slider: - newSize.setHeight(27); - break; - - default: - break; - } - - return newSize; -} - -int ArthurStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const -{ - if (pm == PM_SliderLength) - return 13; - return QWindowsStyle::pixelMetric(pm, opt, widget); -} - -void ArthurStyle::polish(QWidget *widget) -{ - if (widget->layout() && qobject_cast(widget)) { - if (widget->findChildren().size() == 0) { - widget->layout()->setSpacing(0); - widget->layout()->setMargin(12); - } else { - widget->layout()->setMargin(13); - } - } - - if (qobject_cast(widget) - || qobject_cast(widget) - || qobject_cast(widget)) { - widget->setAttribute(Qt::WA_Hover); - } - - QPalette pal = widget->palette(); - if (widget->isWindow()) { - pal.setColor(QPalette::Background, QColor(241, 241, 241)); - widget->setPalette(pal); - } - -} - -void ArthurStyle::unpolish(QWidget *widget) -{ - if (qobject_cast(widget) - || qobject_cast(widget) - || qobject_cast(widget)) { - widget->setAttribute(Qt::WA_Hover, false); - } -} - -void ArthurStyle::polish(QPalette &palette) -{ - palette.setColor(QPalette::Background, QColor(241, 241, 241)); -} - -QRect ArthurStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const -{ - QRect r; - switch(element) { - case SE_RadioButtonClickRect: - r = widget->rect(); - break; - case SE_RadioButtonContents: - r = widget->rect().adjusted(20, 0, 0, 0); - break; - default: - r = QWindowsStyle::subElementRect(element, option, widget); - break; - } - - if (qobject_cast(widget)) - r = r.adjusted(5, 0, -5, 0); - - return r; -} diff --git a/examples/painting/shared/arthurstyle.h b/examples/painting/shared/arthurstyle.h deleted file mode 100644 index 1d6a573a4e..0000000000 --- a/examples/painting/shared/arthurstyle.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ARTHURSTYLE_H -#define ARTHURSTYLE_H - -#include - -QT_USE_NAMESPACE - -class ArthurStyle : public QWindowsStyle -{ -public: - ArthurStyle(); - - void drawHoverRect(QPainter *painter, const QRect &rect) const; - - void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0) const; -// void drawControl(ControlElement element, const QStyleOption *option, -// QPainter *painter, const QWidget *widget) const; - void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const; - QSize sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const; - - QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const; - QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget) const; - -// SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, -// const QPoint &pos, const QWidget *widget = 0) const; - - int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const; - - void polish(QPalette &palette); - void polish(QWidget *widget); - void unpolish(QWidget *widget); -}; - -#endif diff --git a/examples/painting/shared/arthurwidgets.cpp b/examples/painting/shared/arthurwidgets.cpp deleted file mode 100644 index cf790fea3b..0000000000 --- a/examples/painting/shared/arthurwidgets.cpp +++ /dev/null @@ -1,355 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "arthurwidgets.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern QPixmap cached(const QString &img); - -ArthurFrame::ArthurFrame(QWidget *parent) - : QWidget(parent) - , m_prefer_image(false) -{ -#ifdef QT_OPENGL_SUPPORT - glw = 0; - m_use_opengl = false; - QGLFormat f = QGLFormat::defaultFormat(); - f.setSampleBuffers(true); - f.setStencil(true); - f.setAlpha(true); - f.setAlphaBufferSize(8); - QGLFormat::setDefaultFormat(f); -#endif - m_document = 0; - m_show_doc = false; - - m_tile = QPixmap(128, 128); - m_tile.fill(Qt::white); - QPainter pt(&m_tile); - QColor color(230, 230, 230); - pt.fillRect(0, 0, 64, 64, color); - pt.fillRect(64, 64, 64, 64, color); - pt.end(); - -// QPalette pal = palette(); -// pal.setBrush(backgroundRole(), m_tile); -// setPalette(pal); -} - - -#ifdef QT_OPENGL_SUPPORT -void ArthurFrame::enableOpenGL(bool use_opengl) -{ - if (m_use_opengl == use_opengl) - return; - - if (!glw && use_opengl) { - glw = new GLWidget(this); - glw->setAutoFillBackground(false); - glw->disableAutoBufferSwap(); - QApplication::postEvent(this, new QResizeEvent(size(), size())); - } - - m_use_opengl = use_opengl; - if (use_opengl) { - glw->show(); - } else { - if (glw) - glw->hide(); - } - - update(); -} -#endif - -void ArthurFrame::paintEvent(QPaintEvent *e) -{ - static QImage *static_image = 0; - QPainter painter; - if (preferImage() -#ifdef QT_OPENGL_SUPPORT - && !m_use_opengl -#endif - ) { - if (!static_image || static_image->size() != size()) { - delete static_image; - static_image = new QImage(size(), QImage::Format_RGB32); - } - painter.begin(static_image); - - int o = 10; - - QBrush bg = palette().brush(QPalette::Background); - painter.fillRect(0, 0, o, o, bg); - painter.fillRect(width() - o, 0, o, o, bg); - painter.fillRect(0, height() - o, o, o, bg); - painter.fillRect(width() - o, height() - o, o, o, bg); - } else { -#ifdef QT_OPENGL_SUPPORT - if (m_use_opengl) { - painter.begin(glw); - painter.fillRect(QRectF(0, 0, glw->width(), glw->height()), palette().color(backgroundRole())); - } else { - painter.begin(this); - } -#else - painter.begin(this); -#endif - } - - painter.setClipRect(e->rect()); - - painter.setRenderHint(QPainter::Antialiasing); - - QPainterPath clipPath; - - QRect r = rect(); - qreal left = r.x() + 1; - qreal top = r.y() + 1; - qreal right = r.right(); - qreal bottom = r.bottom(); - qreal radius2 = 8 * 2; - - clipPath.moveTo(right - radius2, top); - clipPath.arcTo(right - radius2, top, radius2, radius2, 90, -90); - clipPath.arcTo(right - radius2, bottom - radius2, radius2, radius2, 0, -90); - clipPath.arcTo(left, bottom - radius2, radius2, radius2, 270, -90); - clipPath.arcTo(left, top, radius2, radius2, 180, -90); - clipPath.closeSubpath(); - - painter.save(); - painter.setClipPath(clipPath, Qt::IntersectClip); - - painter.drawTiledPixmap(rect(), m_tile); - - // client painting - - paint(&painter); - - painter.restore(); - - painter.save(); - if (m_show_doc) - paintDescription(&painter); - painter.restore(); - - int level = 180; - painter.setPen(QPen(QColor(level, level, level), 2)); - painter.setBrush(Qt::NoBrush); - painter.drawPath(clipPath); - - if (preferImage() -#ifdef QT_OPENGL_SUPPORT - && !m_use_opengl -#endif - ) { - painter.end(); - painter.begin(this); - painter.drawImage(e->rect(), *static_image, e->rect()); - } - -#ifdef QT_OPENGL_SUPPORT - if (m_use_opengl && (inherits("PathDeformRenderer") || inherits("PathStrokeRenderer") || inherits("CompositionRenderer") || m_show_doc)) - glw->swapBuffers(); -#endif -} - -void ArthurFrame::resizeEvent(QResizeEvent *e) -{ -#ifdef QT_OPENGL_SUPPORT - if (glw) - glw->setGeometry(0, 0, e->size().width()-1, e->size().height()-1); -#endif - QWidget::resizeEvent(e); -} - -void ArthurFrame::setDescriptionEnabled(bool enabled) -{ - if (m_show_doc != enabled) { - m_show_doc = enabled; - emit descriptionEnabledChanged(m_show_doc); - update(); - } -} - -void ArthurFrame::loadDescription(const QString &fileName) -{ - QFile textFile(fileName); - QString text; - if (!textFile.open(QFile::ReadOnly)) - text = QString("Unable to load resource file: '%1'").arg(fileName); - else - text = textFile.readAll(); - setDescription(text); -} - - -void ArthurFrame::setDescription(const QString &text) -{ - m_document = new QTextDocument(this); - m_document->setHtml(text); -} - -void ArthurFrame::paintDescription(QPainter *painter) -{ - if (!m_document) - return; - - int pageWidth = qMax(width() - 100, 100); - int pageHeight = qMax(height() - 100, 100); - if (pageWidth != m_document->pageSize().width()) { - m_document->setPageSize(QSize(pageWidth, pageHeight)); - } - - QRect textRect(width() / 2 - pageWidth / 2, - height() / 2 - pageHeight / 2, - pageWidth, - pageHeight); - int pad = 10; - QRect clearRect = textRect.adjusted(-pad, -pad, pad, pad); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor(0, 0, 0, 63)); - int shade = 10; - painter->drawRect(clearRect.x() + clearRect.width() + 1, - clearRect.y() + shade, - shade, - clearRect.height() + 1); - painter->drawRect(clearRect.x() + shade, - clearRect.y() + clearRect.height() + 1, - clearRect.width() - shade + 1, - shade); - - painter->setRenderHint(QPainter::Antialiasing, false); - painter->setBrush(QColor(255, 255, 255, 220)); - painter->setPen(Qt::black); - painter->drawRect(clearRect); - - painter->setClipRegion(textRect, Qt::IntersectClip); - painter->translate(textRect.topLeft()); - - QAbstractTextDocumentLayout::PaintContext ctx; - - QLinearGradient g(0, 0, 0, textRect.height()); - g.setColorAt(0, Qt::black); - g.setColorAt(0.9, Qt::black); - g.setColorAt(1, Qt::transparent); - - QPalette pal = palette(); - pal.setBrush(QPalette::Text, g); - - ctx.palette = pal; - ctx.clip = QRect(0, 0, textRect.width(), textRect.height()); - m_document->documentLayout()->draw(painter, ctx); -} - -void ArthurFrame::loadSourceFile(const QString &sourceFile) -{ - m_sourceFileName = sourceFile; -} - -void ArthurFrame::showSource() -{ - // Check for existing source - if (findChild()) - return; - - QString contents; - if (m_sourceFileName.isEmpty()) { - contents = QString("No source for widget: '%1'").arg(objectName()); - } else { - QFile f(m_sourceFileName); - if (!f.open(QFile::ReadOnly)) - contents = QString("Could not open file: '%1'").arg(m_sourceFileName); - else - contents = f.readAll(); - } - - contents.replace('&', "&"); - contents.replace('<', "<"); - contents.replace('>', ">"); - - QStringList keywords; - keywords << "for " << "if " << "switch " << " int " << "#include " << "const" - << "void " << "uint " << "case " << "double " << "#define " << "static" - << "new" << "this"; - - foreach (QString keyword, keywords) - contents.replace(keyword, QLatin1String("") + keyword + QLatin1String("")); - contents.replace("(int ", "(int "); - - QStringList ppKeywords; - ppKeywords << "#ifdef" << "#ifndef" << "#if" << "#endif" << "#else"; - - foreach (QString keyword, ppKeywords) - contents.replace(keyword, QLatin1String("") + keyword + QLatin1String("")); - - contents.replace(QRegExp("(\\d\\d?)"), QLatin1String("\\1")); - - QRegExp commentRe("(//.+)\\n"); - commentRe.setMinimal(true); - contents.replace(commentRe, QLatin1String("\\1\n")); - - QRegExp stringLiteralRe("(\".+\")"); - stringLiteralRe.setMinimal(true); - contents.replace(stringLiteralRe, QLatin1String("\\1")); - - QString html = contents; - html.prepend("
      ");
      -    html.append("
      "); - - QTextBrowser *sourceViewer = new QTextBrowser(0); - sourceViewer->setWindowTitle("Source: " + m_sourceFileName.mid(5)); - sourceViewer->setParent(this, Qt::Dialog); - sourceViewer->setAttribute(Qt::WA_DeleteOnClose); - sourceViewer->setLineWrapMode(QTextEdit::NoWrap); - sourceViewer->setHtml(html); - sourceViewer->resize(600, 600); - sourceViewer->show(); -} diff --git a/examples/painting/shared/arthurwidgets.h b/examples/painting/shared/arthurwidgets.h deleted file mode 100644 index 28b986dd0b..0000000000 --- a/examples/painting/shared/arthurwidgets.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ARTHURWIDGETS_H -#define ARTHURWIDGETS_H - -#include "arthurstyle.h" -#include -#include -#include - -#if defined(QT_OPENGL_SUPPORT) -#include -#include -class GLWidget : public QGLWidget -{ -public: - GLWidget(QWidget *parent) - : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) - { - setAttribute(Qt::WA_AcceptTouchEvents); - } - void disableAutoBufferSwap() { setAutoBufferSwap(false); } - void paintEvent(QPaintEvent *) { parentWidget()->update(); } -protected: - bool event(QEvent *event) - { - switch (event->type()) { - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - event->ignore(); - return false; - break; - default: - break; - } - return QGLWidget::event(event); - } -}; -#endif - -QT_FORWARD_DECLARE_CLASS(QTextDocument) -QT_FORWARD_DECLARE_CLASS(QTextEdit) -QT_FORWARD_DECLARE_CLASS(QVBoxLayout) - -class ArthurFrame : public QWidget -{ - Q_OBJECT -public: - ArthurFrame(QWidget *parent); - virtual void paint(QPainter *) {} - - - void paintDescription(QPainter *p); - - void loadDescription(const QString &filename); - void setDescription(const QString &htmlDesc); - - void loadSourceFile(const QString &fileName); - - bool preferImage() const { return m_prefer_image; } - -#if defined(QT_OPENGL_SUPPORT) - QGLWidget *glWidget() const { return glw; } -#endif - -public slots: - void setPreferImage(bool pi) { m_prefer_image = pi; } - void setDescriptionEnabled(bool enabled); - void showSource(); - -#if defined(QT_OPENGL_SUPPORT) - void enableOpenGL(bool use_opengl); - bool usesOpenGL() { return m_use_opengl; } -#endif - -signals: - void descriptionEnabledChanged(bool); - -protected: - void paintEvent(QPaintEvent *); - void resizeEvent(QResizeEvent *); - -#if defined(QT_OPENGL_SUPPORT) - GLWidget *glw; - bool m_use_opengl; -#endif - QPixmap m_tile; - - bool m_show_doc; - bool m_prefer_image; - QTextDocument *m_document; - - QString m_sourceFileName; - -}; - -#endif diff --git a/examples/painting/shared/hoverpoints.cpp b/examples/painting/shared/hoverpoints.cpp deleted file mode 100644 index 824d92eb30..0000000000 --- a/examples/painting/shared/hoverpoints.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifdef QT_OPENGL_SUPPORT -#include -#endif - -#include "arthurwidgets.h" -#include "hoverpoints.h" - -#define printf - -HoverPoints::HoverPoints(QWidget *widget, PointShape shape) - : QObject(widget) -{ - m_widget = widget; - widget->installEventFilter(this); - widget->setAttribute(Qt::WA_AcceptTouchEvents); - - m_connectionType = CurveConnection; - m_sortType = NoSort; - m_shape = shape; - m_pointPen = QPen(QColor(255, 255, 255, 191), 1); - m_connectionPen = QPen(QColor(255, 255, 255, 127), 2); - m_pointBrush = QBrush(QColor(191, 191, 191, 127)); - m_pointSize = QSize(11, 11); - m_currentIndex = -1; - m_editable = true; - m_enabled = true; - - connect(this, SIGNAL(pointsChanged(QPolygonF)), - m_widget, SLOT(update())); -} - - -void HoverPoints::setEnabled(bool enabled) -{ - if (m_enabled != enabled) { - m_enabled = enabled; - m_widget->update(); - } -} - - -bool HoverPoints::eventFilter(QObject *object, QEvent *event) -{ - if (object == m_widget && m_enabled) { - switch (event->type()) { - - case QEvent::MouseButtonPress: - { - if (!m_fingerPointMapping.isEmpty()) - return true; - QMouseEvent *me = (QMouseEvent *) event; - - QPointF clickPos = me->pos(); - int index = -1; - for (int i=0; ibutton() == Qt::LeftButton) { - if (index == -1) { - if (!m_editable) - return false; - int pos = 0; - // Insert sort for x or y - if (m_sortType == XSort) { - for (int i=0; i clickPos.x()) { - pos = i; - break; - } - } else if (m_sortType == YSort) { - for (int i=0; i clickPos.y()) { - pos = i; - break; - } - } - - m_points.insert(pos, clickPos); - m_locks.insert(pos, 0); - m_currentIndex = pos; - firePointChange(); - } else { - m_currentIndex = index; - } - return true; - - } else if (me->button() == Qt::RightButton) { - if (index >= 0 && m_editable) { - if (m_locks[index] == 0) { - m_locks.remove(index); - m_points.remove(index); - } - firePointChange(); - return true; - } - } - - } - break; - - case QEvent::MouseButtonRelease: - if (!m_fingerPointMapping.isEmpty()) - return true; - m_currentIndex = -1; - break; - - case QEvent::MouseMove: - if (!m_fingerPointMapping.isEmpty()) - return true; - if (m_currentIndex >= 0) - movePoint(m_currentIndex, ((QMouseEvent *)event)->pos()); - break; - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - { - const QTouchEvent *const touchEvent = static_cast(event); - const QList points = touchEvent->touchPoints(); - const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); - foreach (const QTouchEvent::TouchPoint &touchPoint, points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: - { - // find the point, move it - QSet activePoints = QSet::fromList(m_fingerPointMapping.values()); - int activePoint = -1; - qreal distance = -1; - const int pointsCount = m_points.size(); - const int activePointCount = activePoints.size(); - if (pointsCount == 2 && activePointCount == 1) { // only two points - activePoint = activePoints.contains(0) ? 1 : 0; - } else { - for (int i=0; i::iterator it = m_fingerPointMapping.find(id); - movePoint(it.value(), touchPoint.pos()); - m_fingerPointMapping.erase(it); - } - break; - case Qt::TouchPointMoved: - { - // move the point - const int pointIdx = m_fingerPointMapping.value(id, -1); - if (pointIdx >= 0) // do we track this point? - movePoint(pointIdx, touchPoint.pos()); - } - break; - default: - break; - } - } - if (m_fingerPointMapping.isEmpty()) { - event->ignore(); - return false; - } else { - return true; - } - } - break; - case QEvent::TouchEnd: - if (m_fingerPointMapping.isEmpty()) { - event->ignore(); - return false; - } - return true; - break; - - case QEvent::Resize: - { - QResizeEvent *e = (QResizeEvent *) event; - if (e->oldSize().width() == 0 || e->oldSize().height() == 0) - break; - qreal stretch_x = e->size().width() / qreal(e->oldSize().width()); - qreal stretch_y = e->size().height() / qreal(e->oldSize().height()); - for (int i=0; i(that_widget); - if (af && af->usesOpenGL()) - af->glWidget()->swapBuffers(); -#endif - return true; - } - default: - break; - } - } - - return false; -} - - -void HoverPoints::paintPoints() -{ - QPainter p; -#ifdef QT_OPENGL_SUPPORT - ArthurFrame *af = qobject_cast(m_widget); - if (af && af->usesOpenGL()) - p.begin(af->glWidget()); - else - p.begin(m_widget); -#else - p.begin(m_widget); -#endif - - p.setRenderHint(QPainter::Antialiasing); - - if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection) { - p.setPen(m_connectionPen); - - if (m_connectionType == CurveConnection) { - QPainterPath path; - path.moveTo(m_points.at(0)); - for (int i=1; i right || (lock & HoverPoints::LockToRight)) p.setX(right); - - if (p.y() < top || (lock & HoverPoints::LockToTop)) p.setY(top); - else if (p.y() > bottom || (lock & HoverPoints::LockToBottom)) p.setY(bottom); - - return p; -} - -void HoverPoints::setPoints(const QPolygonF &points) -{ - if (points.size() != m_points.size()) - m_fingerPointMapping.clear(); - m_points.clear(); - for (int i=0; i 0) { - m_locks.resize(m_points.size()); - - m_locks.fill(0); - } -} - - -void HoverPoints::movePoint(int index, const QPointF &point, bool emitUpdate) -{ - m_points[index] = bound_point(point, boundingRect(), m_locks.at(index)); - if (emitUpdate) - firePointChange(); -} - - -inline static bool x_less_than(const QPointF &p1, const QPointF &p2) -{ - return p1.x() < p2.x(); -} - - -inline static bool y_less_than(const QPointF &p1, const QPointF &p2) -{ - return p1.y() < p2.y(); -} - -void HoverPoints::firePointChange() -{ -// printf("HoverPoints::firePointChange(), current=%d\n", m_currentIndex); - - if (m_sortType != NoSort) { - - QPointF oldCurrent; - if (m_currentIndex != -1) { - oldCurrent = m_points[m_currentIndex]; - } - - if (m_sortType == XSort) - qSort(m_points.begin(), m_points.end(), x_less_than); - else if (m_sortType == YSort) - qSort(m_points.begin(), m_points.end(), y_less_than); - - // Compensate for changed order... - if (m_currentIndex != -1) { - for (int i=0; i - -QT_FORWARD_DECLARE_CLASS(QBypassWidget) - -class HoverPoints : public QObject -{ - Q_OBJECT -public: - enum PointShape { - CircleShape, - RectangleShape - }; - - enum LockType { - LockToLeft = 0x01, - LockToRight = 0x02, - LockToTop = 0x04, - LockToBottom = 0x08 - }; - - enum SortType { - NoSort, - XSort, - YSort - }; - - enum ConnectionType { - NoConnection, - LineConnection, - CurveConnection - }; - - HoverPoints(QWidget *widget, PointShape shape); - - bool eventFilter(QObject *object, QEvent *event); - - void paintPoints(); - - inline QRectF boundingRect() const; - void setBoundingRect(const QRectF &boundingRect) { m_bounds = boundingRect; } - - QPolygonF points() const { return m_points; } - void setPoints(const QPolygonF &points); - - QSizeF pointSize() const { return m_pointSize; } - void setPointSize(const QSizeF &size) { m_pointSize = size; } - - SortType sortType() const { return m_sortType; } - void setSortType(SortType sortType) { m_sortType = sortType; } - - ConnectionType connectionType() const { return m_connectionType; } - void setConnectionType(ConnectionType connectionType) { m_connectionType = connectionType; } - - void setConnectionPen(const QPen &pen) { m_connectionPen = pen; } - void setShapePen(const QPen &pen) { m_pointPen = pen; } - void setShapeBrush(const QBrush &brush) { m_pointBrush = brush; } - - void setPointLock(int pos, LockType lock) { m_locks[pos] = lock; } - - void setEditable(bool editable) { m_editable = editable; } - bool editable() const { return m_editable; } - -public slots: - void setEnabled(bool enabled); - void setDisabled(bool disabled) { setEnabled(!disabled); } - -signals: - void pointsChanged(const QPolygonF &points); - -public: - void firePointChange(); - -private: - inline QRectF pointBoundingRect(int i) const; - void movePoint(int i, const QPointF &newPos, bool emitChange = true); - - QWidget *m_widget; - - QPolygonF m_points; - QRectF m_bounds; - PointShape m_shape; - SortType m_sortType; - ConnectionType m_connectionType; - - QVector m_locks; - - QSizeF m_pointSize; - int m_currentIndex; - bool m_editable; - bool m_enabled; - - QHash m_fingerPointMapping; - - QPen m_pointPen; - QBrush m_pointBrush; - QPen m_connectionPen; -}; - - -inline QRectF HoverPoints::pointBoundingRect(int i) const -{ - QPointF p = m_points.at(i); - qreal w = m_pointSize.width(); - qreal h = m_pointSize.height(); - qreal x = p.x() - w / 2; - qreal y = p.y() - h / 2; - return QRectF(x, y, w, h); -} - -inline QRectF HoverPoints::boundingRect() const -{ - if (m_bounds.isEmpty()) - return m_widget->rect(); - else - return m_bounds; -} - -#endif // HOVERPOINTS_H diff --git a/examples/painting/shared/images/bg_pattern.png b/examples/painting/shared/images/bg_pattern.png deleted file mode 100644 index ee670266f0..0000000000 Binary files a/examples/painting/shared/images/bg_pattern.png and /dev/null differ diff --git a/examples/painting/shared/images/button_normal_cap_left.png b/examples/painting/shared/images/button_normal_cap_left.png deleted file mode 100644 index db31dd971d..0000000000 Binary files a/examples/painting/shared/images/button_normal_cap_left.png and /dev/null differ diff --git a/examples/painting/shared/images/button_normal_cap_right.png b/examples/painting/shared/images/button_normal_cap_right.png deleted file mode 100644 index 38ead1c719..0000000000 Binary files a/examples/painting/shared/images/button_normal_cap_right.png and /dev/null differ diff --git a/examples/painting/shared/images/button_normal_stretch.png b/examples/painting/shared/images/button_normal_stretch.png deleted file mode 100644 index 87abe67ac9..0000000000 Binary files a/examples/painting/shared/images/button_normal_stretch.png and /dev/null differ diff --git a/examples/painting/shared/images/button_pressed_cap_left.png b/examples/painting/shared/images/button_pressed_cap_left.png deleted file mode 100644 index 66bfc13cb4..0000000000 Binary files a/examples/painting/shared/images/button_pressed_cap_left.png and /dev/null differ diff --git a/examples/painting/shared/images/button_pressed_cap_right.png b/examples/painting/shared/images/button_pressed_cap_right.png deleted file mode 100644 index 3d4cfe25b1..0000000000 Binary files a/examples/painting/shared/images/button_pressed_cap_right.png and /dev/null differ diff --git a/examples/painting/shared/images/button_pressed_stretch.png b/examples/painting/shared/images/button_pressed_stretch.png deleted file mode 100644 index 4dd4ad11e6..0000000000 Binary files a/examples/painting/shared/images/button_pressed_stretch.png and /dev/null differ diff --git a/examples/painting/shared/images/curve_thing_edit-6.png b/examples/painting/shared/images/curve_thing_edit-6.png deleted file mode 100644 index 034b474d02..0000000000 Binary files a/examples/painting/shared/images/curve_thing_edit-6.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_bottom.png b/examples/painting/shared/images/frame_bottom.png deleted file mode 100644 index 889b40d304..0000000000 Binary files a/examples/painting/shared/images/frame_bottom.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_bottomleft.png b/examples/painting/shared/images/frame_bottomleft.png deleted file mode 100644 index 0b3023f397..0000000000 Binary files a/examples/painting/shared/images/frame_bottomleft.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_bottomright.png b/examples/painting/shared/images/frame_bottomright.png deleted file mode 100644 index 0021e35864..0000000000 Binary files a/examples/painting/shared/images/frame_bottomright.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_left.png b/examples/painting/shared/images/frame_left.png deleted file mode 100644 index 40f331c293..0000000000 Binary files a/examples/painting/shared/images/frame_left.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_right.png b/examples/painting/shared/images/frame_right.png deleted file mode 100644 index 023af8c700..0000000000 Binary files a/examples/painting/shared/images/frame_right.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_top.png b/examples/painting/shared/images/frame_top.png deleted file mode 100644 index 001f3a7144..0000000000 Binary files a/examples/painting/shared/images/frame_top.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_topleft.png b/examples/painting/shared/images/frame_topleft.png deleted file mode 100644 index 58c68d407a..0000000000 Binary files a/examples/painting/shared/images/frame_topleft.png and /dev/null differ diff --git a/examples/painting/shared/images/frame_topright.png b/examples/painting/shared/images/frame_topright.png deleted file mode 100644 index 6a7e8d3eb3..0000000000 Binary files a/examples/painting/shared/images/frame_topright.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_bottom_left.png b/examples/painting/shared/images/groupframe_bottom_left.png deleted file mode 100644 index af2fe061e3..0000000000 Binary files a/examples/painting/shared/images/groupframe_bottom_left.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_bottom_right.png b/examples/painting/shared/images/groupframe_bottom_right.png deleted file mode 100644 index fdf2e97b13..0000000000 Binary files a/examples/painting/shared/images/groupframe_bottom_right.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_bottom_stretch.png b/examples/painting/shared/images/groupframe_bottom_stretch.png deleted file mode 100644 index f47b67d7c0..0000000000 Binary files a/examples/painting/shared/images/groupframe_bottom_stretch.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_left_stretch.png b/examples/painting/shared/images/groupframe_left_stretch.png deleted file mode 100644 index c122f462ed..0000000000 Binary files a/examples/painting/shared/images/groupframe_left_stretch.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_right_stretch.png b/examples/painting/shared/images/groupframe_right_stretch.png deleted file mode 100644 index 1056b7812a..0000000000 Binary files a/examples/painting/shared/images/groupframe_right_stretch.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_top_stretch.png b/examples/painting/shared/images/groupframe_top_stretch.png deleted file mode 100644 index 5746ef96fc..0000000000 Binary files a/examples/painting/shared/images/groupframe_top_stretch.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_topleft.png b/examples/painting/shared/images/groupframe_topleft.png deleted file mode 100644 index 98d9cd96b4..0000000000 Binary files a/examples/painting/shared/images/groupframe_topleft.png and /dev/null differ diff --git a/examples/painting/shared/images/groupframe_topright.png b/examples/painting/shared/images/groupframe_topright.png deleted file mode 100644 index 1a0a328c20..0000000000 Binary files a/examples/painting/shared/images/groupframe_topright.png and /dev/null differ diff --git a/examples/painting/shared/images/line_dash_dot.png b/examples/painting/shared/images/line_dash_dot.png deleted file mode 100644 index 1c61442d9f..0000000000 Binary files a/examples/painting/shared/images/line_dash_dot.png and /dev/null differ diff --git a/examples/painting/shared/images/line_dash_dot_dot.png b/examples/painting/shared/images/line_dash_dot_dot.png deleted file mode 100644 index 0d9bb972f9..0000000000 Binary files a/examples/painting/shared/images/line_dash_dot_dot.png and /dev/null differ diff --git a/examples/painting/shared/images/line_dashed.png b/examples/painting/shared/images/line_dashed.png deleted file mode 100644 index d5bc7ea5fe..0000000000 Binary files a/examples/painting/shared/images/line_dashed.png and /dev/null differ diff --git a/examples/painting/shared/images/line_dotted.png b/examples/painting/shared/images/line_dotted.png deleted file mode 100644 index a2f9a35925..0000000000 Binary files a/examples/painting/shared/images/line_dotted.png and /dev/null differ diff --git a/examples/painting/shared/images/line_solid.png b/examples/painting/shared/images/line_solid.png deleted file mode 100644 index 60ef3f9485..0000000000 Binary files a/examples/painting/shared/images/line_solid.png and /dev/null differ diff --git a/examples/painting/shared/images/radiobutton-off.png b/examples/painting/shared/images/radiobutton-off.png deleted file mode 100644 index af1753a3e7..0000000000 Binary files a/examples/painting/shared/images/radiobutton-off.png and /dev/null differ diff --git a/examples/painting/shared/images/radiobutton-on.png b/examples/painting/shared/images/radiobutton-on.png deleted file mode 100644 index f875838bb5..0000000000 Binary files a/examples/painting/shared/images/radiobutton-on.png and /dev/null differ diff --git a/examples/painting/shared/images/radiobutton_off.png b/examples/painting/shared/images/radiobutton_off.png deleted file mode 100644 index 400906ebfa..0000000000 Binary files a/examples/painting/shared/images/radiobutton_off.png and /dev/null differ diff --git a/examples/painting/shared/images/radiobutton_on.png b/examples/painting/shared/images/radiobutton_on.png deleted file mode 100644 index 50a049ec56..0000000000 Binary files a/examples/painting/shared/images/radiobutton_on.png and /dev/null differ diff --git a/examples/painting/shared/images/slider_bar.png b/examples/painting/shared/images/slider_bar.png deleted file mode 100644 index 1b3d62c007..0000000000 Binary files a/examples/painting/shared/images/slider_bar.png and /dev/null differ diff --git a/examples/painting/shared/images/slider_thumb_off.png b/examples/painting/shared/images/slider_thumb_off.png deleted file mode 100644 index d7f141daef..0000000000 Binary files a/examples/painting/shared/images/slider_thumb_off.png and /dev/null differ diff --git a/examples/painting/shared/images/slider_thumb_on.png b/examples/painting/shared/images/slider_thumb_on.png deleted file mode 100644 index 8e1f510813..0000000000 Binary files a/examples/painting/shared/images/slider_thumb_on.png and /dev/null differ diff --git a/examples/painting/shared/images/title_cap_left.png b/examples/painting/shared/images/title_cap_left.png deleted file mode 100644 index 2d475070c8..0000000000 Binary files a/examples/painting/shared/images/title_cap_left.png and /dev/null differ diff --git a/examples/painting/shared/images/title_cap_right.png b/examples/painting/shared/images/title_cap_right.png deleted file mode 100644 index dc3ff8536c..0000000000 Binary files a/examples/painting/shared/images/title_cap_right.png and /dev/null differ diff --git a/examples/painting/shared/images/title_stretch.png b/examples/painting/shared/images/title_stretch.png deleted file mode 100644 index 11043345d0..0000000000 Binary files a/examples/painting/shared/images/title_stretch.png and /dev/null differ diff --git a/examples/painting/shared/shared.pri b/examples/painting/shared/shared.pri deleted file mode 100644 index 2d6b3c78f9..0000000000 --- a/examples/painting/shared/shared.pri +++ /dev/null @@ -1,20 +0,0 @@ -INCLUDEPATH += $$SHARED_FOLDER - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} -contains(CONFIG, debug_and_release_target) { - CONFIG(debug, debug|release) { - QMAKE_LIBDIR += $$SHARED_FOLDER/debug - } else { - QMAKE_LIBDIR += $$SHARED_FOLDER/release - } -} else { - QMAKE_LIBDIR += $$SHARED_FOLDER -} - -hpux-acc*:LIBS += $$SHARED_FOLDER/libdemo_shared.a -hpuxi-acc*:LIBS += $$SHARED_FOLDER/libdemo_shared.a -!hpuxi-acc*:!hpux-acc*:LIBS += -ldemo_shared - diff --git a/examples/painting/shared/shared.pro b/examples/painting/shared/shared.pro deleted file mode 100644 index 212f3a20d7..0000000000 --- a/examples/painting/shared/shared.pro +++ /dev/null @@ -1,34 +0,0 @@ -TEMPLATE = lib -CONFIG += static - -contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl widgets -} - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} -TARGET = demo_shared -QT += widgets - -SOURCES += \ - arthurstyle.cpp\ - arthurwidgets.cpp \ - hoverpoints.cpp - -HEADERS += \ - arthurstyle.h \ - arthurwidgets.h \ - hoverpoints.h - -RESOURCES += shared.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/shared -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.pri images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/shared -INSTALLS += sources - -!cross_compile:INSTALLS += target diff --git a/examples/painting/shared/shared.qrc b/examples/painting/shared/shared.qrc deleted file mode 100644 index 17336ecf80..0000000000 --- a/examples/painting/shared/shared.qrc +++ /dev/null @@ -1,39 +0,0 @@ - - - images/button_normal_cap_left.png - images/button_normal_cap_right.png - images/button_normal_stretch.png - images/button_pressed_cap_left.png - images/button_pressed_cap_right.png - images/button_pressed_stretch.png - images/radiobutton-on.png - images/radiobutton_on.png - images/radiobutton_off.png - images/slider_bar.png - images/slider_thumb_on.png - images/groupframe_topleft.png - images/groupframe_topright.png - images/groupframe_bottom_left.png - images/groupframe_bottom_right.png - images/groupframe_top_stretch.png - images/groupframe_bottom_stretch.png - images/groupframe_left_stretch.png - images/groupframe_right_stretch.png - images/frame_topleft.png - images/frame_topright.png - images/frame_bottomleft.png - images/frame_bottomright.png - images/frame_left.png - images/frame_top.png - images/frame_right.png - images/frame_bottom.png - images/title_cap_left.png - images/title_cap_right.png - images/title_stretch.png - images/line_dash_dot.png - images/line_dotted.png - images/line_dashed.png - images/line_solid.png - images/line_dash_dot_dot.png - - diff --git a/examples/painting/svggenerator/svggenerator.desktop b/examples/painting/svggenerator/svggenerator.desktop deleted file mode 100644 index 3ae32a4908..0000000000 --- a/examples/painting/svggenerator/svggenerator.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=SVG Generator -Exec=/opt/usr/bin/svggenerator -Icon=svggenerator -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/svgviewer/svgviewer.desktop b/examples/painting/svgviewer/svgviewer.desktop deleted file mode 100644 index 477ef789d8..0000000000 --- a/examples/painting/svgviewer/svgviewer.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=SVG Viewer -Exec=/opt/usr/bin/svgviewer -Icon=svgviewer -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/transformations/main.cpp b/examples/painting/transformations/main.cpp deleted file mode 100644 index dcbf1c0449..0000000000 --- a/examples/painting/transformations/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#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/transformations/renderarea.cpp b/examples/painting/transformations/renderarea.cpp deleted file mode 100644 index 58be8143c3..0000000000 --- a/examples/painting/transformations/renderarea.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "renderarea.h" - -//! [0] -RenderArea::RenderArea(QWidget *parent) - : QWidget(parent) -{ - QFont newFont = font(); - newFont.setPixelSize(12); - setFont(newFont); - - QFontMetrics fontMetrics(newFont); - xBoundingRect = fontMetrics.boundingRect(tr("x")); - yBoundingRect = fontMetrics.boundingRect(tr("y")); -} -//! [0] - -//! [1] -void RenderArea::setOperations(const QList &operations) -{ - this->operations = operations; - update(); -} -//! [1] - -//! [2] -void RenderArea::setShape(const QPainterPath &shape) -{ - this->shape = shape; - update(); -} -//! [2] - -//! [3] -QSize RenderArea::minimumSizeHint() const -{ - return QSize(182, 182); -} -//! [3] - -//! [4] -QSize RenderArea::sizeHint() const -{ - return QSize(232, 232); -} -//! [4] - -//! [5] -void RenderArea::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.fillRect(event->rect(), QBrush(Qt::white)); - - painter.translate(66, 66); -//! [5] - -//! [6] - painter.save(); - transformPainter(painter); - drawShape(painter); - painter.restore(); -//! [6] - -//! [7] - drawOutline(painter); -//! [7] - -//! [8] - transformPainter(painter); - drawCoordinates(painter); -} -//! [8] - -//! [9] -void RenderArea::drawCoordinates(QPainter &painter) -{ - painter.setPen(Qt::red); - - painter.drawLine(0, 0, 50, 0); - painter.drawLine(48, -2, 50, 0); - painter.drawLine(48, 2, 50, 0); - painter.drawText(60 - xBoundingRect.width() / 2, - 0 + xBoundingRect.height() / 2, tr("x")); - - painter.drawLine(0, 0, 0, 50); - painter.drawLine(-2, 48, 0, 50); - painter.drawLine(2, 48, 0, 50); - painter.drawText(0 - yBoundingRect.width() / 2, - 60 + yBoundingRect.height() / 2, tr("y")); -} -//! [9] - -//! [10] -void RenderArea::drawOutline(QPainter &painter) -{ - painter.setPen(Qt::darkGreen); - painter.setPen(Qt::DashLine); - painter.setBrush(Qt::NoBrush); - painter.drawRect(0, 0, 100, 100); -} -//! [10] - -//! [11] -void RenderArea::drawShape(QPainter &painter) -{ - painter.fillPath(shape, Qt::blue); -} -//! [11] - -//! [12] -void RenderArea::transformPainter(QPainter &painter) -{ - for (int i = 0; i < operations.size(); ++i) { - switch (operations[i]) { - case Translate: - painter.translate(50, 50); - break; - case Scale: - painter.scale(0.75, 0.75); - break; - case Rotate: - painter.rotate(60); - break; - case NoTransformation: - default: - ; - } - } -} -//! [12] diff --git a/examples/painting/transformations/renderarea.h b/examples/painting/transformations/renderarea.h deleted file mode 100644 index adc6c1ad7f..0000000000 --- a/examples/painting/transformations/renderarea.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 RENDERAREA_H -#define RENDERAREA_H - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QPaintEvent; -QT_END_NAMESPACE - -//! [0] -enum Operation { NoTransformation, Translate, Rotate, Scale }; -//! [0] - -//! [1] -class RenderArea : public QWidget -{ - Q_OBJECT - -public: - RenderArea(QWidget *parent = 0); - - void setOperations(const QList &operations); - void setShape(const QPainterPath &shape); - - QSize minimumSizeHint() const; - QSize sizeHint() const; - -protected: - void paintEvent(QPaintEvent *event); -//! [1] - -//! [2] -private: - void drawCoordinates(QPainter &painter); - void drawOutline(QPainter &painter); - void drawShape(QPainter &painter); - void transformPainter(QPainter &painter); - - QList operations; - QPainterPath shape; - QRect xBoundingRect; - QRect yBoundingRect; -}; -//! [2] - -#endif diff --git a/examples/painting/transformations/transformations.desktop b/examples/painting/transformations/transformations.desktop deleted file mode 100644 index 2f53891069..0000000000 --- a/examples/painting/transformations/transformations.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Transformations -Exec=/opt/usr/bin/transformations -Icon=transformations -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/painting/transformations/transformations.pro b/examples/painting/transformations/transformations.pro deleted file mode 100644 index a261c53371..0000000000 --- a/examples/painting/transformations/transformations.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = renderarea.h \ - window.h -SOURCES = main.cpp \ - renderarea.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/transformations -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS transformations.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/transformations -INSTALLS += target sources - -QT += widgets diff --git a/examples/painting/transformations/window.cpp b/examples/painting/transformations/window.cpp deleted file mode 100644 index 5f9296be7f..0000000000 --- a/examples/painting/transformations/window.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "window.h" - -//! [0] -Window::Window() -{ - originalRenderArea = new RenderArea; - - shapeComboBox = new QComboBox; - shapeComboBox->addItem(tr("Clock")); - shapeComboBox->addItem(tr("House")); - shapeComboBox->addItem(tr("Text")); - shapeComboBox->addItem(tr("Truck")); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(originalRenderArea, 0, 0); - layout->addWidget(shapeComboBox, 1, 0); -//! [0] - -//! [1] - for (int i = 0; i < NumTransformedAreas; ++i) { - transformedRenderAreas[i] = new RenderArea; - - operationComboBoxes[i] = new QComboBox; - operationComboBoxes[i]->addItem(tr("No transformation")); - operationComboBoxes[i]->addItem(tr("Rotate by 60\xC2\xB0")); - operationComboBoxes[i]->addItem(tr("Scale to 75%")); - operationComboBoxes[i]->addItem(tr("Translate by (50, 50)")); - - connect(operationComboBoxes[i], SIGNAL(activated(int)), - this, SLOT(operationChanged())); - - layout->addWidget(transformedRenderAreas[i], 0, i + 1); - layout->addWidget(operationComboBoxes[i], 1, i + 1); - } -//! [1] - -//! [2] - setLayout(layout); - setupShapes(); - shapeSelected(0); - - setWindowTitle(tr("Transformations")); -} -//! [2] - -//! [3] -void Window::setupShapes() -{ - QPainterPath truck; -//! [3] - truck.setFillRule(Qt::WindingFill); - truck.moveTo(0.0, 87.0); - truck.lineTo(0.0, 60.0); - truck.lineTo(10.0, 60.0); - truck.lineTo(35.0, 35.0); - truck.lineTo(100.0, 35.0); - truck.lineTo(100.0, 87.0); - truck.lineTo(0.0, 87.0); - truck.moveTo(17.0, 60.0); - truck.lineTo(55.0, 60.0); - truck.lineTo(55.0, 40.0); - truck.lineTo(37.0, 40.0); - truck.lineTo(17.0, 60.0); - truck.addEllipse(17.0, 75.0, 25.0, 25.0); - truck.addEllipse(63.0, 75.0, 25.0, 25.0); - -//! [4] - QPainterPath clock; -//! [4] - clock.addEllipse(-50.0, -50.0, 100.0, 100.0); - clock.addEllipse(-48.0, -48.0, 96.0, 96.0); - clock.moveTo(0.0, 0.0); - clock.lineTo(-2.0, -2.0); - clock.lineTo(0.0, -42.0); - clock.lineTo(2.0, -2.0); - clock.lineTo(0.0, 0.0); - clock.moveTo(0.0, 0.0); - clock.lineTo(2.732, -0.732); - clock.lineTo(24.495, 14.142); - clock.lineTo(0.732, 2.732); - clock.lineTo(0.0, 0.0); - -//! [5] - QPainterPath house; -//! [5] - house.moveTo(-45.0, -20.0); - house.lineTo(0.0, -45.0); - house.lineTo(45.0, -20.0); - house.lineTo(45.0, 45.0); - house.lineTo(-45.0, 45.0); - house.lineTo(-45.0, -20.0); - house.addRect(15.0, 5.0, 20.0, 35.0); - house.addRect(-35.0, -15.0, 25.0, 25.0); - -//! [6] - QPainterPath text; -//! [6] - QFont font; - font.setPixelSize(50); - QRect fontBoundingRect = QFontMetrics(font).boundingRect(tr("Qt")); - text.addText(-QPointF(fontBoundingRect.center()), font, tr("Qt")); - -//! [7] - shapes.append(clock); - shapes.append(house); - shapes.append(text); - shapes.append(truck); - - connect(shapeComboBox, SIGNAL(activated(int)), - this, SLOT(shapeSelected(int))); -} -//! [7] - -//! [8] -void Window::operationChanged() -{ - static const Operation operationTable[] = { - NoTransformation, Rotate, Scale, Translate - }; - - QList operations; - for (int i = 0; i < NumTransformedAreas; ++i) { - int index = operationComboBoxes[i]->currentIndex(); - operations.append(operationTable[index]); - transformedRenderAreas[i]->setOperations(operations); - } -} -//! [8] - -//! [9] -void Window::shapeSelected(int index) -{ - QPainterPath shape = shapes[index]; - originalRenderArea->setShape(shape); - for (int i = 0; i < NumTransformedAreas; ++i) - transformedRenderAreas[i]->setShape(shape); -} -//! [9] diff --git a/examples/painting/transformations/window.h b/examples/painting/transformations/window.h deleted file mode 100644 index f28e53e494..0000000000 --- a/examples/painting/transformations/window.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include - -#include "renderarea.h" - -QT_BEGIN_NAMESPACE -class QComboBox; -QT_END_NAMESPACE - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -public slots: - void operationChanged(); - void shapeSelected(int index); -//! [0] - -//! [1] -private: - void setupShapes(); - - enum { NumTransformedAreas = 3 }; - RenderArea *originalRenderArea; - RenderArea *transformedRenderAreas[NumTransformedAreas]; - QComboBox *shapeComboBox; - QComboBox *operationComboBoxes[NumTransformedAreas]; - QList shapes; -}; -//! [1] - -#endif diff --git a/examples/richtext/README b/examples/richtext/README deleted file mode 100644 index 647029b8a2..0000000000 --- a/examples/richtext/README +++ /dev/null @@ -1,11 +0,0 @@ -Qt provides powerful document-oriented rich text engine that supports Unicode -and right-to-left scripts. Documents can be manipulated using a cursor-based -API, and their contents can be imported and exported as both HTML and in a -custom XML format. - -Text is rendered using anti-aliased outline fonts to provide the best -possible on-screen representation. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/richtext/calendar/calendar.desktop b/examples/richtext/calendar/calendar.desktop deleted file mode 100644 index 41ba6dd95a..0000000000 --- a/examples/richtext/calendar/calendar.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Calendar -Exec=/opt/usr/bin/calendar -Icon=calendar -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/richtext/calendar/calendar.pro b/examples/richtext/calendar/calendar.pro deleted file mode 100644 index 3867a027cf..0000000000 --- a/examples/richtext/calendar/calendar.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/calendar -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS calendar.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/calendar -INSTALLS += target sources - -QT += widgets diff --git a/examples/richtext/calendar/main.cpp b/examples/richtext/calendar/main.cpp deleted file mode 100644 index 35b6b90c13..0000000000 --- a/examples/richtext/calendar/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.resize(640, 256); - window.show(); - return app.exec(); -} diff --git a/examples/richtext/calendar/mainwindow.cpp b/examples/richtext/calendar/mainwindow.cpp deleted file mode 100644 index 366ebff2a9..0000000000 --- a/examples/richtext/calendar/mainwindow.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -//! [0] -MainWindow::MainWindow() -{ - selectedDate = QDate::currentDate(); - fontSize = 10; - - QWidget *centralWidget = new QWidget; -//! [0] - -//! [1] - QLabel *dateLabel = new QLabel(tr("Date:")); - QComboBox *monthCombo = new QComboBox; - - for (int month = 1; month <= 12; ++month) - monthCombo->addItem(QDate::longMonthName(month)); - - QDateTimeEdit *yearEdit = new QDateTimeEdit; - yearEdit->setDisplayFormat("yyyy"); - yearEdit->setDateRange(QDate(1753, 1, 1), QDate(8000, 1, 1)); -//! [1] - - monthCombo->setCurrentIndex(selectedDate.month() - 1); - yearEdit->setDate(selectedDate); - -//! [2] - QLabel *fontSizeLabel = new QLabel(tr("Font size:")); - QSpinBox *fontSizeSpinBox = new QSpinBox; - fontSizeSpinBox->setRange(1, 64); - - editor = new QTextBrowser; - insertCalendar(); -//! [2] - -//! [3] - connect(monthCombo, SIGNAL(activated(int)), this, SLOT(setMonth(int))); - connect(yearEdit, SIGNAL(dateChanged(QDate)), this, SLOT(setYear(QDate))); - connect(fontSizeSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(setFontSize(int))); -//! [3] - - fontSizeSpinBox->setValue(10); - -//! [4] - QHBoxLayout *controlsLayout = new QHBoxLayout; - controlsLayout->addWidget(dateLabel); - controlsLayout->addWidget(monthCombo); - controlsLayout->addWidget(yearEdit); - controlsLayout->addSpacing(24); - controlsLayout->addWidget(fontSizeLabel); - controlsLayout->addWidget(fontSizeSpinBox); - controlsLayout->addStretch(1); - - QVBoxLayout *centralLayout = new QVBoxLayout; - centralLayout->addLayout(controlsLayout); - centralLayout->addWidget(editor, 1); - centralWidget->setLayout(centralLayout); - - setCentralWidget(centralWidget); -//! [4] -} - -//! [5] -void MainWindow::insertCalendar() -{ - editor->clear(); - QTextCursor cursor = editor->textCursor(); - cursor.beginEditBlock(); - - QDate date(selectedDate.year(), selectedDate.month(), 1); -//! [5] - -//! [6] - QTextTableFormat tableFormat; - tableFormat.setAlignment(Qt::AlignHCenter); - tableFormat.setBackground(QColor("#e0e0e0")); - tableFormat.setCellPadding(2); - tableFormat.setCellSpacing(4); -//! [6] //! [7] - QVector constraints; - constraints << QTextLength(QTextLength::PercentageLength, 14) - << QTextLength(QTextLength::PercentageLength, 14) - << QTextLength(QTextLength::PercentageLength, 14) - << QTextLength(QTextLength::PercentageLength, 14) - << QTextLength(QTextLength::PercentageLength, 14) - << QTextLength(QTextLength::PercentageLength, 14) - << QTextLength(QTextLength::PercentageLength, 14); - tableFormat.setColumnWidthConstraints(constraints); -//! [7] - -//! [8] - QTextTable *table = cursor.insertTable(1, 7, tableFormat); -//! [8] - -//! [9] - QTextFrame *frame = cursor.currentFrame(); - QTextFrameFormat frameFormat = frame->frameFormat(); - frameFormat.setBorder(1); - frame->setFrameFormat(frameFormat); -//! [9] - -//! [10] - QTextCharFormat format = cursor.charFormat(); - format.setFontPointSize(fontSize); - - QTextCharFormat boldFormat = format; - boldFormat.setFontWeight(QFont::Bold); - - QTextCharFormat highlightedFormat = boldFormat; - highlightedFormat.setBackground(Qt::yellow); -//! [10] - -//! [11] - for (int weekDay = 1; weekDay <= 7; ++weekDay) { - QTextTableCell cell = table->cellAt(0, weekDay-1); -//! [11] //! [12] - QTextCursor cellCursor = cell.firstCursorPosition(); - cellCursor.insertText(QString("%1").arg(QDate::longDayName(weekDay)), - boldFormat); - } -//! [12] - -//! [13] - table->insertRows(table->rows(), 1); -//! [13] - - while (date.month() == selectedDate.month()) { - int weekDay = date.dayOfWeek(); - QTextTableCell cell = table->cellAt(table->rows()-1, weekDay-1); - QTextCursor cellCursor = cell.firstCursorPosition(); - - if (date == QDate::currentDate()) - cellCursor.insertText(QString("%1").arg(date.day()), highlightedFormat); - else - cellCursor.insertText(QString("%1").arg(date.day()), format); - - date = date.addDays(1); - if (weekDay == 7 && date.month() == selectedDate.month()) - table->insertRows(table->rows(), 1); - } - - cursor.endEditBlock(); -//! [14] - setWindowTitle(tr("Calendar for %1 %2" - ).arg(QDate::longMonthName(selectedDate.month()) - ).arg(selectedDate.year())); -} -//! [14] - -//! [15] -void MainWindow::setFontSize(int size) -{ - fontSize = size; - insertCalendar(); -} -//! [15] - -//! [16] -void MainWindow::setMonth(int month) -{ - selectedDate = QDate(selectedDate.year(), month + 1, selectedDate.day()); - insertCalendar(); -} -//! [16] - -//! [17] -void MainWindow::setYear(QDate date) -{ - selectedDate = QDate(date.year(), selectedDate.month(), selectedDate.day()); - insertCalendar(); -} -//! [17] diff --git a/examples/richtext/calendar/mainwindow.h b/examples/richtext/calendar/mainwindow.h deleted file mode 100644 index 665452b688..0000000000 --- a/examples/richtext/calendar/mainwindow.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -QT_BEGIN_NAMESPACE -class QTextBrowser; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -public slots: - void setFontSize(int size); - void setMonth(int month); - void setYear(QDate date); - -private: - void insertCalendar(); - - int fontSize; - QDate selectedDate; - QTextBrowser *editor; -}; -//! [0] - -#endif diff --git a/examples/richtext/orderform/detailsdialog.cpp b/examples/richtext/orderform/detailsdialog.cpp deleted file mode 100644 index 3dbdee58c7..0000000000 --- a/examples/richtext/orderform/detailsdialog.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "detailsdialog.h" - -//! [0] -DetailsDialog::DetailsDialog(const QString &title, QWidget *parent) - : QDialog(parent) -{ - nameLabel = new QLabel(tr("Name:")); - addressLabel = new QLabel(tr("Address:")); - addressLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); - - nameEdit = new QLineEdit; - addressEdit = new QTextEdit; - - offersCheckBox = new QCheckBox(tr("Send information about products and " - "special offers")); - - setupItemsTable(); - - buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok - | QDialogButtonBox::Cancel); - - connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); -//! [0] - -//! [1] - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(nameLabel, 0, 0); - mainLayout->addWidget(nameEdit, 0, 1); - mainLayout->addWidget(addressLabel, 1, 0); - mainLayout->addWidget(addressEdit, 1, 1); - mainLayout->addWidget(itemsTable, 0, 2, 2, 1); - mainLayout->addWidget(offersCheckBox, 2, 1, 1, 2); - mainLayout->addWidget(buttonBox, 3, 0, 1, 3); - setLayout(mainLayout); - - setWindowTitle(title); -} -//! [1] - -//! [2] -void DetailsDialog::setupItemsTable() -{ - items << tr("T-shirt") << tr("Badge") << tr("Reference book") - << tr("Coffee cup"); - - itemsTable = new QTableWidget(items.count(), 2); - - for (int row = 0; row < items.count(); ++row) { - QTableWidgetItem *name = new QTableWidgetItem(items[row]); - name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - itemsTable->setItem(row, 0, name); - QTableWidgetItem *quantity = new QTableWidgetItem("1"); - itemsTable->setItem(row, 1, quantity); - } -} -//! [2] - -//! [3] -QList > DetailsDialog::orderItems() -{ - QList > orderList; - - for (int row = 0; row < items.count(); ++row) { - QPair item; - item.first = itemsTable->item(row, 0)->text(); - int quantity = itemsTable->item(row, 1)->data(Qt::DisplayRole).toInt(); - item.second = qMax(0, quantity); - orderList.append(item); - } - - return orderList; -} -//! [3] - -//! [4] -QString DetailsDialog::senderName() const -{ - return nameEdit->text(); -} -//! [4] - -//! [5] -QString DetailsDialog::senderAddress() const -{ - return addressEdit->toPlainText(); -} -//! [5] - -//! [6] -bool DetailsDialog::sendOffers() -{ - return offersCheckBox->isChecked(); -} -//! [6] - -//! [7] -void DetailsDialog::verify() -{ - if (!nameEdit->text().isEmpty() && !addressEdit->toPlainText().isEmpty()) { - accept(); - return; - } - - QMessageBox::StandardButton answer; - answer = QMessageBox::warning(this, tr("Incomplete Form"), - tr("The form does not contain all the necessary information.\n" - "Do you want to discard it?"), - QMessageBox::Yes | QMessageBox::No); - - if (answer == QMessageBox::Yes) - reject(); -} -//! [7] diff --git a/examples/richtext/orderform/detailsdialog.h b/examples/richtext/orderform/detailsdialog.h deleted file mode 100644 index ee964d082e..0000000000 --- a/examples/richtext/orderform/detailsdialog.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 DETAILSDIALOG_H -#define DETAILSDIALOG_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QDialogButtonBox; -class QLabel; -class QLineEdit; -class QTableWidget; -class QTextEdit; -class QWidget; -QT_END_NAMESPACE - -//! [0] -class DetailsDialog : public QDialog -{ - Q_OBJECT - -public: - DetailsDialog(const QString &title, QWidget *parent); - -public slots: - void verify(); - -public: - QList > orderItems(); - QString senderName() const; - QString senderAddress() const; - bool sendOffers(); - -private: - void setupItemsTable(); - - QLabel *nameLabel; - QLabel *addressLabel; - QCheckBox *offersCheckBox; - QLineEdit *nameEdit; - QStringList items; - QTableWidget *itemsTable; - QTextEdit *addressEdit; - QDialogButtonBox *buttonBox; -}; -//! [0] - -#endif diff --git a/examples/richtext/orderform/main.cpp b/examples/richtext/orderform/main.cpp deleted file mode 100644 index fc14fbb625..0000000000 --- a/examples/richtext/orderform/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.resize(640, 480); - window.show(); - window.createSample(); - return app.exec(); -} -//! [0] diff --git a/examples/richtext/orderform/mainwindow.cpp b/examples/richtext/orderform/mainwindow.cpp deleted file mode 100644 index 44b3cb4f9a..0000000000 --- a/examples/richtext/orderform/mainwindow.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#ifndef QT_NO_PRINTER -#include -#include -#endif - -#include "detailsdialog.h" -#include "mainwindow.h" - -//! [0] -MainWindow::MainWindow() -{ - QMenu *fileMenu = new QMenu(tr("&File"), this); - QAction *newAction = fileMenu->addAction(tr("&New...")); - newAction->setShortcuts(QKeySequence::New); - printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile())); - printAction->setShortcuts(QKeySequence::Print); - printAction->setEnabled(false); - QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcuts(QKeySequence::Quit); - menuBar()->addMenu(fileMenu); - - letters = new QTabWidget; - - connect(newAction, SIGNAL(triggered()), this, SLOT(openDialog())); - connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); - - setCentralWidget(letters); - setWindowTitle(tr("Order Form")); -} -//! [0] - -//! [1] -void MainWindow::createLetter(const QString &name, const QString &address, - QList > orderItems, - bool sendOffers) -{ - QTextEdit *editor = new QTextEdit; - int tabIndex = letters->addTab(editor, name); - letters->setCurrentIndex(tabIndex); -//! [1] - -//! [2] - QTextCursor cursor(editor->textCursor()); - cursor.movePosition(QTextCursor::Start); -//! [2] //! [3] - QTextFrame *topFrame = cursor.currentFrame(); - QTextFrameFormat topFrameFormat = topFrame->frameFormat(); - topFrameFormat.setPadding(16); - topFrame->setFrameFormat(topFrameFormat); - - QTextCharFormat textFormat; - QTextCharFormat boldFormat; - boldFormat.setFontWeight(QFont::Bold); - - QTextFrameFormat referenceFrameFormat; - referenceFrameFormat.setBorder(1); - referenceFrameFormat.setPadding(8); - referenceFrameFormat.setPosition(QTextFrameFormat::FloatRight); - referenceFrameFormat.setWidth(QTextLength(QTextLength::PercentageLength, 40)); - cursor.insertFrame(referenceFrameFormat); - - cursor.insertText("A company", boldFormat); - cursor.insertBlock(); - cursor.insertText("321 City Street"); - cursor.insertBlock(); - cursor.insertText("Industry Park"); - cursor.insertBlock(); - cursor.insertText("Another country"); -//! [3] - -//! [4] - cursor.setPosition(topFrame->lastPosition()); - - cursor.insertText(name, textFormat); - QString line; - foreach (line, address.split("\n")) { - cursor.insertBlock(); - cursor.insertText(line); - } -//! [4] //! [5] - cursor.insertBlock(); - cursor.insertBlock(); - - QDate date = QDate::currentDate(); - cursor.insertText(tr("Date: %1").arg(date.toString("d MMMM yyyy")), - textFormat); - cursor.insertBlock(); - - QTextFrameFormat bodyFrameFormat; - bodyFrameFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100)); - cursor.insertFrame(bodyFrameFormat); -//! [5] - -//! [6] - cursor.insertText(tr("I would like to place an order for the following " - "items:"), textFormat); - cursor.insertBlock(); -//! [6] //! [7] - cursor.insertBlock(); -//! [7] - -//! [8] - QTextTableFormat orderTableFormat; - orderTableFormat.setAlignment(Qt::AlignHCenter); - QTextTable *orderTable = cursor.insertTable(1, 2, orderTableFormat); - - QTextFrameFormat orderFrameFormat = cursor.currentFrame()->frameFormat(); - orderFrameFormat.setBorder(1); - cursor.currentFrame()->setFrameFormat(orderFrameFormat); -//! [8] - -//! [9] - cursor = orderTable->cellAt(0, 0).firstCursorPosition(); - cursor.insertText(tr("Product"), boldFormat); - cursor = orderTable->cellAt(0, 1).firstCursorPosition(); - cursor.insertText(tr("Quantity"), boldFormat); -//! [9] - -//! [10] - for (int i = 0; i < orderItems.count(); ++i) { - QPair item = orderItems[i]; - int row = orderTable->rows(); - - orderTable->insertRows(row, 1); - cursor = orderTable->cellAt(row, 0).firstCursorPosition(); - cursor.insertText(item.first, textFormat); - cursor = orderTable->cellAt(row, 1).firstCursorPosition(); - cursor.insertText(QString("%1").arg(item.second), textFormat); - } -//! [10] - -//! [11] - cursor.setPosition(topFrame->lastPosition()); - - cursor.insertBlock(); -//! [11] //! [12] - cursor.insertText(tr("Please update my records to take account of the " - "following privacy information:")); - cursor.insertBlock(); -//! [12] - -//! [13] - QTextTable *offersTable = cursor.insertTable(2, 2); - - cursor = offersTable->cellAt(0, 1).firstCursorPosition(); - cursor.insertText(tr("I want to receive more information about your " - "company's products and special offers."), textFormat); - cursor = offersTable->cellAt(1, 1).firstCursorPosition(); - cursor.insertText(tr("I do not want to receive any promotional information " - "from your company."), textFormat); - - if (sendOffers) - cursor = offersTable->cellAt(0, 0).firstCursorPosition(); - else - cursor = offersTable->cellAt(1, 0).firstCursorPosition(); - - cursor.insertText("X", boldFormat); -//! [13] - -//! [14] - cursor.setPosition(topFrame->lastPosition()); - cursor.insertBlock(); - cursor.insertText(tr("Sincerely,"), textFormat); - cursor.insertBlock(); - cursor.insertBlock(); - cursor.insertBlock(); - cursor.insertText(name); - - printAction->setEnabled(true); -} -//! [14] - -//! [15] -void MainWindow::createSample() -{ - DetailsDialog dialog("Dialog with default values", this); - createLetter("Mr. Smith", "12 High Street\nSmall Town\nThis country", - dialog.orderItems(), true); -} -//! [15] - -//! [16] -void MainWindow::openDialog() -{ - DetailsDialog dialog(tr("Enter Customer Details"), this); - - if (dialog.exec() == QDialog::Accepted) - createLetter(dialog.senderName(), dialog.senderAddress(), - dialog.orderItems(), dialog.sendOffers()); -} -//! [16] - -//! [17] -void MainWindow::printFile() -{ -#ifndef QT_NO_PRINTER - QTextEdit *editor = static_cast(letters->currentWidget()); -//! [18] - QPrinter printer; - - QPrintDialog *dialog = new QPrintDialog(&printer, this); - dialog->setWindowTitle(tr("Print Document")); - if (editor->textCursor().hasSelection()) - dialog->addEnabledOption(QAbstractPrintDialog::PrintSelection); - if (dialog->exec() != QDialog::Accepted) - return; -//! [18] - - editor->print(&printer); -#endif -} -//! [17] diff --git a/examples/richtext/orderform/mainwindow.h b/examples/richtext/orderform/mainwindow.h deleted file mode 100644 index e688f42a80..0000000000 --- a/examples/richtext/orderform/mainwindow.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QTabWidget; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - void createSample(); - -public slots: - void openDialog(); - void printFile(); - -private: - void createLetter(const QString &name, const QString &address, - QList > orderItems, - bool sendOffers); - - QAction *printAction; - QTabWidget *letters; -}; -//! [0] - -#endif diff --git a/examples/richtext/orderform/orderform.desktop b/examples/richtext/orderform/orderform.desktop deleted file mode 100644 index 4690cbc876..0000000000 --- a/examples/richtext/orderform/orderform.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Order Form -Exec=/opt/usr/bin/orderform -Icon=orderform -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/richtext/orderform/orderform.pro b/examples/richtext/orderform/orderform.pro deleted file mode 100644 index 4aefb99428..0000000000 --- a/examples/richtext/orderform/orderform.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = detailsdialog.h \ - mainwindow.h -SOURCES = detailsdialog.cpp \ - main.cpp \ - mainwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/orderform -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS orderform.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/orderform -INSTALLS += target sources - -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport diff --git a/examples/richtext/richtext.pro b/examples/richtext/richtext.pro deleted file mode 100644 index 511edb9ea9..0000000000 --- a/examples/richtext/richtext.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = calendar \ - orderform \ - syntaxhighlighter \ - textedit - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS richtext.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext -INSTALLS += target sources diff --git a/examples/richtext/syntaxhighlighter/highlighter.cpp b/examples/richtext/syntaxhighlighter/highlighter.cpp deleted file mode 100644 index 826e132110..0000000000 --- a/examples/richtext/syntaxhighlighter/highlighter.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "highlighter.h" - -//! [0] -Highlighter::Highlighter(QTextDocument *parent) - : QSyntaxHighlighter(parent) -{ - HighlightingRule rule; - - keywordFormat.setForeground(Qt::darkBlue); - keywordFormat.setFontWeight(QFont::Bold); - QStringList keywordPatterns; - keywordPatterns << "\\bchar\\b" << "\\bclass\\b" << "\\bconst\\b" - << "\\bdouble\\b" << "\\benum\\b" << "\\bexplicit\\b" - << "\\bfriend\\b" << "\\binline\\b" << "\\bint\\b" - << "\\blong\\b" << "\\bnamespace\\b" << "\\boperator\\b" - << "\\bprivate\\b" << "\\bprotected\\b" << "\\bpublic\\b" - << "\\bshort\\b" << "\\bsignals\\b" << "\\bsigned\\b" - << "\\bslots\\b" << "\\bstatic\\b" << "\\bstruct\\b" - << "\\btemplate\\b" << "\\btypedef\\b" << "\\btypename\\b" - << "\\bunion\\b" << "\\bunsigned\\b" << "\\bvirtual\\b" - << "\\bvoid\\b" << "\\bvolatile\\b"; - foreach (const QString &pattern, keywordPatterns) { - rule.pattern = QRegExp(pattern); - rule.format = keywordFormat; - highlightingRules.append(rule); -//! [0] //! [1] - } -//! [1] - -//! [2] - classFormat.setFontWeight(QFont::Bold); - classFormat.setForeground(Qt::darkMagenta); - rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b"); - rule.format = classFormat; - highlightingRules.append(rule); -//! [2] - -//! [3] - singleLineCommentFormat.setForeground(Qt::red); - rule.pattern = QRegExp("//[^\n]*"); - rule.format = singleLineCommentFormat; - highlightingRules.append(rule); - - multiLineCommentFormat.setForeground(Qt::red); -//! [3] - -//! [4] - quotationFormat.setForeground(Qt::darkGreen); - rule.pattern = QRegExp("\".*\""); - rule.format = quotationFormat; - highlightingRules.append(rule); -//! [4] - -//! [5] - functionFormat.setFontItalic(true); - functionFormat.setForeground(Qt::blue); - rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); - rule.format = functionFormat; - highlightingRules.append(rule); -//! [5] - -//! [6] - commentStartExpression = QRegExp("/\\*"); - commentEndExpression = QRegExp("\\*/"); -} -//! [6] - -//! [7] -void Highlighter::highlightBlock(const QString &text) -{ - foreach (const HighlightingRule &rule, highlightingRules) { - QRegExp expression(rule.pattern); - int index = expression.indexIn(text); - while (index >= 0) { - int length = expression.matchedLength(); - setFormat(index, length, rule.format); - index = expression.indexIn(text, index + length); - } - } -//! [7] //! [8] - setCurrentBlockState(0); -//! [8] - -//! [9] - int startIndex = 0; - if (previousBlockState() != 1) - startIndex = commentStartExpression.indexIn(text); - -//! [9] //! [10] - while (startIndex >= 0) { -//! [10] //! [11] - int endIndex = commentEndExpression.indexIn(text, startIndex); - int commentLength; - if (endIndex == -1) { - setCurrentBlockState(1); - commentLength = text.length() - startIndex; - } else { - commentLength = endIndex - startIndex - + commentEndExpression.matchedLength(); - } - setFormat(startIndex, commentLength, multiLineCommentFormat); - startIndex = commentStartExpression.indexIn(text, startIndex + commentLength); - } -} -//! [11] diff --git a/examples/richtext/syntaxhighlighter/highlighter.h b/examples/richtext/syntaxhighlighter/highlighter.h deleted file mode 100644 index 3f75063f89..0000000000 --- a/examples/richtext/syntaxhighlighter/highlighter.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 HIGHLIGHTER_H -#define HIGHLIGHTER_H - -#include - -#include -#include - -QT_BEGIN_NAMESPACE -class QTextDocument; -QT_END_NAMESPACE - -//! [0] -class Highlighter : public QSyntaxHighlighter -{ - Q_OBJECT - -public: - Highlighter(QTextDocument *parent = 0); - -protected: - void highlightBlock(const QString &text); - -private: - struct HighlightingRule - { - QRegExp pattern; - QTextCharFormat format; - }; - QVector highlightingRules; - - QRegExp commentStartExpression; - QRegExp commentEndExpression; - - QTextCharFormat keywordFormat; - QTextCharFormat classFormat; - QTextCharFormat singleLineCommentFormat; - QTextCharFormat multiLineCommentFormat; - QTextCharFormat quotationFormat; - QTextCharFormat functionFormat; -}; -//! [0] - -#endif diff --git a/examples/richtext/syntaxhighlighter/main.cpp b/examples/richtext/syntaxhighlighter/main.cpp deleted file mode 100644 index 5c2f0f236d..0000000000 --- a/examples/richtext/syntaxhighlighter/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.resize(640, 512); - window.show(); - return app.exec(); -} diff --git a/examples/richtext/syntaxhighlighter/mainwindow.cpp b/examples/richtext/syntaxhighlighter/mainwindow.cpp deleted file mode 100644 index ffb02ebb9b..0000000000 --- a/examples/richtext/syntaxhighlighter/mainwindow.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "mainwindow.h" - -//! [0] -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - setupFileMenu(); - setupHelpMenu(); - setupEditor(); - - setCentralWidget(editor); - setWindowTitle(tr("Syntax Highlighter")); -} -//! [0] - -void MainWindow::about() -{ - QMessageBox::about(this, tr("About Syntax Highlighter"), - tr("

      The Syntax Highlighter example shows how " \ - "to perform simple syntax highlighting by subclassing " \ - "the QSyntaxHighlighter class and describing " \ - "highlighting rules using regular expressions.

      ")); -} - -void MainWindow::newFile() -{ - editor->clear(); -} - -void MainWindow::openFile(const QString &path) -{ - QString fileName = path; - - if (fileName.isNull()) - fileName = QFileDialog::getOpenFileName(this, - tr("Open File"), "", "C++ Files (*.cpp *.h)"); - - if (!fileName.isEmpty()) { - QFile file(fileName); - if (file.open(QFile::ReadOnly | QFile::Text)) - editor->setPlainText(file.readAll()); - } -} - -//! [1] -void MainWindow::setupEditor() -{ - QFont font; - font.setFamily("Courier"); - font.setFixedPitch(true); - font.setPointSize(10); - - editor = new QTextEdit; - editor->setFont(font); - - highlighter = new Highlighter(editor->document()); - - QFile file("mainwindow.h"); - if (file.open(QFile::ReadOnly | QFile::Text)) - editor->setPlainText(file.readAll()); -} -//! [1] - -void MainWindow::setupFileMenu() -{ - QMenu *fileMenu = new QMenu(tr("&File"), this); - menuBar()->addMenu(fileMenu); - - fileMenu->addAction(tr("&New"), this, SLOT(newFile()), - QKeySequence::New); - - fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), - QKeySequence::Open); - - fileMenu->addAction(tr("E&xit"), qApp, SLOT(quit()), - QKeySequence::Quit); -} - -void MainWindow::setupHelpMenu() -{ - QMenu *helpMenu = new QMenu(tr("&Help"), this); - menuBar()->addMenu(helpMenu); - - helpMenu->addAction(tr("&About"), this, SLOT(about())); - helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); -} diff --git a/examples/richtext/syntaxhighlighter/mainwindow.h b/examples/richtext/syntaxhighlighter/mainwindow.h deleted file mode 100644 index 082ea77ba4..0000000000 --- a/examples/richtext/syntaxhighlighter/mainwindow.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "highlighter.h" - -QT_BEGIN_NAMESPACE -class QTextEdit; -QT_END_NAMESPACE - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - -public slots: - void about(); - void newFile(); - void openFile(const QString &path = QString()); - -private: - void setupEditor(); - void setupFileMenu(); - void setupHelpMenu(); - - QTextEdit *editor; - Highlighter *highlighter; -}; -//! [0] - -#endif diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.desktop b/examples/richtext/syntaxhighlighter/syntaxhighlighter.desktop deleted file mode 100644 index 2e3c833f0e..0000000000 --- a/examples/richtext/syntaxhighlighter/syntaxhighlighter.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Syntax Highlighter -Exec=/opt/usr/bin/syntaxhighlighter -Icon=syntaxhighlighter -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro deleted file mode 100644 index 0f9b447a74..0000000000 --- a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro +++ /dev/null @@ -1,20 +0,0 @@ -HEADERS = highlighter.h \ - mainwindow.h -SOURCES = highlighter.cpp \ - mainwindow.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/syntaxhighlighter -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS syntaxhighlighter.pro examples -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/syntaxhighlighter -INSTALLS += target sources - - -wince*: { - addFiles.files = main.cpp mainwindow.cpp - addFiles.path = . - DEPLOYMENT += addFiles -} -QT += widgets - diff --git a/examples/richtext/textedit/example.html b/examples/richtext/textedit/example.html deleted file mode 100644 index cdc8d2a23d..0000000000 --- a/examples/richtext/textedit/example.html +++ /dev/null @@ -1,79 +0,0 @@ -QTextEdit Example -

      QTextEdit

      -

      The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.

      -

      If you are viewing this document in the textedit example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment.

      -

      Font and Paragraph Styles

      -

      QTextEdit supports bold, italic, and underlined font styles, and can display multicolored text. Font families such as Times New Roman and Courier can also be used directly. If you place the cursor in a region of styled text, the controls in the tool bars will change to reflect the current style.

      -

      Paragraphs can be formatted so that the text is left-aligned, right-aligned, centered, or fully justified.

      -

      Try changing the alignment of some text and resize the editor to see how the text layout changes.

      -

      Lists

      -

      Different kinds of lists can be included in rich text documents. Standard bullet lists can be nested, using different symbols for each level of the list:

      -
      • Disc symbols are typically used for top-level list items.
      -
      • Circle symbols can be used to distinguish between items in lower-level lists.
      -
      • Square symbols provide a reasonable alternative to discs and circles.
      -

      Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure:

      -
      1. Introduction
      2. -
      3. Qt Tools
      -
      1. Qt Assistant
      2. -
      3. Qt Designer
      4. -
        1. Form Editor
        2. -
        3. Component Architecture
        -
      5. Qt Linguist
      -

      -

      The list will automatically be renumbered if you add or remove items. Try adding new sections to the above list or removing existing item to see the numbers change.

      -

      -

      Images

      -

      Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them.

      -

      Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.

      -

      Tables

      -

      QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns.

      -

      -

      - - - - - - - - - - - - - - - - - - - - - - -
      -

      -

      Development Tools

      -

      Programming Techniques

      -

      Graphical User Interfaces

      -

      9:00 - 11:00

      -

      Introduction to Qt

      -

      11:00 - 13:00

      -

      Using qmake

      -

      Object-oriented Programming

      -

      Layouts in Qt

      -

      13:00 - 15:00

      -

      Qt Designer Tutorial

      -

      Extreme Programming

      -

      Writing Custom Styles

      -

      15:00 - 17:00

      -

      Qt Linguist and Internationalization

      -

      -

      Try adding text to the cells in the table and experiment with the alignment of the paragraphs.

      -

      Hyperlinks

      -

      QTextEdit is designed to support hyperlinks between documents, and this feature is used extensively in Qt Assistant. Hyperlinks are automatically created when an HTML file is imported into an editor. Since the rich text framework supports hyperlinks natively, they can also be created programatically.

      -

      Undo and Redo

      -

      Full support for undo and redo operations is built into QTextEdit and the underlying rich text framework. Operations on a document can be packaged together to make editing a more comfortable experience for the user.

      -

      Try making changes to this document and press Ctrl+Z to undo them. You can always recover the original contents of the document.

      diff --git a/examples/richtext/textedit/images/logo32.png b/examples/richtext/textedit/images/logo32.png deleted file mode 100644 index 5f91e9873b..0000000000 Binary files a/examples/richtext/textedit/images/logo32.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/editcopy.png b/examples/richtext/textedit/images/mac/editcopy.png deleted file mode 100644 index f551364464..0000000000 Binary files a/examples/richtext/textedit/images/mac/editcopy.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/editcut.png b/examples/richtext/textedit/images/mac/editcut.png deleted file mode 100644 index a784fd5709..0000000000 Binary files a/examples/richtext/textedit/images/mac/editcut.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/editpaste.png b/examples/richtext/textedit/images/mac/editpaste.png deleted file mode 100644 index 64c0b2d6ab..0000000000 Binary files a/examples/richtext/textedit/images/mac/editpaste.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/editredo.png b/examples/richtext/textedit/images/mac/editredo.png deleted file mode 100644 index 8875bf246c..0000000000 Binary files a/examples/richtext/textedit/images/mac/editredo.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/editundo.png b/examples/richtext/textedit/images/mac/editundo.png deleted file mode 100644 index a3bd5e0bf2..0000000000 Binary files a/examples/richtext/textedit/images/mac/editundo.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/exportpdf.png b/examples/richtext/textedit/images/mac/exportpdf.png deleted file mode 100644 index ebb44e6b88..0000000000 Binary files a/examples/richtext/textedit/images/mac/exportpdf.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/filenew.png b/examples/richtext/textedit/images/mac/filenew.png deleted file mode 100644 index d3882c7b3f..0000000000 Binary files a/examples/richtext/textedit/images/mac/filenew.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/fileopen.png b/examples/richtext/textedit/images/mac/fileopen.png deleted file mode 100644 index fc06c5ec63..0000000000 Binary files a/examples/richtext/textedit/images/mac/fileopen.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/fileprint.png b/examples/richtext/textedit/images/mac/fileprint.png deleted file mode 100644 index 10ca56c82a..0000000000 Binary files a/examples/richtext/textedit/images/mac/fileprint.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/filesave.png b/examples/richtext/textedit/images/mac/filesave.png deleted file mode 100644 index b41ecf5319..0000000000 Binary files a/examples/richtext/textedit/images/mac/filesave.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textbold.png b/examples/richtext/textedit/images/mac/textbold.png deleted file mode 100644 index 38400bd1f6..0000000000 Binary files a/examples/richtext/textedit/images/mac/textbold.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textcenter.png b/examples/richtext/textedit/images/mac/textcenter.png deleted file mode 100644 index 2ef5b2ee6f..0000000000 Binary files a/examples/richtext/textedit/images/mac/textcenter.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textitalic.png b/examples/richtext/textedit/images/mac/textitalic.png deleted file mode 100644 index 0170ee26a6..0000000000 Binary files a/examples/richtext/textedit/images/mac/textitalic.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textjustify.png b/examples/richtext/textedit/images/mac/textjustify.png deleted file mode 100644 index 39cd6c1a9d..0000000000 Binary files a/examples/richtext/textedit/images/mac/textjustify.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textleft.png b/examples/richtext/textedit/images/mac/textleft.png deleted file mode 100644 index 83a66d5535..0000000000 Binary files a/examples/richtext/textedit/images/mac/textleft.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textright.png b/examples/richtext/textedit/images/mac/textright.png deleted file mode 100644 index e7c04645cf..0000000000 Binary files a/examples/richtext/textedit/images/mac/textright.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/textunder.png b/examples/richtext/textedit/images/mac/textunder.png deleted file mode 100644 index 968bac5e90..0000000000 Binary files a/examples/richtext/textedit/images/mac/textunder.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/zoomin.png b/examples/richtext/textedit/images/mac/zoomin.png deleted file mode 100644 index d46f5aff0d..0000000000 Binary files a/examples/richtext/textedit/images/mac/zoomin.png and /dev/null differ diff --git a/examples/richtext/textedit/images/mac/zoomout.png b/examples/richtext/textedit/images/mac/zoomout.png deleted file mode 100644 index 46326566d1..0000000000 Binary files a/examples/richtext/textedit/images/mac/zoomout.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/editcopy.png b/examples/richtext/textedit/images/win/editcopy.png deleted file mode 100644 index 1121b47d8b..0000000000 Binary files a/examples/richtext/textedit/images/win/editcopy.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/editcut.png b/examples/richtext/textedit/images/win/editcut.png deleted file mode 100644 index 38e55f7420..0000000000 Binary files a/examples/richtext/textedit/images/win/editcut.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/editpaste.png b/examples/richtext/textedit/images/win/editpaste.png deleted file mode 100644 index ffab15aaf8..0000000000 Binary files a/examples/richtext/textedit/images/win/editpaste.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/editredo.png b/examples/richtext/textedit/images/win/editredo.png deleted file mode 100644 index 9d679fe6fc..0000000000 Binary files a/examples/richtext/textedit/images/win/editredo.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/editundo.png b/examples/richtext/textedit/images/win/editundo.png deleted file mode 100644 index eee23d24a3..0000000000 Binary files a/examples/richtext/textedit/images/win/editundo.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/exportpdf.png b/examples/richtext/textedit/images/win/exportpdf.png deleted file mode 100644 index eef5132928..0000000000 Binary files a/examples/richtext/textedit/images/win/exportpdf.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/filenew.png b/examples/richtext/textedit/images/win/filenew.png deleted file mode 100644 index af5d122141..0000000000 Binary files a/examples/richtext/textedit/images/win/filenew.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/fileopen.png b/examples/richtext/textedit/images/win/fileopen.png deleted file mode 100644 index fc6f17e977..0000000000 Binary files a/examples/richtext/textedit/images/win/fileopen.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/fileprint.png b/examples/richtext/textedit/images/win/fileprint.png deleted file mode 100644 index ba7c02dc18..0000000000 Binary files a/examples/richtext/textedit/images/win/fileprint.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/filesave.png b/examples/richtext/textedit/images/win/filesave.png deleted file mode 100644 index 8feec99bee..0000000000 Binary files a/examples/richtext/textedit/images/win/filesave.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textbold.png b/examples/richtext/textedit/images/win/textbold.png deleted file mode 100644 index 9cbc7138b9..0000000000 Binary files a/examples/richtext/textedit/images/win/textbold.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textcenter.png b/examples/richtext/textedit/images/win/textcenter.png deleted file mode 100644 index 11efb4b852..0000000000 Binary files a/examples/richtext/textedit/images/win/textcenter.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textitalic.png b/examples/richtext/textedit/images/win/textitalic.png deleted file mode 100644 index b30ce14c14..0000000000 Binary files a/examples/richtext/textedit/images/win/textitalic.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textjustify.png b/examples/richtext/textedit/images/win/textjustify.png deleted file mode 100644 index 9de0c88085..0000000000 Binary files a/examples/richtext/textedit/images/win/textjustify.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textleft.png b/examples/richtext/textedit/images/win/textleft.png deleted file mode 100644 index 16f80bc325..0000000000 Binary files a/examples/richtext/textedit/images/win/textleft.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textright.png b/examples/richtext/textedit/images/win/textright.png deleted file mode 100644 index 16872df62a..0000000000 Binary files a/examples/richtext/textedit/images/win/textright.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/textunder.png b/examples/richtext/textedit/images/win/textunder.png deleted file mode 100644 index c72eff53fb..0000000000 Binary files a/examples/richtext/textedit/images/win/textunder.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/zoomin.png b/examples/richtext/textedit/images/win/zoomin.png deleted file mode 100644 index 2e586fc7bf..0000000000 Binary files a/examples/richtext/textedit/images/win/zoomin.png and /dev/null differ diff --git a/examples/richtext/textedit/images/win/zoomout.png b/examples/richtext/textedit/images/win/zoomout.png deleted file mode 100644 index a736d39343..0000000000 Binary files a/examples/richtext/textedit/images/win/zoomout.png and /dev/null differ diff --git a/examples/richtext/textedit/main.cpp b/examples/richtext/textedit/main.cpp deleted file mode 100644 index ae12cd9979..0000000000 --- a/examples/richtext/textedit/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textedit.h" -#include - -int main( int argc, char ** argv ) -{ - Q_INIT_RESOURCE(textedit); - - QApplication a( argc, argv ); - TextEdit mw; - mw.resize( 700, 800 ); - mw.show(); - return a.exec(); -} diff --git a/examples/richtext/textedit/textedit.cpp b/examples/richtext/textedit/textedit.cpp deleted file mode 100644 index 0be60230ca..0000000000 --- a/examples/richtext/textedit/textedit.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textedit.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_PRINTER -#include -#include -#include -#endif - -#ifdef Q_OS_MAC -const QString rsrcPath = ":/images/mac"; -#else -const QString rsrcPath = ":/images/win"; -#endif - -TextEdit::TextEdit(QWidget *parent) - : QMainWindow(parent) -{ - setToolButtonStyle(Qt::ToolButtonFollowStyle); - setupFileActions(); - setupEditActions(); - setupTextActions(); - - { - QMenu *helpMenu = new QMenu(tr("Help"), this); - menuBar()->addMenu(helpMenu); - helpMenu->addAction(tr("About"), this, SLOT(about())); - helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); - } - - textEdit = new QTextEdit(this); - connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), - this, SLOT(currentCharFormatChanged(QTextCharFormat))); - connect(textEdit, SIGNAL(cursorPositionChanged()), - this, SLOT(cursorPositionChanged())); - - setCentralWidget(textEdit); - textEdit->setFocus(); - setCurrentFileName(QString()); - - fontChanged(textEdit->font()); - colorChanged(textEdit->textColor()); - alignmentChanged(textEdit->alignment()); - - connect(textEdit->document(), SIGNAL(modificationChanged(bool)), - actionSave, SLOT(setEnabled(bool))); - connect(textEdit->document(), SIGNAL(modificationChanged(bool)), - this, SLOT(setWindowModified(bool))); - connect(textEdit->document(), SIGNAL(undoAvailable(bool)), - actionUndo, SLOT(setEnabled(bool))); - connect(textEdit->document(), SIGNAL(redoAvailable(bool)), - actionRedo, SLOT(setEnabled(bool))); - - setWindowModified(textEdit->document()->isModified()); - actionSave->setEnabled(textEdit->document()->isModified()); - actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); - actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); - - connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); - connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); - - actionCut->setEnabled(false); - actionCopy->setEnabled(false); - - connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); - connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); - connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); - - connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); - connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); - -#ifndef QT_NO_CLIPBOARD - connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); -#endif - - QString initialFile = ":/example.html"; - const QStringList args = QCoreApplication::arguments(); - if (args.count() == 2) - initialFile = args.at(1); - - if (!load(initialFile)) - fileNew(); -} - -void TextEdit::closeEvent(QCloseEvent *e) -{ - if (maybeSave()) - e->accept(); - else - e->ignore(); -} - -void TextEdit::setupFileActions() -{ - QToolBar *tb = new QToolBar(this); - tb->setWindowTitle(tr("File Actions")); - addToolBar(tb); - - QMenu *menu = new QMenu(tr("&File"), this); - menuBar()->addMenu(menu); - - QAction *a; - - QIcon newIcon = QIcon::fromTheme("document-new", QIcon(rsrcPath + "/filenew.png")); - a = new QAction( newIcon, tr("&New"), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(QKeySequence::New); - connect(a, SIGNAL(triggered()), this, SLOT(fileNew())); - tb->addAction(a); - menu->addAction(a); - - a = new QAction(QIcon::fromTheme("document-open", QIcon(rsrcPath + "/fileopen.png")), - tr("&Open..."), this); - a->setShortcut(QKeySequence::Open); - connect(a, SIGNAL(triggered()), this, SLOT(fileOpen())); - tb->addAction(a); - menu->addAction(a); - - menu->addSeparator(); - - actionSave = a = new QAction(QIcon::fromTheme("document-save", QIcon(rsrcPath + "/filesave.png")), - tr("&Save"), this); - a->setShortcut(QKeySequence::Save); - connect(a, SIGNAL(triggered()), this, SLOT(fileSave())); - a->setEnabled(false); - tb->addAction(a); - menu->addAction(a); - - a = new QAction(tr("Save &As..."), this); - a->setPriority(QAction::LowPriority); - connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs())); - menu->addAction(a); - menu->addSeparator(); - -#ifndef QT_NO_PRINTER - a = new QAction(QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png")), - tr("&Print..."), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(QKeySequence::Print); - connect(a, SIGNAL(triggered()), this, SLOT(filePrint())); - tb->addAction(a); - menu->addAction(a); - - a = new QAction(QIcon::fromTheme("fileprint", QIcon(rsrcPath + "/fileprint.png")), - tr("Print Preview..."), this); - connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview())); - menu->addAction(a); - - a = new QAction(QIcon::fromTheme("exportpdf", QIcon(rsrcPath + "/exportpdf.png")), - tr("&Export PDF..."), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(Qt::CTRL + Qt::Key_D); - connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf())); - tb->addAction(a); - menu->addAction(a); - - menu->addSeparator(); -#endif - - a = new QAction(tr("&Quit"), this); - a->setShortcut(Qt::CTRL + Qt::Key_Q); - connect(a, SIGNAL(triggered()), this, SLOT(close())); - menu->addAction(a); -} - -void TextEdit::setupEditActions() -{ - QToolBar *tb = new QToolBar(this); - tb->setWindowTitle(tr("Edit Actions")); - addToolBar(tb); - QMenu *menu = new QMenu(tr("&Edit"), this); - menuBar()->addMenu(menu); - - QAction *a; - a = actionUndo = new QAction(QIcon::fromTheme("edit-undo", QIcon(rsrcPath + "/editundo.png")), - tr("&Undo"), this); - a->setShortcut(QKeySequence::Undo); - tb->addAction(a); - menu->addAction(a); - a = actionRedo = new QAction(QIcon::fromTheme("edit-redo", QIcon(rsrcPath + "/editredo.png")), - tr("&Redo"), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(QKeySequence::Redo); - tb->addAction(a); - menu->addAction(a); - menu->addSeparator(); - a = actionCut = new QAction(QIcon::fromTheme("edit-cut", QIcon(rsrcPath + "/editcut.png")), - tr("Cu&t"), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(QKeySequence::Cut); - tb->addAction(a); - menu->addAction(a); - a = actionCopy = new QAction(QIcon::fromTheme("edit-copy", QIcon(rsrcPath + "/editcopy.png")), - tr("&Copy"), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(QKeySequence::Copy); - tb->addAction(a); - menu->addAction(a); - a = actionPaste = new QAction(QIcon::fromTheme("edit-paste", QIcon(rsrcPath + "/editpaste.png")), - tr("&Paste"), this); - a->setPriority(QAction::LowPriority); - a->setShortcut(QKeySequence::Paste); - tb->addAction(a); - menu->addAction(a); -#ifndef QT_NO_CLIPBOARD - if (const QMimeData *md = QApplication::clipboard()->mimeData()) - actionPaste->setEnabled(md->hasText()); -#endif -} - -void TextEdit::setupTextActions() -{ - QToolBar *tb = new QToolBar(this); - tb->setWindowTitle(tr("Format Actions")); - addToolBar(tb); - - QMenu *menu = new QMenu(tr("F&ormat"), this); - menuBar()->addMenu(menu); - - actionTextBold = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")), - tr("&Bold"), this); - actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); - actionTextBold->setPriority(QAction::LowPriority); - QFont bold; - bold.setBold(true); - actionTextBold->setFont(bold); - connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); - tb->addAction(actionTextBold); - menu->addAction(actionTextBold); - actionTextBold->setCheckable(true); - - actionTextItalic = new QAction(QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png")), - tr("&Italic"), this); - actionTextItalic->setPriority(QAction::LowPriority); - actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); - QFont italic; - italic.setItalic(true); - actionTextItalic->setFont(italic); - connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); - tb->addAction(actionTextItalic); - menu->addAction(actionTextItalic); - actionTextItalic->setCheckable(true); - - actionTextUnderline = new QAction(QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png")), - tr("&Underline"), this); - actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); - actionTextUnderline->setPriority(QAction::LowPriority); - QFont underline; - underline.setUnderline(true); - actionTextUnderline->setFont(underline); - connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); - tb->addAction(actionTextUnderline); - menu->addAction(actionTextUnderline); - actionTextUnderline->setCheckable(true); - - menu->addSeparator(); - - QActionGroup *grp = new QActionGroup(this); - connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); - - // Make sure the alignLeft is always left of the alignRight - if (QApplication::isLeftToRight()) { - actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), - tr("&Left"), grp); - actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); - actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); - } else { - actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); - actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); - actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); - } - actionAlignJustify = new QAction(QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png")), tr("&Justify"), grp); - - actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); - actionAlignLeft->setCheckable(true); - actionAlignLeft->setPriority(QAction::LowPriority); - actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); - actionAlignCenter->setCheckable(true); - actionAlignCenter->setPriority(QAction::LowPriority); - actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); - actionAlignRight->setCheckable(true); - actionAlignRight->setPriority(QAction::LowPriority); - actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); - actionAlignJustify->setCheckable(true); - actionAlignJustify->setPriority(QAction::LowPriority); - - tb->addActions(grp->actions()); - menu->addActions(grp->actions()); - - menu->addSeparator(); - - QPixmap pix(16, 16); - pix.fill(Qt::black); - actionTextColor = new QAction(pix, tr("&Color..."), this); - connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); - tb->addAction(actionTextColor); - menu->addAction(actionTextColor); - - - tb = new QToolBar(this); - tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); - tb->setWindowTitle(tr("Format Actions")); - addToolBarBreak(Qt::TopToolBarArea); - addToolBar(tb); - - comboStyle = new QComboBox(tb); - tb->addWidget(comboStyle); - comboStyle->addItem("Standard"); - comboStyle->addItem("Bullet List (Disc)"); - comboStyle->addItem("Bullet List (Circle)"); - comboStyle->addItem("Bullet List (Square)"); - comboStyle->addItem("Ordered List (Decimal)"); - comboStyle->addItem("Ordered List (Alpha lower)"); - comboStyle->addItem("Ordered List (Alpha upper)"); - comboStyle->addItem("Ordered List (Roman lower)"); - comboStyle->addItem("Ordered List (Roman upper)"); - connect(comboStyle, SIGNAL(activated(int)), - this, SLOT(textStyle(int))); - - comboFont = new QFontComboBox(tb); - tb->addWidget(comboFont); - connect(comboFont, SIGNAL(activated(QString)), - this, SLOT(textFamily(QString))); - - comboSize = new QComboBox(tb); - comboSize->setObjectName("comboSize"); - tb->addWidget(comboSize); - comboSize->setEditable(true); - - QFontDatabase db; - foreach(int size, db.standardSizes()) - comboSize->addItem(QString::number(size)); - - connect(comboSize, SIGNAL(activated(QString)), - this, SLOT(textSize(QString))); - comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() - .pointSize()))); -} - -bool TextEdit::load(const QString &f) -{ - if (!QFile::exists(f)) - return false; - QFile file(f); - if (!file.open(QFile::ReadOnly)) - return false; - - QByteArray data = file.readAll(); - QTextCodec *codec = Qt::codecForHtml(data); - QString str = codec->toUnicode(data); - if (Qt::mightBeRichText(str)) { - textEdit->setHtml(str); - } else { - str = QString::fromLocal8Bit(data); - textEdit->setPlainText(str); - } - - setCurrentFileName(f); - return true; -} - -bool TextEdit::maybeSave() -{ - if (!textEdit->document()->isModified()) - return true; - if (fileName.startsWith(QLatin1String(":/"))) - return true; - QMessageBox::StandardButton ret; - ret = QMessageBox::warning(this, tr("Application"), - tr("The document has been modified.\n" - "Do you want to save your changes?"), - QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel); - if (ret == QMessageBox::Save) - return fileSave(); - else if (ret == QMessageBox::Cancel) - return false; - return true; -} - -void TextEdit::setCurrentFileName(const QString &fileName) -{ - this->fileName = fileName; - textEdit->document()->setModified(false); - - QString shownName; - if (fileName.isEmpty()) - shownName = "untitled.txt"; - else - shownName = QFileInfo(fileName).fileName(); - - setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Rich Text"))); - setWindowModified(false); -} - -void TextEdit::fileNew() -{ - if (maybeSave()) { - textEdit->clear(); - setCurrentFileName(QString()); - } -} - -void TextEdit::fileOpen() -{ - QString fn = QFileDialog::getOpenFileName(this, tr("Open File..."), - QString(), tr("HTML-Files (*.htm *.html);;All Files (*)")); - if (!fn.isEmpty()) - load(fn); -} - -bool TextEdit::fileSave() -{ - if (fileName.isEmpty()) - return fileSaveAs(); - - QTextDocumentWriter writer(fileName); - bool success = writer.write(textEdit->document()); - if (success) - textEdit->document()->setModified(false); - return success; -} - -bool TextEdit::fileSaveAs() -{ - QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."), - QString(), tr("ODF files (*.odt);;HTML-Files (*.htm *.html);;All Files (*)")); - if (fn.isEmpty()) - return false; - if (! (fn.endsWith(".odt", Qt::CaseInsensitive) || fn.endsWith(".htm", Qt::CaseInsensitive) || fn.endsWith(".html", Qt::CaseInsensitive)) ) - fn += ".odt"; // default - setCurrentFileName(fn); - return fileSave(); -} - -void TextEdit::filePrint() -{ -#ifndef QT_NO_PRINTER - QPrinter printer(QPrinter::HighResolution); - QPrintDialog *dlg = new QPrintDialog(&printer, this); - if (textEdit->textCursor().hasSelection()) - dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection); - dlg->setWindowTitle(tr("Print Document")); - if (dlg->exec() == QDialog::Accepted) { - textEdit->print(&printer); - } - delete dlg; -#endif -} - -void TextEdit::filePrintPreview() -{ -#ifndef QT_NO_PRINTER - QPrinter printer(QPrinter::HighResolution); - QPrintPreviewDialog preview(&printer, this); - connect(&preview, SIGNAL(paintRequested(QPrinter*)), SLOT(printPreview(QPrinter*))); - preview.exec(); -#endif -} - -void TextEdit::printPreview(QPrinter *printer) -{ -#ifdef QT_NO_PRINTER - Q_UNUSED(printer); -#else - textEdit->print(printer); -#endif -} - - -void TextEdit::filePrintPdf() -{ -#ifndef QT_NO_PRINTER -//! [0] - QString fileName = QFileDialog::getSaveFileName(this, "Export PDF", - QString(), "*.pdf"); - if (!fileName.isEmpty()) { - if (QFileInfo(fileName).suffix().isEmpty()) - fileName.append(".pdf"); - QPrinter printer(QPrinter::HighResolution); - printer.setOutputFormat(QPrinter::PdfFormat); - printer.setOutputFileName(fileName); - textEdit->document()->print(&printer); - } -//! [0] -#endif -} - -void TextEdit::textBold() -{ - QTextCharFormat fmt; - fmt.setFontWeight(actionTextBold->isChecked() ? QFont::Bold : QFont::Normal); - mergeFormatOnWordOrSelection(fmt); -} - -void TextEdit::textUnderline() -{ - QTextCharFormat fmt; - fmt.setFontUnderline(actionTextUnderline->isChecked()); - mergeFormatOnWordOrSelection(fmt); -} - -void TextEdit::textItalic() -{ - QTextCharFormat fmt; - fmt.setFontItalic(actionTextItalic->isChecked()); - mergeFormatOnWordOrSelection(fmt); -} - -void TextEdit::textFamily(const QString &f) -{ - QTextCharFormat fmt; - fmt.setFontFamily(f); - mergeFormatOnWordOrSelection(fmt); -} - -void TextEdit::textSize(const QString &p) -{ - qreal pointSize = p.toFloat(); - if (p.toFloat() > 0) { - QTextCharFormat fmt; - fmt.setFontPointSize(pointSize); - mergeFormatOnWordOrSelection(fmt); - } -} - -void TextEdit::textStyle(int styleIndex) -{ - QTextCursor cursor = textEdit->textCursor(); - - if (styleIndex != 0) { - QTextListFormat::Style style = QTextListFormat::ListDisc; - - switch (styleIndex) { - default: - case 1: - style = QTextListFormat::ListDisc; - break; - case 2: - style = QTextListFormat::ListCircle; - break; - case 3: - style = QTextListFormat::ListSquare; - break; - case 4: - style = QTextListFormat::ListDecimal; - break; - case 5: - style = QTextListFormat::ListLowerAlpha; - break; - case 6: - style = QTextListFormat::ListUpperAlpha; - break; - case 7: - style = QTextListFormat::ListLowerRoman; - break; - case 8: - style = QTextListFormat::ListUpperRoman; - break; - } - - cursor.beginEditBlock(); - - QTextBlockFormat blockFmt = cursor.blockFormat(); - - QTextListFormat listFmt; - - if (cursor.currentList()) { - listFmt = cursor.currentList()->format(); - } else { - listFmt.setIndent(blockFmt.indent() + 1); - blockFmt.setIndent(0); - cursor.setBlockFormat(blockFmt); - } - - listFmt.setStyle(style); - - cursor.createList(listFmt); - - cursor.endEditBlock(); - } else { - // #### - QTextBlockFormat bfmt; - bfmt.setObjectIndex(-1); - cursor.mergeBlockFormat(bfmt); - } -} - -void TextEdit::textColor() -{ - QColor col = QColorDialog::getColor(textEdit->textColor(), this); - if (!col.isValid()) - return; - QTextCharFormat fmt; - fmt.setForeground(col); - mergeFormatOnWordOrSelection(fmt); - colorChanged(col); -} - -void TextEdit::textAlign(QAction *a) -{ - if (a == actionAlignLeft) - textEdit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute); - else if (a == actionAlignCenter) - textEdit->setAlignment(Qt::AlignHCenter); - else if (a == actionAlignRight) - textEdit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute); - else if (a == actionAlignJustify) - textEdit->setAlignment(Qt::AlignJustify); -} - -void TextEdit::currentCharFormatChanged(const QTextCharFormat &format) -{ - fontChanged(format.font()); - colorChanged(format.foreground().color()); -} - -void TextEdit::cursorPositionChanged() -{ - alignmentChanged(textEdit->alignment()); -} - -void TextEdit::clipboardDataChanged() -{ -#ifndef QT_NO_CLIPBOARD - if (const QMimeData *md = QApplication::clipboard()->mimeData()) - actionPaste->setEnabled(md->hasText()); -#endif -} - -void TextEdit::about() -{ - QMessageBox::about(this, tr("About"), tr("This example demonstrates Qt's " - "rich text editing facilities in action, providing an example " - "document for you to experiment with.")); -} - -void TextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) -{ - QTextCursor cursor = textEdit->textCursor(); - if (!cursor.hasSelection()) - cursor.select(QTextCursor::WordUnderCursor); - cursor.mergeCharFormat(format); - textEdit->mergeCurrentCharFormat(format); -} - -void TextEdit::fontChanged(const QFont &f) -{ - comboFont->setCurrentIndex(comboFont->findText(QFontInfo(f).family())); - comboSize->setCurrentIndex(comboSize->findText(QString::number(f.pointSize()))); - actionTextBold->setChecked(f.bold()); - actionTextItalic->setChecked(f.italic()); - actionTextUnderline->setChecked(f.underline()); -} - -void TextEdit::colorChanged(const QColor &c) -{ - QPixmap pix(16, 16); - pix.fill(c); - actionTextColor->setIcon(pix); -} - -void TextEdit::alignmentChanged(Qt::Alignment a) -{ - if (a & Qt::AlignLeft) { - actionAlignLeft->setChecked(true); - } else if (a & Qt::AlignHCenter) { - actionAlignCenter->setChecked(true); - } else if (a & Qt::AlignRight) { - actionAlignRight->setChecked(true); - } else if (a & Qt::AlignJustify) { - actionAlignJustify->setChecked(true); - } -} - diff --git a/examples/richtext/textedit/textedit.h b/examples/richtext/textedit/textedit.h deleted file mode 100644 index e04fde4604..0000000000 --- a/examples/richtext/textedit/textedit.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTEDIT_H -#define TEXTEDIT_H - -#include -#include -#include - -QT_FORWARD_DECLARE_CLASS(QAction) -QT_FORWARD_DECLARE_CLASS(QComboBox) -QT_FORWARD_DECLARE_CLASS(QFontComboBox) -QT_FORWARD_DECLARE_CLASS(QTextEdit) -QT_FORWARD_DECLARE_CLASS(QTextCharFormat) -QT_FORWARD_DECLARE_CLASS(QMenu) -QT_FORWARD_DECLARE_CLASS(QPrinter) - -class TextEdit : public QMainWindow -{ - Q_OBJECT - -public: - TextEdit(QWidget *parent = 0); - -protected: - virtual void closeEvent(QCloseEvent *e); - -private: - void setupFileActions(); - void setupEditActions(); - void setupTextActions(); - bool load(const QString &f); - bool maybeSave(); - void setCurrentFileName(const QString &fileName); - -private slots: - void fileNew(); - void fileOpen(); - bool fileSave(); - bool fileSaveAs(); - void filePrint(); - void filePrintPreview(); - void filePrintPdf(); - - void textBold(); - void textUnderline(); - void textItalic(); - void textFamily(const QString &f); - void textSize(const QString &p); - void textStyle(int styleIndex); - void textColor(); - void textAlign(QAction *a); - - void currentCharFormatChanged(const QTextCharFormat &format); - void cursorPositionChanged(); - - void clipboardDataChanged(); - void about(); - void printPreview(QPrinter *); - -private: - void mergeFormatOnWordOrSelection(const QTextCharFormat &format); - void fontChanged(const QFont &f); - void colorChanged(const QColor &c); - void alignmentChanged(Qt::Alignment a); - - QAction *actionSave, - *actionTextBold, - *actionTextUnderline, - *actionTextItalic, - *actionTextColor, - *actionAlignLeft, - *actionAlignCenter, - *actionAlignRight, - *actionAlignJustify, - *actionUndo, - *actionRedo, - *actionCut, - *actionCopy, - *actionPaste; - - QComboBox *comboStyle; - QFontComboBox *comboFont; - QComboBox *comboSize; - - QToolBar *tb; - QString fileName; - QTextEdit *textEdit; -}; - -#endif diff --git a/examples/richtext/textedit/textedit.pro b/examples/richtext/textedit/textedit.pro deleted file mode 100644 index e172e79fe6..0000000000 --- a/examples/richtext/textedit/textedit.pro +++ /dev/null @@ -1,23 +0,0 @@ -TEMPLATE = app -TARGET = textedit - -CONFIG += qt warn_on - -HEADERS = textedit.h -SOURCES = textedit.cpp \ - main.cpp - -RESOURCES += textedit.qrc -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/textedit -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/textedit -INSTALLS += target sources - -QT += widgets -!isEmpty(QT.printsupport.name): QT += printsupport diff --git a/examples/richtext/textedit/textedit.qdoc b/examples/richtext/textedit/textedit.qdoc deleted file mode 100644 index 7a3aa76ab6..0000000000 --- a/examples/richtext/textedit/textedit.qdoc +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! \page textedit-example.html - - \ingroup examples - \title Text Edit Example - - This example displays a text editor with the user interface written - in pure C++. - - A similar example which uses \link designer-manual.book Qt - Designer\endlink to produce the user interface is in the \link - designer-manual.book Qt Designer manual\endlink. - - - See \c{$QTDIR/examples/textedit} for the source code. - -*/ - - diff --git a/examples/richtext/textedit/textedit.qrc b/examples/richtext/textedit/textedit.qrc deleted file mode 100644 index 7d6efd7d67..0000000000 --- a/examples/richtext/textedit/textedit.qrc +++ /dev/null @@ -1,44 +0,0 @@ - - - images/logo32.png - images/mac/editcopy.png - images/mac/editcut.png - images/mac/editpaste.png - images/mac/editredo.png - images/mac/editundo.png - images/mac/exportpdf.png - images/mac/filenew.png - images/mac/fileopen.png - images/mac/fileprint.png - images/mac/filesave.png - images/mac/textbold.png - images/mac/textcenter.png - images/mac/textitalic.png - images/mac/textjustify.png - images/mac/textleft.png - images/mac/textright.png - images/mac/textunder.png - images/mac/zoomin.png - images/mac/zoomout.png - images/win/editcopy.png - images/win/editcut.png - images/win/editpaste.png - images/win/editredo.png - images/win/editundo.png - images/win/exportpdf.png - images/win/filenew.png - images/win/fileopen.png - images/win/fileprint.png - images/win/filesave.png - images/win/textbold.png - images/win/textcenter.png - images/win/textitalic.png - images/win/textjustify.png - images/win/textleft.png - images/win/textright.png - images/win/textunder.png - images/win/zoomin.png - images/win/zoomout.png - example.html - - diff --git a/examples/scroller/graphicsview/graphicsview.pro b/examples/scroller/graphicsview/graphicsview.pro deleted file mode 100644 index ccfb82d0ca..0000000000 --- a/examples/scroller/graphicsview/graphicsview.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/scroller/graphicsview -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS graphicsview.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/scroller/graphicsview -INSTALLS += target sources -QT += widgets diff --git a/examples/scroller/graphicsview/main.cpp b/examples/scroller/graphicsview/main.cpp deleted file mode 100644 index 0837719bb5..0000000000 --- a/examples/scroller/graphicsview/main.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 -#include - -#define NUM_ITEMS 100 -#define NUM_LISTS 10 - -/*! - \class RectObject - Note that it needs to be a QGraphicsObject or else the gestures will not work correctly. -*/ -class RectObject : public QGraphicsObject -{ - Q_OBJECT - -public: - - RectObject(const QString &text, qreal x, qreal y, qreal width, qreal height, QBrush brush, QGraphicsItem *parent = 0) - : QGraphicsObject(parent) - , m_text(text) - , m_rect(x, y, width, height) - , m_pen(brush.color().lighter(), 3.0) - , m_brush(brush) - { - setFlag(QGraphicsItem::ItemClipsToShape, true); - } - - QRectF boundingRect() const - { - // here we only want the size of the children and not the size of the children of the children... - qreal halfpw = m_pen.widthF() / 2; - QRectF rect = m_rect; - if (halfpw > 0.0) - rect.adjust(-halfpw, -halfpw, halfpw, halfpw); - - return rect; - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(m_pen); - painter->setBrush(m_brush); - painter->drawRect(m_rect); - - painter->setPen(Qt::black); - QFont f; - f.setPixelSize(m_rect.height()); - painter->setFont(f); - painter->drawText(m_rect, Qt::AlignCenter, m_text); - } - - QString m_text; - QRectF m_rect; - QPen m_pen; - QBrush m_brush; -}; - -class ViewObject : public QGraphicsObject -{ - Q_OBJECT -public: - ViewObject(QGraphicsObject *parent) - : QGraphicsObject(parent) - { } - - QRectF boundingRect() const - { - QRectF rect; - foreach (QGraphicsItem *item, childItems()) - rect |= item->boundingRect().translated(item->pos()); - return rect; - } - - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) - { } -}; - -class ListObject : public QGraphicsObject -{ - Q_OBJECT - -public: - ListObject(const QSizeF &size, bool useTouch) - { - m_size = size; - setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); - // grab gesture via Touch or Mouse events - QScroller::grabGesture(this, useTouch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture); - - // this needs to be QGraphicsOBJECT - otherwise gesture recognition - // will not work for the parent of the viewport (in this case the - // list) - m_viewport = new ViewObject(this); - - } - - QGraphicsObject *viewport() const - { - return m_viewport; - } - - bool event(QEvent *e) - { - switch (e->type()) { -// ![2] - case QEvent::ScrollPrepare: { - QScrollPrepareEvent *se = static_cast(e); - se->setViewportSize(m_size); - QRectF br = m_viewport->boundingRect(); - se->setContentPosRange(QRectF(0, 0, - qMax(qreal(0), br.width() - m_size.width()), - qMax(qreal(0), br.height() - m_size.height()))); - se->setContentPos(-m_viewport->pos()); - se->accept(); - return true; - } -// ![1] -// ![2] - case QEvent::Scroll: { - QScrollEvent *se = static_cast(e); - m_viewport->setPos(-se->contentPos() - se->overshootDistance()); - return true; - } -// ![2] - default: - break; - } - return QGraphicsObject::event(e); - } - - bool sceneEvent(QEvent *e) - { - switch (e->type()) { - case QEvent::TouchBegin: { - // We need to return true for the TouchBegin here in the - // top-most graphics object - otherwise gestures in our parent - // objects will NOT work at all (the accept() flag is already - // set due to our setAcceptTouchEvents(true) call in the c'tor - return true; - - } - case QEvent::GraphicsSceneMousePress: { - // We need to return true for the MousePress here in the - // top-most graphics object - otherwise gestures in our parent - // objects will NOT work at all (the accept() flag is already - // set to true by Qt) - return true; - - } - default: - break; - } - return QGraphicsObject::sceneEvent(e); - } - - QRectF boundingRect() const - { - return QRectF(0, 0, m_size.width() + 3, m_size.height()); - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(QPen(QColor(100, 100, 100), 3.0)); - painter->drawRect(QRect(1.5, 1.5, m_size.width() - 3, m_size.height() - 3)); - } - - QSizeF m_size; - ViewObject *m_viewport; -}; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(bool useTouch) - { - m_scene = new QGraphicsScene(); - - // -- make the main list - ListObject *mainList = new ListObject(QSizeF(780, 400), useTouch); - mainList->setObjectName(QLatin1String("MainList")); - m_scene->addItem(mainList); -// ![3] - for (int i=0; im_size.width()/3, mainList->m_size.height()), useTouch); - childList->setObjectName(QString("ChildList %1").arg(i)); - fillList(childList); - childList->setParentItem(mainList->viewport()); - childList->setPos(i*mainList->m_size.width()/3, 0); - } - mainList->viewport()->setPos(0, 0); - - - /* - list1->setTransformOriginPoint(200, 200); - list1->setRotation(135); - list1->setPos(20 + 200 * .41, 20 + 200 * .41); - */ -// ![3] - - m_view = new QGraphicsView(m_scene); - setCentralWidget(m_view); - setWindowTitle(tr("Gesture example")); - m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height()); - } - - /** - * Fills the list object \a list with RectObjects. - */ - void fillList(ListObject *list) - { - qreal h = list->m_size.height() / 10; - for (int i=0; im_size.width() - 6, h - 3, QBrush(color), list->viewport()); - rect->setPos(3, h*i+3); - } - list->viewport()->setPos(0, 0); - } - - -protected: - void resizeEvent(QResizeEvent *e) - { - // resize the scene according to our own size to prevent scrolling - m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height()); - QMainWindow::resizeEvent(e); - } - - QGraphicsScene *m_scene; - QGraphicsView *m_view; -}; - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - bool touch = (a.arguments().contains(QLatin1String("--touch"))); - MainWindow mw(touch); - mw.show(); -#ifdef Q_OS_MAC - mw.raise(); -#endif - return a.exec(); -} - -#include "main.moc" diff --git a/examples/scroller/scroller.pro b/examples/scroller/scroller.pro deleted file mode 100644 index bac3f26554..0000000000 --- a/examples/scroller/scroller.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += graphicsview diff --git a/examples/statemachine/README b/examples/statemachine/README deleted file mode 100644 index a0ac35a89b..0000000000 --- a/examples/statemachine/README +++ /dev/null @@ -1,6 +0,0 @@ -Qt is provided with a powerful hierchical finite state machine through -the Qt State Machine classes. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/statemachine/eventtransitions/eventtransitions.desktop b/examples/statemachine/eventtransitions/eventtransitions.desktop deleted file mode 100644 index c1bceb2240..0000000000 --- a/examples/statemachine/eventtransitions/eventtransitions.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Event Transitions -Exec=/opt/usr/bin/eventtransitions -Icon=eventtransitions -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/statemachine/eventtransitions/eventtransitions.pro b/examples/statemachine/eventtransitions/eventtransitions.pro deleted file mode 100644 index 8a9d84e646..0000000000 --- a/examples/statemachine/eventtransitions/eventtransitions.pro +++ /dev/null @@ -1,11 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/eventtransitions -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS eventtransitions.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/eventtransitions -INSTALLS += target sources -QT += widgets - - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/statemachine/eventtransitions/main.cpp b/examples/statemachine/eventtransitions/main.cpp deleted file mode 100644 index b3af3b825f..0000000000 --- a/examples/statemachine/eventtransitions/main.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 - -//! [0] -class Window : public QWidget -{ -public: - Window(QWidget *parent = 0) - : QWidget(parent) - { - QPushButton *button = new QPushButton(this); - button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(button); - layout->setContentsMargins(80, 80, 80, 80); - setLayout(layout); -//! [0] - -//! [1] - QStateMachine *machine = new QStateMachine(this); - - QState *s1 = new QState(); - s1->assignProperty(button, "text", "Outside"); - - QState *s2 = new QState(); - s2->assignProperty(button, "text", "Inside"); -//! [1] - -//! [2] - QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter); - enterTransition->setTargetState(s2); - s1->addTransition(enterTransition); -//! [2] - -//! [3] - QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave); - leaveTransition->setTargetState(s1); - s2->addTransition(leaveTransition); -//! [3] - -//! [4] - QState *s3 = new QState(); - s3->assignProperty(button, "text", "Pressing..."); - - QEventTransition *pressTransition = new QEventTransition(button, QEvent::MouseButtonPress); - pressTransition->setTargetState(s3); - s2->addTransition(pressTransition); - - QEventTransition *releaseTransition = new QEventTransition(button, QEvent::MouseButtonRelease); - releaseTransition->setTargetState(s2); - s3->addTransition(releaseTransition); -//! [4] - -//! [5] - machine->addState(s1); - machine->addState(s2); - machine->addState(s3); - - machine->setInitialState(s1); - machine->start(); - } -}; -//! [5] - -//! [6] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - Window window; - window.resize(300, 300); - window.show(); - - return app.exec(); -} -//! [6] diff --git a/examples/statemachine/factorial/factorial.desktop b/examples/statemachine/factorial/factorial.desktop deleted file mode 100644 index 41b27227f9..0000000000 --- a/examples/statemachine/factorial/factorial.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Factorial States -Exec=/opt/usr/bin/factorial -Icon=factorial -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/statemachine/factorial/factorial.pro b/examples/statemachine/factorial/factorial.pro deleted file mode 100644 index fe3dd23e87..0000000000 --- a/examples/statemachine/factorial/factorial.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT = core -win32: CONFIG += console -mac:CONFIG -= app_bundle - -SOURCES += main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/factorial -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS factorial.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/factorial -INSTALLS += target sources - - diff --git a/examples/statemachine/factorial/main.cpp b/examples/statemachine/factorial/main.cpp deleted file mode 100644 index df50cab02f..0000000000 --- a/examples/statemachine/factorial/main.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include - -//! [0] -class Factorial : public QObject -{ - Q_OBJECT - Q_PROPERTY(int x READ x WRITE setX) - Q_PROPERTY(int fac READ fac WRITE setFac) -public: - Factorial(QObject *parent = 0) - : QObject(parent), m_x(-1), m_fac(1) - { - } - - int x() const - { - return m_x; - } - - void setX(int x) - { - if (x == m_x) - return; - m_x = x; - emit xChanged(x); - } - - int fac() const - { - return m_fac; - } - - void setFac(int fac) - { - m_fac = fac; - } - -Q_SIGNALS: - void xChanged(int value); - -private: - int m_x; - int m_fac; -}; -//! [0] - -//! [1] -class FactorialLoopTransition : public QSignalTransition -{ -public: - FactorialLoopTransition(Factorial *fact) - : QSignalTransition(fact, SIGNAL(xChanged(int))), m_fact(fact) - {} - - virtual bool eventTest(QEvent *e) - { - if (!QSignalTransition::eventTest(e)) - return false; - QStateMachine::SignalEvent *se = static_cast(e); - return se->arguments().at(0).toInt() > 1; - } - - virtual void onTransition(QEvent *e) - { - QStateMachine::SignalEvent *se = static_cast(e); - int x = se->arguments().at(0).toInt(); - int fac = m_fact->property("fac").toInt(); - m_fact->setProperty("fac", x * fac); - m_fact->setProperty("x", x - 1); - } - -private: - Factorial *m_fact; -}; -//! [1] - -//! [2] -class FactorialDoneTransition : public QSignalTransition -{ -public: - FactorialDoneTransition(Factorial *fact) - : QSignalTransition(fact, SIGNAL(xChanged(int))), m_fact(fact) - {} - - virtual bool eventTest(QEvent *e) - { - if (!QSignalTransition::eventTest(e)) - return false; - QStateMachine::SignalEvent *se = static_cast(e); - return se->arguments().at(0).toInt() <= 1; - } - - virtual void onTransition(QEvent *) - { - fprintf(stdout, "%d\n", m_fact->property("fac").toInt()); - } - -private: - Factorial *m_fact; -}; -//! [2] - -//! [3] -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - Factorial factorial; - QStateMachine machine; -//! [3] - -//! [4] - QState *compute = new QState(&machine); - compute->assignProperty(&factorial, "fac", 1); - compute->assignProperty(&factorial, "x", 6); - compute->addTransition(new FactorialLoopTransition(&factorial)); -//! [4] - -//! [5] - QFinalState *done = new QFinalState(&machine); - FactorialDoneTransition *doneTransition = new FactorialDoneTransition(&factorial); - doneTransition->setTargetState(done); - compute->addTransition(doneTransition); -//! [5] - -//! [6] - machine.setInitialState(compute); - QObject::connect(&machine, SIGNAL(finished()), &app, SLOT(quit())); - machine.start(); - - return app.exec(); -} -//! [6] - -#include "main.moc" diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp deleted file mode 100644 index 636e7193b2..0000000000 --- a/examples/statemachine/pingpong/main.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include - -//! [0] -class PingEvent : public QEvent -{ -public: - PingEvent() : QEvent(QEvent::Type(QEvent::User+2)) - {} -}; - -class PongEvent : public QEvent -{ -public: - PongEvent() : QEvent(QEvent::Type(QEvent::User+3)) - {} -}; -//! [0] - -//! [1] -class Pinger : public QState -{ -public: - Pinger(QState *parent) - : QState(parent) {} - -protected: - virtual void onEntry(QEvent *) - { - machine()->postEvent(new PingEvent()); - fprintf(stdout, "ping?\n"); - } -}; -//! [1] - -//! [3] -class PongTransition : public QAbstractTransition -{ -public: - PongTransition() {} - -protected: - virtual bool eventTest(QEvent *e) { - return (e->type() == QEvent::User+3); - } - virtual void onTransition(QEvent *) - { - machine()->postDelayedEvent(new PingEvent(), 500); - fprintf(stdout, "ping?\n"); - } -}; -//! [3] - -//! [2] -class PingTransition : public QAbstractTransition -{ -public: - PingTransition() {} - -protected: - virtual bool eventTest(QEvent *e) { - return (e->type() == QEvent::User+2); - } - virtual void onTransition(QEvent *) - { - machine()->postDelayedEvent(new PongEvent(), 500); - fprintf(stdout, "pong!\n"); - } -}; -//! [2] - -//! [4] -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QStateMachine machine; - QState *group = new QState(QState::ParallelStates); - group->setObjectName("group"); -//! [4] - -//! [5] - Pinger *pinger = new Pinger(group); - pinger->setObjectName("pinger"); - pinger->addTransition(new PongTransition()); - - QState *ponger = new QState(group); - ponger->setObjectName("ponger"); - ponger->addTransition(new PingTransition()); -//! [5] - -//! [6] - machine.addState(group); - machine.setInitialState(group); - machine.start(); - - return app.exec(); -} -//! [6] diff --git a/examples/statemachine/pingpong/pingpong.desktop b/examples/statemachine/pingpong/pingpong.desktop deleted file mode 100644 index 79646a2cc8..0000000000 --- a/examples/statemachine/pingpong/pingpong.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Ping Pong States -Exec=/opt/usr/bin/pingpong -Icon=pingpong -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/statemachine/pingpong/pingpong.pro b/examples/statemachine/pingpong/pingpong.pro deleted file mode 100644 index 1cfddaf282..0000000000 --- a/examples/statemachine/pingpong/pingpong.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT = core -win32: CONFIG += console -mac:CONFIG -= app_bundle - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/pingpong -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS pingpong.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/pingpong -INSTALLS += target sources - - diff --git a/examples/statemachine/rogue/main.cpp b/examples/statemachine/rogue/main.cpp deleted file mode 100644 index c909c17cde..0000000000 --- a/examples/statemachine/rogue/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation 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 - -#include "window.h" - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - Window window; - window.show(); - - return app.exec(); -} - diff --git a/examples/statemachine/rogue/movementtransition.h b/examples/statemachine/rogue/movementtransition.h deleted file mode 100644 index 6f27da93b8..0000000000 --- a/examples/statemachine/rogue/movementtransition.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation 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 MOVEMENTTRANSITION_H -#define MOVEMENTTRANSITION_H - -#include - -#include "window.h" - -//![0] -class MovementTransition : public QEventTransition -{ - Q_OBJECT - -public: - MovementTransition(Window *window) : - QEventTransition(window, QEvent::KeyPress) { - this->window = window; - } -//![0] - -//![1] -protected: - bool eventTest(QEvent *event) { - if (event->type() == QEvent::StateMachineWrapped && - static_cast(event)->event()->type() == QEvent::KeyPress) { - QEvent *wrappedEvent = static_cast(event)->event(); - - QKeyEvent *keyEvent = static_cast(wrappedEvent); - int key = keyEvent->key(); - - return key == Qt::Key_2 || key == Qt::Key_8 || key == Qt::Key_6 || - key == Qt::Key_4 || key == Qt::Key_Down || key == Qt::Key_Up || - key == Qt::Key_Right || key == Qt::Key_Left; - } - return false; - } -//![1] - -//![2] - void onTransition(QEvent *event) { - QKeyEvent *keyEvent = static_cast( - static_cast(event)->event()); - - int key = keyEvent->key(); - switch (key) { - case Qt::Key_Left: - case Qt::Key_4: - window->movePlayer(Window::Left); - break; - case Qt::Key_Up: - case Qt::Key_8: - window->movePlayer(Window::Up); - break; - case Qt::Key_Right: - case Qt::Key_6: - window->movePlayer(Window::Right); - break; - case Qt::Key_Down: - case Qt::Key_2: - window->movePlayer(Window::Down); - break; - default: - ; - } - } -//![2] - -private: - Window *window; -}; - -#endif - diff --git a/examples/statemachine/rogue/rogue.desktop b/examples/statemachine/rogue/rogue.desktop deleted file mode 100644 index 71ca4b6511..0000000000 --- a/examples/statemachine/rogue/rogue.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Rogue -Exec=/opt/usr/bin/rogue -Icon=rogue -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/statemachine/rogue/rogue.pro b/examples/statemachine/rogue/rogue.pro deleted file mode 100644 index 4ed132db06..0000000000 --- a/examples/statemachine/rogue/rogue.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = window.h \ - movementtransition.h -SOURCES = main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/rogue -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/rogue -INSTALLS += target sources - -QT += widgets - diff --git a/examples/statemachine/rogue/window.cpp b/examples/statemachine/rogue/window.cpp deleted file mode 100644 index 0c57b2c2d7..0000000000 --- a/examples/statemachine/rogue/window.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation 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 - -#include "window.h" -#include "movementtransition.h" - -//![0] -Window::Window() -{ - pX = 5; - pY = 5; -//![0] - - QFontDatabase database; - QFont font; - if (database.families().contains("Monospace")) { - font = QFont("Monospace"); - } - else { - foreach (QString family, database.families()) { - if (database.isFixedPitch(family)) { - font = QFont(family); - break; - } - } - } - font.setPointSize(12); - setFont(font); - -//![1] - setupMap(); - buildMachine(); -} -//![1] - -void Window::setStatus(const QString &status) -{ - myStatus = status; - repaint(); -} - -QString Window::status() const -{ - return myStatus; -} - -void Window::paintEvent(QPaintEvent * /* event */) -{ - QFontMetrics metrics(font()); - QPainter painter(this); - int fontHeight = metrics.height(); - int fontWidth = metrics.width('X'); - int yPos = fontHeight; - int xPos; - - painter.fillRect(rect(), Qt::black); - painter.setPen(Qt::white); - - painter.drawText(QPoint(0, yPos), status()); - - for (int y = 0; y < HEIGHT; ++y) { - yPos += fontHeight; - xPos = 0; - - for (int x = 0; x < WIDTH; ++x) { - if (y == pY && x == pX) { - xPos += fontWidth; - continue; - } - - painter.setPen(Qt::white); - - double x1 = static_cast(pX); - double y1 = static_cast(pY); - double x2 = static_cast(x); - double y2 = static_cast(y); - - if (x2x1) { - x2-=0.5; - } - - if (y2y1) { - y2-=0.5; - } - - double dx = x2 - x1; - double dy = y2 - y1; - - double length = qSqrt(dx*dx+dy*dy); - - dx /= length; - dy /= length; - - double xi = x1; - double yi = y1; - - while (length > 0) { - int cx = static_cast(xi+0.5); - int cy = static_cast(yi+0.5); - - if (x2 == cx && y2 == cy) - break; - - if (!(x1==cx && y1==cy) - && (map[cx][cy] == '#' || (length-10) > 0)) { - painter.setPen(QColor(60,60,60)); - break; - } - - xi += dx; - yi += dy; - --length; - } - - painter.drawText(QPoint(xPos, yPos), map[x][y]); - xPos += fontWidth; - } - } - painter.setPen(Qt::white); - painter.drawText(QPoint(pX * fontWidth, (pY + 2) * fontHeight), QChar('@')); -} - -QSize Window::sizeHint() const -{ - QFontMetrics metrics(font()); - - return QSize(metrics.width('X') * WIDTH, metrics.height() * (HEIGHT + 1)); -} - -//![2] -void Window::buildMachine() -{ - machine = new QStateMachine; - - QState *inputState = new QState(machine); - inputState->assignProperty(this, "status", "Move the rogue with 2, 4, 6, and 8"); - - MovementTransition *transition = new MovementTransition(this); - inputState->addTransition(transition); -//![2] - -//![3] - QState *quitState = new QState(machine); - quitState->assignProperty(this, "status", "Really quit(y/n)?"); - - QKeyEventTransition *yesTransition = new - QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Y); - yesTransition->setTargetState(new QFinalState(machine)); - quitState->addTransition(yesTransition); - - QKeyEventTransition *noTransition = - new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_N); - noTransition->setTargetState(inputState); - quitState->addTransition(noTransition); -//![3] - -//![4] - QKeyEventTransition *quitTransition = - new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Q); - quitTransition->setTargetState(quitState); - inputState->addTransition(quitTransition); -//![4] - -//![5] - machine->setInitialState(inputState); - - connect(machine, SIGNAL(finished()), qApp, SLOT(quit())); - - machine->start(); -} -//![5] - -void Window::movePlayer(Direction direction) -{ - switch (direction) { - case Left: - if (map[pX - 1][pY] != '#') - --pX; - break; - case Right: - if (map[pX + 1][pY] != '#') - ++pX; - break; - case Up: - if (map[pX][pY - 1] != '#') - --pY; - break; - case Down: - if (map[pX][pY + 1] != '#') - ++pY; - break; - } - repaint(); -} - -void Window::setupMap() -{ - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); - - for (int x = 0; x < WIDTH; ++x) - for (int y = 0; y < HEIGHT; ++y) { - if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || qrand() % 40 == 0) - map[x][y] = '#'; - else - map[x][y] = '.'; - } -} - diff --git a/examples/statemachine/rogue/window.h b/examples/statemachine/rogue/window.h deleted file mode 100644 index 8ef3591e96..0000000000 --- a/examples/statemachine/rogue/window.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation 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 - -QT_BEGIN_NAMESPACE -class QState; -class QStateMachine; -class QTransition; -QT_END_NAMESPACE - -#define WIDTH 35 -#define HEIGHT 20 - -//![0] -class Window : public QWidget -{ - Q_OBJECT - Q_PROPERTY(QString status READ status WRITE setStatus) - -public: - enum Direction { Up, Down, Left, Right }; - - Window(); - - void movePlayer(Direction direction); - void setStatus(const QString &status); - QString status() const; - - QSize sizeHint() const; - -protected: - void paintEvent(QPaintEvent *event); -//![0] - -//![1] -private: - void buildMachine(); - void setupMap(); - - QChar map[WIDTH][HEIGHT]; - int pX, pY; - - QStateMachine *machine; - QString myStatus; -}; -//![1] - -#endif - diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro deleted file mode 100644 index 7d510b29be..0000000000 --- a/examples/statemachine/statemachine.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = \ - factorial \ - pingpong - -!contains(QT_CONFIG, no-widgets) { - SUBDIRS += \ - eventtransitions \ - rogue \ - trafficlight \ - twowaybutton -} - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS statemachine.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine -INSTALLS += target sources diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp deleted file mode 100644 index 624e3f1559..0000000000 --- a/examples/statemachine/trafficlight/main.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 - -//! [0] -class LightWidget : public QWidget -{ - Q_OBJECT - Q_PROPERTY(bool on READ isOn WRITE setOn) -public: - LightWidget(const QColor &color, QWidget *parent = 0) - : QWidget(parent), m_color(color), m_on(false) {} - - bool isOn() const - { return m_on; } - void setOn(bool on) - { - if (on == m_on) - return; - m_on = on; - update(); - } - -public slots: - void turnOff() { setOn(false); } - void turnOn() { setOn(true); } - -protected: - virtual void paintEvent(QPaintEvent *) - { - if (!m_on) - return; - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(m_color); - painter.drawEllipse(0, 0, width(), height()); - } - -private: - QColor m_color; - bool m_on; -}; -//! [0] - -//! [1] -class TrafficLightWidget : public QWidget -{ -public: - TrafficLightWidget(QWidget *parent = 0) - : QWidget(parent) - { - QVBoxLayout *vbox = new QVBoxLayout(this); - m_red = new LightWidget(Qt::red); - vbox->addWidget(m_red); - m_yellow = new LightWidget(Qt::yellow); - vbox->addWidget(m_yellow); - m_green = new LightWidget(Qt::green); - vbox->addWidget(m_green); - QPalette pal = palette(); - pal.setColor(QPalette::Background, Qt::black); - setPalette(pal); - setAutoFillBackground(true); - } - - LightWidget *redLight() const - { return m_red; } - LightWidget *yellowLight() const - { return m_yellow; } - LightWidget *greenLight() const - { return m_green; } - -private: - LightWidget *m_red; - LightWidget *m_yellow; - LightWidget *m_green; -}; -//! [1] - -//! [2] -QState *createLightState(LightWidget *light, int duration, QState *parent = 0) -{ - QState *lightState = new QState(parent); - QTimer *timer = new QTimer(lightState); - timer->setInterval(duration); - timer->setSingleShot(true); - QState *timing = new QState(lightState); - QObject::connect(timing, SIGNAL(entered()), light, SLOT(turnOn())); - QObject::connect(timing, SIGNAL(entered()), timer, SLOT(start())); - QObject::connect(timing, SIGNAL(exited()), light, SLOT(turnOff())); - QFinalState *done = new QFinalState(lightState); - timing->addTransition(timer, SIGNAL(timeout()), done); - lightState->setInitialState(timing); - return lightState; -} -//! [2] - -//! [3] -class TrafficLight : public QWidget -{ -public: - TrafficLight(QWidget *parent = 0) - : QWidget(parent) - { - QVBoxLayout *vbox = new QVBoxLayout(this); - TrafficLightWidget *widget = new TrafficLightWidget(); - vbox->addWidget(widget); - vbox->setMargin(0); - - QStateMachine *machine = new QStateMachine(this); - QState *redGoingYellow = createLightState(widget->redLight(), 3000); - redGoingYellow->setObjectName("redGoingYellow"); - QState *yellowGoingGreen = createLightState(widget->yellowLight(), 1000); - yellowGoingGreen->setObjectName("yellowGoingGreen"); - redGoingYellow->addTransition(redGoingYellow, SIGNAL(finished()), yellowGoingGreen); - QState *greenGoingYellow = createLightState(widget->greenLight(), 3000); - greenGoingYellow->setObjectName("greenGoingYellow"); - yellowGoingGreen->addTransition(yellowGoingGreen, SIGNAL(finished()), greenGoingYellow); - QState *yellowGoingRed = createLightState(widget->yellowLight(), 1000); - yellowGoingRed->setObjectName("yellowGoingRed"); - greenGoingYellow->addTransition(greenGoingYellow, SIGNAL(finished()), yellowGoingRed); - yellowGoingRed->addTransition(yellowGoingRed, SIGNAL(finished()), redGoingYellow); - - machine->addState(redGoingYellow); - machine->addState(yellowGoingGreen); - machine->addState(greenGoingYellow); - machine->addState(yellowGoingRed); - machine->setInitialState(redGoingYellow); - machine->start(); - } -}; -//! [3] - -//! [4] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - TrafficLight widget; - widget.resize(110, 300); - widget.show(); - - return app.exec(); -} -//! [4] - -#include "main.moc" diff --git a/examples/statemachine/trafficlight/trafficlight.desktop b/examples/statemachine/trafficlight/trafficlight.desktop deleted file mode 100644 index 8a5cc1673b..0000000000 --- a/examples/statemachine/trafficlight/trafficlight.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Traffic Light -Exec=/opt/usr/bin/trafficlight -Icon=trafficlight -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/statemachine/trafficlight/trafficlight.pro b/examples/statemachine/trafficlight/trafficlight.pro deleted file mode 100644 index 5bc0cdaef5..0000000000 --- a/examples/statemachine/trafficlight/trafficlight.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/trafficlight -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS trafficlight.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/trafficlight -INSTALLS += target sources -QT += widgets - - diff --git a/examples/statemachine/twowaybutton/main.cpp b/examples/statemachine/twowaybutton/main.cpp deleted file mode 100644 index 05f82538ff..0000000000 --- a/examples/statemachine/twowaybutton/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 - -//! [0] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - QPushButton button; - QStateMachine machine; -//! [0] - -//! [1] - QState *off = new QState(); - off->assignProperty(&button, "text", "Off"); - off->setObjectName("off"); - - QState *on = new QState(); - on->setObjectName("on"); - on->assignProperty(&button, "text", "On"); -//! [1] - -//! [2] - off->addTransition(&button, SIGNAL(clicked()), on); - on->addTransition(&button, SIGNAL(clicked()), off); -//! [2] - -//! [3] - machine.addState(off); - machine.addState(on); -//! [3] - -//! [4] - machine.setInitialState(off); - machine.start(); -//! [4] - -//! [5] - button.resize(100, 50); - button.show(); - return app.exec(); -} -//! [5] diff --git a/examples/statemachine/twowaybutton/twowaybutton.desktop b/examples/statemachine/twowaybutton/twowaybutton.desktop deleted file mode 100644 index 9dd0918937..0000000000 --- a/examples/statemachine/twowaybutton/twowaybutton.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Two-way Button -Exec=/opt/usr/bin/twowaybutton -Icon=twowaybutton -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/statemachine/twowaybutton/twowaybutton.pro b/examples/statemachine/twowaybutton/twowaybutton.pro deleted file mode 100644 index ffbd982845..0000000000 --- a/examples/statemachine/twowaybutton/twowaybutton.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/twowaybutton -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS twowaybutton.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/statemachine/twowaybutton -INSTALLS += target sources -QT += widgets - - diff --git a/examples/widgets/README b/examples/widgets/README deleted file mode 100644 index e862f07b71..0000000000 --- a/examples/widgets/README +++ /dev/null @@ -1,13 +0,0 @@ -Qt comes with a large range of standard widgets that users of modern -applications have come to expect. - -You can also develop your own custom widgets and controls, and use them -alongside standard widgets. - -It is even possible to provide custom styles and themes for widgets that can -be used to change the appearance of standard widgets and appropriately -written custom widgets. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/widgets/analogclock/analogclock.cpp b/examples/widgets/analogclock/analogclock.cpp deleted file mode 100644 index 029ca1031a..0000000000 --- a/examples/widgets/analogclock/analogclock.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "analogclock.h" - -//! [0] //! [1] -AnalogClock::AnalogClock(QWidget *parent) -//! [0] //! [2] - : QWidget(parent) -//! [2] //! [3] -{ -//! [3] //! [4] - QTimer *timer = new QTimer(this); -//! [4] //! [5] - connect(timer, SIGNAL(timeout()), this, SLOT(update())); -//! [5] //! [6] - timer->start(1000); -//! [6] - - setWindowTitle(tr("Analog Clock")); - resize(200, 200); -//! [7] -} -//! [1] //! [7] - -//! [8] //! [9] -void AnalogClock::paintEvent(QPaintEvent *) -//! [8] //! [10] -{ - static const QPoint hourHand[3] = { - QPoint(7, 8), - QPoint(-7, 8), - QPoint(0, -40) - }; - static const QPoint minuteHand[3] = { - QPoint(7, 8), - QPoint(-7, 8), - QPoint(0, -70) - }; - - QColor hourColor(127, 0, 127); - QColor minuteColor(0, 127, 127, 191); - - int side = qMin(width(), height()); - QTime time = QTime::currentTime(); -//! [10] - -//! [11] - QPainter painter(this); -//! [11] //! [12] - painter.setRenderHint(QPainter::Antialiasing); -//! [12] //! [13] - painter.translate(width() / 2, height() / 2); -//! [13] //! [14] - painter.scale(side / 200.0, side / 200.0); -//! [9] //! [14] - -//! [15] - painter.setPen(Qt::NoPen); -//! [15] //! [16] - painter.setBrush(hourColor); -//! [16] - -//! [17] //! [18] - painter.save(); -//! [17] //! [19] - painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); - painter.drawConvexPolygon(hourHand, 3); - painter.restore(); -//! [18] //! [19] - -//! [20] - painter.setPen(hourColor); -//! [20] //! [21] - - for (int i = 0; i < 12; ++i) { - painter.drawLine(88, 0, 96, 0); - painter.rotate(30.0); - } -//! [21] - -//! [22] - painter.setPen(Qt::NoPen); -//! [22] //! [23] - painter.setBrush(minuteColor); - -//! [24] - painter.save(); - painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); - painter.drawConvexPolygon(minuteHand, 3); - painter.restore(); -//! [23] //! [24] - -//! [25] - painter.setPen(minuteColor); -//! [25] //! [26] - -//! [27] - for (int j = 0; j < 60; ++j) { - if ((j % 5) != 0) - painter.drawLine(92, 0, 96, 0); - painter.rotate(6.0); - } -//! [27] -} -//! [26] diff --git a/examples/widgets/analogclock/analogclock.desktop b/examples/widgets/analogclock/analogclock.desktop deleted file mode 100644 index b177a62d35..0000000000 --- a/examples/widgets/analogclock/analogclock.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Analog Clock -Exec=/opt/usr/bin/analogclock -Icon=analogclock -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/widgets/analogclock/analogclock.h b/examples/widgets/analogclock/analogclock.h deleted file mode 100644 index f95a095712..0000000000 --- a/examples/widgets/analogclock/analogclock.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 ANALOGCLOCK_H -#define ANALOGCLOCK_H - -#include - -//! [0] -class AnalogClock : public QWidget -{ - Q_OBJECT - -public: - AnalogClock(QWidget *parent = 0); - -protected: - void paintEvent(QPaintEvent *event); -}; -//! [0] - -#endif diff --git a/examples/widgets/analogclock/analogclock.pro b/examples/widgets/analogclock/analogclock.pro deleted file mode 100644 index a2641150e2..0000000000 --- a/examples/widgets/analogclock/analogclock.pro +++ /dev/null @@ -1,12 +0,0 @@ -HEADERS = analogclock.h -SOURCES = analogclock.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/analogclock -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS analogclock.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/analogclock -INSTALLS += target sources - -QT += widgets - diff --git a/examples/widgets/analogclock/main.cpp b/examples/widgets/analogclock/main.cpp deleted file mode 100644 index 0efedc7acf..0000000000 --- a/examples/widgets/analogclock/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "analogclock.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - AnalogClock clock; - clock.show(); - return app.exec(); -} diff --git a/examples/widgets/animation/README b/examples/widgets/animation/README new file mode 100644 index 0000000000..e723a28722 --- /dev/null +++ b/examples/widgets/animation/README @@ -0,0 +1,8 @@ +The animation framework aims to provide an easy way for creating animated and +smooth GUI's. By animating Qt properties, the framework provides great freedom +for animating widgets and other QObjects. The framework can also be used with +the Graphics View framework. + + +Documentation for these examples can be found via the Examples +link in the main Qt documentation. diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.desktop b/examples/widgets/animation/animatedtiles/animatedtiles.desktop new file mode 100644 index 0000000000..97e646fdf8 --- /dev/null +++ b/examples/widgets/animation/animatedtiles/animatedtiles.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Animated Tiles +Exec=/opt/usr/bin/animatedtiles +Icon=animatedtiles +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.pro b/examples/widgets/animation/animatedtiles/animatedtiles.pro new file mode 100644 index 0000000000..1bba99449c --- /dev/null +++ b/examples/widgets/animation/animatedtiles/animatedtiles.pro @@ -0,0 +1,10 @@ +SOURCES = main.cpp +RESOURCES = animatedtiles.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/animatedtiles +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animatedtiles.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/animatedtiles +INSTALLS += target sources + +QT += widgets diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.qrc b/examples/widgets/animation/animatedtiles/animatedtiles.qrc new file mode 100644 index 0000000000..c43a979723 --- /dev/null +++ b/examples/widgets/animation/animatedtiles/animatedtiles.qrc @@ -0,0 +1,11 @@ + + + images/Time-For-Lunch-2.jpg + images/centered.png + images/ellipse.png + images/figure8.png + images/kinetic.png + images/random.png + images/tile.png + + diff --git a/examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg b/examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg new file mode 100644 index 0000000000..c57a555490 Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg differ diff --git a/examples/widgets/animation/animatedtiles/images/centered.png b/examples/widgets/animation/animatedtiles/images/centered.png new file mode 100644 index 0000000000..e416156a0e Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/centered.png differ diff --git a/examples/widgets/animation/animatedtiles/images/ellipse.png b/examples/widgets/animation/animatedtiles/images/ellipse.png new file mode 100644 index 0000000000..2c3ba881c5 Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/ellipse.png differ diff --git a/examples/widgets/animation/animatedtiles/images/figure8.png b/examples/widgets/animation/animatedtiles/images/figure8.png new file mode 100644 index 0000000000..6b058041c4 Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/figure8.png differ diff --git a/examples/widgets/animation/animatedtiles/images/kinetic.png b/examples/widgets/animation/animatedtiles/images/kinetic.png new file mode 100644 index 0000000000..55cfa5515f Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/kinetic.png differ diff --git a/examples/widgets/animation/animatedtiles/images/random.png b/examples/widgets/animation/animatedtiles/images/random.png new file mode 100644 index 0000000000..415d96f856 Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/random.png differ diff --git a/examples/widgets/animation/animatedtiles/images/tile.png b/examples/widgets/animation/animatedtiles/images/tile.png new file mode 100644 index 0000000000..c8f39d8d40 Binary files /dev/null and b/examples/widgets/animation/animatedtiles/images/tile.png differ diff --git a/examples/widgets/animation/animatedtiles/main.cpp b/examples/widgets/animation/animatedtiles/main.cpp new file mode 100644 index 0000000000..50bd33860e --- /dev/null +++ b/examples/widgets/animation/animatedtiles/main.cpp @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 +#include + +class Pixmap : public QObject, public QGraphicsPixmapItem +{ + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + Pixmap(const QPixmap &pix) + : QObject(), QGraphicsPixmapItem(pix) + { + setCacheMode(DeviceCoordinateCache); + } +}; + +class Button : public QGraphicsWidget +{ + Q_OBJECT +public: + Button(const QPixmap &pixmap, QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), _pix(pixmap) + { + setAcceptHoverEvents(true); + setCacheMode(DeviceCoordinateCache); + } + + QRectF boundingRect() const + { + return QRectF(-65, -65, 130, 130); + } + + QPainterPath shape() const + { + QPainterPath path; + path.addEllipse(boundingRect()); + return path; + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) + { + bool down = option->state & QStyle::State_Sunken; + QRectF r = boundingRect(); + QLinearGradient grad(r.topLeft(), r.bottomRight()); + grad.setColorAt(down ? 1 : 0, option->state & QStyle::State_MouseOver ? Qt::white : Qt::lightGray); + grad.setColorAt(down ? 0 : 1, Qt::darkGray); + painter->setPen(Qt::darkGray); + painter->setBrush(grad); + painter->drawEllipse(r); + QLinearGradient grad2(r.topLeft(), r.bottomRight()); + grad.setColorAt(down ? 1 : 0, Qt::darkGray); + grad.setColorAt(down ? 0 : 1, Qt::lightGray); + painter->setPen(Qt::NoPen); + painter->setBrush(grad); + if (down) + painter->translate(2, 2); + painter->drawEllipse(r.adjusted(5, 5, -5, -5)); + painter->drawPixmap(-_pix.width()/2, -_pix.height()/2, _pix); + } + +signals: + void pressed(); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *) + { + emit pressed(); + update(); + } + + void mouseReleaseEvent(QGraphicsSceneMouseEvent *) + { + update(); + } + +private: + QPixmap _pix; +}; + +class View : public QGraphicsView +{ +public: + View(QGraphicsScene *scene) : QGraphicsView(scene) { } + +protected: + void resizeEvent(QResizeEvent *event) + { + QGraphicsView::resizeEvent(event); + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +}; + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(animatedtiles); + + QApplication app(argc, argv); + + QPixmap kineticPix(":/images/kinetic.png"); + QPixmap bgPix(":/images/Time-For-Lunch-2.jpg"); + + QGraphicsScene scene(-350, -350, 700, 700); + + QList items; + for (int i = 0; i < 64; ++i) { + Pixmap *item = new Pixmap(kineticPix); + item->setOffset(-kineticPix.width()/2, -kineticPix.height()/2); + item->setZValue(i); + items << item; + scene.addItem(item); + } + + // Buttons + QGraphicsItem *buttonParent = new QGraphicsRectItem; + Button *ellipseButton = new Button(QPixmap(":/images/ellipse.png"), buttonParent); + Button *figure8Button = new Button(QPixmap(":/images/figure8.png"), buttonParent); + Button *randomButton = new Button(QPixmap(":/images/random.png"), buttonParent); + Button *tiledButton = new Button(QPixmap(":/images/tile.png"), buttonParent); + Button *centeredButton = new Button(QPixmap(":/images/centered.png"), buttonParent); + + ellipseButton->setPos(-100, -100); + figure8Button->setPos(100, -100); + randomButton->setPos(0, 0); + tiledButton->setPos(-100, 100); + centeredButton->setPos(100, 100); + + scene.addItem(buttonParent); + buttonParent->setTransform(QTransform::fromScale(0.75, 0.75), true); + buttonParent->setPos(200, 200); + buttonParent->setZValue(65); + + // States + QState *rootState = new QState; + QState *ellipseState = new QState(rootState); + QState *figure8State = new QState(rootState); + QState *randomState = new QState(rootState); + QState *tiledState = new QState(rootState); + QState *centeredState = new QState(rootState); + + // Values + for (int i = 0; i < items.count(); ++i) { + Pixmap *item = items.at(i); + // Ellipse + ellipseState->assignProperty(item, "pos", + QPointF(cos((i / 63.0) * 6.28) * 250, + sin((i / 63.0) * 6.28) * 250)); + + // Figure 8 + figure8State->assignProperty(item, "pos", + QPointF(sin((i / 63.0) * 6.28) * 250, + sin(((i * 2)/63.0) * 6.28) * 250)); + + // Random + randomState->assignProperty(item, "pos", + QPointF(-250 + qrand() % 500, + -250 + qrand() % 500)); + + // Tiled + tiledState->assignProperty(item, "pos", + QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2, + ((i / 8) - 4) * kineticPix.height() + kineticPix.height() / 2)); + + // Centered + centeredState->assignProperty(item, "pos", QPointF()); + } + + // Ui + View *view = new View(&scene); + view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Animated Tiles")); + view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + view->setBackgroundBrush(bgPix); + view->setCacheMode(QGraphicsView::CacheBackground); + view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + view->show(); + + QStateMachine states; + states.addState(rootState); + states.setInitialState(rootState); + rootState->setInitialState(centeredState); + + QParallelAnimationGroup *group = new QParallelAnimationGroup; + for (int i = 0; i < items.count(); ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + QAbstractTransition *trans = rootState->addTransition(ellipseButton, SIGNAL(pressed()), ellipseState); + trans->addAnimation(group); + + trans = rootState->addTransition(figure8Button, SIGNAL(pressed()), figure8State); + trans->addAnimation(group); + + trans = rootState->addTransition(randomButton, SIGNAL(pressed()), randomState); + trans->addAnimation(group); + + trans = rootState->addTransition(tiledButton, SIGNAL(pressed()), tiledState); + trans->addAnimation(group); + + trans = rootState->addTransition(centeredButton, SIGNAL(pressed()), centeredState); + trans->addAnimation(group); + + QTimer timer; + timer.start(125); + timer.setSingleShot(true); + trans = rootState->addTransition(&timer, SIGNAL(timeout()), ellipseState); + trans->addAnimation(group); + + states.start(); + +#ifdef QT_KEYPAD_NAVIGATION + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif + return app.exec(); +} + +#include "main.moc" diff --git a/examples/widgets/animation/animation.pro b/examples/widgets/animation/animation.pro new file mode 100644 index 0000000000..b17aa0e0fe --- /dev/null +++ b/examples/widgets/animation/animation.pro @@ -0,0 +1,17 @@ +TEMPLATE = \ + subdirs +SUBDIRS += \ + animatedtiles \ + appchooser \ + easing \ + moveblocks \ + states \ + stickman \ + sub-attaq \ + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animation.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation +INSTALLS += target sources +QT += widgets diff --git a/examples/widgets/animation/appchooser/accessories-dictionary.png b/examples/widgets/animation/appchooser/accessories-dictionary.png new file mode 100644 index 0000000000..e9bd55d918 Binary files /dev/null and b/examples/widgets/animation/appchooser/accessories-dictionary.png differ diff --git a/examples/widgets/animation/appchooser/akregator.png b/examples/widgets/animation/appchooser/akregator.png new file mode 100644 index 0000000000..a086f45ab6 Binary files /dev/null and b/examples/widgets/animation/appchooser/akregator.png differ diff --git a/examples/widgets/animation/appchooser/appchooser.desktop b/examples/widgets/animation/appchooser/appchooser.desktop new file mode 100644 index 0000000000..8e413e96c2 --- /dev/null +++ b/examples/widgets/animation/appchooser/appchooser.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Application Chooser +Exec=/opt/usr/bin/appchooser +Icon=appchooser +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/animation/appchooser/appchooser.pro b/examples/widgets/animation/appchooser/appchooser.pro new file mode 100644 index 0000000000..158a0eca9f --- /dev/null +++ b/examples/widgets/animation/appchooser/appchooser.pro @@ -0,0 +1,10 @@ +SOURCES = main.cpp +RESOURCES = appchooser.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/appchooser +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS appchooser.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/appchooser +INSTALLS += target sources + +QT += widgets diff --git a/examples/widgets/animation/appchooser/appchooser.qrc b/examples/widgets/animation/appchooser/appchooser.qrc new file mode 100644 index 0000000000..28a3e1c4c1 --- /dev/null +++ b/examples/widgets/animation/appchooser/appchooser.qrc @@ -0,0 +1,8 @@ + + + accessories-dictionary.png + akregator.png + digikam.png + k3b.png + + diff --git a/examples/widgets/animation/appchooser/digikam.png b/examples/widgets/animation/appchooser/digikam.png new file mode 100644 index 0000000000..9de9fb2f80 Binary files /dev/null and b/examples/widgets/animation/appchooser/digikam.png differ diff --git a/examples/widgets/animation/appchooser/k3b.png b/examples/widgets/animation/appchooser/k3b.png new file mode 100644 index 0000000000..bbcafcfba1 Binary files /dev/null and b/examples/widgets/animation/appchooser/k3b.png differ diff --git a/examples/widgets/animation/appchooser/main.cpp b/examples/widgets/animation/appchooser/main.cpp new file mode 100644 index 0000000000..c8e60c0641 --- /dev/null +++ b/examples/widgets/animation/appchooser/main.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 +#include + + +class Pixmap : public QGraphicsWidget +{ + Q_OBJECT + +public: + Pixmap(const QPixmap &pix, QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), orig(pix), p(pix) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->drawPixmap(QPointF(), p); + } + + virtual void mousePressEvent(QGraphicsSceneMouseEvent * ) + { + emit clicked(); + } + + virtual void setGeometry(const QRectF &rect) + { + QGraphicsWidget::setGeometry(rect); + + if (rect.size().width() > orig.size().width()) + p = orig.scaled(rect.size().toSize()); + else + p = orig; + } + +Q_SIGNALS: + void clicked(); + +private: + QPixmap orig; + QPixmap p; +}; + +class GraphicsView : public QGraphicsView +{ + Q_OBJECT +public: + GraphicsView(QGraphicsScene *scene, QWidget *parent = 0) : QGraphicsView(scene, parent) + { + } + + virtual void resizeEvent(QResizeEvent *) + { + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +}; + + +void createStates(const QObjectList &objects, + const QRect &selectedRect, QState *parent) +{ + for (int i = 0; i < objects.size(); ++i) { + QState *state = new QState(parent); + state->assignProperty(objects.at(i), "geometry", selectedRect); + parent->addTransition(objects.at(i), SIGNAL(clicked()), state); + } +} + +void createAnimations(const QObjectList &objects, QStateMachine *machine) +{ + for (int i=0; iaddDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry")); +} + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(appchooser); + + QApplication app(argc, argv); + + Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); + Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); + Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); + Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); + + p1->setObjectName("p1"); + p2->setObjectName("p2"); + p3->setObjectName("p3"); + p4->setObjectName("p4"); + + p1->setGeometry(QRectF( 0.0, 0.0, 64.0, 64.0)); + p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0)); + p3->setGeometry(QRectF(236.0, 236.0, 64.0, 64.0)); + p4->setGeometry(QRectF( 0.0, 236.0, 64.0, 64.0)); + + QGraphicsScene scene(0, 0, 300, 300); + scene.setBackgroundBrush(Qt::white); + scene.addItem(p1); + scene.addItem(p2); + scene.addItem(p3); + scene.addItem(p4); + + GraphicsView window(&scene); + window.setFrameStyle(0); + window.setAlignment(Qt::AlignLeft | Qt::AlignTop); + window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QStateMachine machine; + machine.setGlobalRestorePolicy(QState::RestoreProperties); + + QState *group = new QState(&machine); + group->setObjectName("group"); + + QRect selectedRect(86, 86, 128, 128); + + QState *idleState = new QState(group); + group->setInitialState(idleState); + + QObjectList objects; + objects << p1 << p2 << p3 << p4; + createStates(objects, selectedRect, group); + createAnimations(objects, &machine); + + machine.setInitialState(group); + machine.start(); + + window.resize(300, 300); + window.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/widgets/animation/easing/animation.h b/examples/widgets/animation/easing/animation.h new file mode 100644 index 0000000000..35cbed4555 --- /dev/null +++ b/examples/widgets/animation/easing/animation.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 ANIMATION_H +#define ANIMATION_H + +#include + +#include + +class Animation : public QPropertyAnimation { +public: + enum PathType { + LinearPath, + CirclePath, + NPathTypes + }; + Animation(QObject *target, const QByteArray &prop) + : QPropertyAnimation(target, prop) + { + setPathType(LinearPath); + } + + void setPathType(PathType pathType) + { + if (pathType >= NPathTypes) + qWarning("Unknown pathType %d", pathType); + + m_pathType = pathType; + m_path = QPainterPath(); + } + + void updateCurrentTime(int currentTime) + { + if (m_pathType == CirclePath) { + if (m_path.isEmpty()) { + QPointF to = endValue().toPointF(); + QPointF from = startValue().toPointF(); + m_path.moveTo(from); + m_path.addEllipse(QRectF(from, to)); + } + int dura = duration(); + const qreal progress = ((dura == 0) ? 1 : ((((currentTime - 1) % dura) + 1) / qreal(dura))); + + qreal easedProgress = easingCurve().valueForProgress(progress); + if (easedProgress > 1.0) { + easedProgress -= 1.0; + } else if (easedProgress < 0) { + easedProgress += 1.0; + } + QPointF pt = m_path.pointAtPercent(easedProgress); + updateCurrentValue(pt); + emit valueChanged(pt); + } else { + QPropertyAnimation::updateCurrentTime(currentTime); + } + } + + QPainterPath m_path; + PathType m_pathType; +}; + +#endif // ANIMATION_H diff --git a/examples/widgets/animation/easing/easing.desktop b/examples/widgets/animation/easing/easing.desktop new file mode 100644 index 0000000000..56d122217a --- /dev/null +++ b/examples/widgets/animation/easing/easing.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Easing Curves +Exec=/opt/usr/bin/easing +Icon=easing +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/animation/easing/easing.pro b/examples/widgets/animation/easing/easing.pro new file mode 100644 index 0000000000..155d17d9b9 --- /dev/null +++ b/examples/widgets/animation/easing/easing.pro @@ -0,0 +1,17 @@ +HEADERS = window.h \ + animation.h +SOURCES = main.cpp \ + window.cpp + +FORMS = form.ui + +RESOURCES = easing.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/easing +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS easing.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/easing +INSTALLS += target sources + +QT += widgets + diff --git a/examples/widgets/animation/easing/easing.qrc b/examples/widgets/animation/easing/easing.qrc new file mode 100644 index 0000000000..7e112d3a9d --- /dev/null +++ b/examples/widgets/animation/easing/easing.qrc @@ -0,0 +1,5 @@ + + + images/qt-logo.png + + \ No newline at end of file diff --git a/examples/widgets/animation/easing/form.ui b/examples/widgets/animation/easing/form.ui new file mode 100644 index 0000000000..364aebeda6 --- /dev/null +++ b/examples/widgets/animation/easing/form.ui @@ -0,0 +1,270 @@ + + + Form + + + + 0 + 0 + 545 + 471 + + + + Easing curves + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + Qt::ScrollBarAlwaysOff + + + QListView::Static + + + false + + + QListView::IconMode + + + false + + + + + + + + + + 16777215 + 16777215 + + + + Path type + + + + + + + 16777215 + 40 + + + + Qt::LeftToRight + + + Line + + + true + + + buttonGroup + + + + + + + + 16777215 + 40 + + + + Circle + + + buttonGroup + + + + + + + + + + + 0 + 0 + + + + Properties + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 0 + 0 + + + + + 0 + 30 + + + + Period + + + + + + + false + + + + 0 + 0 + + + + + 0 + 30 + + + + -1.000000000000000 + + + 0.100000000000000 + + + -1.000000000000000 + + + + + + + false + + + + 0 + 30 + + + + -1.000000000000000 + + + 0.100000000000000 + + + -1.000000000000000 + + + + + + + + 0 + 30 + + + + Overshoot + + + + + + + false + + + + 0 + 30 + + + + -1.000000000000000 + + + 0.100000000000000 + + + -1.000000000000000 + + + + + + + + 0 + 30 + + + + Amplitude + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + diff --git a/examples/widgets/animation/easing/images/qt-logo.png b/examples/widgets/animation/easing/images/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/examples/widgets/animation/easing/images/qt-logo.png differ diff --git a/examples/widgets/animation/easing/main.cpp b/examples/widgets/animation/easing/main.cpp new file mode 100644 index 0000000000..05d4014fc2 --- /dev/null +++ b/examples/widgets/animation/easing/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 +#include "window.h" + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(easing); + QApplication app(argc, argv); + Window w; + + w.resize(400, 400); + w.show(); + + return app.exec(); +} diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp new file mode 100644 index 0000000000..33468db59c --- /dev/null +++ b/examples/widgets/animation/easing/window.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "window.h" + +Window::Window(QWidget *parent) + : QWidget(parent), + m_iconSize(64, 64) +{ + m_ui.setupUi(this); + QButtonGroup *buttonGroup = findChild(); // ### workaround for uic in 4.4 + m_ui.easingCurvePicker->setIconSize(m_iconSize); + m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); + buttonGroup->setId(m_ui.lineRadio, 0); + buttonGroup->setId(m_ui.circleRadio, 1); + + QEasingCurve dummy; + m_ui.periodSpinBox->setValue(dummy.period()); + m_ui.amplitudeSpinBox->setValue(dummy.amplitude()); + m_ui.overshootSpinBox->setValue(dummy.overshoot()); + + connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int))); + connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int))); + connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double))); + connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double))); + connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double))); + createCurveIcons(); + + QPixmap pix(QLatin1String(":/images/qt-logo.png")); + m_item = new PixmapItem(pix); + m_scene.addItem(m_item); + m_ui.graphicsView->setScene(&m_scene); + + m_anim = new Animation(m_item, "pos"); + m_anim->setEasingCurve(QEasingCurve::OutBounce); + m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce)); + + startAnimation(); +} + +void Window::createCurveIcons() +{ + QPixmap pix(m_iconSize); + QPainter painter(&pix); + QLinearGradient gradient(0,0, 0, m_iconSize.height()); + gradient.setColorAt(0.0, QColor(240, 240, 240)); + gradient.setColorAt(1.0, QColor(224, 224, 224)); + QBrush brush(gradient); + const QMetaObject &mo = QEasingCurve::staticMetaObject; + QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type")); + // Skip QEasingCurve::Custom + for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { + painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); + QEasingCurve curve((QEasingCurve::Type)i); + painter.setPen(QColor(0, 0, 255, 64)); + qreal xAxis = m_iconSize.height()/1.5; + qreal yAxis = m_iconSize.width()/3; + painter.drawLine(0, xAxis, m_iconSize.width(), xAxis); + painter.drawLine(yAxis, 0, yAxis, m_iconSize.height()); + + qreal curveScale = m_iconSize.height()/2; + + painter.setPen(Qt::NoPen); + + // start point + painter.setBrush(Qt::red); + QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0)); + painter.drawRect(start.x() - 1, start.y() - 1, 3, 3); + + // end point + painter.setBrush(Qt::blue); + QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1)); + painter.drawRect(end.x() - 1, end.y() - 1, 3, 3); + + QPainterPath curvePath; + curvePath.moveTo(start); + for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) { + QPoint to; + to.setX(yAxis + curveScale * t); + to.setY(xAxis - curveScale * curve.valueForProgress(t)); + curvePath.lineTo(to); + } + painter.setRenderHint(QPainter::Antialiasing, true); + painter.strokePath(curvePath, QColor(32, 32, 32)); + painter.setRenderHint(QPainter::Antialiasing, false); + QListWidgetItem *item = new QListWidgetItem; + item->setIcon(QIcon(pix)); + item->setText(metaEnum.key(i)); + m_ui.easingCurvePicker->addItem(item); + } +} + +void Window::startAnimation() +{ + m_anim->setStartValue(QPointF(0, 0)); + m_anim->setEndValue(QPointF(100, 100)); + m_anim->setDuration(2000); + m_anim->setLoopCount(-1); // forever + m_anim->start(); +} + +void Window::curveChanged(int row) +{ + QEasingCurve::Type curveType = (QEasingCurve::Type)row; + m_anim->setEasingCurve(curveType); + m_anim->setCurrentTime(0); + + bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic; + bool isBounce = curveType >= QEasingCurve::InBounce && curveType <= QEasingCurve::OutInBounce; + m_ui.periodSpinBox->setEnabled(isElastic); + m_ui.amplitudeSpinBox->setEnabled(isElastic || isBounce); + m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack); +} + +void Window::pathChanged(int index) +{ + m_anim->setPathType((Animation::PathType)index); +} + +void Window::periodChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setPeriod(value); + m_anim->setEasingCurve(curve); +} + +void Window::amplitudeChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setAmplitude(value); + m_anim->setEasingCurve(curve); +} + +void Window::overshootChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setOvershoot(value); + m_anim->setEasingCurve(curve); +} + diff --git a/examples/widgets/animation/easing/window.h b/examples/widgets/animation/easing/window.h new file mode 100644 index 0000000000..bf5014c0cc --- /dev/null +++ b/examples/widgets/animation/easing/window.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 + +#include "ui_form.h" +#include "animation.h" + +class PixmapItem : public QObject, public QGraphicsPixmapItem +{ + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + PixmapItem(const QPixmap &pix) : QGraphicsPixmapItem(pix) + { + } +}; + +class Window : public QWidget { + Q_OBJECT +public: + Window(QWidget *parent = 0); +private slots: + void curveChanged(int row); + void pathChanged(int index); + void periodChanged(double); + void amplitudeChanged(double); + void overshootChanged(double); + +private: + void createCurveIcons(); + void startAnimation(); + + Ui::Form m_ui; + QGraphicsScene m_scene; + PixmapItem *m_item; + Animation *m_anim; + QSize m_iconSize; +}; diff --git a/examples/widgets/animation/moveblocks/main.cpp b/examples/widgets/animation/moveblocks/main.cpp new file mode 100644 index 0000000000..d807bb63d9 --- /dev/null +++ b/examples/widgets/animation/moveblocks/main.cpp @@ -0,0 +1,321 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 +#include + +//![15] +class StateSwitchEvent: public QEvent +{ +public: + StateSwitchEvent() + : QEvent(Type(StateSwitchType)) + { + } + + explicit StateSwitchEvent(int rand) + : QEvent(Type(StateSwitchType)), + m_rand(rand) + { + } + + enum { StateSwitchType = QEvent::User + 256 }; + + int rand() const { return m_rand; } + +private: + int m_rand; +}; +//![15] + +//![16] +class QGraphicsRectWidget : public QGraphicsWidget +{ +public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, + QWidget *) + { + painter->fillRect(rect(), Qt::blue); + } +}; +//![16] + +class StateSwitchTransition: public QAbstractTransition +{ +public: + StateSwitchTransition(int rand) + : QAbstractTransition(), + m_rand(rand) + { + } + +protected: +//![14] + virtual bool eventTest(QEvent *event) + { + return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) + && (static_cast(event)->rand() == m_rand); + } +//![14] + + virtual void onTransition(QEvent *) {} + +private: + int m_rand; +}; + +//![10] +class StateSwitcher : public QState +{ + Q_OBJECT +public: + StateSwitcher(QStateMachine *machine) + : QState(machine), m_stateCount(0), m_lastIndex(0) + { } +//![10] + +//![11] + virtual void onEntry(QEvent *) + { + int n; + while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex) + { } + m_lastIndex = n; + machine()->postEvent(new StateSwitchEvent(n)); + } + virtual void onExit(QEvent *) {} +//![11] + +//![12] + void addState(QState *state, QAbstractAnimation *animation) { + StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount); + trans->setTargetState(state); + addTransition(trans); + trans->addAnimation(animation); + } +//![12] + +private: + int m_stateCount; + int m_lastIndex; +}; + +//![13] +QState *createGeometryState(QObject *w1, const QRect &rect1, + QObject *w2, const QRect &rect2, + QObject *w3, const QRect &rect3, + QObject *w4, const QRect &rect4, + QState *parent) +{ + QState *result = new QState(parent); + result->assignProperty(w1, "geometry", rect1); + result->assignProperty(w2, "geometry", rect2); + result->assignProperty(w3, "geometry", rect3); + result->assignProperty(w4, "geometry", rect4); + + return result; +} +//![13] + + +class GraphicsView : public QGraphicsView +{ + Q_OBJECT +public: + GraphicsView(QGraphicsScene *scene, QWidget *parent = NULL) : QGraphicsView(scene, parent) + { + } + +protected: + virtual void resizeEvent(QResizeEvent *event) + { + fitInView(scene()->sceneRect()); + QGraphicsView::resizeEvent(event); + } +}; + + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + +//![1] + QGraphicsRectWidget *button1 = new QGraphicsRectWidget; + QGraphicsRectWidget *button2 = new QGraphicsRectWidget; + QGraphicsRectWidget *button3 = new QGraphicsRectWidget; + QGraphicsRectWidget *button4 = new QGraphicsRectWidget; + button2->setZValue(1); + button3->setZValue(2); + button4->setZValue(3); + QGraphicsScene scene(0, 0, 300, 300); + scene.setBackgroundBrush(Qt::black); + scene.addItem(button1); + scene.addItem(button2); + scene.addItem(button3); + scene.addItem(button4); +//![1] + GraphicsView window(&scene); + window.setFrameStyle(0); + window.setAlignment(Qt::AlignLeft | Qt::AlignTop); + window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +//![2] + QStateMachine machine; + + QState *group = new QState(); + group->setObjectName("group"); + QTimer timer; + timer.setInterval(1250); + timer.setSingleShot(true); + QObject::connect(group, SIGNAL(entered()), &timer, SLOT(start())); +//![2] + +//![3] + QState *state1; + QState *state2; + QState *state3; + QState *state4; + QState *state5; + QState *state6; + QState *state7; + + state1 = createGeometryState(button1, QRect(100, 0, 50, 50), + button2, QRect(150, 0, 50, 50), + button3, QRect(200, 0, 50, 50), + button4, QRect(250, 0, 50, 50), + group); +//![3] + state2 = createGeometryState(button1, QRect(250, 100, 50, 50), + button2, QRect(250, 150, 50, 50), + button3, QRect(250, 200, 50, 50), + button4, QRect(250, 250, 50, 50), + group); + state3 = createGeometryState(button1, QRect(150, 250, 50, 50), + button2, QRect(100, 250, 50, 50), + button3, QRect(50, 250, 50, 50), + button4, QRect(0, 250, 50, 50), + group); + state4 = createGeometryState(button1, QRect(0, 150, 50, 50), + button2, QRect(0, 100, 50, 50), + button3, QRect(0, 50, 50, 50), + button4, QRect(0, 0, 50, 50), + group); + state5 = createGeometryState(button1, QRect(100, 100, 50, 50), + button2, QRect(150, 100, 50, 50), + button3, QRect(100, 150, 50, 50), + button4, QRect(150, 150, 50, 50), + group); + state6 = createGeometryState(button1, QRect(50, 50, 50, 50), + button2, QRect(200, 50, 50, 50), + button3, QRect(50, 200, 50, 50), + button4, QRect(200, 200, 50, 50), + group); +//![4] + state7 = createGeometryState(button1, QRect(0, 0, 50, 50), + button2, QRect(250, 0, 50, 50), + button3, QRect(0, 250, 50, 50), + button4, QRect(250, 250, 50, 50), + group); + group->setInitialState(state1); +//![4] + +//![5] + QParallelAnimationGroup animationGroup; + QSequentialAnimationGroup *subGroup; + + QPropertyAnimation *anim = new QPropertyAnimation(button4, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + animationGroup.addAnimation(anim); +//![5] + +//![6] + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(100); + anim = new QPropertyAnimation(button3, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); +//![6] + + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(150); + anim = new QPropertyAnimation(button2, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); + + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(200); + anim = new QPropertyAnimation(button1, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); + +//![7] + StateSwitcher *stateSwitcher = new StateSwitcher(&machine); + stateSwitcher->setObjectName("stateSwitcher"); + group->addTransition(&timer, SIGNAL(timeout()), stateSwitcher); + stateSwitcher->addState(state1, &animationGroup); + stateSwitcher->addState(state2, &animationGroup); +//![7] + stateSwitcher->addState(state3, &animationGroup); + stateSwitcher->addState(state4, &animationGroup); + stateSwitcher->addState(state5, &animationGroup); + stateSwitcher->addState(state6, &animationGroup); +//![8] + stateSwitcher->addState(state7, &animationGroup); +//![8] + +//![9] + machine.addState(group); + machine.setInitialState(group); + machine.start(); +//![9] + + window.resize(300, 300); + window.show(); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/widgets/animation/moveblocks/moveblocks.desktop b/examples/widgets/animation/moveblocks/moveblocks.desktop new file mode 100644 index 0000000000..4100f448df --- /dev/null +++ b/examples/widgets/animation/moveblocks/moveblocks.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Move Blocks +Exec=/opt/usr/bin/moveblocks +Icon=moveblocks +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/animation/moveblocks/moveblocks.pro b/examples/widgets/animation/moveblocks/moveblocks.pro new file mode 100644 index 0000000000..7c242e31e6 --- /dev/null +++ b/examples/widgets/animation/moveblocks/moveblocks.pro @@ -0,0 +1,9 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/moveblocks +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS moveblocks.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/moveblocks +INSTALLS += target sources + +QT += widgets diff --git a/examples/widgets/animation/states/accessories-dictionary.png b/examples/widgets/animation/states/accessories-dictionary.png new file mode 100644 index 0000000000..e9bd55d918 Binary files /dev/null and b/examples/widgets/animation/states/accessories-dictionary.png differ diff --git a/examples/widgets/animation/states/akregator.png b/examples/widgets/animation/states/akregator.png new file mode 100644 index 0000000000..a086f45ab6 Binary files /dev/null and b/examples/widgets/animation/states/akregator.png differ diff --git a/examples/widgets/animation/states/digikam.png b/examples/widgets/animation/states/digikam.png new file mode 100644 index 0000000000..9de9fb2f80 Binary files /dev/null and b/examples/widgets/animation/states/digikam.png differ diff --git a/examples/widgets/animation/states/help-browser.png b/examples/widgets/animation/states/help-browser.png new file mode 100644 index 0000000000..db92faa4e7 Binary files /dev/null and b/examples/widgets/animation/states/help-browser.png differ diff --git a/examples/widgets/animation/states/k3b.png b/examples/widgets/animation/states/k3b.png new file mode 100644 index 0000000000..bbcafcfba1 Binary files /dev/null and b/examples/widgets/animation/states/k3b.png differ diff --git a/examples/widgets/animation/states/kchart.png b/examples/widgets/animation/states/kchart.png new file mode 100644 index 0000000000..1dd115be87 Binary files /dev/null and b/examples/widgets/animation/states/kchart.png differ diff --git a/examples/widgets/animation/states/main.cpp b/examples/widgets/animation/states/main.cpp new file mode 100644 index 0000000000..faa97ccbd0 --- /dev/null +++ b/examples/widgets/animation/states/main.cpp @@ -0,0 +1,285 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 + +class Pixmap : public QGraphicsObject +{ + Q_OBJECT +public: + Pixmap(const QPixmap &pix) : QGraphicsObject(), p(pix) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->drawPixmap(QPointF(), p); + } + + QRectF boundingRect() const + { + return QRectF( QPointF(0, 0), p.size()); + } + +private: + QPixmap p; +}; + +class GraphicsView : public QGraphicsView +{ +public: + GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene) + { + } + + virtual void resizeEvent(QResizeEvent *) + { + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +}; + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(states); + + QApplication app(argc, argv); + + // Text edit and button + QTextEdit *edit = new QTextEdit; + edit->setText("asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " + "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " + "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " + "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!"); + + QPushButton *button = new QPushButton; + QGraphicsProxyWidget *buttonProxy = new QGraphicsProxyWidget; + buttonProxy->setWidget(button); + QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget; + editProxy->setWidget(edit); + + QGroupBox *box = new QGroupBox; + box->setFlat(true); + box->setTitle("Options"); + + QVBoxLayout *layout2 = new QVBoxLayout; + box->setLayout(layout2); + layout2->addWidget(new QRadioButton("Herring")); + layout2->addWidget(new QRadioButton("Blue Parrot")); + layout2->addWidget(new QRadioButton("Petunias")); + layout2->addStretch(); + + QGraphicsProxyWidget *boxProxy = new QGraphicsProxyWidget; + boxProxy->setWidget(box); + + // Parent widget + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, widget); + layout->addItem(editProxy); + layout->addItem(buttonProxy); + widget->setLayout(layout); + + Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); + Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); + Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); + Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); + Pixmap *p5 = new Pixmap(QPixmap(":/help-browser.png")); + Pixmap *p6 = new Pixmap(QPixmap(":/kchart.png")); + + QGraphicsScene scene(0, 0, 400, 300); + scene.setBackgroundBrush(scene.palette().window()); + scene.addItem(widget); + scene.addItem(boxProxy); + scene.addItem(p1); + scene.addItem(p2); + scene.addItem(p3); + scene.addItem(p4); + scene.addItem(p5); + scene.addItem(p6); + + QStateMachine machine; + QState *state1 = new QState(&machine); + QState *state2 = new QState(&machine); + QState *state3 = new QState(&machine); + machine.setInitialState(state1); + + // State 1 + state1->assignProperty(button, "text", "Switch to state 2"); + state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150)); + state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150)); + state1->assignProperty(p1, "pos", QPointF(68, 200)); // 185)); + state1->assignProperty(p2, "pos", QPointF(168, 200)); // 185)); + state1->assignProperty(p3, "pos", QPointF(268, 200)); // 185)); + state1->assignProperty(p4, "pos", QPointF(68 - 150, 48 - 150)); + state1->assignProperty(p5, "pos", QPointF(168, 48 - 150)); + state1->assignProperty(p6, "pos", QPointF(268 + 150, 48 - 150)); + state1->assignProperty(p1, "rotation", qreal(0)); + state1->assignProperty(p2, "rotation", qreal(0)); + state1->assignProperty(p3, "rotation", qreal(0)); + state1->assignProperty(p4, "rotation", qreal(-270)); + state1->assignProperty(p5, "rotation", qreal(-90)); + state1->assignProperty(p6, "rotation", qreal(270)); + state1->assignProperty(boxProxy, "opacity", qreal(0)); + state1->assignProperty(p1, "opacity", qreal(1)); + state1->assignProperty(p2, "opacity", qreal(1)); + state1->assignProperty(p3, "opacity", qreal(1)); + state1->assignProperty(p4, "opacity", qreal(0)); + state1->assignProperty(p5, "opacity", qreal(0)); + state1->assignProperty(p6, "opacity", qreal(0)); + + // State 2 + state2->assignProperty(button, "text", "Switch to state 3"); + state2->assignProperty(widget, "geometry", QRectF(200, 150, 200, 150)); + state2->assignProperty(box, "geometry", QRect(9, 150, 190, 150)); + state2->assignProperty(p1, "pos", QPointF(68 - 150, 185 + 150)); + state2->assignProperty(p2, "pos", QPointF(168, 185 + 150)); + state2->assignProperty(p3, "pos", QPointF(268 + 150, 185 + 150)); + state2->assignProperty(p4, "pos", QPointF(64, 48)); + state2->assignProperty(p5, "pos", QPointF(168, 48)); + state2->assignProperty(p6, "pos", QPointF(268, 48)); + state2->assignProperty(p1, "rotation", qreal(-270)); + state2->assignProperty(p2, "rotation", qreal(90)); + state2->assignProperty(p3, "rotation", qreal(270)); + state2->assignProperty(p4, "rotation", qreal(0)); + state2->assignProperty(p5, "rotation", qreal(0)); + state2->assignProperty(p6, "rotation", qreal(0)); + state2->assignProperty(boxProxy, "opacity", qreal(1)); + state2->assignProperty(p1, "opacity", qreal(0)); + state2->assignProperty(p2, "opacity", qreal(0)); + state2->assignProperty(p3, "opacity", qreal(0)); + state2->assignProperty(p4, "opacity", qreal(1)); + state2->assignProperty(p5, "opacity", qreal(1)); + state2->assignProperty(p6, "opacity", qreal(1)); + + // State 3 + state3->assignProperty(button, "text", "Switch to state 1"); + state3->assignProperty(p1, "pos", QPointF(0, 5)); + state3->assignProperty(p2, "pos", QPointF(0, 5 + 64 + 5)); + state3->assignProperty(p3, "pos", QPointF(5, 5 + (64 + 5) + 64)); + state3->assignProperty(p4, "pos", QPointF(5 + 64 + 5, 5)); + state3->assignProperty(p5, "pos", QPointF(5 + 64 + 5, 5 + 64 + 5)); + state3->assignProperty(p6, "pos", QPointF(5 + 64 + 5, 5 + (64 + 5) + 64)); + state3->assignProperty(widget, "geometry", QRectF(138, 5, 400 - 138, 200)); + state3->assignProperty(box, "geometry", QRect(5, 205, 400, 90)); + state3->assignProperty(p1, "opacity", qreal(1)); + state3->assignProperty(p2, "opacity", qreal(1)); + state3->assignProperty(p3, "opacity", qreal(1)); + state3->assignProperty(p4, "opacity", qreal(1)); + state3->assignProperty(p5, "opacity", qreal(1)); + state3->assignProperty(p6, "opacity", qreal(1)); + + QAbstractTransition *t1 = state1->addTransition(button, SIGNAL(clicked()), state2); + QSequentialAnimationGroup *animation1SubGroup = new QSequentialAnimationGroup; + animation1SubGroup->addPause(250); + animation1SubGroup->addAnimation(new QPropertyAnimation(box, "geometry")); + t1->addAnimation(animation1SubGroup); + t1->addAnimation(new QPropertyAnimation(widget, "geometry")); + t1->addAnimation(new QPropertyAnimation(p1, "pos")); + t1->addAnimation(new QPropertyAnimation(p2, "pos")); + t1->addAnimation(new QPropertyAnimation(p3, "pos")); + t1->addAnimation(new QPropertyAnimation(p4, "pos")); + t1->addAnimation(new QPropertyAnimation(p5, "pos")); + t1->addAnimation(new QPropertyAnimation(p6, "pos")); + t1->addAnimation(new QPropertyAnimation(p1, "rotation")); + t1->addAnimation(new QPropertyAnimation(p2, "rotation")); + t1->addAnimation(new QPropertyAnimation(p3, "rotation")); + t1->addAnimation(new QPropertyAnimation(p4, "rotation")); + t1->addAnimation(new QPropertyAnimation(p5, "rotation")); + t1->addAnimation(new QPropertyAnimation(p6, "rotation")); + t1->addAnimation(new QPropertyAnimation(p1, "opacity")); + t1->addAnimation(new QPropertyAnimation(p2, "opacity")); + t1->addAnimation(new QPropertyAnimation(p3, "opacity")); + t1->addAnimation(new QPropertyAnimation(p4, "opacity")); + t1->addAnimation(new QPropertyAnimation(p5, "opacity")); + t1->addAnimation(new QPropertyAnimation(p6, "opacity")); + + QAbstractTransition *t2 = state2->addTransition(button, SIGNAL(clicked()), state3); + t2->addAnimation(new QPropertyAnimation(box, "geometry")); + t2->addAnimation(new QPropertyAnimation(widget, "geometry")); + t2->addAnimation(new QPropertyAnimation(p1, "pos")); + t2->addAnimation(new QPropertyAnimation(p2, "pos")); + t2->addAnimation(new QPropertyAnimation(p3, "pos")); + t2->addAnimation(new QPropertyAnimation(p4, "pos")); + t2->addAnimation(new QPropertyAnimation(p5, "pos")); + t2->addAnimation(new QPropertyAnimation(p6, "pos")); + t2->addAnimation(new QPropertyAnimation(p1, "rotation")); + t2->addAnimation(new QPropertyAnimation(p2, "rotation")); + t2->addAnimation(new QPropertyAnimation(p3, "rotation")); + t2->addAnimation(new QPropertyAnimation(p4, "rotation")); + t2->addAnimation(new QPropertyAnimation(p5, "rotation")); + t2->addAnimation(new QPropertyAnimation(p6, "rotation")); + t2->addAnimation(new QPropertyAnimation(p1, "opacity")); + t2->addAnimation(new QPropertyAnimation(p2, "opacity")); + t2->addAnimation(new QPropertyAnimation(p3, "opacity")); + t2->addAnimation(new QPropertyAnimation(p4, "opacity")); + t2->addAnimation(new QPropertyAnimation(p5, "opacity")); + t2->addAnimation(new QPropertyAnimation(p6, "opacity")); + + QAbstractTransition *t3 = state3->addTransition(button, SIGNAL(clicked()), state1); + t3->addAnimation(new QPropertyAnimation(box, "geometry")); + t3->addAnimation(new QPropertyAnimation(widget, "geometry")); + t3->addAnimation(new QPropertyAnimation(p1, "pos")); + t3->addAnimation(new QPropertyAnimation(p2, "pos")); + t3->addAnimation(new QPropertyAnimation(p3, "pos")); + t3->addAnimation(new QPropertyAnimation(p4, "pos")); + t3->addAnimation(new QPropertyAnimation(p5, "pos")); + t3->addAnimation(new QPropertyAnimation(p6, "pos")); + t3->addAnimation(new QPropertyAnimation(p1, "rotation")); + t3->addAnimation(new QPropertyAnimation(p2, "rotation")); + t3->addAnimation(new QPropertyAnimation(p3, "rotation")); + t3->addAnimation(new QPropertyAnimation(p4, "rotation")); + t3->addAnimation(new QPropertyAnimation(p5, "rotation")); + t3->addAnimation(new QPropertyAnimation(p6, "rotation")); + t3->addAnimation(new QPropertyAnimation(p1, "opacity")); + t3->addAnimation(new QPropertyAnimation(p2, "opacity")); + t3->addAnimation(new QPropertyAnimation(p3, "opacity")); + t3->addAnimation(new QPropertyAnimation(p4, "opacity")); + t3->addAnimation(new QPropertyAnimation(p5, "opacity")); + t3->addAnimation(new QPropertyAnimation(p6, "opacity")); + + machine.start(); + + GraphicsView view(&scene); + + view.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/widgets/animation/states/states.desktop b/examples/widgets/animation/states/states.desktop new file mode 100644 index 0000000000..8429979f23 --- /dev/null +++ b/examples/widgets/animation/states/states.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=States +Exec=/opt/usr/bin/states +Icon=states +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/animation/states/states.pro b/examples/widgets/animation/states/states.pro new file mode 100644 index 0000000000..adf0e8d58c --- /dev/null +++ b/examples/widgets/animation/states/states.pro @@ -0,0 +1,10 @@ +SOURCES += main.cpp +RESOURCES += states.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/states +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS states.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/states +INSTALLS += target sources + +QT += widgets diff --git a/examples/widgets/animation/states/states.qrc b/examples/widgets/animation/states/states.qrc new file mode 100644 index 0000000000..60ab3f7a60 --- /dev/null +++ b/examples/widgets/animation/states/states.qrc @@ -0,0 +1,10 @@ + + + accessories-dictionary.png + akregator.png + digikam.png + help-browser.png + k3b.png + kchart.png + + diff --git a/examples/widgets/animation/stickman/animation.cpp b/examples/widgets/animation/stickman/animation.cpp new file mode 100644 index 0000000000..afdfae6eca --- /dev/null +++ b/examples/widgets/animation/stickman/animation.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "animation.h" + +#include +#include +#include +#include + +class Frame +{ +public: + Frame() { + } + + int nodeCount() const + { + return m_nodePositions.size(); + } + + void setNodeCount(int nodeCount) + { + m_nodePositions.resize(nodeCount); + } + + QPointF nodePos(int idx) const + { + return m_nodePositions.at(idx); + } + + void setNodePos(int idx, const QPointF &pos) + { + m_nodePositions[idx] = pos; + } + +private: + QVector m_nodePositions; +}; + +Animation::Animation() +{ + m_currentFrame = 0; + m_frames.append(new Frame); +} + +Animation::~Animation() +{ + qDeleteAll(m_frames); +} + +void Animation::setTotalFrames(int totalFrames) +{ + while (m_frames.size() < totalFrames) + m_frames.append(new Frame); + + while (totalFrames < m_frames.size()) + delete m_frames.takeLast(); +} + +int Animation::totalFrames() const +{ + return m_frames.size(); +} + +void Animation::setCurrentFrame(int currentFrame) +{ + m_currentFrame = qMax(qMin(currentFrame, totalFrames()-1), 0); +} + +int Animation::currentFrame() const +{ + return m_currentFrame; +} + +void Animation::setNodeCount(int nodeCount) +{ + Frame *frame = m_frames.at(m_currentFrame); + frame->setNodeCount(nodeCount); +} + +int Animation::nodeCount() const +{ + Frame *frame = m_frames.at(m_currentFrame); + return frame->nodeCount(); +} + +void Animation::setNodePos(int idx, const QPointF &pos) +{ + Frame *frame = m_frames.at(m_currentFrame); + frame->setNodePos(idx, pos); +} + +QPointF Animation::nodePos(int idx) const +{ + Frame *frame = m_frames.at(m_currentFrame); + return frame->nodePos(idx); +} + +QString Animation::name() const +{ + return m_name; +} + +void Animation::setName(const QString &name) +{ + m_name = name; +} + +void Animation::save(QIODevice *device) const +{ + QDataStream stream(device); + stream << m_name; + stream << m_frames.size(); + foreach (Frame *frame, m_frames) { + stream << frame->nodeCount(); + for (int i=0; inodeCount(); ++i) + stream << frame->nodePos(i); + } +} + +void Animation::load(QIODevice *device) +{ + if (!m_frames.isEmpty()) + qDeleteAll(m_frames); + + m_frames.clear(); + + QDataStream stream(device); + stream >> m_name; + + int frameCount; + stream >> frameCount; + + for (int i=0; i> nodeCount; + + Frame *frame = new Frame; + frame->setNodeCount(nodeCount); + + for (int j=0; j> pos; + + frame->setNodePos(j, pos); + } + + m_frames.append(frame); + } +} diff --git a/examples/widgets/animation/stickman/animation.h b/examples/widgets/animation/stickman/animation.h new file mode 100644 index 0000000000..d5dab530e6 --- /dev/null +++ b/examples/widgets/animation/stickman/animation.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 ANIMATION_H +#define ANIMATION_H + +#include +#include +#include + +class Frame; +QT_BEGIN_NAMESPACE +class QIODevice; +QT_END_NAMESPACE +class Animation +{ +public: + Animation(); + ~Animation(); + + void setTotalFrames(int totalFrames); + int totalFrames() const; + + void setCurrentFrame(int currentFrame); + int currentFrame() const; + + void setNodeCount(int nodeCount); + int nodeCount() const; + + void setNodePos(int idx, const QPointF &pos); + QPointF nodePos(int idx) const; + + QString name() const; + void setName(const QString &name); + + void save(QIODevice *device) const; + void load(QIODevice *device); + +private: + QString m_name; + QList m_frames; + int m_currentFrame; +}; + +#endif diff --git a/examples/widgets/animation/stickman/animations/chilling.bin b/examples/widgets/animation/stickman/animations/chilling.bin new file mode 100644 index 0000000000..a81fc7a18c Binary files /dev/null and b/examples/widgets/animation/stickman/animations/chilling.bin differ diff --git a/examples/widgets/animation/stickman/animations/dancing.bin b/examples/widgets/animation/stickman/animations/dancing.bin new file mode 100644 index 0000000000..462f66f89b Binary files /dev/null and b/examples/widgets/animation/stickman/animations/dancing.bin differ diff --git a/examples/widgets/animation/stickman/animations/dead.bin b/examples/widgets/animation/stickman/animations/dead.bin new file mode 100644 index 0000000000..9859b4b4cd Binary files /dev/null and b/examples/widgets/animation/stickman/animations/dead.bin differ diff --git a/examples/widgets/animation/stickman/animations/jumping.bin b/examples/widgets/animation/stickman/animations/jumping.bin new file mode 100644 index 0000000000..12661a15f8 Binary files /dev/null and b/examples/widgets/animation/stickman/animations/jumping.bin differ diff --git a/examples/widgets/animation/stickman/graphicsview.cpp b/examples/widgets/animation/stickman/graphicsview.cpp new file mode 100644 index 0000000000..134fb8acf1 --- /dev/null +++ b/examples/widgets/animation/stickman/graphicsview.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "graphicsview.h" +#include "stickman.h" + +#include +#include +#include + +GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent), m_editor(0) {} + +void GraphicsView::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Escape) + close(); + emit keyPressed(Qt::Key(e->key())); +} + +void GraphicsView::resizeEvent(QResizeEvent *) +{ + fitInView(scene()->sceneRect()); +} diff --git a/examples/widgets/animation/stickman/graphicsview.h b/examples/widgets/animation/stickman/graphicsview.h new file mode 100644 index 0000000000..38bf6e1eb6 --- /dev/null +++ b/examples/widgets/animation/stickman/graphicsview.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 GRAPHICSVIEW_H +#define GRAPHICSVIEW + +#include + +class MainWindow; +class GraphicsView: public QGraphicsView +{ + Q_OBJECT +public: + GraphicsView(QWidget *parent = 0); + +protected: + virtual void resizeEvent(QResizeEvent *event); + void keyPressEvent(QKeyEvent *); + +signals: + void keyPressed(int key); + +private: + MainWindow *m_editor; +}; + +#endif diff --git a/examples/widgets/animation/stickman/lifecycle.cpp b/examples/widgets/animation/stickman/lifecycle.cpp new file mode 100644 index 0000000000..53249ccd6f --- /dev/null +++ b/examples/widgets/animation/stickman/lifecycle.cpp @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "lifecycle.h" +#include "stickman.h" +#include "node.h" +#include "animation.h" +#include "graphicsview.h" + +#include +#include + +class KeyPressTransition: public QSignalTransition +{ +public: + KeyPressTransition(GraphicsView *receiver, Qt::Key key) + : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + { + } + KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target) + : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + { + setTargetState(target); + } + + virtual bool eventTest(QEvent *e) + { + if (QSignalTransition::eventTest(e)) { + QVariant key = static_cast(e)->arguments().at(0); + return (key.toInt() == int(m_key)); + } + + return false; + } +private: + Qt::Key m_key; +}; + +//! [4] +class LightningStrikesTransition: public QEventTransition +{ +public: + LightningStrikesTransition(QAbstractState *target) + : QEventTransition(this, QEvent::Timer) + { + setTargetState(target); + qsrand((uint)QDateTime::currentDateTime().toTime_t()); + startTimer(1000); + } + + virtual bool eventTest(QEvent *e) + { + return QEventTransition::eventTest(e) && ((qrand() % 50) == 0); + } +}; +//! [4] + +LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) + : m_stickMan(stickMan), m_keyReceiver(keyReceiver) +{ + // Create animation group to be used for all transitions + m_animationGroup = new QParallelAnimationGroup(); + const int stickManNodeCount = m_stickMan->nodeCount(); + for (int i=0; inode(i), "pos"); + m_animationGroup->addAnimation(pa); + } + + // Set up initial state graph +//! [3] + m_machine = new QStateMachine(); + m_machine->addDefaultAnimation(m_animationGroup); +//! [3] + + m_alive = new QState(m_machine); + m_alive->setObjectName("alive"); + + // Make it blink when lightning strikes before entering dead animation + QState *lightningBlink = new QState(m_machine); + lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::white); + lightningBlink->assignProperty(m_stickMan, "penColor", Qt::black); + lightningBlink->assignProperty(m_stickMan, "fillColor", Qt::white); + lightningBlink->assignProperty(m_stickMan, "isDead", true); + +//! [5] + QTimer *timer = new QTimer(lightningBlink); + timer->setSingleShot(true); + timer->setInterval(100); + QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start())); + QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop())); +//! [5] + + m_dead = new QState(m_machine); + m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::black); + m_dead->assignProperty(m_stickMan, "penColor", Qt::white); + m_dead->assignProperty(m_stickMan, "fillColor", Qt::black); + m_dead->setObjectName("dead"); + + // Idle state (sets no properties) + m_idle = new QState(m_alive); + m_idle->setObjectName("idle"); + + m_alive->setInitialState(m_idle); + + // Lightning strikes at random + m_alive->addTransition(new LightningStrikesTransition(lightningBlink)); +//! [0] + lightningBlink->addTransition(timer, SIGNAL(timeout()), m_dead); +//! [0] + + m_machine->setInitialState(m_alive); +} + +void LifeCycle::setDeathAnimation(const QString &fileName) +{ + QState *deathAnimation = makeState(m_dead, fileName); + m_dead->setInitialState(deathAnimation); +} + +void LifeCycle::start() +{ + m_machine->start(); +} + +void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sender, const char *signal) +{ + QState *state = makeState(m_alive, fileName); + m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state)); + + if((sender != NULL) || (signal != NULL)) { + m_alive->addTransition(sender, signal, state); + } +} + +QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName) +{ + QState *topLevel = new QState(parentState); + + Animation animation; + { + QFile file(animationFileName); + if (file.open(QIODevice::ReadOnly)) + animation.load(&file); + } + + const int frameCount = animation.totalFrames(); + QState *previousState = 0; + for (int i=0; iassignProperty(m_stickMan->node(j), "pos", animation.nodePos(j)); +//! [1] + + frameState->setObjectName(QString::fromLatin1("frame %0").arg(i)); + if (previousState == 0) + topLevel->setInitialState(frameState); + else +//! [2] + previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState); +//! [2] + + previousState = frameState; + } + + // Loop + previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState()); + + return topLevel; + +} + +LifeCycle::~LifeCycle() +{ + delete m_machine; + delete m_animationGroup; +} diff --git a/examples/widgets/animation/stickman/lifecycle.h b/examples/widgets/animation/stickman/lifecycle.h new file mode 100644 index 0000000000..8e8bb50659 --- /dev/null +++ b/examples/widgets/animation/stickman/lifecycle.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 LIFECYCLE_H +#define LIFECYCLE_H + +#include + +class StickMan; +QT_BEGIN_NAMESPACE +class QStateMachine; +class QAnimationGroup; +class QState; +class QAbstractState; +class QAbstractTransition; +class QObject; +QT_END_NAMESPACE +class GraphicsView; +class LifeCycle +{ +public: + LifeCycle(StickMan *stickMan, GraphicsView *keyEventReceiver); + ~LifeCycle(); + + void setDeathAnimation(const QString &fileName); + void addActivity(const QString &fileName, Qt::Key key, QObject *sender = NULL, const char *signal = NULL); + + void start(); + +private: + QState *makeState(QState *parentState, const QString &animationFileName); + + StickMan *m_stickMan; + QStateMachine *m_machine; + QAnimationGroup *m_animationGroup; + GraphicsView *m_keyReceiver; + + QState *m_alive; + QState *m_dead; + QState *m_idle; +}; + +#endif diff --git a/examples/widgets/animation/stickman/main.cpp b/examples/widgets/animation/stickman/main.cpp new file mode 100644 index 0000000000..3e49da8de3 --- /dev/null +++ b/examples/widgets/animation/stickman/main.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "animation.h" +#include "node.h" +#include "lifecycle.h" +#include "stickman.h" +#include "graphicsview.h" +#include "rectbutton.h" + +#include +#include + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(stickman); + QApplication app(argc, argv); + + StickMan *stickMan = new StickMan; + stickMan->setDrawSticks(false); + + QGraphicsTextItem *textItem = new QGraphicsTextItem(); + textItem->setHtml("Stickman" + "

      " + "Tell the stickman what to do!" + "

      " + "

      " + "

    • Press J to make the stickman jump.
    • " + "
    • Press D to make the stickman dance.
    • " + "
    • Press C to make him chill out.
    • " + "
    • When you are done, press Escape.
    • " + "

      " + "

      If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again." + "

      "); + qreal w = textItem->boundingRect().width(); + QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect(); + textItem->setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0); + + QGraphicsScene scene; + scene.addItem(stickMan); + + scene.addItem(textItem); + scene.setBackgroundBrush(Qt::black); + + GraphicsView view; + view.setRenderHints(QPainter::Antialiasing); + view.setTransformationAnchor(QGraphicsView::NoAnchor); + view.setScene(&scene); + + QRectF sceneRect = scene.sceneRect(); + // making enough room in the scene for stickman to jump and die + view.resize(sceneRect.width() + 100, sceneRect.height() + 100); + view.setSceneRect(sceneRect); + + view.show(); + view.setFocus(); + + LifeCycle cycle(stickMan, &view); + cycle.setDeathAnimation(":/animations/dead.bin"); + + cycle.addActivity(":/animations/jumping.bin", Qt::Key_J); + cycle.addActivity(":/animations/dancing.bin", Qt::Key_D); + cycle.addActivity(":/animations/chilling.bin", Qt::Key_C); + + cycle.start(); + + + return app.exec(); +} diff --git a/examples/widgets/animation/stickman/node.cpp b/examples/widgets/animation/stickman/node.cpp new file mode 100644 index 0000000000..2de34b379c --- /dev/null +++ b/examples/widgets/animation/stickman/node.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "node.h" +#include "stickman.h" + +#include +#include +#include + +Node::Node(const QPointF &pos, QGraphicsItem *parent) + : QGraphicsObject(parent), m_dragging(false) +{ + setPos(pos); + setFlag(QGraphicsItem::ItemSendsGeometryChanges); +} + +Node::~Node() +{ +} + +QRectF Node::boundingRect() const +{ + return QRectF(-6.0, -6.0, 12.0, 12.0); +} + +void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + painter->setPen(Qt::white); + painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0); +} + +QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemPositionChange) + emit positionChanged(); + + return QGraphicsObject::itemChange(change, value); +} + +void Node::mousePressEvent(QGraphicsSceneMouseEvent *) +{ + m_dragging = true; +} + +void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (m_dragging) + setPos(mapToParent(event->pos())); +} + +void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *) +{ + m_dragging = false; +} diff --git a/examples/widgets/animation/stickman/node.h b/examples/widgets/animation/stickman/node.h new file mode 100644 index 0000000000..ae6e2a3ed0 --- /dev/null +++ b/examples/widgets/animation/stickman/node.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 NODE_H +#define NODE_H + +#include + +class Node: public QGraphicsObject +{ + Q_OBJECT +public: + Node(const QPointF &pos, QGraphicsItem *parent = 0); + ~Node(); + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +signals: + void positionChanged(); + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + void mousePressEvent(QGraphicsSceneMouseEvent *); + void mouseMoveEvent(QGraphicsSceneMouseEvent *); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *); + +private: + bool m_dragging; +}; + +#endif diff --git a/examples/widgets/animation/stickman/rectbutton.cpp b/examples/widgets/animation/stickman/rectbutton.cpp new file mode 100644 index 0000000000..8b17600ef5 --- /dev/null +++ b/examples/widgets/animation/stickman/rectbutton.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "rectbutton.h" +#include + +RectButton::RectButton(QString buttonText) : m_ButtonText(buttonText) +{ +} + + +RectButton::~RectButton() +{ +} + + +void RectButton::mousePressEvent (QGraphicsSceneMouseEvent *) +{ + emit clicked(); +} + + +QRectF RectButton::boundingRect() const +{ + return QRectF(0.0, 0.0, 90.0, 40.0); +} + + +void RectButton::paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */) +{ + painter->setBrush(Qt::gray); + painter->drawRoundedRect(boundingRect(), 5, 5); + + painter->setPen(Qt::white); + painter->drawText(20, 25, m_ButtonText); +} diff --git a/examples/widgets/animation/stickman/rectbutton.h b/examples/widgets/animation/stickman/rectbutton.h new file mode 100644 index 0000000000..ead8f21420 --- /dev/null +++ b/examples/widgets/animation/stickman/rectbutton.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 RECTBUTTON_H +#define RECTBUTTON_H + +#include + +class RectButton : public QGraphicsObject +{ + Q_OBJECT +public: + RectButton(QString buttonText); + ~RectButton(); + + virtual QRectF boundingRect() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + QString m_ButtonText; + + virtual void mousePressEvent (QGraphicsSceneMouseEvent *event); + +signals: + void clicked(); +}; + +#endif // RECTBUTTON_H diff --git a/examples/widgets/animation/stickman/stickman.cpp b/examples/widgets/animation/stickman/stickman.cpp new file mode 100644 index 0000000000..667ed7d141 --- /dev/null +++ b/examples/widgets/animation/stickman/stickman.cpp @@ -0,0 +1,337 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 "stickman.h" +#include "node.h" + +#include +#include + +#define _USE_MATH_DEFINES +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +static const qreal Coords[NodeCount * 2] = { + 0.0, -150.0, // head, #0 + + 0.0, -100.0, // body pentagon, top->bottom, left->right, #1 - 5 + -50.0, -50.0, + 50.0, -50.0, + -25.0, 50.0, + 25.0, 50.0, + + -100.0, 0.0, // right arm, #6 - 7 + -125.0, 50.0, + + 100.0, 0.0, // left arm, #8 - 9 + 125.0, 50.0, + + -35.0, 75.0, // lower body, #10 - 11 + 35.0, 75.0, + + -25.0, 200.0, // right leg, #12 - 13 + -30.0, 300.0, + + 25.0, 200.0, // left leg, #14 - 15 + 30.0, 300.0 + +}; + +static const int Bones[BoneCount * 2] = { + 0, 1, // neck + + 1, 2, // body + 1, 3, + 1, 4, + 1, 5, + 2, 3, + 2, 4, + 2, 5, + 3, 4, + 3, 5, + 4, 5, + + 2, 6, // right arm + 6, 7, + + 3, 8, // left arm + 8, 9, + + 4, 10, // lower body + 4, 11, + 5, 10, + 5, 11, + 10, 11, + + 10, 12, // right leg + 12, 13, + + 11, 14, // left leg + 14, 15 + +}; + +StickMan::StickMan() +{ + m_sticks = true; + m_isDead = false; + m_pixmap = QPixmap("images/head.png"); + m_penColor = Qt::white; + m_fillColor = Qt::black; + + // Set up start position of limbs + for (int i=0; ipos() - node2->pos(); + m_perfectBoneLengths[i] = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); + } + + startTimer(10); +} + +StickMan::~StickMan() +{ +} + +void StickMan::childPositionChanged() +{ + prepareGeometryChange(); +} + +void StickMan::setDrawSticks(bool on) +{ + m_sticks = on; + for (int i=0;isetVisible(on); + } +} + +QRectF StickMan::boundingRect() const +{ + // account for head radius=50.0 plus pen which is 5.0 + return childrenBoundingRect().adjusted(-55.0, -55.0, 55.0, 55.0); +} + +int StickMan::nodeCount() const +{ + return NodeCount; +} + +Node *StickMan::node(int idx) const +{ + if (idx >= 0 && idx < NodeCount) + return m_nodes[idx]; + else + return 0; +} + +void StickMan::timerEvent(QTimerEvent *) +{ + update(); +} + +void StickMan::stabilize() +{ + static const qreal threshold = 0.001; + + for (int i=0; ipos(); + QPointF pos2 = node2->pos(); + + QPointF dist = pos1 - pos2; + qreal length = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); + qreal diff = (length - m_perfectBoneLengths[i]) / length; + + QPointF p = dist * (0.5 * diff); + if (p.x() > threshold && p.y() > threshold) { + pos1 -= p; + pos2 += p; + + node1->setPos(pos1); + node2->setPos(pos2); + } + } +} + +QPointF StickMan::posFor(int idx) const +{ + return m_nodes[idx]->pos(); +} + +//#include +void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + /* static int frames = 0; + static QTime time; + if (frames++ % 100 == 0) { + frames = 1; + time.restart(); + } + + if (time.elapsed() > 0) { + painter->setPen(Qt::white); + painter->drawText(0, 0, QString::number(frames / (time.elapsed() / 1000.0))); + }*/ + + stabilize(); + if (m_sticks) { + painter->setPen(Qt::white); + for (int i=0; idrawLine(node1->pos(), node2->pos()); + } + } else { + // first bone is neck and will be used for head + + QPainterPath path; + path.moveTo(posFor(0)); + path.lineTo(posFor(1)); + + // right arm + path.lineTo(posFor(2)); + path.lineTo(posFor(6)); + path.lineTo(posFor(7)); + + // left arm + path.moveTo(posFor(3)); + path.lineTo(posFor(8)); + path.lineTo(posFor(9)); + + // body + path.moveTo(posFor(2)); + path.lineTo(posFor(4)); + path.lineTo(posFor(10)); + path.lineTo(posFor(11)); + path.lineTo(posFor(5)); + path.lineTo(posFor(3)); + path.lineTo(posFor(1)); + + // right leg + path.moveTo(posFor(10)); + path.lineTo(posFor(12)); + path.lineTo(posFor(13)); + + // left leg + path.moveTo(posFor(11)); + path.lineTo(posFor(14)); + path.lineTo(posFor(15)); + + painter->setPen(QPen(m_penColor, 5.0, Qt::SolidLine, Qt::RoundCap)); + painter->drawPath(path); + + { + int n1 = Bones[0]; + int n2 = Bones[1]; + Node *node1 = m_nodes[n1]; + Node *node2 = m_nodes[n2]; + + QPointF dist = node2->pos() - node1->pos(); + + qreal sinAngle = dist.x() / sqrt(pow(dist.x(), 2) + pow(dist.y(), 2)); + qreal angle = asin(sinAngle) * 180.0 / M_PI; + + QPointF headPos = node1->pos(); + painter->translate(headPos); + painter->rotate(-angle); + + painter->setBrush(m_fillColor); + painter->drawEllipse(QPointF(0,0), 50.0, 50.0); + + painter->setBrush(m_penColor); + painter->setPen(QPen(m_penColor, 2.5, Qt::SolidLine, Qt::RoundCap)); + + // eyes + if (m_isDead) { + painter->drawLine(-30.0, -30.0, -20.0, -20.0); + painter->drawLine(-20.0, -30.0, -30.0, -20.0); + + painter->drawLine(20.0, -30.0, 30.0, -20.0); + painter->drawLine(30.0, -30.0, 20.0, -20.0); + } else { + painter->drawChord(QRectF(-30.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16); + painter->drawChord(QRectF(5.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16); + } + + // mouth + if (m_isDead) { + painter->drawLine(-28.0, 2.0, 29.0, 2.0); + } else { + painter->setBrush(QColor(128, 0, 64 )); + painter->drawChord(QRectF(-28.0, 2.0-55.0/2.0, 57.0, 55.0), 0.0, -180.0*16); + } + + // pupils + if (!m_isDead) { + painter->setPen(QPen(m_fillColor, 1.0, Qt::SolidLine, Qt::RoundCap)); + painter->setBrush(m_fillColor); + painter->drawEllipse(QPointF(-12.0, -25.0), 5.0, 5.0); + painter->drawEllipse(QPointF(22.0, -25.0), 5.0, 5.0); + } + } + } +} + + + diff --git a/examples/widgets/animation/stickman/stickman.desktop b/examples/widgets/animation/stickman/stickman.desktop new file mode 100644 index 0000000000..1722d4db3e --- /dev/null +++ b/examples/widgets/animation/stickman/stickman.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Stickman +Exec=/opt/usr/bin/stickman +Icon=stickman +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/animation/stickman/stickman.h b/examples/widgets/animation/stickman/stickman.h new file mode 100644 index 0000000000..f50ed1a6c2 --- /dev/null +++ b/examples/widgets/animation/stickman/stickman.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module 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 STICKMAN_H +#define STICKMAN_H + +#include + +static const int NodeCount = 16; +static const int BoneCount = 24; + +class Node; +QT_BEGIN_NAMESPACE +QT_END_NAMESPACE +class StickMan: public QGraphicsObject +{ + Q_OBJECT + Q_PROPERTY(QColor penColor WRITE setPenColor READ penColor) + Q_PROPERTY(QColor fillColor WRITE setFillColor READ fillColor) + Q_PROPERTY(bool isDead WRITE setIsDead READ isDead) +public: + StickMan(); + ~StickMan(); + + virtual QRectF boundingRect() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + int nodeCount() const; + Node *node(int idx) const; + + void setDrawSticks(bool on); + bool drawSticks() const { return m_sticks; } + + QColor penColor() const { return m_penColor; } + void setPenColor(const QColor &color) { m_penColor = color; } + + QColor fillColor() const { return m_fillColor; } + void setFillColor(const QColor &color) { m_fillColor = color; } + + bool isDead() const { return m_isDead; } + void setIsDead(bool isDead) { m_isDead = isDead; } + +public slots: + void stabilize(); + void childPositionChanged(); + +protected: + void timerEvent(QTimerEvent *e); + +private: + + QPointF posFor(int idx) const; + + Node *m_nodes[NodeCount]; + qreal m_perfectBoneLengths[BoneCount]; + + uint m_sticks : 1; + uint m_isDead : 1; + uint m_reserved : 30; + + QPixmap m_pixmap; + QColor m_penColor; + QColor m_fillColor; +}; + +#endif // STICKMAN_H diff --git a/examples/widgets/animation/stickman/stickman.pro b/examples/widgets/animation/stickman/stickman.pro new file mode 100644 index 0000000000..43aaec113d --- /dev/null +++ b/examples/widgets/animation/stickman/stickman.pro @@ -0,0 +1,23 @@ +HEADERS += stickman.h \ + animation.h \ + node.h \ + lifecycle.h \ + graphicsview.h \ + rectbutton.h +SOURCES += main.cpp \ + stickman.cpp \ + animation.cpp \ + node.cpp \ + lifecycle.cpp \ + graphicsview.cpp \ + rectbutton.cpp + +RESOURCES += stickman.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/stickman +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS stickman.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/stickman +INSTALLS += target sources + +QT += widgets diff --git a/examples/widgets/animation/stickman/stickman.qrc b/examples/widgets/animation/stickman/stickman.qrc new file mode 100644 index 0000000000..4cf3ba3828 --- /dev/null +++ b/examples/widgets/animation/stickman/stickman.qrc @@ -0,0 +1,8 @@ + + + animations/chilling.bin + animations/dancing.bin + animations/dead.bin + animations/jumping.bin + + diff --git a/examples/widgets/animation/sub-attaq/animationmanager.cpp b/examples/widgets/animation/sub-attaq/animationmanager.cpp new file mode 100644 index 0000000000..7dcb9dfb50 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/animationmanager.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "animationmanager.h" + +//Qt +#include +#include + +// the universe's only animation manager +AnimationManager *AnimationManager::instance = 0; + +AnimationManager::AnimationManager() +{ +} + +AnimationManager *AnimationManager::self() +{ + if (!instance) + instance = new AnimationManager; + return instance; +} + +void AnimationManager::registerAnimation(QAbstractAnimation *anim) +{ + QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); + animations.append(anim); +} + +void AnimationManager::unregisterAnimation_helper(QObject *obj) +{ + unregisterAnimation(static_cast(obj)); +} + +void AnimationManager::unregisterAnimation(QAbstractAnimation *anim) +{ + QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); + animations.removeAll(anim); +} + +void AnimationManager::unregisterAllAnimations() +{ + animations.clear(); +} + +void AnimationManager::pauseAll() +{ + foreach (QAbstractAnimation* animation, animations) { + if (animation->state() == QAbstractAnimation::Running) + animation->pause(); + } +} +void AnimationManager::resumeAll() +{ + foreach (QAbstractAnimation* animation, animations) { + if (animation->state() == QAbstractAnimation::Paused) + animation->resume(); + } +} diff --git a/examples/widgets/animation/sub-attaq/animationmanager.h b/examples/widgets/animation/sub-attaq/animationmanager.h new file mode 100644 index 0000000000..6587e39b14 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/animationmanager.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ANIMATIONMANAGER_H +#define ANIMATIONMANAGER_H + +#include + +QT_BEGIN_NAMESPACE +class QAbstractAnimation; +QT_END_NAMESPACE + +class AnimationManager : public QObject +{ +Q_OBJECT +public: + AnimationManager(); + void registerAnimation(QAbstractAnimation *anim); + void unregisterAnimation(QAbstractAnimation *anim); + void unregisterAllAnimations(); + static AnimationManager *self(); + +public slots: + void pauseAll(); + void resumeAll(); + +private slots: + void unregisterAnimation_helper(QObject *obj); + +private: + static AnimationManager *instance; + QList animations; +}; + +#endif // ANIMATIONMANAGER_H diff --git a/examples/widgets/animation/sub-attaq/boat.cpp b/examples/widgets/animation/sub-attaq/boat.cpp new file mode 100644 index 0000000000..88332dbfe7 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/boat.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "boat.h" +#include "boat_p.h" +#include "bomb.h" +#include "pixmapitem.h" +#include "graphicsscene.h" +#include "animationmanager.h" +#include "qanimationstate.h" + +//Qt +#include +#include +#include +#include +#include +#include + +static QAbstractAnimation *setupDestroyAnimation(Boat *boat) +{ + QSequentialAnimationGroup *group = new QSequentialAnimationGroup(boat); + for (int i = 1; i <= 4; i++) { + PixmapItem *step = new PixmapItem(QString("explosion/boat/step%1").arg(i),GraphicsScene::Big, boat); + step->setZValue(6); + step->setOpacity(0); + + //fade-in + QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity"); + anim->setEndValue(1); + anim->setDuration(100); + group->insertAnimation(i-1, anim); + + //and then fade-out + QPropertyAnimation *anim2 = new QPropertyAnimation(step, "opacity"); + anim2->setEndValue(0); + anim2->setDuration(100); + group->addAnimation(anim2); + } + + AnimationManager::self()->registerAnimation(group); + return group; +} + + + +Boat::Boat() : PixmapItem(QString("boat"), GraphicsScene::Big), + speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0) +{ + setZValue(4); + setFlags(QGraphicsItem::ItemIsFocusable); + + //The movement animation used to animate the boat + movementAnimation = new QPropertyAnimation(this, "pos"); + + //The destroy animation used to explode the boat + destroyAnimation = setupDestroyAnimation(this); + + //We setup the state machine of the boat + machine = new QStateMachine(this); + QState *moving = new QState(machine); + StopState *stopState = new StopState(this, moving); + machine->setInitialState(moving); + moving->setInitialState(stopState); + MoveStateRight *moveStateRight = new MoveStateRight(this, moving); + MoveStateLeft *moveStateLeft = new MoveStateLeft(this, moving); + LaunchStateRight *launchStateRight = new LaunchStateRight(this, machine); + LaunchStateLeft *launchStateLeft = new LaunchStateLeft(this, machine); + + //then setup the transitions for the rightMove state + KeyStopTransition *leftStopRight = new KeyStopTransition(this, QEvent::KeyPress, Qt::Key_Left); + leftStopRight->setTargetState(stopState); + KeyMoveTransition *leftMoveRight = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Left); + leftMoveRight->setTargetState(moveStateRight); + KeyMoveTransition *rightMoveRight = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); + rightMoveRight->setTargetState(moveStateRight); + KeyMoveTransition *rightMoveStop = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); + rightMoveStop->setTargetState(moveStateRight); + + //then setup the transitions for the leftMove state + KeyStopTransition *rightStopLeft = new KeyStopTransition(this, QEvent::KeyPress, Qt::Key_Right); + rightStopLeft->setTargetState(stopState); + KeyMoveTransition *rightMoveLeft = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); + rightMoveLeft->setTargetState(moveStateLeft); + KeyMoveTransition *leftMoveLeft = new KeyMoveTransition(this, QEvent::KeyPress,Qt::Key_Left); + leftMoveLeft->setTargetState(moveStateLeft); + KeyMoveTransition *leftMoveStop = new KeyMoveTransition(this, QEvent::KeyPress,Qt::Key_Left); + leftMoveStop->setTargetState(moveStateLeft); + + //We set up the right move state + moveStateRight->addTransition(leftStopRight); + moveStateRight->addTransition(leftMoveRight); + moveStateRight->addTransition(rightMoveRight); + stopState->addTransition(rightMoveStop); + + //We set up the left move state + moveStateLeft->addTransition(rightStopLeft); + moveStateLeft->addTransition(leftMoveLeft); + moveStateLeft->addTransition(rightMoveLeft); + stopState->addTransition(leftMoveStop); + + //The animation is finished, it means we reached the border of the screen, the boat is stopped so we move to the stop state + moveStateLeft->addTransition(movementAnimation, SIGNAL(finished()), stopState); + moveStateRight->addTransition(movementAnimation, SIGNAL(finished()), stopState); + + //We set up the keys for dropping bombs + KeyLaunchTransition *upFireLeft = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); + upFireLeft->setTargetState(launchStateRight); + KeyLaunchTransition *upFireRight = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); + upFireRight->setTargetState(launchStateRight); + KeyLaunchTransition *upFireStop = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); + upFireStop->setTargetState(launchStateRight); + KeyLaunchTransition *downFireLeft = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); + downFireLeft->setTargetState(launchStateLeft); + KeyLaunchTransition *downFireRight = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); + downFireRight->setTargetState(launchStateLeft); + KeyLaunchTransition *downFireMove = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); + downFireMove->setTargetState(launchStateLeft); + + //We set up transitions for fire up + moveStateRight->addTransition(upFireRight); + moveStateLeft->addTransition(upFireLeft); + stopState->addTransition(upFireStop); + + //We set up transitions for fire down + moveStateRight->addTransition(downFireRight); + moveStateLeft->addTransition(downFireLeft); + stopState->addTransition(downFireMove); + + //Finally the launch state should come back to its original state + QHistoryState *historyState = new QHistoryState(moving); + launchStateLeft->addTransition(historyState); + launchStateRight->addTransition(historyState); + + QFinalState *final = new QFinalState(machine); + + //This state play the destroyed animation + QAnimationState *destroyedState = new QAnimationState(machine); + destroyedState->setAnimation(destroyAnimation); + + //Play a nice animation when the boat is destroyed + moving->addTransition(this, SIGNAL(boatDestroyed()), destroyedState); + + //Transition to final state when the destroyed animation is finished + destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final); + + //The machine has finished to be executed, then the boat is dead + connect(machine,SIGNAL(finished()), this, SIGNAL(boatExecutionFinished())); + +} + +void Boat::run() +{ + //We register animations + AnimationManager::self()->registerAnimation(movementAnimation); + AnimationManager::self()->registerAnimation(destroyAnimation); + machine->start(); +} + +void Boat::stop() +{ + movementAnimation->stop(); + machine->stop(); +} + +void Boat::updateBoatMovement() +{ + if (speed == 0 || direction == Boat::None) { + movementAnimation->stop(); + return; + } + + movementAnimation->stop(); + + if (direction == Boat::Left) { + movementAnimation->setEndValue(QPointF(0,y())); + movementAnimation->setDuration(x()/speed*15); + } + else /*if (direction == Boat::Right)*/ { + movementAnimation->setEndValue(QPointF(scene()->width()-size().width(),y())); + movementAnimation->setDuration((scene()->width()-size().width()-x())/speed*15); + } + movementAnimation->start(); +} + +void Boat::destroy() +{ + movementAnimation->stop(); + emit boatDestroyed(); +} + +int Boat::bombsLaunched() const +{ + return bombsAlreadyLaunched; +} + +void Boat::setBombsLaunched(int number) +{ + if (number > MAX_BOMB) { + qWarning("Boat::setBombsLaunched : It impossible to launch that number of bombs"); + return; + } + bombsAlreadyLaunched = number; +} + +int Boat::currentSpeed() const +{ + return speed; +} + +void Boat::setCurrentSpeed(int speed) +{ + if (speed > 3 || speed < 0) { + qWarning("Boat::setCurrentSpeed: The boat can't run on that speed"); + return; + } + this->speed = speed; +} + +enum Boat::Movement Boat::currentDirection() const +{ + return direction; +} + +void Boat::setCurrentDirection(Movement direction) +{ + this->direction = direction; +} + +int Boat::type() const +{ + return Type; +} diff --git a/examples/widgets/animation/sub-attaq/boat.h b/examples/widgets/animation/sub-attaq/boat.h new file mode 100644 index 0000000000..0b2fe5c8eb --- /dev/null +++ b/examples/widgets/animation/sub-attaq/boat.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __BOAT__H__ +#define __BOAT__H__ + +#include "pixmapitem.h" + +class Bomb; +QT_BEGIN_NAMESPACE +class QVariantAnimation; +class QAbstractAnimation; +class QStateMachine; +QT_END_NAMESPACE + +class Boat : public PixmapItem +{ +Q_OBJECT +public: + enum Movement { + None = 0, + Left, + Right + }; + enum { Type = UserType + 2 }; + Boat(); + void destroy(); + void run(); + void stop(); + + int bombsLaunched() const; + void setBombsLaunched(int number); + + int currentSpeed() const; + void setCurrentSpeed(int speed); + + enum Movement currentDirection() const; + void setCurrentDirection(Movement direction); + + void updateBoatMovement(); + + virtual int type() const; + +signals: + void boatDestroyed(); + void boatExecutionFinished(); + +private: + int speed; + int bombsAlreadyLaunched; + Movement direction; + QVariantAnimation *movementAnimation; + QAbstractAnimation *destroyAnimation; + QStateMachine *machine; +}; + +#endif //__BOAT__H__ diff --git a/examples/widgets/animation/sub-attaq/boat_p.h b/examples/widgets/animation/sub-attaq/boat_p.h new file mode 100644 index 0000000000..38be985777 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/boat_p.h @@ -0,0 +1,232 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BOAT_P_H +#define BOAT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +//Own +#include "bomb.h" +#include "graphicsscene.h" + +// Qt +#include + +static const int MAX_BOMB = 5; + + +//These transtion test if we have to stop the boat (i.e current speed is 1) +class KeyStopTransition : public QKeyEventTransition +{ +public: + KeyStopTransition(Boat *b, QEvent::Type t, int k) + : QKeyEventTransition(b, t, k), boat(b), key(k) + { + } +protected: + virtual bool eventTest(QEvent *event) + { + if (!QKeyEventTransition::eventTest(event)) + return false; + return (boat->currentSpeed() == 1); + } +private: + Boat * boat; + int key; +}; + +//These transtion test if we have to move the boat (i.e current speed was 0 or another value) + class KeyMoveTransition : public QKeyEventTransition +{ +public: + KeyMoveTransition(Boat *b, QEvent::Type t, int k) + : QKeyEventTransition(b, t, k), boat(b), key(k) + { + } +protected: + virtual bool eventTest(QEvent *event) + { + if (!QKeyEventTransition::eventTest(event)) + return false; + return (boat->currentSpeed() >= 0); + } + void onTransition(QEvent *) + { + //We decrease the speed if needed + if (key == Qt::Key_Left && boat->currentDirection() == Boat::Right) + boat->setCurrentSpeed(boat->currentSpeed() - 1); + else if (key == Qt::Key_Right && boat->currentDirection() == Boat::Left) + boat->setCurrentSpeed(boat->currentSpeed() - 1); + else if (boat->currentSpeed() < 3) + boat->setCurrentSpeed(boat->currentSpeed() + 1); + boat->updateBoatMovement(); + } +private: + Boat * boat; + int key; +}; + +//This transition trigger the bombs launch + class KeyLaunchTransition : public QKeyEventTransition +{ +public: + KeyLaunchTransition(Boat *boat, QEvent::Type type, int key) + : QKeyEventTransition(boat, type, key), boat(boat), key(key) + { + } +protected: + virtual bool eventTest(QEvent *event) + { + if (!QKeyEventTransition::eventTest(event)) + return false; + //We have enough bomb? + return (boat->bombsLaunched() < MAX_BOMB); + } +private: + Boat * boat; + int key; +}; + +//This state is describing when the boat is moving right +class MoveStateRight : public QState +{ +public: + MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + { + } +protected: + void onEntry(QEvent *) + { + boat->setCurrentDirection(Boat::Right); + boat->updateBoatMovement(); + } +private: + Boat * boat; +}; + + //This state is describing when the boat is moving left +class MoveStateLeft : public QState +{ +public: + MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + { + } +protected: + void onEntry(QEvent *) + { + boat->setCurrentDirection(Boat::Left); + boat->updateBoatMovement(); + } +private: + Boat * boat; +}; + +//This state is describing when the boat is in a stand by position +class StopState : public QState +{ +public: + StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + { + } +protected: + void onEntry(QEvent *) + { + boat->setCurrentSpeed(0); + boat->setCurrentDirection(Boat::None); + boat->updateBoatMovement(); + } +private: + Boat * boat; +}; + +//This state is describing the launch of the torpedo on the right +class LaunchStateRight : public QState +{ +public: + LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + { + } +protected: + void onEntry(QEvent *) + { + Bomb *b = new Bomb(); + b->setPos(boat->x()+boat->size().width(),boat->y()); + GraphicsScene *scene = static_cast(boat->scene()); + scene->addItem(b); + b->launch(Bomb::Right); + boat->setBombsLaunched(boat->bombsLaunched() + 1); + } +private: + Boat * boat; +}; + +//This state is describing the launch of the torpedo on the left +class LaunchStateLeft : public QState +{ +public: + LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + { + } +protected: + void onEntry(QEvent *) + { + Bomb *b = new Bomb(); + b->setPos(boat->x() - b->size().width(), boat->y()); + GraphicsScene *scene = static_cast(boat->scene()); + scene->addItem(b); + b->launch(Bomb::Left); + boat->setBombsLaunched(boat->bombsLaunched() + 1); + } +private: + Boat * boat; +}; + +#endif // BOAT_P_H diff --git a/examples/widgets/animation/sub-attaq/bomb.cpp b/examples/widgets/animation/sub-attaq/bomb.cpp new file mode 100644 index 0000000000..e47e9423a9 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/bomb.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "bomb.h" +#include "submarine.h" +#include "pixmapitem.h" +#include "animationmanager.h" +#include "qanimationstate.h" + +//Qt +#include +#include +#include +#include + +Bomb::Bomb() : PixmapItem(QString("bomb"), GraphicsScene::Big) +{ + setZValue(2); +} + +void Bomb::launch(Bomb::Direction direction) +{ + QSequentialAnimationGroup *launchAnimation = new QSequentialAnimationGroup; + AnimationManager::self()->registerAnimation(launchAnimation); + qreal delta = direction == Right ? 20 : - 20; + QPropertyAnimation *anim = new QPropertyAnimation(this, "pos"); + anim->setEndValue(QPointF(x() + delta,y() - 20)); + anim->setDuration(150); + launchAnimation->addAnimation(anim); + anim = new QPropertyAnimation(this, "pos"); + anim->setEndValue(QPointF(x() + delta*2, y() )); + anim->setDuration(150); + launchAnimation->addAnimation(anim); + anim = new QPropertyAnimation(this, "pos"); + anim->setEndValue(QPointF(x() + delta*2,scene()->height())); + anim->setDuration(y()/2*60); + launchAnimation->addAnimation(anim); + connect(anim,SIGNAL(valueChanged(QVariant)),this,SLOT(onAnimationLaunchValueChanged(QVariant))); + connect(this, SIGNAL(bombExploded()), launchAnimation, SLOT(stop())); + //We setup the state machine of the bomb + QStateMachine *machine = new QStateMachine(this); + + //This state is when the launch animation is playing + QAnimationState *launched = new QAnimationState(machine); + launched->setAnimation(launchAnimation); + + //End + QFinalState *final = new QFinalState(machine); + + machine->setInitialState(launched); + + //### Add a nice animation when the bomb is destroyed + launched->addTransition(this, SIGNAL(bombExploded()),final); + + //If the animation is finished, then we move to the final state + launched->addTransition(launched, SIGNAL(animationFinished()), final); + + //The machine has finished to be executed, then the boat is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(bombExecutionFinished())); + + machine->start(); + +} + +void Bomb::onAnimationLaunchValueChanged(const QVariant &) +{ + foreach (QGraphicsItem * item , collidingItems(Qt::IntersectsItemBoundingRect)) { + if (item->type() == SubMarine::Type) { + SubMarine *s = static_cast(item); + destroy(); + s->destroy(); + } + } +} + +void Bomb::destroy() +{ + emit bombExploded(); +} diff --git a/examples/widgets/animation/sub-attaq/bomb.h b/examples/widgets/animation/sub-attaq/bomb.h new file mode 100644 index 0000000000..74ed734caf --- /dev/null +++ b/examples/widgets/animation/sub-attaq/bomb.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __BOMB__H__ +#define __BOMB__H__ + +#include "pixmapitem.h" + +class Bomb : public PixmapItem +{ +Q_OBJECT +public: + enum Direction { + Left = 0, + Right + }; + Bomb(); + void launch(Direction direction); + void destroy(); + +signals: + void bombExploded(); + void bombExecutionFinished(); + +private slots: + void onAnimationLaunchValueChanged(const QVariant &); +}; + +#endif //__BOMB__H__ diff --git a/examples/widgets/animation/sub-attaq/data.xml b/examples/widgets/animation/sub-attaq/data.xml new file mode 100644 index 0000000000..0f30515ddf --- /dev/null +++ b/examples/widgets/animation/sub-attaq/data.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/graphicsscene.cpp b/examples/widgets/animation/sub-attaq/graphicsscene.cpp new file mode 100644 index 0000000000..a2b3e2f101 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/graphicsscene.cpp @@ -0,0 +1,282 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "graphicsscene.h" +#include "states.h" +#include "boat.h" +#include "submarine.h" +#include "torpedo.h" +#include "bomb.h" +#include "pixmapitem.h" +#include "animationmanager.h" +#include "qanimationstate.h" +#include "progressitem.h" +#include "textinformationitem.h" + +//Qt +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) + : QGraphicsScene(x , y, width, height), mode(mode), boat(new Boat) +{ + PixmapItem *backgroundItem = new PixmapItem(QString("background"),mode); + backgroundItem->setZValue(1); + backgroundItem->setPos(0,0); + addItem(backgroundItem); + + PixmapItem *surfaceItem = new PixmapItem(QString("surface"),mode); + surfaceItem->setZValue(3); + surfaceItem->setPos(0,sealLevel() - surfaceItem->boundingRect().height()/2); + addItem(surfaceItem); + + //The item that display score and level + progressItem = new ProgressItem(backgroundItem); + + textInformationItem = new TextInformationItem(backgroundItem); + textInformationItem->hide(); + //We create the boat + addItem(boat); + boat->setPos(this->width()/2, sealLevel() - boat->size().height()); + boat->hide(); + + //parse the xml that contain all data of the game + QXmlStreamReader reader; + QFile file(":data.xml"); + file.open(QIODevice::ReadOnly); + reader.setDevice(&file); + LevelDescription currentLevel; + while (!reader.atEnd()) { + reader.readNext(); + if (reader.tokenType() == QXmlStreamReader::StartElement) { + if (reader.name() == "submarine") { + SubmarineDescription desc; + desc.name = reader.attributes().value("name").toString(); + desc.points = reader.attributes().value("points").toString().toInt(); + desc.type = reader.attributes().value("type").toString().toInt(); + submarinesData.append(desc); + } else if (reader.name() == "level") { + currentLevel.id = reader.attributes().value("id").toString().toInt(); + currentLevel.name = reader.attributes().value("name").toString(); + } else if (reader.name() == "subinstance") { + currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(), reader.attributes().value("nb").toString().toInt())); + } + } else if (reader.tokenType() == QXmlStreamReader::EndElement) { + if (reader.name() == "level") { + levelsData.insert(currentLevel.id, currentLevel); + currentLevel.submarines.clear(); + } + } + } +} + +qreal GraphicsScene::sealLevel() const +{ + return (mode == Big) ? 220 : 160; +} + +void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction) +{ + static const int nLetters = 10; + static struct { + char const *pix; + qreal initX, initY; + qreal destX, destY; + } logoData[nLetters] = { + {"s", -1000, -1000, 300, 150 }, + {"u", -800, -1000, 350, 150 }, + {"b", -600, -1000, 400, 120 }, + {"dash", -400, -1000, 460, 150 }, + {"a", 1000, 2000, 350, 250 }, + {"t", 800, 2000, 400, 250 }, + {"t2", 600, 2000, 430, 250 }, + {"a2", 400, 2000, 465, 250 }, + {"q", 200, 2000, 510, 250 }, + {"excl", 0, 2000, 570, 220 } }; + + QSequentialAnimationGroup * lettersGroupMoving = new QSequentialAnimationGroup(this); + QParallelAnimationGroup * lettersGroupFading = new QParallelAnimationGroup(this); + + for (int i = 0; i < nLetters; ++i) { + PixmapItem *logo = new PixmapItem(QLatin1String(":/logo-") + logoData[i].pix, this); + logo->setPos(logoData[i].initX, logoData[i].initY); + logo->setZValue(i + 3); + //creation of the animations for moving letters + QPropertyAnimation *moveAnim = new QPropertyAnimation(logo, "pos", lettersGroupMoving); + moveAnim->setEndValue(QPointF(logoData[i].destX, logoData[i].destY)); + moveAnim->setDuration(200); + moveAnim->setEasingCurve(QEasingCurve::OutElastic); + lettersGroupMoving->addPause(50); + //creation of the animations for fading out the letters + QPropertyAnimation *fadeAnim = new QPropertyAnimation(logo, "opacity", lettersGroupFading); + fadeAnim->setDuration(800); + fadeAnim->setEndValue(0); + fadeAnim->setEasingCurve(QEasingCurve::OutQuad); + } + + QStateMachine *machine = new QStateMachine(this); + + //This state is when the player is playing + PlayState *gameState = new PlayState(this, machine); + + //Final state + QFinalState *final = new QFinalState(machine); + + //Animation when the player enter in the game + QAnimationState *lettersMovingState = new QAnimationState(machine); + lettersMovingState->setAnimation(lettersGroupMoving); + + //Animation when the welcome screen disappear + QAnimationState *lettersFadingState = new QAnimationState(machine); + lettersFadingState->setAnimation(lettersGroupFading); + + //if new game then we fade out the welcome screen and start playing + lettersMovingState->addTransition(newAction, SIGNAL(triggered()), lettersFadingState); + lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()), gameState); + + //New Game is triggered then player start playing + gameState->addTransition(newAction, SIGNAL(triggered()), gameState); + + //Wanna quit, then connect to CTRL+Q + gameState->addTransition(quitAction, SIGNAL(triggered()), final); + lettersMovingState->addTransition(quitAction, SIGNAL(triggered()), final); + + //Welcome screen is the initial state + machine->setInitialState(lettersMovingState); + + machine->start(); + + //We reach the final state, then we quit + connect(machine, SIGNAL(finished()), qApp, SLOT(quit())); +} + +void GraphicsScene::addItem(Bomb *bomb) +{ + bombs.insert(bomb); + connect(bomb,SIGNAL(bombExecutionFinished()),this, SLOT(onBombExecutionFinished())); + QGraphicsScene::addItem(bomb); +} + +void GraphicsScene::addItem(Torpedo *torpedo) +{ + torpedos.insert(torpedo); + connect(torpedo,SIGNAL(torpedoExecutionFinished()),this, SLOT(onTorpedoExecutionFinished())); + QGraphicsScene::addItem(torpedo); +} + +void GraphicsScene::addItem(SubMarine *submarine) +{ + submarines.insert(submarine); + connect(submarine,SIGNAL(subMarineExecutionFinished()),this, SLOT(onSubMarineExecutionFinished())); + QGraphicsScene::addItem(submarine); +} + +void GraphicsScene::addItem(QGraphicsItem *item) +{ + QGraphicsScene::addItem(item); +} + +void GraphicsScene::onBombExecutionFinished() +{ + Bomb *bomb = qobject_cast(sender()); + bombs.remove(bomb); + bomb->deleteLater(); + if (boat) + boat->setBombsLaunched(boat->bombsLaunched() - 1); +} + +void GraphicsScene::onTorpedoExecutionFinished() +{ + Torpedo *torpedo = qobject_cast(sender()); + torpedos.remove(torpedo); + torpedo->deleteLater(); +} + +void GraphicsScene::onSubMarineExecutionFinished() +{ + SubMarine *submarine = qobject_cast(sender()); + submarines.remove(submarine); + if (submarines.count() == 0) + emit allSubMarineDestroyed(submarine->points()); + else + emit subMarineDestroyed(submarine->points()); + submarine->deleteLater(); +} + +void GraphicsScene::clearScene() +{ + foreach (SubMarine *sub, submarines) { + sub->destroy(); + sub->deleteLater(); + } + + foreach (Torpedo *torpedo, torpedos) { + torpedo->destroy(); + torpedo->deleteLater(); + } + + foreach (Bomb *bomb, bombs) { + bomb->destroy(); + bomb->deleteLater(); + } + + submarines.clear(); + bombs.clear(); + torpedos.clear(); + + AnimationManager::self()->unregisterAllAnimations(); + + boat->stop(); + boat->hide(); + boat->setEnabled(true); +} diff --git a/examples/widgets/animation/sub-attaq/graphicsscene.h b/examples/widgets/animation/sub-attaq/graphicsscene.h new file mode 100644 index 0000000000..3e571a878c --- /dev/null +++ b/examples/widgets/animation/sub-attaq/graphicsscene.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __GRAPHICSSCENE__H__ +#define __GRAPHICSSCENE__H__ + +//Qt +#include +#include +#include + + +class Boat; +class SubMarine; +class Torpedo; +class Bomb; +class PixmapItem; +class ProgressItem; +class TextInformationItem; +QT_BEGIN_NAMESPACE +class QAction; +QT_END_NAMESPACE + +class GraphicsScene : public QGraphicsScene +{ +Q_OBJECT +public: + enum Mode { + Big = 0, + Small + }; + + struct SubmarineDescription { + int type; + int points; + QString name; + }; + + struct LevelDescription { + int id; + QString name; + QList > submarines; + }; + + GraphicsScene(int x, int y, int width, int height, Mode mode = Big); + qreal sealLevel() const; + void setupScene(QAction *newAction, QAction *quitAction); + void addItem(Bomb *bomb); + void addItem(Torpedo *torpedo); + void addItem(SubMarine *submarine); + void addItem(QGraphicsItem *item); + void clearScene(); + +signals: + void subMarineDestroyed(int); + void allSubMarineDestroyed(int); + +private slots: + void onBombExecutionFinished(); + void onTorpedoExecutionFinished(); + void onSubMarineExecutionFinished(); + +private: + Mode mode; + ProgressItem *progressItem; + TextInformationItem *textInformationItem; + Boat *boat; + QSet submarines; + QSet bombs; + QSet torpedos; + QVector submarinesData; + QHash levelsData; + + friend class PauseState; + friend class PlayState; + friend class LevelState; + friend class LostState; + friend class WinState; + friend class WinTransition; + friend class UpdateScoreTransition; +}; + +#endif //__GRAPHICSSCENE__H__ + diff --git a/examples/widgets/animation/sub-attaq/main.cpp b/examples/widgets/animation/sub-attaq/main.cpp new file mode 100644 index 0000000000..df18c83435 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(subattaq); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + MainWindow w; + w.show(); + + return app.exec(); +} diff --git a/examples/widgets/animation/sub-attaq/mainwindow.cpp b/examples/widgets/animation/sub-attaq/mainwindow.cpp new file mode 100644 index 0000000000..70f0303177 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/mainwindow.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "mainwindow.h" +#include "graphicsscene.h" + +//Qt +#include +#include +#include +#include +#include + +#ifndef QT_NO_OPENGL +# include +#endif + +MainWindow::MainWindow() : QMainWindow(0) +{ + QMenu *file = menuBar()->addMenu(tr("&File")); + + QAction *newAction = file->addAction(tr("New Game")); + newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); + QAction *quitAction = file->addAction(tr("Quit")); + quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); + + if (QApplication::arguments().contains("-fullscreen")) { + scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small); + setWindowState(Qt::WindowFullScreen); + } else { + scene = new GraphicsScene(0, 0, 880, 630); + layout()->setSizeConstraint(QLayout::SetFixedSize); + } + + view = new QGraphicsView(scene, this); + view->setAlignment(Qt::AlignLeft | Qt::AlignTop); + scene->setupScene(newAction, quitAction); +#ifndef QT_NO_OPENGL + view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); +#endif + + setCentralWidget(view); +} diff --git a/examples/widgets/animation/sub-attaq/mainwindow.h b/examples/widgets/animation/sub-attaq/mainwindow.h new file mode 100644 index 0000000000..596157d38f --- /dev/null +++ b/examples/widgets/animation/sub-attaq/mainwindow.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __MAINWINDOW__H__ +#define __MAINWINDOW__H__ + +//Qt +#include +class GraphicsScene; +QT_BEGIN_NAMESPACE +class QGraphicsView; +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ +Q_OBJECT +public: + MainWindow(); + +private: + GraphicsScene *scene; + QGraphicsView *view; +}; + +#endif //__MAINWINDOW__H__ diff --git a/examples/widgets/animation/sub-attaq/pics/big/background.png b/examples/widgets/animation/sub-attaq/pics/big/background.png new file mode 100644 index 0000000000..9f581571fa Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/background.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/boat.png b/examples/widgets/animation/sub-attaq/pics/big/boat.png new file mode 100644 index 0000000000..be82dff62a Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/boat.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/bomb.png b/examples/widgets/animation/sub-attaq/pics/big/bomb.png new file mode 100644 index 0000000000..3af5f2f29c Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/bomb.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png new file mode 100644 index 0000000000..c9fd8b0984 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png new file mode 100644 index 0000000000..7528f2d2da Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png new file mode 100644 index 0000000000..aae9c9c184 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png new file mode 100644 index 0000000000..d697c1bae8 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png new file mode 100644 index 0000000000..88ca5144b7 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png new file mode 100644 index 0000000000..524f5890ee Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png new file mode 100644 index 0000000000..2cca1e80fe Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png new file mode 100644 index 0000000000..82100a8260 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/submarine.png b/examples/widgets/animation/sub-attaq/pics/big/submarine.png new file mode 100644 index 0000000000..df435dc47d Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/submarine.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/surface.png b/examples/widgets/animation/sub-attaq/pics/big/surface.png new file mode 100644 index 0000000000..4eba29e9cd Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/surface.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/torpedo.png b/examples/widgets/animation/sub-attaq/pics/big/torpedo.png new file mode 100644 index 0000000000..f9c26873f1 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/big/torpedo.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg b/examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg new file mode 100644 index 0000000000..ece9f7aaf1 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg @@ -0,0 +1,171 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/background.svg b/examples/widgets/animation/sub-attaq/pics/scalable/background.svg new file mode 100644 index 0000000000..0be268010e --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/background.svg @@ -0,0 +1,171 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/boat.svg b/examples/widgets/animation/sub-attaq/pics/scalable/boat.svg new file mode 100644 index 0000000000..5298821ba8 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/boat.svg @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg b/examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg new file mode 100644 index 0000000000..294771a6dd --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/sand.svg b/examples/widgets/animation/sub-attaq/pics/scalable/sand.svg new file mode 100644 index 0000000000..8af11b7a66 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/sand.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/see.svg b/examples/widgets/animation/sub-attaq/pics/scalable/see.svg new file mode 100644 index 0000000000..0666691215 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/see.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/sky.svg b/examples/widgets/animation/sub-attaq/pics/scalable/sky.svg new file mode 100644 index 0000000000..1546c087a7 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/sky.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg b/examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg new file mode 100644 index 0000000000..b075179b46 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg @@ -0,0 +1,1473 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg b/examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg new file mode 100644 index 0000000000..8a0ffddbca --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/surface.svg b/examples/widgets/animation/sub-attaq/pics/scalable/surface.svg new file mode 100644 index 0000000000..40ed239638 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/surface.svg @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg b/examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg new file mode 100644 index 0000000000..48e429d2bf --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/widgets/animation/sub-attaq/pics/small/background.png b/examples/widgets/animation/sub-attaq/pics/small/background.png new file mode 100644 index 0000000000..5ad3db660a Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/small/background.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/boat.png b/examples/widgets/animation/sub-attaq/pics/small/boat.png new file mode 100644 index 0000000000..114ccc310e Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/small/boat.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/bomb.png b/examples/widgets/animation/sub-attaq/pics/small/bomb.png new file mode 100644 index 0000000000..3af5f2f29c Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/small/bomb.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/submarine.png b/examples/widgets/animation/sub-attaq/pics/small/submarine.png new file mode 100644 index 0000000000..0c0c350600 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/small/submarine.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/surface.png b/examples/widgets/animation/sub-attaq/pics/small/surface.png new file mode 100644 index 0000000000..06d0e47a5c Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/small/surface.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/torpedo.png b/examples/widgets/animation/sub-attaq/pics/small/torpedo.png new file mode 100644 index 0000000000..f9c26873f1 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/small/torpedo.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png new file mode 100644 index 0000000000..67dd76dac0 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png new file mode 100644 index 0000000000..17668b07de Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png new file mode 100644 index 0000000000..cf6c04560b Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png new file mode 100644 index 0000000000..219233ce6b Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png new file mode 100644 index 0000000000..8dd0a2eb86 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png new file mode 100644 index 0000000000..86e588d4d8 Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png new file mode 100644 index 0000000000..7b6a36e93a Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png new file mode 100644 index 0000000000..b2e3526bea Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png new file mode 100644 index 0000000000..b11a77886e Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png new file mode 100644 index 0000000000..24eede887a Binary files /dev/null and b/examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png differ diff --git a/examples/widgets/animation/sub-attaq/pixmapitem.cpp b/examples/widgets/animation/sub-attaq/pixmapitem.cpp new file mode 100644 index 0000000000..077151d708 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pixmapitem.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "pixmapitem.h" + +//Qt +#include + +PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent) +{ + if (mode == GraphicsScene::Big) + pix = QPixmap(QStringLiteral(":/big/") + fileName); + else + pix = QPixmap(QStringLiteral(":/small/") + fileName); +} + +PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName) +{ + scene->addItem(this); +} + +QSizeF PixmapItem::size() const +{ + return pix.size(); +} + +QRectF PixmapItem::boundingRect() const +{ + return QRectF(QPointF(0, 0), pix.size()); +} + +void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + painter->drawPixmap(0, 0, pix); +} + + diff --git a/examples/widgets/animation/sub-attaq/pixmapitem.h b/examples/widgets/animation/sub-attaq/pixmapitem.h new file mode 100644 index 0000000000..0a3b1287c7 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/pixmapitem.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __PIXMAPITEM__H__ +#define __PIXMAPITEM__H__ + +//Own +#include "graphicsscene.h" + +//Qt +#include + +class PixmapItem : public QGraphicsObject +{ +public: + PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0); + PixmapItem(const QString &fileName, QGraphicsScene *scene); + QSizeF size() const; + QRectF boundingRect() const; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); +private: + QPixmap pix; +}; + +#endif //__PIXMAPITEM__H__ diff --git a/examples/widgets/animation/sub-attaq/progressitem.cpp b/examples/widgets/animation/sub-attaq/progressitem.cpp new file mode 100644 index 0000000000..bad9ceb471 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/progressitem.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "progressitem.h" +#include "pixmapitem.h" + +ProgressItem::ProgressItem (QGraphicsItem * parent) + : QGraphicsTextItem(parent), currentLevel(1), currentScore(0) +{ + setFont(QFont("Comic Sans MS")); + setPos(parentItem()->boundingRect().topRight() - QPointF(180, -5)); +} + +void ProgressItem::setLevel(int level) +{ + currentLevel = level; + updateProgress(); +} + +void ProgressItem::setScore(int score) +{ + currentScore = score; + updateProgress(); +} + +void ProgressItem::updateProgress() +{ + setHtml(QString("Level : %1 Score : %2").arg(currentLevel).arg(currentScore)); +} diff --git a/examples/widgets/animation/sub-attaq/progressitem.h b/examples/widgets/animation/sub-attaq/progressitem.h new file mode 100644 index 0000000000..dc6d7ba6bc --- /dev/null +++ b/examples/widgets/animation/sub-attaq/progressitem.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PROGRESSITEM_H +#define PROGRESSITEM_H + +//Qt +#include + +class ProgressItem : public QGraphicsTextItem +{ +public: + ProgressItem(QGraphicsItem * parent = 0); + void setLevel(int level); + void setScore(int score); + +private: + void updateProgress(); + int currentLevel; + int currentScore; +}; + +#endif // PROGRESSITEM_H diff --git a/examples/widgets/animation/sub-attaq/qanimationstate.cpp b/examples/widgets/animation/sub-attaq/qanimationstate.cpp new file mode 100644 index 0000000000..b122acc858 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/qanimationstate.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qanimationstate.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! +\class QAnimationState + +\brief The QAnimationState class provides state that handle an animation and emit +a signal when this animation is finished. + +\ingroup statemachine + +QAnimationState provides a state that handle an animation. It will start this animation +when the state is entered and stop it when it is leaved. When the animation has finished the +state emit animationFinished signal. +QAnimationState is part of \l{The State Machine Framework}. + +\code +QStateMachine machine; +QAnimationState *s = new QAnimationState(machine->rootState()); +QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); +s->setAnimation(animation); +QState *s2 = new QState(machine->rootState()); +s->addTransition(s, SIGNAL(animationFinished()), s2); +machine.start(); +\endcode + +\sa QState, {The Animation Framework} +*/ + + +#ifndef QT_NO_ANIMATION + +/*! + Constructs a new state with the given \a parent state. +*/ +QAnimationState::QAnimationState(QState *parent) + : QState(parent), m_animation(0) +{ +} + +/*! + Destroys the animation state. +*/ +QAnimationState::~QAnimationState() +{ +} + +/*! + Set an \a animation for this QAnimationState. If an animation was previously handle by this + state then it won't emit animationFinished for the old animation. The QAnimationState doesn't + take the ownership of the animation. +*/ +void QAnimationState::setAnimation(QAbstractAnimation *animation) +{ + if (animation == m_animation) + return; + + //Disconnect from the previous animation if exist + if(m_animation) + disconnect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); + + m_animation = animation; + + if (m_animation) { + //connect the new animation + connect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); + } +} + +/*! + Returns the animation handle by this animation state, or 0 if there is no animation. +*/ +QAbstractAnimation* QAnimationState::animation() const +{ + return m_animation; +} + +/*! + \reimp +*/ +void QAnimationState::onEntry(QEvent *) +{ + if (m_animation) + m_animation->start(); +} + +/*! + \reimp +*/ +void QAnimationState::onExit(QEvent *) +{ + if (m_animation) + m_animation->stop(); +} + +/*! + \reimp +*/ +bool QAnimationState::event(QEvent *e) +{ + return QState::event(e); +} + +QT_END_NAMESPACE + +#endif diff --git a/examples/widgets/animation/sub-attaq/qanimationstate.h b/examples/widgets/animation/sub-attaq/qanimationstate.h new file mode 100644 index 0000000000..2672f640e4 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/qanimationstate.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QANIMATIONSTATE_H +#define QANIMATIONSTATE_H + +#ifndef QT_STATEMACHINE_SOLUTION +# include +# include +#else +# include "qstate.h" +# include "qabstractanimation.h" +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + + +#ifndef QT_NO_ANIMATION + +class QAbstractAnimation; + +class QAnimationState : public QState +{ + Q_OBJECT +public: + QAnimationState(QState *parent = 0); + ~QAnimationState(); + + void setAnimation(QAbstractAnimation *animation); + QAbstractAnimation* animation() const; + +signals: + void animationFinished(); + +protected: + void onEntry(QEvent *); + void onExit(QEvent *); + bool event(QEvent *e); + +private: + Q_DISABLE_COPY(QAnimationState) + QAbstractAnimation *m_animation; +}; + +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QANIMATIONSTATE_H diff --git a/examples/widgets/animation/sub-attaq/states.cpp b/examples/widgets/animation/sub-attaq/states.cpp new file mode 100644 index 0000000000..32ad218693 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/states.cpp @@ -0,0 +1,330 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "states.h" +#include "graphicsscene.h" +#include "boat.h" +#include "submarine.h" +#include "torpedo.h" +#include "animationmanager.h" +#include "progressitem.h" +#include "textinformationitem.h" + +//Qt +#include +#include +#include +#include +#include + +PlayState::PlayState(GraphicsScene *scene, QState *parent) + : QState(parent), + scene(scene), + machine(0), + currentLevel(0), + score(0) +{ +} + +PlayState::~PlayState() +{ + delete machine; +} + +void PlayState::onEntry(QEvent *) +{ + //We are now playing? + if (machine) { + machine->stop(); + //we hide the information + scene->textInformationItem->hide(); + scene->clearScene(); + currentLevel = 0; + score = 0; + delete machine; + } + + machine = new QStateMachine; + + //This state is when player is playing + LevelState *levelState = new LevelState(scene, this, machine); + + //This state is when the player is actually playing but the game is not paused + QState *playingState = new QState(levelState); + levelState->setInitialState(playingState); + + //This state is when the game is paused + PauseState *pauseState = new PauseState(scene, levelState); + + //We have one view, it receive the key press event + QKeyEventTransition *pressPplay = new QKeyEventTransition(scene->views().at(0), QEvent::KeyPress, Qt::Key_P); + pressPplay->setTargetState(pauseState); + QKeyEventTransition *pressPpause = new QKeyEventTransition(scene->views().at(0), QEvent::KeyPress, Qt::Key_P); + pressPpause->setTargetState(playingState); + + //Pause "P" is triggered, the player pause the game + playingState->addTransition(pressPplay); + + //To get back playing when the game has been paused + pauseState->addTransition(pressPpause); + + //This state is when player have lost + LostState *lostState = new LostState(scene, this, machine); + + //This state is when player have won + WinState *winState = new WinState(scene, this, machine); + + //The boat has been destroyed then the game is finished + levelState->addTransition(scene->boat, SIGNAL(boatExecutionFinished()),lostState); + + //This transition check if we won or not + WinTransition *winTransition = new WinTransition(scene, this, winState); + + //The boat has been destroyed then the game is finished + levelState->addTransition(winTransition); + + //This state is an animation when the score changed + UpdateScoreState *scoreState = new UpdateScoreState(this, levelState); + + //This transition update the score when a submarine die + UpdateScoreTransition *scoreTransition = new UpdateScoreTransition(scene, this, levelState); + scoreTransition->setTargetState(scoreState); + + //The boat has been destroyed then the game is finished + playingState->addTransition(scoreTransition); + + //We go back to play state + scoreState->addTransition(playingState); + + //We start playing!!! + machine->setInitialState(levelState); + + //Final state + QFinalState *final = new QFinalState(machine); + + //This transition is triggered when the player press space after completing a level + CustomSpaceTransition *spaceTransition = new CustomSpaceTransition(scene->views().at(0), this, QEvent::KeyPress, Qt::Key_Space); + spaceTransition->setTargetState(levelState); + winState->addTransition(spaceTransition); + + //We lost we should reach the final state + lostState->addTransition(lostState, SIGNAL(finished()), final); + + machine->start(); +} + +LevelState::LevelState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) +{ +} +void LevelState::onEntry(QEvent *) +{ + initializeLevel(); +} + +void LevelState::initializeLevel() +{ + //we re-init the boat + scene->boat->setPos(scene->width()/2, scene->sealLevel() - scene->boat->size().height()); + scene->boat->setCurrentSpeed(0); + scene->boat->setCurrentDirection(Boat::None); + scene->boat->setBombsLaunched(0); + scene->boat->show(); + scene->setFocusItem(scene->boat, Qt::OtherFocusReason); + scene->boat->run(); + + scene->progressItem->setScore(game->score); + scene->progressItem->setLevel(game->currentLevel + 1); + + GraphicsScene::LevelDescription currentLevelDescription = scene->levelsData.value(game->currentLevel); + + for (int i = 0; i < currentLevelDescription.submarines.size(); ++i ) { + + QPair subContent = currentLevelDescription.submarines.at(i); + GraphicsScene::SubmarineDescription submarineDesc = scene->submarinesData.at(subContent.first); + + for (int j = 0; j < subContent.second; ++j ) { + SubMarine *sub = new SubMarine(submarineDesc.type, submarineDesc.name, submarineDesc.points); + scene->addItem(sub); + int random = (qrand() % 15 + 1); + qreal x = random == 13 || random == 5 ? 0 : scene->width() - sub->size().width(); + qreal y = scene->height() -(qrand() % 150 + 1) - sub->size().height(); + sub->setPos(x,y); + sub->setCurrentDirection(x == 0 ? SubMarine::Right : SubMarine::Left); + sub->setCurrentSpeed(qrand() % 3 + 1); + } + } +} + +/** Pause State */ +PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent),scene(scene) +{ +} +void PauseState::onEntry(QEvent *) +{ + AnimationManager::self()->pauseAll(); + scene->boat->setEnabled(false); +} +void PauseState::onExit(QEvent *) +{ + AnimationManager::self()->resumeAll(); + scene->boat->setEnabled(true); + scene->boat->setFocus(); +} + +/** Lost State */ +LostState::LostState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) +{ +} + +void LostState::onEntry(QEvent *) +{ + //The message to display + QString message = QString("You lose on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score); + + //We set the level back to 0 + game->currentLevel = 0; + + //We set the score back to 0 + game->score = 0; + + //We clear the scene + scene->clearScene(); + + //We inform the player + scene->textInformationItem->setMessage(message); + scene->textInformationItem->show(); +} + +void LostState::onExit(QEvent *) +{ + //we hide the information + scene->textInformationItem->hide(); +} + +/** Win State */ +WinState::WinState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) +{ +} + +void WinState::onEntry(QEvent *) +{ + //We clear the scene + scene->clearScene(); + + QString message; + if (scene->levelsData.size() - 1 != game->currentLevel) { + message = QString("You win the level %1. Your score is %2.\nPress Space to continue.").arg(game->currentLevel+1).arg(game->score); + //We increment the level number + game->currentLevel++; + } else { + message = QString("You finish the game on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score); + //We set the level back to 0 + game->currentLevel = 0; + //We set the score back to 0 + game->score = 0; + } + + //We inform the player + scene->textInformationItem->setMessage(message); + scene->textInformationItem->show(); +} + +void WinState::onExit(QEvent *) +{ + //we hide the information + scene->textInformationItem->hide(); +} + +/** UpdateScore State */ +UpdateScoreState::UpdateScoreState(PlayState *g, QState *parent) : QState(parent), game(g) +{ +} + +/** Win transition */ +UpdateScoreTransition::UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) + : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int))), + game(game), scene(scene) +{ + setTargetState(target); +} + +bool UpdateScoreTransition::eventTest(QEvent *event) +{ + if (!QSignalTransition::eventTest(event)) + return false; + QStateMachine::SignalEvent *se = static_cast(event); + game->score += se->arguments().at(0).toInt(); + scene->progressItem->setScore(game->score); + return true; +} + +/** Win transition */ +WinTransition::WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) + : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int))), + game(game), scene(scene) +{ + setTargetState(target); +} + +bool WinTransition::eventTest(QEvent *event) +{ + if (!QSignalTransition::eventTest(event)) + return false; + QStateMachine::SignalEvent *se = static_cast(event); + game->score += se->arguments().at(0).toInt(); + scene->progressItem->setScore(game->score); + return true; +} + +/** Space transition */ +CustomSpaceTransition::CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key) + : QKeyEventTransition(widget, type, key), + game(game) +{ +} + +bool CustomSpaceTransition::eventTest(QEvent *event) +{ + if (!QKeyEventTransition::eventTest(event)) + return false; + return (game->currentLevel != 0); +} diff --git a/examples/widgets/animation/sub-attaq/states.h b/examples/widgets/animation/sub-attaq/states.h new file mode 100644 index 0000000000..e43370302c --- /dev/null +++ b/examples/widgets/animation/sub-attaq/states.h @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STATES_H +#define STATES_H + +//Qt +#include +#include +#include +#include +#include + +class GraphicsScene; +class Boat; +class SubMarine; +QT_BEGIN_NAMESPACE +class QStateMachine; +QT_END_NAMESPACE + +class PlayState : public QState +{ +public: + PlayState(GraphicsScene *scene, QState *parent = 0); + ~PlayState(); + + protected: + void onEntry(QEvent *); + +private : + GraphicsScene *scene; + QStateMachine *machine; + int currentLevel; + int score; + QState *parallelChild; + + friend class UpdateScoreState; + friend class UpdateScoreTransition; + friend class WinTransition; + friend class CustomSpaceTransition; + friend class WinState; + friend class LostState; + friend class LevelState; +}; + +class LevelState : public QState +{ +public: + LevelState(GraphicsScene *scene, PlayState *game, QState *parent = 0); +protected: + void onEntry(QEvent *); +private : + void initializeLevel(); + GraphicsScene *scene; + PlayState *game; +}; + +class PauseState : public QState +{ +public: + PauseState(GraphicsScene *scene, QState *parent = 0); + +protected: + void onEntry(QEvent *); + void onExit(QEvent *); +private : + GraphicsScene *scene; + Boat *boat; +}; + +class LostState : public QState +{ +public: + LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0); + +protected: + void onEntry(QEvent *); + void onExit(QEvent *); +private : + GraphicsScene *scene; + PlayState *game; +}; + +class WinState : public QState +{ +public: + WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0); + +protected: + void onEntry(QEvent *); + void onExit(QEvent *); +private : + GraphicsScene *scene; + PlayState *game; +}; + +class UpdateScoreState : public QState +{ +public: + UpdateScoreState(PlayState *game, QState *parent); +private: + QPropertyAnimation *scoreAnimation; + PlayState *game; +}; + +//These transtion is used to update the score +class UpdateScoreTransition : public QSignalTransition +{ +public: + UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); +protected: + virtual bool eventTest(QEvent *event); +private: + PlayState * game; + GraphicsScene *scene; +}; + +//These transtion test if we have won the game +class WinTransition : public QSignalTransition +{ +public: + WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); +protected: + virtual bool eventTest(QEvent *event); +private: + PlayState * game; + GraphicsScene *scene; +}; + +//These transtion is true if one level has been completed and the player want to continue + class CustomSpaceTransition : public QKeyEventTransition +{ +public: + CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key); +protected: + virtual bool eventTest(QEvent *event); +private: + PlayState *game; + int key; +}; + +#endif // STATES_H diff --git a/examples/widgets/animation/sub-attaq/sub-attaq.pro b/examples/widgets/animation/sub-attaq/sub-attaq.pro new file mode 100644 index 0000000000..6d9b3195ac --- /dev/null +++ b/examples/widgets/animation/sub-attaq/sub-attaq.pro @@ -0,0 +1,42 @@ +QT += widgets +contains(QT_CONFIG, opengl):QT += opengl +HEADERS += boat.h \ + bomb.h \ + mainwindow.h \ + submarine.h \ + torpedo.h \ + pixmapitem.h \ + graphicsscene.h \ + animationmanager.h \ + states.h \ + boat_p.h \ + submarine_p.h \ + qanimationstate.h \ + progressitem.h \ + textinformationitem.h +SOURCES += boat.cpp \ + bomb.cpp \ + main.cpp \ + mainwindow.cpp \ + submarine.cpp \ + torpedo.cpp \ + pixmapitem.cpp \ + graphicsscene.cpp \ + animationmanager.cpp \ + states.cpp \ + qanimationstate.cpp \ + progressitem.cpp \ + textinformationitem.cpp +RESOURCES += subattaq.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/sub-attaq +sources.files = $$SOURCES \ + $$HEADERS \ + $$RESOURCES \ + $$FORMS \ + sub-attaq.pro \ + pics +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/sub-attaq +INSTALLS += target \ + sources diff --git a/examples/widgets/animation/sub-attaq/subattaq.qrc b/examples/widgets/animation/sub-attaq/subattaq.qrc new file mode 100644 index 0000000000..80a3af11cc --- /dev/null +++ b/examples/widgets/animation/sub-attaq/subattaq.qrc @@ -0,0 +1,39 @@ + + + pics/scalable/sub-attaq.svg + pics/scalable/submarine.svg + pics/scalable/boat.svg + pics/scalable/torpedo.svg + pics/welcome/logo-s.png + pics/welcome/logo-u.png + pics/welcome/logo-b.png + pics/welcome/logo-dash.png + pics/welcome/logo-a.png + pics/welcome/logo-t.png + pics/welcome/logo-t2.png + pics/welcome/logo-a2.png + pics/welcome/logo-q.png + pics/welcome/logo-excl.png + pics/big/background.png + pics/big/boat.png + pics/big/bomb.png + pics/big/submarine.png + pics/big/surface.png + pics/big/torpedo.png + pics/small/background.png + pics/small/boat.png + pics/small/bomb.png + pics/small/submarine.png + pics/small/surface.png + pics/small/torpedo.png + pics/big/explosion/boat/step1.png + pics/big/explosion/boat/step2.png + pics/big/explosion/boat/step3.png + pics/big/explosion/boat/step4.png + pics/big/explosion/submarine/step1.png + pics/big/explosion/submarine/step2.png + pics/big/explosion/submarine/step3.png + pics/big/explosion/submarine/step4.png + data.xml + + diff --git a/examples/widgets/animation/sub-attaq/submarine.cpp b/examples/widgets/animation/sub-attaq/submarine.cpp new file mode 100644 index 0000000000..68eaf7ef38 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/submarine.cpp @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "submarine.h" +#include "submarine_p.h" +#include "torpedo.h" +#include "pixmapitem.h" +#include "graphicsscene.h" +#include "animationmanager.h" +#include "qanimationstate.h" + +#include +#include +#include +#include + +static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub) +{ + QSequentialAnimationGroup *group = new QSequentialAnimationGroup(sub); + for (int i = 1; i <= 4; ++i) { + PixmapItem *step = new PixmapItem(QString::fromLatin1("explosion/submarine/step%1").arg(i), GraphicsScene::Big, sub); + step->setZValue(6); + step->setOpacity(0); + QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity", group); + anim->setDuration(100); + anim->setEndValue(1); + } + AnimationManager::self()->registerAnimation(group); + return group; +} + + +SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QString("submarine"), GraphicsScene::Big), + subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None) +{ + setZValue(5); + setTransformOriginPoint(boundingRect().center()); + + graphicsRotation = new QGraphicsRotation(this); + graphicsRotation->setAxis(Qt::YAxis); + graphicsRotation->setOrigin(QVector3D(size().width()/2, size().height()/2, 0)); + QList r; + r.append(graphicsRotation); + setTransformations(r); + + //We setup the state machine of the submarine + QStateMachine *machine = new QStateMachine(this); + + //This state is when the boat is moving/rotating + QState *moving = new QState(machine); + + //This state is when the boat is moving from left to right + MovementState *movement = new MovementState(this, moving); + + //This state is when the boat is moving from left to right + ReturnState *rotation = new ReturnState(this, moving); + + //This is the initial state of the moving root state + moving->setInitialState(movement); + + movement->addTransition(this, SIGNAL(subMarineStateChanged()), moving); + + //This is the initial state of the machine + machine->setInitialState(moving); + + //End + QFinalState *final = new QFinalState(machine); + + //If the moving animation is finished we move to the return state + movement->addTransition(movement, SIGNAL(animationFinished()), rotation); + + //If the return animation is finished we move to the moving state + rotation->addTransition(rotation, SIGNAL(animationFinished()), movement); + + //This state play the destroyed animation + QAnimationState *destroyedState = new QAnimationState(machine); + destroyedState->setAnimation(setupDestroyAnimation(this)); + + //Play a nice animation when the submarine is destroyed + moving->addTransition(this, SIGNAL(subMarineDestroyed()), destroyedState); + + //Transition to final state when the destroyed animation is finished + destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final); + + //The machine has finished to be executed, then the submarine is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(subMarineExecutionFinished())); + + machine->start(); +} + +int SubMarine::points() const +{ + return subPoints; +} + +void SubMarine::setCurrentDirection(SubMarine::Movement direction) +{ + if (this->direction == direction) + return; + if (direction == SubMarine::Right && this->direction == SubMarine::None) { + graphicsRotation->setAngle(180); + } + this->direction = direction; +} + +enum SubMarine::Movement SubMarine::currentDirection() const +{ + return direction; +} + +void SubMarine::setCurrentSpeed(int speed) +{ + if (speed < 0 || speed > 3) { + qWarning("SubMarine::setCurrentSpeed : The speed is invalid"); + } + this->speed = speed; + emit subMarineStateChanged(); +} + +int SubMarine::currentSpeed() const +{ + return speed; +} + +void SubMarine::launchTorpedo(int speed) +{ + Torpedo * torp = new Torpedo(); + GraphicsScene *scene = static_cast(this->scene()); + scene->addItem(torp); + torp->setPos(pos()); + torp->setCurrentSpeed(speed); + torp->launch(); +} + +void SubMarine::destroy() +{ + emit subMarineDestroyed(); +} + +int SubMarine::type() const +{ + return Type; +} diff --git a/examples/widgets/animation/sub-attaq/submarine.h b/examples/widgets/animation/sub-attaq/submarine.h new file mode 100644 index 0000000000..b113bc8797 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/submarine.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __SUBMARINE__H__ +#define __SUBMARINE__H__ + +//Qt +#include + +#include "pixmapitem.h" + +class Torpedo; + +class SubMarine : public PixmapItem +{ +Q_OBJECT +public: + enum Movement { + None = 0, + Left, + Right + }; + enum { Type = UserType + 1 }; + SubMarine(int type, const QString &name, int points); + + int points() const; + + void setCurrentDirection(Movement direction); + enum Movement currentDirection() const; + + void setCurrentSpeed(int speed); + int currentSpeed() const; + + void launchTorpedo(int speed); + void destroy(); + + virtual int type() const; + + QGraphicsRotation *rotation() const { return graphicsRotation; } + +signals: + void subMarineDestroyed(); + void subMarineExecutionFinished(); + void subMarineStateChanged(); + +private: + int subType; + QString subName; + int subPoints; + int speed; + Movement direction; + QGraphicsRotation *graphicsRotation; +}; + +#endif //__SUBMARINE__H__ diff --git a/examples/widgets/animation/sub-attaq/submarine_p.h b/examples/widgets/animation/sub-attaq/submarine_p.h new file mode 100644 index 0000000000..f24487aa17 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/submarine_p.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SUBMARINE_P_H +#define SUBMARINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +//Own +#include "animationmanager.h" +#include "submarine.h" +#include "qanimationstate.h" + +//Qt +#include +#include + +//This state is describing when the boat is moving right +class MovementState : public QAnimationState +{ +Q_OBJECT +public: + MovementState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) + { + movementAnimation = new QPropertyAnimation(submarine, "pos"); + connect(movementAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationMovementValueChanged(const QVariant &))); + setAnimation(movementAnimation); + AnimationManager::self()->registerAnimation(movementAnimation); + this->submarine = submarine; + } + +protected slots: + void onAnimationMovementValueChanged(const QVariant &) + { + if (qrand() % 200 + 1 == 3) + submarine->launchTorpedo(qrand() % 3 + 1); + } + +protected: + void onEntry(QEvent *e) + { + if (submarine->currentDirection() == SubMarine::Left) { + movementAnimation->setEndValue(QPointF(0,submarine->y())); + movementAnimation->setDuration(submarine->x()/submarine->currentSpeed()*12); + } + else /*if (submarine->currentDirection() == SubMarine::Right)*/ { + movementAnimation->setEndValue(QPointF(submarine->scene()->width()-submarine->size().width(),submarine->y())); + movementAnimation->setDuration((submarine->scene()->width()-submarine->size().width()-submarine->x())/submarine->currentSpeed()*12); + } + QAnimationState::onEntry(e); + } + +private: + SubMarine *submarine; + QPropertyAnimation *movementAnimation; +}; + +//This state is describing when the boat is moving right +class ReturnState : public QAnimationState +{ +public: + ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) + { + returnAnimation = new QPropertyAnimation(submarine->rotation(), "angle"); + returnAnimation->setDuration(500); + AnimationManager::self()->registerAnimation(returnAnimation); + setAnimation(returnAnimation); + this->submarine = submarine; + } + +protected: + void onEntry(QEvent *e) + { + returnAnimation->stop(); + returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.); + QAnimationState::onEntry(e); + } + + void onExit(QEvent *e) + { + submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right); + QAnimationState::onExit(e); + } + +private: + SubMarine *submarine; + QPropertyAnimation *returnAnimation; +}; + +#endif // SUBMARINE_P_H diff --git a/examples/widgets/animation/sub-attaq/textinformationitem.cpp b/examples/widgets/animation/sub-attaq/textinformationitem.cpp new file mode 100644 index 0000000000..ce2e297287 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/textinformationitem.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "textinformationitem.h" +#include "pixmapitem.h" + +TextInformationItem::TextInformationItem (QGraphicsItem * parent) + : QGraphicsTextItem(parent) +{ + setFont(QFont("Comic Sans MS", 15)); +} +#include +void TextInformationItem::setMessage(const QString& text) +{ + setHtml(text); + setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y()); +} diff --git a/examples/widgets/animation/sub-attaq/textinformationitem.h b/examples/widgets/animation/sub-attaq/textinformationitem.h new file mode 100644 index 0000000000..adad8be90b --- /dev/null +++ b/examples/widgets/animation/sub-attaq/textinformationitem.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTINFORMATIONITEM_H +#define TEXTINFORMATIONITEM_H + +//Qt +#include + +class TextInformationItem : public QGraphicsTextItem +{ +public: + TextInformationItem(QGraphicsItem * parent = 0); + void setMessage(const QString& text); +}; + +#endif // TEXTINFORMATIONITEM_H diff --git a/examples/widgets/animation/sub-attaq/torpedo.cpp b/examples/widgets/animation/sub-attaq/torpedo.cpp new file mode 100644 index 0000000000..34c32fe059 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/torpedo.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "torpedo.h" +#include "pixmapitem.h" +#include "boat.h" +#include "graphicsscene.h" +#include "animationmanager.h" +#include "qanimationstate.h" + +#include +#include +#include + +Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big), + currentSpeed(0) +{ + setZValue(2); +} + +void Torpedo::launch() +{ + QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos"); + AnimationManager::self()->registerAnimation(launchAnimation); + launchAnimation->setEndValue(QPointF(x(),qobject_cast(scene())->sealLevel() - 15)); + launchAnimation->setEasingCurve(QEasingCurve::InQuad); + launchAnimation->setDuration(y()/currentSpeed*10); + connect(launchAnimation,SIGNAL(valueChanged(QVariant)),this,SLOT(onAnimationLaunchValueChanged(QVariant))); + connect(this,SIGNAL(torpedoExploded()), launchAnimation, SLOT(stop())); + + //We setup the state machine of the torpedo + QStateMachine *machine = new QStateMachine(this); + + //This state is when the launch animation is playing + QAnimationState *launched = new QAnimationState(machine); + launched->setAnimation(launchAnimation); + + //End + QFinalState *final = new QFinalState(machine); + + machine->setInitialState(launched); + + //### Add a nice animation when the torpedo is destroyed + launched->addTransition(this, SIGNAL(torpedoExploded()),final); + + //If the animation is finished, then we move to the final state + launched->addTransition(launched, SIGNAL(animationFinished()), final); + + //The machine has finished to be executed, then the boat is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(torpedoExecutionFinished())); + + machine->start(); +} + +void Torpedo::setCurrentSpeed(int speed) +{ + if (speed < 0) { + qWarning("Torpedo::setCurrentSpeed : The speed is invalid"); + return; + } + currentSpeed = speed; +} + +void Torpedo::onAnimationLaunchValueChanged(const QVariant &) +{ + foreach (QGraphicsItem *item , collidingItems(Qt::IntersectsItemBoundingRect)) { + if (Boat *b = qgraphicsitem_cast(item)) + b->destroy(); + } +} + +void Torpedo::destroy() +{ + emit torpedoExploded(); +} diff --git a/examples/widgets/animation/sub-attaq/torpedo.h b/examples/widgets/animation/sub-attaq/torpedo.h new file mode 100644 index 0000000000..59209e3d75 --- /dev/null +++ b/examples/widgets/animation/sub-attaq/torpedo.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __TORPEDO__H__ +#define __TORPEDO__H__ + +#include "pixmapitem.h" + +class Torpedo : public PixmapItem +{ +Q_OBJECT +public: + Torpedo(); + void launch(); + void setCurrentSpeed(int speed); + void destroy(); + +signals: + void torpedoExploded(); + void torpedoExecutionFinished(); + +private slots: + void onAnimationLaunchValueChanged(const QVariant &); + +private: + int currentSpeed; +}; + +#endif //__TORPEDO__H__ diff --git a/examples/widgets/applicationicon/applicationicon.desktop b/examples/widgets/applicationicon/applicationicon.desktop deleted file mode 100644 index 9645802195..0000000000 --- a/examples/widgets/applicationicon/applicationicon.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Application Icon -Exec=/opt/usr/bin/applicationicon -Icon=applicationicon -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/widgets/applicationicon/applicationicon.png b/examples/widgets/applicationicon/applicationicon.png deleted file mode 100644 index 83a186ee56..0000000000 Binary files a/examples/widgets/applicationicon/applicationicon.png and /dev/null differ diff --git a/examples/widgets/applicationicon/applicationicon.pro b/examples/widgets/applicationicon/applicationicon.pro deleted file mode 100644 index 0a3ba8bbdd..0000000000 --- a/examples/widgets/applicationicon/applicationicon.pro +++ /dev/null @@ -1,17 +0,0 @@ - -QT += core gui widgets - -TARGET = applicationicon -TEMPLATE = app - -SOURCES += main.cpp - -OTHER_FILES += applicationicon.svg \ - applicationicon.png \ - applicationicon.desktop - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/applicationicon -sources.files = $$SOURCES $$HEADERS applicationicon.svg applicationicon.png *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/applicationicon -INSTALLS += target sources diff --git a/examples/widgets/applicationicon/applicationicon.svg b/examples/widgets/applicationicon/applicationicon.svg deleted file mode 100644 index aa2835b08f..0000000000 --- a/examples/widgets/applicationicon/applicationicon.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/widgets/applicationicon/main.cpp b/examples/widgets/applicationicon/main.cpp deleted file mode 100644 index 1314de1cbf..0000000000 --- a/examples/widgets/applicationicon/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module 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 -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QLabel label(QObject::tr("Hello, world!")); - label.show(); - return a.exec(); -} diff --git a/examples/widgets/calculator/button.cpp b/examples/widgets/calculator/button.cpp deleted file mode 100644 index 14c3ebe20d..0000000000 --- a/examples/widgets/calculator/button.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include "button.h" - -//! [0] -Button::Button(const QString &text, QWidget *parent) - : QToolButton(parent) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - setText(text); -} -//! [0] - -//! [1] -QSize Button::sizeHint() const -//! [1] //! [2] -{ - QSize size = QToolButton::sizeHint(); - size.rheight() += 20; - size.rwidth() = qMax(size.width(), size.height()); - return size; -} -//! [2] diff --git a/examples/widgets/calculator/button.h b/examples/widgets/calculator/button.h deleted file mode 100644 index 50874ea574..0000000000 --- a/examples/widgets/calculator/button.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 BUTTON_H -#define BUTTON_H - -#include - -//! [0] -class Button : public QToolButton -{ - Q_OBJECT - -public: - Button(const QString &text, QWidget *parent = 0); - - QSize sizeHint() const; -}; -//! [0] - -#endif diff --git a/examples/widgets/calculator/calculator.cpp b/examples/widgets/calculator/calculator.cpp deleted file mode 100644 index 29503befc5..0000000000 --- a/examples/widgets/calculator/calculator.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - -#include - -#include "button.h" -#include "calculator.h" - -//! [0] -Calculator::Calculator(QWidget *parent) - : QWidget(parent) -{ - sumInMemory = 0.0; - sumSoFar = 0.0; - factorSoFar = 0.0; - waitingForOperand = true; -//! [0] - -//! [1] - display = new QLineEdit("0"); -//! [1] //! [2] - display->setReadOnly(true); - display->setAlignment(Qt::AlignRight); - display->setMaxLength(15); - - QFont font = display->font(); - font.setPointSize(font.pointSize() + 8); - display->setFont(font); -//! [2] - -//! [4] - for (int i = 0; i < NumDigitButtons; ++i) { - digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); - } - - Button *pointButton = createButton(tr("."), SLOT(pointClicked())); - Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked())); - - Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); - Button *clearButton = createButton(tr("Clear"), SLOT(clear())); - Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); - - Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); - Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); - Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); - Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); - - Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked())); - Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked())); - Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); - Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); - - Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); - Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked())); - Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); - Button *equalButton = createButton(tr("="), SLOT(equalClicked())); -//! [4] - -//! [5] - QGridLayout *mainLayout = new QGridLayout; -//! [5] //! [6] - mainLayout->setSizeConstraint(QLayout::SetFixedSize); - mainLayout->addWidget(display, 0, 0, 1, 6); - mainLayout->addWidget(backspaceButton, 1, 0, 1, 2); - mainLayout->addWidget(clearButton, 1, 2, 1, 2); - mainLayout->addWidget(clearAllButton, 1, 4, 1, 2); - - mainLayout->addWidget(clearMemoryButton, 2, 0); - mainLayout->addWidget(readMemoryButton, 3, 0); - mainLayout->addWidget(setMemoryButton, 4, 0); - mainLayout->addWidget(addToMemoryButton, 5, 0); - - for (int i = 1; i < NumDigitButtons; ++i) { - int row = ((9 - i) / 3) + 2; - int column = ((i - 1) % 3) + 1; - mainLayout->addWidget(digitButtons[i], row, column); - } - - mainLayout->addWidget(digitButtons[0], 5, 1); - mainLayout->addWidget(pointButton, 5, 2); - mainLayout->addWidget(changeSignButton, 5, 3); - - mainLayout->addWidget(divisionButton, 2, 4); - mainLayout->addWidget(timesButton, 3, 4); - mainLayout->addWidget(minusButton, 4, 4); - mainLayout->addWidget(plusButton, 5, 4); - - mainLayout->addWidget(squareRootButton, 2, 5); - mainLayout->addWidget(powerButton, 3, 5); - mainLayout->addWidget(reciprocalButton, 4, 5); - mainLayout->addWidget(equalButton, 5, 5); - setLayout(mainLayout); - - setWindowTitle(tr("Calculator")); -} -//! [6] - -//! [7] -void Calculator::digitClicked() -{ - Button *clickedButton = qobject_cast